Mon Nov 3 19:18:09 2014 UTC ()
Pull up following revision(s) (requested by manu in ticket #1140):
	lib/libperfuse/ops.c				1.63-1.69
	lib/libperfuse/perfuse.c			1.32-1.33
	lib/libperfuse/perfuse_priv.h			1.32-1.34
	lib/libperfuse/subr.c				1.20
	lib/libpuffs/creds.c				1.16
	lib/libpuffs/dispatcher.c			1.47
	lib/libpuffs/puffs.h				1.125
	lib/libpuffs/puffs_ops.3			1.37-1.38
	lib/libpuffs/requests.c				1.24
	sys/fs/puffs/puffs_msgif.h			1.81
	sys/fs/puffs/puffs_sys.h			1.85
	sys/fs/puffs/puffs_vnops.c			1.183
	usr.sbin/perfused/msg.c				1.22
Bring libpuffs, libperfuse and perfused on par with -current:
- implement  FUSE direct I/O
- remove useless code and warnings
- fix missing GETATTR bugs
- fix exended attribute get and list operations


(msaitoh)
diff -r1.50.2.7 -r1.50.2.8 src/lib/libperfuse/ops.c
diff -r1.25.2.3 -r1.25.2.4 src/lib/libperfuse/perfuse.c
diff -r1.25.2.4 -r1.25.2.5 src/lib/libperfuse/perfuse_priv.h
diff -r1.15.2.3 -r1.15.2.4 src/lib/libperfuse/subr.c
diff -r1.15 -r1.15.8.1 src/lib/libpuffs/creds.c
diff -r1.38.2.4 -r1.38.2.5 src/lib/libpuffs/dispatcher.c
diff -r1.119.4.4 -r1.119.4.5 src/lib/libpuffs/puffs.h
diff -r1.29.4.4 -r1.29.4.5 src/lib/libpuffs/puffs_ops.3
diff -r1.23 -r1.23.28.1 src/lib/libpuffs/requests.c
diff -r1.77.8.2 -r1.77.8.3 src/sys/fs/puffs/puffs_msgif.h
diff -r1.78.8.2 -r1.78.8.3 src/sys/fs/puffs/puffs_sys.h
diff -r1.163.2.4 -r1.163.2.5 src/sys/fs/puffs/puffs_vnops.c
diff -r1.20.2.1 -r1.20.2.2 src/usr.sbin/perfused/msg.c

cvs diff -r1.50.2.7 -r1.50.2.8 src/lib/libperfuse/ops.c (expand / switch to unified diff)

--- src/lib/libperfuse/ops.c 2013/07/30 04:05:32 1.50.2.7
+++ src/lib/libperfuse/ops.c 2014/11/03 19:18:09 1.50.2.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ops.c,v 1.50.2.7 2013/07/30 04:05:32 msaitoh Exp $ */ 1/* $NetBSD: ops.c,v 1.50.2.8 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. 4 * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 *  14 *
@@ -624,33 +624,43 @@ fuse_to_dirent(struct puffs_usermount *p @@ -624,33 +624,43 @@ fuse_to_dirent(struct puffs_usermount *p
624 /* 624 /*
625 * (void *) for delint 625 * (void *) for delint
626 */ 626 */
627 ndp = (char *)(void *)dents + written; 627 ndp = (char *)(void *)dents + written;
628 dents = (struct dirent *)(void *)ndp; 628 dents = (struct dirent *)(void *)ndp;
629 } 629 }
630  630
631 /* 631 /*
632 * Filesystem was mounted without -o use_ino 632 * Filesystem was mounted without -o use_ino
633 * Perform a lookup to find it. 633 * Perform a lookup to find it.
634 */ 634 */
635 if (fd->ino == PERFUSE_UNKNOWN_INO) { 635 if (fd->ino == PERFUSE_UNKNOWN_INO) {
636 struct puffs_node *pn; 636 struct puffs_node *pn;
 637 struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc);
637 638
638 if (node_lookup_common(pu, opc, NULL, fd->name, 639 /*
639 NULL, &pn) != 0) { 640 * Avoid breaking out of fs
640 DWARNX("node_lookup_common failed"); 641 * by lookup to .. on root
 642 */
 643 if ((strcmp(fd->name, "..") == 0) &&
 644 (pnd->pnd_nodeid == FUSE_ROOT_ID)) {
 645 fd->ino = FUSE_ROOT_ID;
641 } else { 646 } else {
642 fd->ino = pn->pn_va.va_fileid; 647 if (node_lookup_common(pu, opc, NULL, fd->name,
643 (void)perfuse_node_reclaim(pu, pn); 648 NULL, &pn) != 0) {
 649 DWARNX("node_lookup_common failed");
 650 } else {
 651 fd->ino = pn->pn_va.va_fileid;
 652 (void)perfuse_node_reclaim(pu, pn);
 653 }
644 } 654 }
645 } 655 }
646 656
647 dents->d_fileno = fd->ino; 657 dents->d_fileno = fd->ino;
648 dents->d_reclen = (unsigned short)reclen; 658 dents->d_reclen = (unsigned short)reclen;
649 dents->d_namlen = fd->namelen; 659 dents->d_namlen = fd->namelen;
650 dents->d_type = fd->type; 660 dents->d_type = fd->type;
651 strlcpy(dents->d_name, fd->name, fd->namelen + 1); 661 strlcpy(dents->d_name, fd->name, fd->namelen + 1);
652 662
653#ifdef PERFUSE_DEBUG 663#ifdef PERFUSE_DEBUG
654 if (perfuse_diagflags & PDF_READDIR) 664 if (perfuse_diagflags & PDF_READDIR)
655 DPRINTF("%s: translated \"%s\" ino = %"PRIu64"\n", 665 DPRINTF("%s: translated \"%s\" ino = %"PRIu64"\n",
656 __func__, dents->d_name, dents->d_fileno); 666 __func__, dents->d_name, dents->d_fileno);
@@ -1308,26 +1318,33 @@ perfuse_node_mknod(struct puffs_usermoun @@ -1308,26 +1318,33 @@ perfuse_node_mknod(struct puffs_usermoun
1308 1318
1309 error = node_mk_common(pu, opc, pni, pcn, pm); 1319 error = node_mk_common(pu, opc, pni, pcn, pm);
1310 1320
1311out: 1321out:
1312 node_rele(opc); 1322 node_rele(opc);
1313 return error;  1323 return error;
1314} 1324}
1315 1325
1316 1326
1317int 1327int
1318perfuse_node_open(struct puffs_usermount *pu, puffs_cookie_t opc, int mode, 1328perfuse_node_open(struct puffs_usermount *pu, puffs_cookie_t opc, int mode,
1319 const struct puffs_cred *pcr) 1329 const struct puffs_cred *pcr)
1320{ 1330{
 1331 return perfuse_node_open2(pu, opc, mode, pcr, NULL);
 1332}
 1333
 1334int
 1335perfuse_node_open2(struct puffs_usermount *pu, puffs_cookie_t opc, int mode,
 1336 const struct puffs_cred *pcr, int *oflags)
 1337{
1321 struct perfuse_state *ps; 1338 struct perfuse_state *ps;
1322 struct perfuse_node_data *pnd; 1339 struct perfuse_node_data *pnd;
1323 perfuse_msg_t *pm; 1340 perfuse_msg_t *pm;
1324 mode_t fmode; 1341 mode_t fmode;
1325 int op; 1342 int op;
1326 struct fuse_open_in *foi; 1343 struct fuse_open_in *foi;
1327 struct fuse_open_out *foo; 1344 struct fuse_open_out *foo;
1328 struct puffs_node *pn; 1345 struct puffs_node *pn;
1329 int error; 1346 int error;
1330  1347
1331 ps = puffs_getspecific(pu); 1348 ps = puffs_getspecific(pu);
1332 pn = (struct puffs_node *)opc; 1349 pn = (struct puffs_node *)opc;
1333 pnd = PERFUSE_NODE_DATA(opc); 1350 pnd = PERFUSE_NODE_DATA(opc);
@@ -1409,26 +1426,32 @@ perfuse_node_open(struct puffs_usermount @@ -1409,26 +1426,32 @@ perfuse_node_open(struct puffs_usermount
1409 foi->unused = 0; 1426 foi->unused = 0;
1410 1427
1411 if ((error = xchg_msg(pu, opc, pm, sizeof(*foo), wait_reply)) != 0) 1428 if ((error = xchg_msg(pu, opc, pm, sizeof(*foo), wait_reply)) != 0)
1412 goto out; 1429 goto out;
1413 1430
1414 foo = GET_OUTPAYLOAD(ps, pm, fuse_open_out); 1431 foo = GET_OUTPAYLOAD(ps, pm, fuse_open_out);
1415 1432
1416 /* 1433 /*
1417 * Save the file handle in node private data  1434 * Save the file handle in node private data
1418 * so that we can reuse it later 1435 * so that we can reuse it later
1419 */ 1436 */
1420 perfuse_new_fh(opc, foo->fh, mode); 1437 perfuse_new_fh(opc, foo->fh, mode);
1421 1438
 1439 /*
 1440 * Set direct I/O if the filesystems forces it
 1441 */
 1442 if ((foo->open_flags & FUSE_FOPEN_DIRECT_IO) && (oflags != NULL))
 1443 *oflags |= PUFFS_OPEN_IO_DIRECT;
 1444
1422#ifdef PERFUSE_DEBUG 1445#ifdef PERFUSE_DEBUG
1423 if (perfuse_diagflags & (PDF_FH|PDF_FILENAME)) 1446 if (perfuse_diagflags & (PDF_FH|PDF_FILENAME))
1424 DPRINTF("%s: opc = %p, file = \"%s\", " 1447 DPRINTF("%s: opc = %p, file = \"%s\", "
1425 "nodeid = 0x%"PRIx64", %s%sfh = 0x%"PRIx64"\n", 1448 "nodeid = 0x%"PRIx64", %s%sfh = 0x%"PRIx64"\n",
1426 __func__, (void *)opc, perfuse_node_path(ps, opc), 1449 __func__, (void *)opc, perfuse_node_path(ps, opc),
1427 pnd->pnd_nodeid, mode & FREAD ? "r" : "", 1450 pnd->pnd_nodeid, mode & FREAD ? "r" : "",
1428 mode & FWRITE ? "w" : "", foo->fh); 1451 mode & FWRITE ? "w" : "", foo->fh);
1429#endif 1452#endif
1430 1453
1431 ps->ps_destroy_msg(pm); 1454 ps->ps_destroy_msg(pm);
1432out: 1455out:
1433 1456
1434 pnd->pnd_flags &= ~PND_INOPEN; 1457 pnd->pnd_flags &= ~PND_INOPEN;
@@ -1524,27 +1547,27 @@ perfuse_node_getattr(struct puffs_usermo @@ -1524,27 +1547,27 @@ perfuse_node_getattr(struct puffs_usermo
1524 1547
1525int 1548int
1526perfuse_node_getattr_ttl(struct puffs_usermount *pu, puffs_cookie_t opc, 1549perfuse_node_getattr_ttl(struct puffs_usermount *pu, puffs_cookie_t opc,
1527 struct vattr *vap, const struct puffs_cred *pcr, 1550 struct vattr *vap, const struct puffs_cred *pcr,
1528 struct timespec *va_ttl) 1551 struct timespec *va_ttl)
1529{ 1552{
1530 perfuse_msg_t *pm = NULL; 1553 perfuse_msg_t *pm = NULL;
1531 struct perfuse_state *ps; 1554 struct perfuse_state *ps;
1532 struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc); 1555 struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc);
1533 struct fuse_getattr_in *fgi; 1556 struct fuse_getattr_in *fgi;
1534 struct fuse_attr_out *fao; 1557 struct fuse_attr_out *fao;
1535 int error = 0; 1558 int error = 0;
1536  1559
1537 if (pnd->pnd_flags & PND_REMOVED) 1560 if ((pnd->pnd_flags & PND_REMOVED) && !(pnd->pnd_flags & PND_OPEN))
1538 return ENOENT; 1561 return ENOENT;
1539 1562
1540 node_ref(opc); 1563 node_ref(opc);
1541 1564
1542 /*  1565 /*
1543 * Serialize size access, see comment in perfuse_node_setattr(). 1566 * Serialize size access, see comment in perfuse_node_setattr().
1544 */ 1567 */
1545 while (pnd->pnd_flags & PND_INRESIZE) 1568 while (pnd->pnd_flags & PND_INRESIZE)
1546 requeue_request(pu, opc, PCQ_RESIZE); 1569 requeue_request(pu, opc, PCQ_RESIZE);
1547 pnd->pnd_flags |= PND_INRESIZE; 1570 pnd->pnd_flags |= PND_INRESIZE;
1548 1571
1549 ps = puffs_getspecific(pu); 1572 ps = puffs_getspecific(pu);
1550  1573
@@ -1917,37 +1940,26 @@ perfuse_node_poll(struct puffs_usermount @@ -1917,37 +1940,26 @@ perfuse_node_poll(struct puffs_usermount
1917 goto out; 1940 goto out;
1918 1941
1919 fpo = GET_OUTPAYLOAD(ps, pm, fuse_poll_out); 1942 fpo = GET_OUTPAYLOAD(ps, pm, fuse_poll_out);
1920 *events = fpo->revents; 1943 *events = fpo->revents;
1921 1944
1922 ps->ps_destroy_msg(pm); 1945 ps->ps_destroy_msg(pm);
1923 error = 0; 1946 error = 0;
1924 1947
1925out: 1948out:
1926 node_rele(opc); 1949 node_rele(opc);
1927 return error; 1950 return error;
1928} 1951}
1929 1952
1930/* ARGSUSED0 */ 
1931int 
1932perfuse_node_mmap(struct puffs_usermount *pu, puffs_cookie_t opc, int flags, 
1933 const struct puffs_cred *pcr) 
1934{ 
1935 /*  
1936 * Not implemented anymore in libfuse 
1937 */ 
1938 return ENOSYS; 
1939} 
1940 
1941/* ARGSUSED2 */ 1953/* ARGSUSED2 */
1942int 1954int
1943perfuse_node_fsync(struct puffs_usermount *pu, puffs_cookie_t opc, 1955perfuse_node_fsync(struct puffs_usermount *pu, puffs_cookie_t opc,
1944 const struct puffs_cred *pcr, int flags, off_t offlo, off_t offhi) 1956 const struct puffs_cred *pcr, int flags, off_t offlo, off_t offhi)
1945{ 1957{
1946 int op; 1958 int op;
1947 perfuse_msg_t *pm; 1959 perfuse_msg_t *pm;
1948 struct perfuse_state *ps; 1960 struct perfuse_state *ps;
1949 struct perfuse_node_data *pnd; 1961 struct perfuse_node_data *pnd;
1950 struct fuse_fsync_in *ffi; 1962 struct fuse_fsync_in *ffi;
1951 uint64_t fh; 1963 uint64_t fh;
1952 int error = 0; 1964 int error = 0;
1953  1965
@@ -2042,34 +2054,26 @@ perfuse_node_fsync(struct puffs_usermoun @@ -2042,34 +2054,26 @@ perfuse_node_fsync(struct puffs_usermoun
2042 error = 0; 2054 error = 0;
2043 2055
2044out: 2056out:
2045 /* 2057 /*
2046 * ENOSYS is not returned to kernel, 2058 * ENOSYS is not returned to kernel,
2047 */ 2059 */
2048 if (error == ENOSYS) 2060 if (error == ENOSYS)
2049 error = 0; 2061 error = 0;
2050 2062
2051 node_rele(opc); 2063 node_rele(opc);
2052 return error; 2064 return error;
2053} 2065}
2054 2066
2055/* ARGSUSED0 */ 
2056int 
2057perfuse_node_seek(struct puffs_usermount *pu, puffs_cookie_t opc, 
2058 off_t oldoff, off_t newoff, const struct puffs_cred *pcr) 
2059{ 
2060 return 0; 
2061} 
2062 
2063int 2067int
2064perfuse_node_remove(struct puffs_usermount *pu, puffs_cookie_t opc, 2068perfuse_node_remove(struct puffs_usermount *pu, puffs_cookie_t opc,
2065 puffs_cookie_t targ, const struct puffs_cn *pcn) 2069 puffs_cookie_t targ, const struct puffs_cn *pcn)
2066{ 2070{
2067 struct perfuse_state *ps; 2071 struct perfuse_state *ps;
2068 struct perfuse_node_data *pnd; 2072 struct perfuse_node_data *pnd;
2069 perfuse_msg_t *pm; 2073 perfuse_msg_t *pm;
2070 char *path; 2074 char *path;
2071 const char *name; 2075 const char *name;
2072 size_t len; 2076 size_t len;
2073 int error; 2077 int error;
2074  2078
2075 pnd = PERFUSE_NODE_DATA(opc); 2079 pnd = PERFUSE_NODE_DATA(opc);
@@ -3001,31 +3005,26 @@ perfuse_node_read(struct puffs_usermount @@ -3001,31 +3005,26 @@ perfuse_node_read(struct puffs_usermount
3001 int error; 3005 int error;
3002  3006
3003 ps = puffs_getspecific(pu); 3007 ps = puffs_getspecific(pu);
3004 pnd = PERFUSE_NODE_DATA(opc); 3008 pnd = PERFUSE_NODE_DATA(opc);
3005 vap = puffs_pn_getvap((struct puffs_node *)opc); 3009 vap = puffs_pn_getvap((struct puffs_node *)opc);
3006 3010
3007 /* 3011 /*
3008 * NetBSD turns that into a getdents(2) output 3012 * NetBSD turns that into a getdents(2) output
3009 * We just do a EISDIR as this feature is of little use. 3013 * We just do a EISDIR as this feature is of little use.
3010 */ 3014 */
3011 if (vap->va_type == VDIR) 3015 if (vap->va_type == VDIR)
3012 return EISDIR; 3016 return EISDIR;
3013 3017
3014 if ((u_quad_t)offset + *resid > vap->va_size) 
3015 DWARNX("%s %p read %lld@%zu beyond EOF %" PRIu64 "\n", 
3016 __func__, (void *)opc, (long long)offset, 
3017 *resid, vap->va_size); 
3018 
3019 do { 3018 do {
3020 size_t max_read; 3019 size_t max_read;
3021 3020
3022 max_read = ps->ps_max_readahead - sizeof(*foh); 3021 max_read = ps->ps_max_readahead - sizeof(*foh);
3023 /* 3022 /*
3024 * flags may be set to FUSE_READ_LOCKOWNER  3023 * flags may be set to FUSE_READ_LOCKOWNER
3025 * if lock_owner is provided. 3024 * if lock_owner is provided.
3026 */ 3025 */
3027 pm = ps->ps_new_msg(pu, opc, FUSE_READ, sizeof(*fri), pcr); 3026 pm = ps->ps_new_msg(pu, opc, FUSE_READ, sizeof(*fri), pcr);
3028 fri = GET_INPAYLOAD(ps, pm, fuse_read_in); 3027 fri = GET_INPAYLOAD(ps, pm, fuse_read_in);
3029 fri->fh = perfuse_get_fh(opc, FREAD); 3028 fri->fh = perfuse_get_fh(opc, FREAD);
3030 fri->offset = offset; 3029 fri->offset = offset;
3031 fri->size = (uint32_t)MIN(*resid, max_read); 3030 fri->size = (uint32_t)MIN(*resid, max_read);
@@ -3120,28 +3119,26 @@ perfuse_node_write2(struct puffs_usermou @@ -3120,28 +3119,26 @@ perfuse_node_write2(struct puffs_usermou
3120 */ 3119 */
3121 if ((u_quad_t)offset + *resid > vap->va_size) { 3120 if ((u_quad_t)offset + *resid > vap->va_size) {
3122 while (pnd->pnd_flags & PND_INRESIZE) 3121 while (pnd->pnd_flags & PND_INRESIZE)
3123 requeue_request(pu, opc, PCQ_RESIZE); 3122 requeue_request(pu, opc, PCQ_RESIZE);
3124 pnd->pnd_flags |= PND_INRESIZE; 3123 pnd->pnd_flags |= PND_INRESIZE;
3125 inresize = 1; 3124 inresize = 1;
3126 } 3125 }
3127 3126
3128 /* 3127 /*
3129 * append flag: re-read the file size so that  3128 * append flag: re-read the file size so that
3130 * we get the latest value. 3129 * we get the latest value.
3131 */ 3130 */
3132 if (ioflag & PUFFS_IO_APPEND) { 3131 if (ioflag & PUFFS_IO_APPEND) {
3133 DWARNX("%s: PUFFS_IO_APPEND set, untested code", __func__); 
3134 
3135 if ((error = perfuse_node_getattr(pu, opc, vap, pcr)) != 0) 3132 if ((error = perfuse_node_getattr(pu, opc, vap, pcr)) != 0)
3136 goto out; 3133 goto out;
3137 3134
3138 offset = vap->va_size; 3135 offset = vap->va_size;
3139 } 3136 }
3140 3137
3141#ifdef PERFUSE_DEBUG 3138#ifdef PERFUSE_DEBUG
3142 if (perfuse_diagflags & PDF_RESIZE) 3139 if (perfuse_diagflags & PDF_RESIZE)
3143 DPRINTF(">> %s %p %" PRIu64 "\n", __func__, 3140 DPRINTF(">> %s %p %" PRIu64 "\n", __func__,
3144 (void *)opc, vap->va_size); 3141 (void *)opc, vap->va_size);
3145#endif 3142#endif
3146 3143
3147 do { 3144 do {
@@ -3293,26 +3290,30 @@ perfuse_node_getextattr(struct puffs_use @@ -3293,26 +3290,30 @@ perfuse_node_getextattr(struct puffs_use
3293 size_t *resid, const struct puffs_cred *pcr) 3290 size_t *resid, const struct puffs_cred *pcr)
3294{ 3291{
3295 struct perfuse_state *ps; 3292 struct perfuse_state *ps;
3296 char fuse_attrname[LINUX_XATTR_NAME_MAX + 1]; 3293 char fuse_attrname[LINUX_XATTR_NAME_MAX + 1];
3297 perfuse_msg_t *pm; 3294 perfuse_msg_t *pm;
3298 struct fuse_getxattr_in *fgi; 3295 struct fuse_getxattr_in *fgi;
3299 struct fuse_getxattr_out *fgo; 3296 struct fuse_getxattr_out *fgo;
3300 struct fuse_out_header *foh; 3297 struct fuse_out_header *foh;
3301 size_t attrnamelen; 3298 size_t attrnamelen;
3302 size_t len; 3299 size_t len;
3303 char *np; 3300 char *np;
3304 int error; 3301 int error;
3305 3302
 3303 /* system namespace attrs are not accessible to non root users */
 3304 if (attrns == EXTATTR_NAMESPACE_SYSTEM && !puffs_cred_isjuggernaut(pcr))
 3305 return EPERM;
 3306
3306 node_ref(opc); 3307 node_ref(opc);
3307 ps = puffs_getspecific(pu); 3308 ps = puffs_getspecific(pu);
3308 attrname = perfuse_native_ns(attrns, attrname, fuse_attrname); 3309 attrname = perfuse_native_ns(attrns, attrname, fuse_attrname);
3309 attrnamelen = strlen(attrname) + 1; 3310 attrnamelen = strlen(attrname) + 1;
3310 len = sizeof(*fgi) + attrnamelen; 3311 len = sizeof(*fgi) + attrnamelen;
3311 3312
3312 pm = ps->ps_new_msg(pu, opc, FUSE_GETXATTR, len, pcr); 3313 pm = ps->ps_new_msg(pu, opc, FUSE_GETXATTR, len, pcr);
3313 fgi = GET_INPAYLOAD(ps, pm, fuse_getxattr_in); 3314 fgi = GET_INPAYLOAD(ps, pm, fuse_getxattr_in);
3314 fgi->size = (unsigned int)((resid != NULL) ? *resid : 0); 3315 fgi->size = (unsigned int)((resid != NULL) ? *resid : 0);
3315 np = (char *)(void *)(fgi + 1); 3316 np = (char *)(void *)(fgi + 1);
3316 (void)strlcpy(np, attrname, attrnamelen); 3317 (void)strlcpy(np, attrname, attrnamelen);
3317  3318
3318 if ((error = xchg_msg(pu, opc, pm, UNSPEC_REPLY_LEN, wait_reply)) != 0) 3319 if ((error = xchg_msg(pu, opc, pm, UNSPEC_REPLY_LEN, wait_reply)) != 0)
@@ -3329,55 +3330,68 @@ perfuse_node_getextattr(struct puffs_use @@ -3329,55 +3330,68 @@ perfuse_node_getextattr(struct puffs_use
3329 *attrsize = fgo->size; 3330 *attrsize = fgo->size;
3330 3331
3331 ps->ps_destroy_msg(pm); 3332 ps->ps_destroy_msg(pm);
3332 error = 0; 3333 error = 0;
3333 goto out; 3334 goto out;
3334 } 3335 }
3335 3336
3336 /* 3337 /*
3337 * And with a non null requested size, we get the list just  3338 * And with a non null requested size, we get the list just
3338 * after the header 3339 * after the header
3339 */ 3340 */
3340 foh = GET_OUTHDR(ps, pm); 3341 foh = GET_OUTHDR(ps, pm);
3341 np = (char *)(void *)(foh + 1); 3342 np = (char *)(void *)(foh + 1);
 3343 len = foh->len - sizeof(*foh);
 3344
 3345 if (attrsize != NULL)
 3346 *attrsize = len;
3342 3347
3343 if (resid != NULL) { 3348 if (resid != NULL) {
3344 len = MAX(foh->len - sizeof(*foh), *resid); 3349 if (*resid < len) {
 3350 error = ERANGE;
 3351 ps->ps_destroy_msg(pm);
 3352 goto out;
 3353 }
 3354
3345 (void)memcpy(attr, np, len); 3355 (void)memcpy(attr, np, len);
3346 *resid -= len; 3356 *resid -= len;
3347 } 3357 }
3348  3358
3349 ps->ps_destroy_msg(pm); 3359 ps->ps_destroy_msg(pm);
3350 error = 0; 3360 error = 0;
3351 3361
3352out: 3362out:
3353 node_rele(opc); 3363 node_rele(opc);
3354 return error; 3364 return error;
3355} 3365}
3356 3366
3357int 3367int
3358perfuse_node_setextattr(struct puffs_usermount *pu, puffs_cookie_t opc, 3368perfuse_node_setextattr(struct puffs_usermount *pu, puffs_cookie_t opc,
3359 int attrns, const char *attrname, uint8_t *attr, size_t *resid, 3369 int attrns, const char *attrname, uint8_t *attr, size_t *resid,
3360 const struct puffs_cred *pcr) 3370 const struct puffs_cred *pcr)
3361{ 3371{
3362 struct perfuse_state *ps; 3372 struct perfuse_state *ps;
3363 char fuse_attrname[LINUX_XATTR_NAME_MAX + 1]; 3373 char fuse_attrname[LINUX_XATTR_NAME_MAX + 1];
3364 perfuse_msg_t *pm; 3374 perfuse_msg_t *pm;
3365 struct fuse_setxattr_in *fsi; 3375 struct fuse_setxattr_in *fsi;
3366 size_t attrnamelen; 3376 size_t attrnamelen;
3367 size_t len; 3377 size_t len;
3368 char *np; 3378 char *np;
3369 int error; 3379 int error;
3370  3380
 3381 /* system namespace attrs are not accessible to non root users */
 3382 if (attrns == EXTATTR_NAMESPACE_SYSTEM && !puffs_cred_isjuggernaut(pcr))
 3383 return EPERM;
 3384
3371 node_ref(opc); 3385 node_ref(opc);
3372 ps = puffs_getspecific(pu); 3386 ps = puffs_getspecific(pu);
3373 attrname = perfuse_native_ns(attrns, attrname, fuse_attrname); 3387 attrname = perfuse_native_ns(attrns, attrname, fuse_attrname);
3374 attrnamelen = strlen(attrname) + 1; 3388 attrnamelen = strlen(attrname) + 1;
3375 len = sizeof(*fsi) + attrnamelen + *resid; 3389 len = sizeof(*fsi) + attrnamelen + *resid;
3376 3390
3377 pm = ps->ps_new_msg(pu, opc, FUSE_SETXATTR, len, pcr); 3391 pm = ps->ps_new_msg(pu, opc, FUSE_SETXATTR, len, pcr);
3378 fsi = GET_INPAYLOAD(ps, pm, fuse_setxattr_in); 3392 fsi = GET_INPAYLOAD(ps, pm, fuse_setxattr_in);
3379 fsi->size = (unsigned int)*resid; 3393 fsi->size = (unsigned int)*resid;
3380 fsi->flags = 0; 3394 fsi->flags = 0;
3381 np = (char *)(void *)(fsi + 1); 3395 np = (char *)(void *)(fsi + 1);
3382 (void)strlcpy(np, attrname, attrnamelen); 3396 (void)strlcpy(np, attrname, attrnamelen);
3383 np += attrnamelen; 3397 np += attrnamelen;
@@ -3398,29 +3412,33 @@ out: @@ -3398,29 +3412,33 @@ out:
3398 3412
3399/* ARGSUSED2 */ 3413/* ARGSUSED2 */
3400int 3414int
3401perfuse_node_listextattr(struct puffs_usermount *pu, puffs_cookie_t opc, 3415perfuse_node_listextattr(struct puffs_usermount *pu, puffs_cookie_t opc,
3402 int attrns, size_t *attrsize, uint8_t *attrs, size_t *resid, int flag, 3416 int attrns, size_t *attrsize, uint8_t *attrs, size_t *resid, int flag,
3403 const struct puffs_cred *pcr) 3417 const struct puffs_cred *pcr)
3404{ 3418{
3405 struct perfuse_state *ps; 3419 struct perfuse_state *ps;
3406 perfuse_msg_t *pm; 3420 perfuse_msg_t *pm;
3407 struct fuse_getxattr_in *fgi; 3421 struct fuse_getxattr_in *fgi;
3408 struct fuse_getxattr_out *fgo; 3422 struct fuse_getxattr_out *fgo;
3409 struct fuse_out_header *foh; 3423 struct fuse_out_header *foh;
3410 char *np; 3424 char *np;
3411 size_t len, puffs_len; 3425 size_t len, puffs_len, i, attrlen, outlen;
3412 int error; 3426 int error;
3413  3427
 3428 /* system namespace attrs are not accessible to non root users */
 3429 if (attrns == EXTATTR_NAMESPACE_SYSTEM && !puffs_cred_isjuggernaut(pcr))
 3430 return EPERM;
 3431
3414 node_ref(opc); 3432 node_ref(opc);
3415 3433
3416 ps = puffs_getspecific(pu); 3434 ps = puffs_getspecific(pu);
3417 len = sizeof(*fgi); 3435 len = sizeof(*fgi);
3418 3436
3419 pm = ps->ps_new_msg(pu, opc, FUSE_LISTXATTR, len, pcr); 3437 pm = ps->ps_new_msg(pu, opc, FUSE_LISTXATTR, len, pcr);
3420 fgi = GET_INPAYLOAD(ps, pm, fuse_getxattr_in); 3438 fgi = GET_INPAYLOAD(ps, pm, fuse_getxattr_in);
3421 if (resid != NULL) 3439 if (resid != NULL)
3422 fgi->size = (unsigned int)*resid; 3440 fgi->size = (unsigned int)*resid;
3423 else 3441 else
3424 fgi->size = 0; 3442 fgi->size = 0;
3425  3443
3426 if ((error = xchg_msg(pu, opc, pm, UNSPEC_REPLY_LEN, wait_reply)) != 0) 3444 if ((error = xchg_msg(pu, opc, pm, UNSPEC_REPLY_LEN, wait_reply)) != 0)
@@ -3440,68 +3458,88 @@ perfuse_node_listextattr(struct puffs_us @@ -3440,68 +3458,88 @@ perfuse_node_listextattr(struct puffs_us
3440 3458
3441 error = 0; 3459 error = 0;
3442 goto out; 3460 goto out;
3443 } 3461 }
3444 3462
3445 /* 3463 /*
3446 * And with a non null requested size, we get the list just  3464 * And with a non null requested size, we get the list just
3447 * after the header 3465 * after the header
3448 */ 3466 */
3449 foh = GET_OUTHDR(ps, pm); 3467 foh = GET_OUTHDR(ps, pm);
3450 np = (char *)(void *)(foh + 1); 3468 np = (char *)(void *)(foh + 1);
3451 puffs_len = foh->len - sizeof(*foh); 3469 puffs_len = foh->len - sizeof(*foh);
3452 3470
3453 if (attrs != NULL) { 3471 if (attrsize != NULL)
3454#ifdef PUFFS_EXTATTR_LIST_LENPREFIX 3472 *attrsize = puffs_len;
3455 /*  
3456 * Convert the FUSE reply to length prefixed strings 
3457 * if this is what the kernel wants. 
3458 */ 
3459 if (flag & PUFFS_EXTATTR_LIST_LENPREFIX) { 
3460 size_t i, attrlen; 
3461 3473
3462 for (i = 0; i < puffs_len; i += attrlen + 1) { 3474 if (attrs != NULL) {
3463 attrlen = strlen(np + i); 3475 if (*resid < puffs_len) {
3464 (void)memmove(np + i + 1, np + i, attrlen); 3476 error = ERANGE;
3465 *(np + i) = (uint8_t)attrlen; 3477 ps->ps_destroy_msg(pm);
3466 }  3478 goto out;
3467 } 3479 }
 3480
 3481 outlen = 0;
 3482
 3483 for (i = 0; i < puffs_len; i += attrlen + 1) {
 3484 attrlen = strlen(np + i);
 3485
 3486 /*
 3487 * Filter attributes per namespace
 3488 */
 3489 if (!perfuse_ns_match(attrns, np + i))
 3490 continue;
 3491
 3492#ifdef PUFFS_EXTATTR_LIST_LENPREFIX
 3493 /*
 3494 * Convert the FUSE reply to length prefixed strings
 3495 * if this is what the kernel wants.
 3496 */
 3497 if (flag & PUFFS_EXTATTR_LIST_LENPREFIX) {
 3498 (void)memcpy(attrs + outlen + 1,
 3499 np + i, attrlen);
 3500 *(attrs + outlen) = (uint8_t)attrlen;
 3501 } else
3468#endif /* PUFFS_EXTATTR_LIST_LENPREFIX */ 3502#endif /* PUFFS_EXTATTR_LIST_LENPREFIX */
3469 (void)memcpy(attrs, np, puffs_len); 3503 (void)memcpy(attrs + outlen, np + i, attrlen + 1);
3470 *resid -= puffs_len; 3504 outlen += attrlen + 1;
3471 } 3505 }
3472 3506
3473 if (attrsize != NULL)  3507 *resid -= outlen;
3474 *attrsize = puffs_len; 3508 }
3475 3509
3476 ps->ps_destroy_msg(pm); 3510 ps->ps_destroy_msg(pm);
3477 error = 0; 3511 error = 0;
3478 3512
3479out: 3513out:
3480 node_rele(opc); 3514 node_rele(opc);
3481 return error; 3515 return error;
3482} 3516}
3483 3517
3484int 3518int
3485perfuse_node_deleteextattr(struct puffs_usermount *pu, puffs_cookie_t opc, 3519perfuse_node_deleteextattr(struct puffs_usermount *pu, puffs_cookie_t opc,
3486 int attrns, const char *attrname, const struct puffs_cred *pcr) 3520 int attrns, const char *attrname, const struct puffs_cred *pcr)
3487{ 3521{
3488 struct perfuse_state *ps; 3522 struct perfuse_state *ps;
3489 char fuse_attrname[LINUX_XATTR_NAME_MAX + 1]; 3523 char fuse_attrname[LINUX_XATTR_NAME_MAX + 1];
3490 perfuse_msg_t *pm; 3524 perfuse_msg_t *pm;
3491 size_t attrnamelen; 3525 size_t attrnamelen;
3492 char *np; 3526 char *np;
3493 int error; 3527 int error;
3494  3528
 3529 /* system namespace attrs are not accessible to non root users */
 3530 if (attrns == EXTATTR_NAMESPACE_SYSTEM && !puffs_cred_isjuggernaut(pcr))
 3531 return EPERM;
 3532
3495 node_ref(opc); 3533 node_ref(opc);
3496 3534
3497 ps = puffs_getspecific(pu); 3535 ps = puffs_getspecific(pu);
3498 attrname = perfuse_native_ns(attrns, attrname, fuse_attrname); 3536 attrname = perfuse_native_ns(attrns, attrname, fuse_attrname);
3499 attrnamelen = strlen(attrname) + 1; 3537 attrnamelen = strlen(attrname) + 1;
3500 3538
3501 pm = ps->ps_new_msg(pu, opc, FUSE_REMOVEXATTR, attrnamelen, pcr); 3539 pm = ps->ps_new_msg(pu, opc, FUSE_REMOVEXATTR, attrnamelen, pcr);
3502 np = _GET_INPAYLOAD(ps, pm, char *); 3540 np = _GET_INPAYLOAD(ps, pm, char *);
3503 (void)strlcpy(np, attrname, attrnamelen); 3541 (void)strlcpy(np, attrname, attrnamelen);
3504  3542
3505 error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply); 3543 error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply);
3506  3544
3507 ps->ps_destroy_msg(pm); 3545 ps->ps_destroy_msg(pm);

cvs diff -r1.25.2.3 -r1.25.2.4 src/lib/libperfuse/perfuse.c (expand / switch to unified diff)

--- src/lib/libperfuse/perfuse.c 2012/09/13 22:31:03 1.25.2.3
+++ src/lib/libperfuse/perfuse.c 2014/11/03 19:18:09 1.25.2.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: perfuse.c,v 1.25.2.3 2012/09/13 22:31:03 riz Exp $ */ 1/* $NetBSD: perfuse.c,v 1.25.2.4 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. 4 * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 *  14 *
@@ -461,31 +461,27 @@ perfuse_init(struct perfuse_callbacks *p @@ -461,31 +461,27 @@ perfuse_init(struct perfuse_callbacks *p
461 PUFFSOP_INIT(pops); 461 PUFFSOP_INIT(pops);
462 PUFFSOP_SET(pops, perfuse, fs, unmount); 462 PUFFSOP_SET(pops, perfuse, fs, unmount);
463 PUFFSOP_SET(pops, perfuse, fs, statvfs); 463 PUFFSOP_SET(pops, perfuse, fs, statvfs);
464 PUFFSOP_SET(pops, perfuse, fs, sync); 464 PUFFSOP_SET(pops, perfuse, fs, sync);
465 PUFFSOP_SET(pops, perfuse, node, lookup); 465 PUFFSOP_SET(pops, perfuse, node, lookup);
466 PUFFSOP_SET(pops, perfuse, node, create); 466 PUFFSOP_SET(pops, perfuse, node, create);
467 PUFFSOP_SET(pops, perfuse, node, mknod); 467 PUFFSOP_SET(pops, perfuse, node, mknod);
468 PUFFSOP_SET(pops, perfuse, node, open); 468 PUFFSOP_SET(pops, perfuse, node, open);
469 PUFFSOP_SET(pops, perfuse, node, close); 469 PUFFSOP_SET(pops, perfuse, node, close);
470 PUFFSOP_SET(pops, perfuse, node, access); 470 PUFFSOP_SET(pops, perfuse, node, access);
471 PUFFSOP_SET(pops, perfuse, node, getattr); 471 PUFFSOP_SET(pops, perfuse, node, getattr);
472 PUFFSOP_SET(pops, perfuse, node, setattr); 472 PUFFSOP_SET(pops, perfuse, node, setattr);
473 PUFFSOP_SET(pops, perfuse, node, poll); 473 PUFFSOP_SET(pops, perfuse, node, poll);
474#if 0  
475 PUFFSOP_SET(pops, perfuse, node, mmap); 
476#endif 
477 PUFFSOP_SET(pops, perfuse, node, fsync); 474 PUFFSOP_SET(pops, perfuse, node, fsync);
478 PUFFSOP_SET(pops, perfuse, node, seek); 
479 PUFFSOP_SET(pops, perfuse, node, remove); 475 PUFFSOP_SET(pops, perfuse, node, remove);
480 PUFFSOP_SET(pops, perfuse, node, link); 476 PUFFSOP_SET(pops, perfuse, node, link);
481 PUFFSOP_SET(pops, perfuse, node, rename); 477 PUFFSOP_SET(pops, perfuse, node, rename);
482 PUFFSOP_SET(pops, perfuse, node, mkdir); 478 PUFFSOP_SET(pops, perfuse, node, mkdir);
483 PUFFSOP_SET(pops, perfuse, node, rmdir); 479 PUFFSOP_SET(pops, perfuse, node, rmdir);
484 PUFFSOP_SET(pops, perfuse, node, symlink); 480 PUFFSOP_SET(pops, perfuse, node, symlink);
485 PUFFSOP_SET(pops, perfuse, node, readdir); 481 PUFFSOP_SET(pops, perfuse, node, readdir);
486 PUFFSOP_SET(pops, perfuse, node, readlink); 482 PUFFSOP_SET(pops, perfuse, node, readlink);
487 PUFFSOP_SET(pops, perfuse, node, reclaim); 483 PUFFSOP_SET(pops, perfuse, node, reclaim);
488 PUFFSOP_SET(pops, perfuse, node, inactive); 484 PUFFSOP_SET(pops, perfuse, node, inactive);
489 PUFFSOP_SET(pops, perfuse, node, print); 485 PUFFSOP_SET(pops, perfuse, node, print);
490 PUFFSOP_SET(pops, perfuse, node, advlock); 486 PUFFSOP_SET(pops, perfuse, node, advlock);
491 PUFFSOP_SET(pops, perfuse, node, read); 487 PUFFSOP_SET(pops, perfuse, node, read);
@@ -493,26 +489,29 @@ perfuse_init(struct perfuse_callbacks *p @@ -493,26 +489,29 @@ perfuse_init(struct perfuse_callbacks *p
493#ifdef PUFFS_EXTNAMELEN 489#ifdef PUFFS_EXTNAMELEN
494 PUFFSOP_SET(pops, perfuse, node, getextattr); 490 PUFFSOP_SET(pops, perfuse, node, getextattr);
495 PUFFSOP_SET(pops, perfuse, node, setextattr); 491 PUFFSOP_SET(pops, perfuse, node, setextattr);
496 PUFFSOP_SET(pops, perfuse, node, listextattr); 492 PUFFSOP_SET(pops, perfuse, node, listextattr);
497 PUFFSOP_SET(pops, perfuse, node, deleteextattr); 493 PUFFSOP_SET(pops, perfuse, node, deleteextattr);
498#endif /* PUFFS_EXTNAMELEN */ 494#endif /* PUFFS_EXTNAMELEN */
499#ifdef PUFFS_KFLAG_CACHE_FS_TTL 495#ifdef PUFFS_KFLAG_CACHE_FS_TTL
500 PUFFSOP_SET(pops, perfuse, node, getattr_ttl); 496 PUFFSOP_SET(pops, perfuse, node, getattr_ttl);
501 PUFFSOP_SET(pops, perfuse, node, setattr_ttl); 497 PUFFSOP_SET(pops, perfuse, node, setattr_ttl);
502#endif /* PUFFS_KFLAG_CACHE_FS_TTL */ 498#endif /* PUFFS_KFLAG_CACHE_FS_TTL */
503#ifdef PUFFS_SETATTR_FAF 499#ifdef PUFFS_SETATTR_FAF
504 PUFFSOP_SET(pops, perfuse, node, write2); 500 PUFFSOP_SET(pops, perfuse, node, write2);
505#endif /* PUFFS_SETATTR_FAF */ 501#endif /* PUFFS_SETATTR_FAF */
 502#ifdef PUFFS_OPEN_IO_DIRECT
 503 PUFFSOP_SET(pops, perfuse, node, open2);
 504#endif /* PUFFS_OPEN_IO_DIRECT */
506 505
507 /* 506 /*
508 * PUFFS_KFLAG_NOCACHE_NAME is required so that we can see changes 507 * PUFFS_KFLAG_NOCACHE_NAME is required so that we can see changes
509 * done by other machines in networked filesystems. In later 508 * done by other machines in networked filesystems. In later
510 * NetBSD releases we use the alternative PUFFS_KFLAG_CACHE_FS_TTL,  509 * NetBSD releases we use the alternative PUFFS_KFLAG_CACHE_FS_TTL,
511 * which implement name cache with a filesystem-provided TTL. 510 * which implement name cache with a filesystem-provided TTL.
512 */ 511 */
513#ifdef PUFFS_KFLAG_CACHE_FS_TTL 512#ifdef PUFFS_KFLAG_CACHE_FS_TTL
514 puffs_flags = PUFFS_KFLAG_CACHE_FS_TTL; 513 puffs_flags = PUFFS_KFLAG_CACHE_FS_TTL;
515#else 514#else
516 puffs_flags = PUFFS_KFLAG_NOCACHE_NAME; 515 puffs_flags = PUFFS_KFLAG_NOCACHE_NAME;
517#endif 516#endif
518 517

cvs diff -r1.25.2.4 -r1.25.2.5 src/lib/libperfuse/perfuse_priv.h (expand / switch to unified diff)

--- src/lib/libperfuse/perfuse_priv.h 2012/08/12 13:13:20 1.25.2.4
+++ src/lib/libperfuse/perfuse_priv.h 2014/11/03 19:18:09 1.25.2.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: perfuse_priv.h,v 1.25.2.4 2012/08/12 13:13:20 martin Exp $ */ 1/* $NetBSD: perfuse_priv.h,v 1.25.2.5 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. 4 * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 *  14 *
@@ -176,26 +176,27 @@ struct perfuse_node_data { @@ -176,26 +176,27 @@ struct perfuse_node_data {
176#define _GET_OUTPAYLOAD(ps, pm, type) (type)ps->ps_get_outpayload(pm) 176#define _GET_OUTPAYLOAD(ps, pm, type) (type)ps->ps_get_outpayload(pm)
177 177
178__BEGIN_DECLS 178__BEGIN_DECLS
179 179
180struct puffs_node *perfuse_new_pn(struct puffs_usermount *, const char *, 180struct puffs_node *perfuse_new_pn(struct puffs_usermount *, const char *,
181 struct puffs_node *); 181 struct puffs_node *);
182void perfuse_destroy_pn(struct puffs_usermount *, struct puffs_node *); 182void perfuse_destroy_pn(struct puffs_usermount *, struct puffs_node *);
183void perfuse_new_fh(puffs_cookie_t, uint64_t, int); 183void perfuse_new_fh(puffs_cookie_t, uint64_t, int);
184void perfuse_destroy_fh(puffs_cookie_t, uint64_t); 184void perfuse_destroy_fh(puffs_cookie_t, uint64_t);
185uint64_t perfuse_get_fh(puffs_cookie_t, int); 185uint64_t perfuse_get_fh(puffs_cookie_t, int);
186uint64_t perfuse_next_unique(struct puffs_usermount *); 186uint64_t perfuse_next_unique(struct puffs_usermount *);
187char *perfuse_node_path(struct perfuse_state *, puffs_cookie_t); 187char *perfuse_node_path(struct perfuse_state *, puffs_cookie_t);
188int perfuse_node_close_common(struct puffs_usermount *, puffs_cookie_t, int); 188int perfuse_node_close_common(struct puffs_usermount *, puffs_cookie_t, int);
 189int perfuse_ns_match(const int, const char *);
189const char *perfuse_native_ns(const int, const char *, char *); 190const char *perfuse_native_ns(const int, const char *, char *);
190 191
191char *perfuse_fs_mount(int, ssize_t); 192char *perfuse_fs_mount(int, ssize_t);
192 193
193 194
194/* 195/*
195 * ops.c - filesystem operations 196 * ops.c - filesystem operations
196 */ 197 */
197int perfuse_fs_unmount(struct puffs_usermount *, int); 198int perfuse_fs_unmount(struct puffs_usermount *, int);
198int perfuse_fs_statvfs(struct puffs_usermount *, struct statvfs *); 199int perfuse_fs_statvfs(struct puffs_usermount *, struct statvfs *);
199int perfuse_fs_sync(struct puffs_usermount *, int, 200int perfuse_fs_sync(struct puffs_usermount *, int,
200 const struct puffs_cred *); 201 const struct puffs_cred *);
201int perfuse_fs_fhtonode(struct puffs_usermount *, void *, size_t, 202int perfuse_fs_fhtonode(struct puffs_usermount *, void *, size_t,
@@ -212,32 +213,28 @@ int perfuse_node_mknod(struct puffs_user @@ -212,32 +213,28 @@ int perfuse_node_mknod(struct puffs_user
212 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *, 213 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
213 const struct vattr *); 214 const struct vattr *);
214int perfuse_node_open(struct puffs_usermount *, 215int perfuse_node_open(struct puffs_usermount *,
215 puffs_cookie_t, int, const struct puffs_cred *); 216 puffs_cookie_t, int, const struct puffs_cred *);
216int perfuse_node_close(struct puffs_usermount *, 217int perfuse_node_close(struct puffs_usermount *,
217 puffs_cookie_t, int, const struct puffs_cred *); 218 puffs_cookie_t, int, const struct puffs_cred *);
218int perfuse_node_access(struct puffs_usermount *, 219int perfuse_node_access(struct puffs_usermount *,
219 puffs_cookie_t, int, const struct puffs_cred *); 220 puffs_cookie_t, int, const struct puffs_cred *);
220int perfuse_node_getattr(struct puffs_usermount *, 221int perfuse_node_getattr(struct puffs_usermount *,
221 puffs_cookie_t, struct vattr *, const struct puffs_cred *); 222 puffs_cookie_t, struct vattr *, const struct puffs_cred *);
222int perfuse_node_setattr(struct puffs_usermount *, 223int perfuse_node_setattr(struct puffs_usermount *,
223 puffs_cookie_t, const struct vattr *, const struct puffs_cred *); 224 puffs_cookie_t, const struct vattr *, const struct puffs_cred *);
224int perfuse_node_poll(struct puffs_usermount *, puffs_cookie_t, int *); 225int perfuse_node_poll(struct puffs_usermount *, puffs_cookie_t, int *);
225int perfuse_node_mmap(struct puffs_usermount *, 
226 puffs_cookie_t, vm_prot_t, const struct puffs_cred *); 
227int perfuse_node_fsync(struct puffs_usermount *, 226int perfuse_node_fsync(struct puffs_usermount *,
228 puffs_cookie_t, const struct puffs_cred *, int, off_t, off_t); 227 puffs_cookie_t, const struct puffs_cred *, int, off_t, off_t);
229int perfuse_node_seek(struct puffs_usermount *, 
230 puffs_cookie_t, off_t, off_t, const struct puffs_cred *); 
231int perfuse_node_remove(struct puffs_usermount *, 228int perfuse_node_remove(struct puffs_usermount *,
232 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); 229 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
233int perfuse_node_link(struct puffs_usermount *, 230int perfuse_node_link(struct puffs_usermount *,
234 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); 231 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
235int perfuse_node_rename(struct puffs_usermount *, 232int perfuse_node_rename(struct puffs_usermount *,
236 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *, 233 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *,
237 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); 234 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
238int perfuse_node_mkdir(struct puffs_usermount *, 235int perfuse_node_mkdir(struct puffs_usermount *,
239 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *, 236 puffs_cookie_t, struct puffs_newinfo *, const struct puffs_cn *,
240 const struct vattr *); 237 const struct vattr *);
241int perfuse_node_rmdir(struct puffs_usermount *, 238int perfuse_node_rmdir(struct puffs_usermount *,
242 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); 239 puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *);
243int perfuse_node_symlink(struct puffs_usermount *, 240int perfuse_node_symlink(struct puffs_usermount *,
@@ -251,26 +248,28 @@ int perfuse_node_readlink(struct puffs_u @@ -251,26 +248,28 @@ int perfuse_node_readlink(struct puffs_u
251int perfuse_node_reclaim(struct puffs_usermount *, puffs_cookie_t); 248int perfuse_node_reclaim(struct puffs_usermount *, puffs_cookie_t);
252int perfuse_node_inactive(struct puffs_usermount *, puffs_cookie_t); 249int perfuse_node_inactive(struct puffs_usermount *, puffs_cookie_t);
253int perfuse_node_print(struct puffs_usermount *, puffs_cookie_t); 250int perfuse_node_print(struct puffs_usermount *, puffs_cookie_t);
254int perfuse_node_pathconf(struct puffs_usermount *, 251int perfuse_node_pathconf(struct puffs_usermount *,
255 puffs_cookie_t, int, int *); 252 puffs_cookie_t, int, int *);
256int perfuse_node_advlock(struct puffs_usermount *, 253int perfuse_node_advlock(struct puffs_usermount *,
257 puffs_cookie_t, void *, int, struct flock *, int); 254 puffs_cookie_t, void *, int, struct flock *, int);
258int perfuse_node_read(struct puffs_usermount *, puffs_cookie_t, 255int perfuse_node_read(struct puffs_usermount *, puffs_cookie_t,
259 uint8_t *, off_t, size_t *, const struct puffs_cred *, int); 256 uint8_t *, off_t, size_t *, const struct puffs_cred *, int);
260int perfuse_node_write(struct puffs_usermount *, puffs_cookie_t, 257int perfuse_node_write(struct puffs_usermount *, puffs_cookie_t,
261 uint8_t *, off_t, size_t *, const struct puffs_cred *, int); 258 uint8_t *, off_t, size_t *, const struct puffs_cred *, int);
262int perfuse_node_write2(struct puffs_usermount *, puffs_cookie_t, 259int perfuse_node_write2(struct puffs_usermount *, puffs_cookie_t,
263 uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int); 260 uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int);
 261int perfuse_node_open2(struct puffs_usermount *,
 262 puffs_cookie_t, int, const struct puffs_cred *, int *);
264void perfuse_cache_write(struct puffs_usermount *, 263void perfuse_cache_write(struct puffs_usermount *,
265 puffs_cookie_t, size_t, struct puffs_cacherun *); 264 puffs_cookie_t, size_t, struct puffs_cacherun *);
266int perfuse_node_getextattr(struct puffs_usermount *, puffs_cookie_t, 265int perfuse_node_getextattr(struct puffs_usermount *, puffs_cookie_t,
267 int, const char *, size_t *, uint8_t *, size_t *,  266 int, const char *, size_t *, uint8_t *, size_t *,
268 const struct puffs_cred *); 267 const struct puffs_cred *);
269int perfuse_node_setextattr(struct puffs_usermount *, puffs_cookie_t, 268int perfuse_node_setextattr(struct puffs_usermount *, puffs_cookie_t,
270 int, const char *, uint8_t *, size_t *, const struct puffs_cred *); 269 int, const char *, uint8_t *, size_t *, const struct puffs_cred *);
271int perfuse_node_listextattr(struct puffs_usermount *, puffs_cookie_t, 270int perfuse_node_listextattr(struct puffs_usermount *, puffs_cookie_t,
272 int, size_t *, uint8_t *, size_t *, int, const struct puffs_cred *); 271 int, size_t *, uint8_t *, size_t *, int, const struct puffs_cred *);
273int perfuse_node_deleteextattr(struct puffs_usermount *, puffs_cookie_t, 272int perfuse_node_deleteextattr(struct puffs_usermount *, puffs_cookie_t,
274 int, const char *, const struct puffs_cred *); 273 int, const char *, const struct puffs_cred *);
275int perfuse_node_getattr_ttl(struct puffs_usermount *, 274int perfuse_node_getattr_ttl(struct puffs_usermount *,
276 puffs_cookie_t, struct vattr *, const struct puffs_cred *, 275 puffs_cookie_t, struct vattr *, const struct puffs_cred *,

cvs diff -r1.15.2.3 -r1.15.2.4 src/lib/libperfuse/subr.c (expand / switch to unified diff)

--- src/lib/libperfuse/subr.c 2012/08/12 13:13:20 1.15.2.3
+++ src/lib/libperfuse/subr.c 2014/11/03 19:18:09 1.15.2.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: subr.c,v 1.15.2.3 2012/08/12 13:13:20 martin Exp $ */ 1/* $NetBSD: subr.c,v 1.15.2.4 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. 4 * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 *  14 *
@@ -205,26 +205,40 @@ char * @@ -205,26 +205,40 @@ char *
205perfuse_node_path(struct perfuse_state *ps, puffs_cookie_t opc) 205perfuse_node_path(struct perfuse_state *ps, puffs_cookie_t opc)
206{ 206{
207 static char buf[MAXPATHLEN + 1]; 207 static char buf[MAXPATHLEN + 1];
208 208
209#if 0 209#if 0
210 if (node_path(ps, opc, buf, sizeof(buf)) == 0) 210 if (node_path(ps, opc, buf, sizeof(buf)) == 0)
211 sprintf(buf, "/"); 211 sprintf(buf, "/");
212#endif 212#endif
213 sprintf(buf, "%s", PERFUSE_NODE_DATA(opc)->pnd_name); 213 sprintf(buf, "%s", PERFUSE_NODE_DATA(opc)->pnd_name);
214 214
215 return buf; 215 return buf;
216} 216}
217 217
 218int
 219perfuse_ns_match(const int attrnamespace, const char *attrname)
 220{
 221 const char *system_ns[] = { "system.", "trusted.", "security", NULL };
 222 int i;
 223
 224 for (i = 0; system_ns[i]; i++) {
 225 if (strncmp(attrname, system_ns[i], strlen(system_ns[i])) == 0)
 226 return (attrnamespace == EXTATTR_NAMESPACE_SYSTEM);
 227 }
 228
 229 return (attrnamespace == EXTATTR_NAMESPACE_USER);
 230}
 231
218const char * 232const char *
219perfuse_native_ns(const int attrnamespace, const char *attrname, 233perfuse_native_ns(const int attrnamespace, const char *attrname,
220 char *fuse_attrname) 234 char *fuse_attrname)
221{ 235{
222 const struct perfuse_ns_map *pnm; 236 const struct perfuse_ns_map *pnm;
223 const struct perfuse_ns_map perfuse_ns_map[] = { 237 const struct perfuse_ns_map perfuse_ns_map[] = {
224 PERFUSE_NS_MAP("trusted", EXTATTR_NAMESPACE_SYSTEM), 238 PERFUSE_NS_MAP("trusted", EXTATTR_NAMESPACE_SYSTEM),
225 PERFUSE_NS_MAP("security", EXTATTR_NAMESPACE_SYSTEM), 239 PERFUSE_NS_MAP("security", EXTATTR_NAMESPACE_SYSTEM),
226 PERFUSE_NS_MAP("system", EXTATTR_NAMESPACE_SYSTEM), 240 PERFUSE_NS_MAP("system", EXTATTR_NAMESPACE_SYSTEM),
227 PERFUSE_NS_MAP("user", EXTATTR_NAMESPACE_USER), 241 PERFUSE_NS_MAP("user", EXTATTR_NAMESPACE_USER),
228 { NULL, 0, EXTATTR_NAMESPACE_USER }, 242 { NULL, 0, EXTATTR_NAMESPACE_USER },
229 }; 243 };
230 244

cvs diff -r1.15 -r1.15.8.1 src/lib/libpuffs/creds.c (expand / switch to unified diff)

--- src/lib/libpuffs/creds.c 2009/11/20 14:23:54 1.15
+++ src/lib/libpuffs/creds.c 2014/11/03 19:18:09 1.15.8.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: creds.c,v 1.15 2009/11/20 14:23:54 pooka Exp $ */ 1/* $NetBSD: creds.c,v 1.15.8.1 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2006 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the Ulla Tuominen Foundation. 6 * Development of this software was supported by the Ulla Tuominen Foundation.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31#if !defined(lint) 31#if !defined(lint)
32__RCSID("$NetBSD: creds.c,v 1.15 2009/11/20 14:23:54 pooka Exp $"); 32__RCSID("$NetBSD: creds.c,v 1.15.8.1 2014/11/03 19:18:09 msaitoh Exp $");
33#endif /* !lint */ 33#endif /* !lint */
34 34
35/* 35/*
36 * Interface for dealing with credits. 36 * Interface for dealing with credits.
37 */ 37 */
38 38
39#include <sys/types.h> 39#include <sys/types.h>
40#include <sys/param.h> 40#include <sys/param.h>
41 41
42#include <errno.h> 42#include <errno.h>
43#include <puffs.h> 43#include <puffs.h>
44#include <stdbool.h> 44#include <stdbool.h>
45#include <string.h> 45#include <string.h>
@@ -240,20 +240,21 @@ puffs_access_chmod(uid_t owner, gid_t gr @@ -240,20 +240,21 @@ puffs_access_chmod(uid_t owner, gid_t gr
240 return EFTYPE; 240 return EFTYPE;
241 if (!puffs_cred_hasgroup(pcr, group) && (mode & S_ISGID)) 241 if (!puffs_cred_hasgroup(pcr, group) && (mode & S_ISGID))
242 return EPERM; 242 return EPERM;
243 } 243 }
244 244
245 return 0; 245 return 0;
246} 246}
247 247
248int 248int
249puffs_access_times(uid_t uid, gid_t gid, mode_t mode, int va_utimes_null, 249puffs_access_times(uid_t uid, gid_t gid, mode_t mode, int va_utimes_null,
250 const struct puffs_cred *pcr) 250 const struct puffs_cred *pcr)
251{ 251{
252 252
253 if (!puffs_cred_isuid(pcr, uid) && !puffs_cred_isjuggernaut(pcr) 253 if (puffs_cred_isuid(pcr, uid) || puffs_cred_isjuggernaut(pcr))
254 && (va_utimes_null == 0 254 return 0;
255 || puffs_access(VNON, mode, uid, gid, PUFFS_VWRITE, pcr) != 0)) 255
 256 if (va_utimes_null == 0)
256 return EPERM; 257 return EPERM;
257 258
258 return 0; 259 return puffs_access(VNON, mode, uid, gid, PUFFS_VWRITE, pcr);
259} 260}

cvs diff -r1.38.2.4 -r1.38.2.5 src/lib/libpuffs/dispatcher.c (expand / switch to unified diff)

--- src/lib/libpuffs/dispatcher.c 2012/09/13 20:20:15 1.38.2.4
+++ src/lib/libpuffs/dispatcher.c 2014/11/03 19:18:09 1.38.2.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dispatcher.c,v 1.38.2.4 2012/09/13 20:20:15 riz Exp $ */ 1/* $NetBSD: dispatcher.c,v 1.38.2.5 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006, 2007, 2008 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2006, 2007, 2008 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the 6 * Development of this software was supported by the
7 * Ulla Tuominen Foundation, the Finnish Cultural Foundation and 7 * Ulla Tuominen Foundation, the Finnish Cultural Foundation and
8 * Research Foundation of Helsinki University of Technology. 8 * Research Foundation of Helsinki University of Technology.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#if !defined(lint) 33#if !defined(lint)
34__RCSID("$NetBSD: dispatcher.c,v 1.38.2.4 2012/09/13 20:20:15 riz Exp $"); 34__RCSID("$NetBSD: dispatcher.c,v 1.38.2.5 2014/11/03 19:18:09 msaitoh Exp $");
35#endif /* !lint */ 35#endif /* !lint */
36 36
37#include <sys/types.h> 37#include <sys/types.h>
38#include <sys/poll.h> 38#include <sys/poll.h>
39 39
40#include <assert.h> 40#include <assert.h>
41#include <errno.h> 41#include <errno.h>
42#include <pthread.h> 42#include <pthread.h>
43#include <puffs.h> 43#include <puffs.h>
44#include <puffsdump.h> 44#include <puffsdump.h>
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <unistd.h> 47#include <unistd.h>
@@ -402,26 +402,34 @@ dispatch(struct puffs_cc *pcc) @@ -402,26 +402,34 @@ dispatch(struct puffs_cc *pcc)
402 if (pncookie && !error) { 402 if (pncookie && !error) {
403 if (pn == NULL) 403 if (pn == NULL)
404 pn = PU_CMAP(pu, auxt->pvnr_newnode); 404 pn = PU_CMAP(pu, auxt->pvnr_newnode);
405 pn->pn_nlookup++; 405 pn->pn_nlookup++;
406 } 406 }
407 break; 407 break;
408 } 408 }
409 409
410 case PUFFS_VN_OPEN: 410 case PUFFS_VN_OPEN:
411 { 411 {
412 struct puffs_vnmsg_open *auxt = auxbuf; 412 struct puffs_vnmsg_open *auxt = auxbuf;
413 PUFFS_MAKECRED(pcr, &auxt->pvnr_cred); 413 PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
414 414
 415 if (pops->puffs_node_open2 != NULL) {
 416 error = pops->puffs_node_open2(pu,
 417 opcookie, auxt->pvnr_mode, pcr,
 418 &auxt->pvnr_oflags);
 419
 420 break;
 421 }
 422
415 if (pops->puffs_node_open == NULL) { 423 if (pops->puffs_node_open == NULL) {
416 error = 0; 424 error = 0;
417 break; 425 break;
418 } 426 }
419 427
420 error = pops->puffs_node_open(pu, 428 error = pops->puffs_node_open(pu,
421 opcookie, auxt->pvnr_mode, pcr); 429 opcookie, auxt->pvnr_mode, pcr);
422 break; 430 break;
423 } 431 }
424 432
425 case PUFFS_VN_CLOSE: 433 case PUFFS_VN_CLOSE:
426 { 434 {
427 struct puffs_vnmsg_close *auxt = auxbuf; 435 struct puffs_vnmsg_close *auxt = auxbuf;

cvs diff -r1.119.4.4 -r1.119.4.5 src/lib/libpuffs/puffs.h (expand / switch to unified diff)

--- src/lib/libpuffs/puffs.h 2012/09/13 20:20:16 1.119.4.4
+++ src/lib/libpuffs/puffs.h 2014/11/03 19:18:09 1.119.4.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: puffs.h,v 1.119.4.4 2012/09/13 20:20:16 riz Exp $ */ 1/* $NetBSD: puffs.h,v 1.119.4.5 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the 6 * Development of this software was supported by the
7 * Google Summer of Code program and the Ulla Tuominen Foundation. 7 * Google Summer of Code program and the Ulla Tuominen Foundation.
8 * The Google SoC project was mentored by Bill Studenmund. 8 * The Google SoC project was mentored by Bill Studenmund.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -240,26 +240,28 @@ struct puffs_ops { @@ -240,26 +240,28 @@ struct puffs_ops {
240 int, size_t *, uint8_t *, size_t *, int, const struct puffs_cred *); 240 int, size_t *, uint8_t *, size_t *, int, const struct puffs_cred *);
241 int (*puffs_node_deleteextattr)(struct puffs_usermount *, 241 int (*puffs_node_deleteextattr)(struct puffs_usermount *,
242 puffs_cookie_t, int, const char *, const struct puffs_cred *); 242 puffs_cookie_t, int, const char *, const struct puffs_cred *);
243 int (*puffs_node_getattr_ttl)(struct puffs_usermount *, 243 int (*puffs_node_getattr_ttl)(struct puffs_usermount *,
244 puffs_cookie_t, struct vattr *, const struct puffs_cred *, 244 puffs_cookie_t, struct vattr *, const struct puffs_cred *,
245 struct timespec *); 245 struct timespec *);
246 int (*puffs_node_setattr_ttl)(struct puffs_usermount *, 246 int (*puffs_node_setattr_ttl)(struct puffs_usermount *,
247 puffs_cookie_t, struct vattr *, const struct puffs_cred *, 247 puffs_cookie_t, struct vattr *, const struct puffs_cred *,
248 struct timespec *, int); 248 struct timespec *, int);
249 int (*puffs_node_write2)(struct puffs_usermount *, puffs_cookie_t, 249 int (*puffs_node_write2)(struct puffs_usermount *, puffs_cookie_t,
250 uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int); 250 uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int);
251 int (*puffs_node_reclaim2)(struct puffs_usermount *, 251 int (*puffs_node_reclaim2)(struct puffs_usermount *,
252 puffs_cookie_t, int); 252 puffs_cookie_t, int);
 253 int (*puffs_node_open2)(struct puffs_usermount *,
 254 puffs_cookie_t, int, const struct puffs_cred *, int *);
253 255
254 void *puffs_ops_spare[28]; 256 void *puffs_ops_spare[28];
255}; 257};
256 258
257typedef int (*pu_pathbuild_fn)(struct puffs_usermount *, 259typedef int (*pu_pathbuild_fn)(struct puffs_usermount *,
258 const struct puffs_pathobj *, 260 const struct puffs_pathobj *,
259 const struct puffs_pathobj *, size_t, 261 const struct puffs_pathobj *, size_t,
260 struct puffs_pathobj *); 262 struct puffs_pathobj *);
261typedef int (*pu_pathtransform_fn)(struct puffs_usermount *, 263typedef int (*pu_pathtransform_fn)(struct puffs_usermount *,
262 const struct puffs_pathobj *, 264 const struct puffs_pathobj *,
263 const struct puffs_cn *, 265 const struct puffs_cn *,
264 struct puffs_pathobj *); 266 struct puffs_pathobj *);
265typedef int (*pu_pathcmp_fn)(struct puffs_usermount *, struct puffs_pathobj *, 267typedef int (*pu_pathcmp_fn)(struct puffs_usermount *, struct puffs_pathobj *,
@@ -400,27 +402,29 @@ enum { @@ -400,27 +402,29 @@ enum {
400 int fsname##_node_deleteextattr(struct puffs_usermount *, \ 402 int fsname##_node_deleteextattr(struct puffs_usermount *, \
401 puffs_cookie_t, int, const char *, \ 403 puffs_cookie_t, int, const char *, \
402 const struct puffs_cred *); \ 404 const struct puffs_cred *); \
403 int fsname##_node_getattr_ttl(struct puffs_usermount *, \ 405 int fsname##_node_getattr_ttl(struct puffs_usermount *, \
404 puffs_cookie_t, struct vattr *, const struct puffs_cred *, \ 406 puffs_cookie_t, struct vattr *, const struct puffs_cred *, \
405 struct timespec *); \ 407 struct timespec *); \
406 int fsname##_node_setattr_ttl(struct puffs_usermount *, \ 408 int fsname##_node_setattr_ttl(struct puffs_usermount *, \
407 puffs_cookie_t, struct vattr *, const struct puffs_cred *, \ 409 puffs_cookie_t, struct vattr *, const struct puffs_cred *, \
408 struct timespec *, int); \ 410 struct timespec *, int); \
409 int fsname##_node_write2(struct puffs_usermount *, \ 411 int fsname##_node_write2(struct puffs_usermount *, \
410 puffs_cookie_t, uint8_t *, off_t, size_t *, \ 412 puffs_cookie_t, uint8_t *, off_t, size_t *, \
411 const struct puffs_cred *, int, int); \ 413 const struct puffs_cred *, int, int); \
412 int fsname##_node_reclaim2(struct puffs_usermount *, \ 414 int fsname##_node_reclaim2(struct puffs_usermount *, \
413 puffs_cookie_t, int); 415 puffs_cookie_t, int); \
 416 int fsname##_node_open2(struct puffs_usermount *, \
 417 puffs_cookie_t, int, const struct puffs_cred *, int *);
414 418
415 419
416#define PUFFSOP_INIT(ops) \ 420#define PUFFSOP_INIT(ops) \
417 ops = malloc(sizeof(struct puffs_ops)); \ 421 ops = malloc(sizeof(struct puffs_ops)); \
418 memset(ops, 0, sizeof(struct puffs_ops)) 422 memset(ops, 0, sizeof(struct puffs_ops))
419#define PUFFSOP_SET(ops, fsname, fsornode, opname) \ 423#define PUFFSOP_SET(ops, fsname, fsornode, opname) \
420 (ops)->puffs_##fsornode##_##opname = fsname##_##fsornode##_##opname 424 (ops)->puffs_##fsornode##_##opname = fsname##_##fsornode##_##opname
421#define PUFFSOP_SETFSNOP(ops, opname) \ 425#define PUFFSOP_SETFSNOP(ops, opname) \
422 (ops)->puffs_fs_##opname = puffs_fsnop_##opname 426 (ops)->puffs_fs_##opname = puffs_fsnop_##opname
423 427
424PUFFSOP_PROTOS(puffs_null) /* XXX */ 428PUFFSOP_PROTOS(puffs_null) /* XXX */
425 429
426#define PNPATH(pnode) ((pnode)->pn_po.po_path) 430#define PNPATH(pnode) ((pnode)->pn_po.po_path)

cvs diff -r1.29.4.4 -r1.29.4.5 src/lib/libpuffs/puffs_ops.3 (expand / switch to unified diff)

--- src/lib/libpuffs/puffs_ops.3 2012/09/13 20:20:15 1.29.4.4
+++ src/lib/libpuffs/puffs_ops.3 2014/11/03 19:18:09 1.29.4.5
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1.\" $NetBSD: puffs_ops.3,v 1.29.4.4 2012/09/13 20:20:15 riz Exp $ 1.\" $NetBSD: puffs_ops.3,v 1.29.4.5 2014/11/03 19:18:09 msaitoh Exp $
2.\" 2.\"
3.\" Copyright (c) 2007 Antti Kantee. All rights reserved. 3.\" Copyright (c) 2007 Antti Kantee. All rights reserved.
4.\" 4.\"
5.\" Redistribution and use in source and binary forms, with or without 5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions 6.\" modification, are permitted provided that the following conditions
7.\" are met: 7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright 8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer. 9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the 11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution. 12.\" documentation and/or other materials provided with the distribution.
13.\" 13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE. 24.\" SUCH DAMAGE.
25.\" 25.\"
26.Dd April 18, 2012 26.Dd April 16, 2014
27.Dt PUFFS_OPS 3 27.Dt PUFFS_OPS 3
28.Os 28.Os
29.Sh NAME 29.Sh NAME
30.Nm puffs_ops 30.Nm puffs_ops
31.Nd puffs callback operations 31.Nd puffs callback operations
32.Sh LIBRARY 32.Sh LIBRARY
33.Lb libpuffs 33.Lb libpuffs
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.In puffs.h 35.In puffs.h
36.Ft int 36.Ft int
37.Fo puffs_fs_statvfs 37.Fo puffs_fs_statvfs
38.Fa "struct puffs_usermount *pu" "struct statvfs *sbp" 38.Fa "struct puffs_usermount *pu" "struct statvfs *sbp"
39.Fc 39.Fc
@@ -73,26 +73,31 @@ @@ -73,26 +73,31 @@
73.Fc 73.Fc
74.Ft int 74.Ft int
75.Fo puffs_node_mknod 75.Fo puffs_node_mknod
76.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" 76.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc"
77.Fa "struct puffs_newinfo *pni" "const struct puffs_cn *pcn" 77.Fa "struct puffs_newinfo *pni" "const struct puffs_cn *pcn"
78.Fa "const struct vattr *vap" 78.Fa "const struct vattr *vap"
79.Fc 79.Fc
80.Ft int 80.Ft int
81.Fo puffs_node_open 81.Fo puffs_node_open
82.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int mode" 82.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int mode"
83.Fa "const struct puffs_cred *pcr" 83.Fa "const struct puffs_cred *pcr"
84.Fc 84.Fc
85.Ft int 85.Ft int
 86.Fo puffs_node_open2
 87.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int modep"
 88.Fa "const struct puffs_cred *pcr" "int *oflags"
 89.Fc
 90.Ft int
86.Fo puffs_node_close 91.Fo puffs_node_close
87.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int flags" 92.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int flags"
88.Fa "const struct puffs_cred *pcr" 93.Fa "const struct puffs_cred *pcr"
89.Fc 94.Fc
90.Ft int 95.Ft int
91.Fo puffs_node_access 96.Fo puffs_node_access
92.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int mode" 97.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int mode"
93.Fa "const struct puffs_cred *pcr" 98.Fa "const struct puffs_cred *pcr"
94.Fc 99.Fc
95.Ft int 100.Ft int
96.Fo puffs_node_getattr 101.Fo puffs_node_getattr
97.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "struct vattr *vap" 102.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "struct vattr *vap"
98.Fa "const struct puffs_cred *pcr" 103.Fa "const struct puffs_cred *pcr"
@@ -472,36 +477,43 @@ A file node is created in the directory  @@ -472,36 +477,43 @@ A file node is created in the directory
472by any of the above callbacks. 477by any of the above callbacks.
473The name of the new file can be found from 478The name of the new file can be found from
474.Fa pcn 479.Fa pcn
475and the attributes are specified by 480and the attributes are specified by
476.Fa va 481.Fa va
477and the cookie for the newly created node should be set in 482and the cookie for the newly created node should be set in
478.Fa pni . 483.Fa pni .
479The only difference between these three is that they create a regular 484The only difference between these three is that they create a regular
480file, directory and device special file, respectively. 485file, directory and device special file, respectively.
481.Pp 486.Pp
482In case of mknod, the device identifier can be found in 487In case of mknod, the device identifier can be found in
483.Fa va-\*[Gt]va_rdev . 488.Fa va-\*[Gt]va_rdev .
484.It Fn puffs_node_open "pu" "opc" "mode" "pcr" 489.It Fn puffs_node_open "pu" "opc" "mode" "pcr"
 490.It Fn puffs_node_open2 "pu" "opc" "mode" "pcr" "oflags"
485Open the node denoted by the cookie 491Open the node denoted by the cookie
486.Fa opc . 492.Fa opc .
487The parameter 493The parameter
488.Fa mode 494.Fa mode
489specifies the flags that 495specifies the flags that
490.Xr open 2 496.Xr open 2
491was called with, e.g. 497was called with, e.g.
492.Dv O_APPEND 498.Dv O_APPEND
493and 499and
494.Dv O_NONBLOCK . 500.Dv O_NONBLOCK .
 501.Fn puffs_node_open2
 502allows the filesystem to pass back information for the file in
 503.Fa oflags .
 504The only implemented flag for now is
 505.Dv PUFFS_OPEN_IO_DIRECT
 506that cause file read/write to bypass the page cache.
495.It Fn puffs_node_close "pu" "opc" "flags" "pcr" 507.It Fn puffs_node_close "pu" "opc" "flags" "pcr"
496Close a node. 508Close a node.
497The parameter 509The parameter
498.Fa flags 510.Fa flags
499parameter describes the flags that the file was opened with. 511parameter describes the flags that the file was opened with.
500.It Fn puffs_node_access "pu" "opc" "mode" "pcr" 512.It Fn puffs_node_access "pu" "opc" "mode" "pcr"
501Check if the credentials of 513Check if the credentials of
502.Fa pcr 514.Fa pcr
503have the right to perform the operation specified by 515have the right to perform the operation specified by
504.Fa mode 516.Fa mode
505onto the node 517onto the node
506.Fa opc . 518.Fa opc .
507The argument 519The argument

cvs diff -r1.23 -r1.23.28.1 src/lib/libpuffs/requests.c (expand / switch to unified diff)

--- src/lib/libpuffs/requests.c 2008/01/29 14:54:08 1.23
+++ src/lib/libpuffs/requests.c 2014/11/03 19:18:09 1.23.28.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: requests.c,v 1.23 2008/01/29 14:54:08 pooka Exp $ */ 1/* $NetBSD: requests.c,v 1.23.28.1 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the 6 * Development of this software was supported by the
7 * Research Foundation of Helsinki University of Technology 7 * Research Foundation of Helsinki University of Technology
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32#if !defined(lint) 32#if !defined(lint)
33__RCSID("$NetBSD: requests.c,v 1.23 2008/01/29 14:54:08 pooka Exp $"); 33__RCSID("$NetBSD: requests.c,v 1.23.28.1 2014/11/03 19:18:09 msaitoh Exp $");
34#endif /* !lint */ 34#endif /* !lint */
35 35
36#include <sys/types.h> 36#include <sys/types.h>
37#include <sys/ioctl.h> 37#include <sys/ioctl.h>
38#include <sys/queue.h> 38#include <sys/queue.h>
39#include <sys/socket.h> 39#include <sys/socket.h>
40 40
41#include <dev/putter/putter.h> 41#include <dev/putter/putter.h>
42 42
43#include <assert.h> 43#include <assert.h>
44#include <errno.h> 44#include <errno.h>
45#include <puffs.h> 45#include <puffs.h>
46#include <stdio.h> 46#include <stdio.h>
@@ -199,41 +199,41 @@ puffs__fsframe_write(struct puffs_usermo @@ -199,41 +199,41 @@ puffs__fsframe_write(struct puffs_usermo
199/*ARGSUSED*/ 199/*ARGSUSED*/
200int 200int
201puffs__fsframe_cmp(struct puffs_usermount *pu, 201puffs__fsframe_cmp(struct puffs_usermount *pu,
202 struct puffs_framebuf *pb1, struct puffs_framebuf *pb2, int *notresp) 202 struct puffs_framebuf *pb1, struct puffs_framebuf *pb2, int *notresp)
203{ 203{
204 struct puffs_req *preq1, *preq2; 204 struct puffs_req *preq1, *preq2;
205 size_t winlen; 205 size_t winlen;
206 int rv; 206 int rv;
207 207
208 /* map incoming preq */ 208 /* map incoming preq */
209 winlen = sizeof(struct puffs_req); 209 winlen = sizeof(struct puffs_req);
210 rv = puffs_framebuf_getwindow(pb1, 0, (void *)&preq1, &winlen); 210 rv = puffs_framebuf_getwindow(pb1, 0, (void *)&preq1, &winlen);
211 assert(rv == 0); /* frames are always at least puffs_req in size */ 211 assert(rv == 0); /* frames are always at least puffs_req in size */
212 assert(winlen = sizeof(struct puffs_req)); 212 assert(winlen == sizeof(struct puffs_req));
213 213
214 /* 214 /*
215 * Check if this is not a response in this slot. That's the 215 * Check if this is not a response in this slot. That's the
216 * likely case. 216 * likely case.
217 */ 217 */
218 if ((preq1->preq_opclass & PUFFSOPFLAG_ISRESPONSE) == 0) { 218 if ((preq1->preq_opclass & PUFFSOPFLAG_ISRESPONSE) == 0) {
219 *notresp = 1; 219 *notresp = 1;
220 return 0; 220 return 0;
221 } 221 }
222 222
223 /* map second preq */ 223 /* map second preq */
224 winlen = sizeof(struct puffs_req); 224 winlen = sizeof(struct puffs_req);
225 rv = puffs_framebuf_getwindow(pb2, 0, (void *)&preq2, &winlen); 225 rv = puffs_framebuf_getwindow(pb2, 0, (void *)&preq2, &winlen);
226 assert(rv == 0); /* frames are always at least puffs_req in size */ 226 assert(rv == 0); /* frames are always at least puffs_req in size */
227 assert(winlen = sizeof(struct puffs_req)); 227 assert(winlen == sizeof(struct puffs_req));
228 228
229 /* then compare: resid equal? */ 229 /* then compare: resid equal? */
230 return preq1->preq_id != preq2->preq_id; 230 return preq1->preq_id != preq2->preq_id;
231} 231}
232 232
233void 233void
234puffs__fsframe_gotframe(struct puffs_usermount *pu, struct puffs_framebuf *pb) 234puffs__fsframe_gotframe(struct puffs_usermount *pu, struct puffs_framebuf *pb)
235{ 235{
236 236
237 puffs_framebuf_seekset(pb, 0); 237 puffs_framebuf_seekset(pb, 0);
238 puffs__ml_dispatch(pu, pb); 238 puffs__ml_dispatch(pu, pb);
239} 239}

cvs diff -r1.77.8.2 -r1.77.8.3 src/sys/fs/puffs/puffs_msgif.h (expand / switch to unified diff)

--- src/sys/fs/puffs/puffs_msgif.h 2012/08/12 13:13:20 1.77.8.2
+++ src/sys/fs/puffs/puffs_msgif.h 2014/11/03 19:18:09 1.77.8.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: puffs_msgif.h,v 1.77.8.2 2012/08/12 13:13:20 martin Exp $ */ 1/* $NetBSD: puffs_msgif.h,v 1.77.8.3 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the 6 * Development of this software was supported by the
7 * Google Summer of Code program and the Ulla Tuominen Foundation. 7 * Google Summer of Code program and the Ulla Tuominen Foundation.
8 * The Google SoC project was mentored by Bill Studenmund. 8 * The Google SoC project was mentored by Bill Studenmund.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -329,26 +329,29 @@ struct puffs_vfsmsg_nodetofh { @@ -329,26 +329,29 @@ struct puffs_vfsmsg_nodetofh {
329 329
330struct puffs_vfsmsg_suspend { 330struct puffs_vfsmsg_suspend {
331 struct puffs_req pvfsr_pr; 331 struct puffs_req pvfsr_pr;
332 332
333 int pvfsr_status; 333 int pvfsr_status;
334}; 334};
335#define PUFFS_SUSPEND_START 0 335#define PUFFS_SUSPEND_START 0
336#define PUFFS_SUSPEND_SUSPENDED 1 336#define PUFFS_SUSPEND_SUSPENDED 1
337#define PUFFS_SUSPEND_RESUME 2 337#define PUFFS_SUSPEND_RESUME 2
338#define PUFFS_SUSPEND_ERROR 3 338#define PUFFS_SUSPEND_ERROR 3
339 339
340#define PUFFS_EXTATTRCTL_HASNODE 0x01 340#define PUFFS_EXTATTRCTL_HASNODE 0x01
341#define PUFFS_EXTATTRCTL_HASATTRNAME 0x02 341#define PUFFS_EXTATTRCTL_HASATTRNAME 0x02
 342
 343#define PUFFS_OPEN_IO_DIRECT 0x01
 344
342struct puffs_vfsmsg_extattrctl { 345struct puffs_vfsmsg_extattrctl {
343 struct puffs_req pvfsr_pr; 346 struct puffs_req pvfsr_pr;
344 347
345 int pvfsr_cmd; /* OUT */ 348 int pvfsr_cmd; /* OUT */
346 int pvfsr_attrnamespace; /* OUT */ 349 int pvfsr_attrnamespace; /* OUT */
347 int pvfsr_flags; /* OUT */ 350 int pvfsr_flags; /* OUT */
348 char pvfsr_attrname[PUFFS_EXTNAMELEN]; /* OUT */ 351 char pvfsr_attrname[PUFFS_EXTNAMELEN]; /* OUT */
349}; 352};
350 353
351/* 354/*
352 * aux structures for vnode operations. 355 * aux structures for vnode operations.
353 */ 356 */
354 357
@@ -389,26 +392,27 @@ struct puffs_vnmsg_mknod { @@ -389,26 +392,27 @@ struct puffs_vnmsg_mknod {
389 392
390 struct vattr pvnr_va; /* OUT */ 393 struct vattr pvnr_va; /* OUT */
391 puffs_cookie_t pvnr_newnode; /* IN */ 394 puffs_cookie_t pvnr_newnode; /* IN */
392 /* Used only if PUFFS_KFLAG_CACHE_USE_TTL */ 395 /* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
393 struct timespec pvnr_va_ttl; /* IN */ 396 struct timespec pvnr_va_ttl; /* IN */
394 struct timespec pvnr_cn_ttl; /* IN */ 397 struct timespec pvnr_cn_ttl; /* IN */
395}; 398};
396 399
397struct puffs_vnmsg_open { 400struct puffs_vnmsg_open {
398 struct puffs_req pvn_pr; 401 struct puffs_req pvn_pr;
399 402
400 struct puffs_kcred pvnr_cred; /* OUT */ 403 struct puffs_kcred pvnr_cred; /* OUT */
401 int pvnr_mode; /* OUT */ 404 int pvnr_mode; /* OUT */
 405 int pvnr_oflags; /* IN */
402}; 406};
403 407
404struct puffs_vnmsg_close { 408struct puffs_vnmsg_close {
405 struct puffs_req pvn_pr; 409 struct puffs_req pvn_pr;
406 410
407 struct puffs_kcred pvnr_cred; /* OUT */ 411 struct puffs_kcred pvnr_cred; /* OUT */
408 int pvnr_fflag; /* OUT */ 412 int pvnr_fflag; /* OUT */
409}; 413};
410 414
411struct puffs_vnmsg_access { 415struct puffs_vnmsg_access {
412 struct puffs_req pvn_pr; 416 struct puffs_req pvn_pr;
413 417
414 struct puffs_kcred pvnr_cred; /* OUT */ 418 struct puffs_kcred pvnr_cred; /* OUT */

cvs diff -r1.78.8.2 -r1.78.8.3 src/sys/fs/puffs/puffs_sys.h (expand / switch to unified diff)

--- src/sys/fs/puffs/puffs_sys.h 2012/08/12 13:13:20 1.78.8.2
+++ src/sys/fs/puffs/puffs_sys.h 2014/11/03 19:18:09 1.78.8.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: puffs_sys.h,v 1.78.8.2 2012/08/12 13:13:20 martin Exp $ */ 1/* $NetBSD: puffs_sys.h,v 1.78.8.3 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the 6 * Development of this software was supported by the
7 * Google Summer of Code program and the Ulla Tuominen Foundation. 7 * Google Summer of Code program and the Ulla Tuominen Foundation.
8 * The Google SoC project was mentored by Bill Studenmund. 8 * The Google SoC project was mentored by Bill Studenmund.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -183,26 +183,28 @@ struct puffs_mount { @@ -183,26 +183,28 @@ struct puffs_mount {
183}; 183};
184 184
185#define PUFFSTAT_BEFOREINIT 0 185#define PUFFSTAT_BEFOREINIT 0
186#define PUFFSTAT_MOUNTING 1 186#define PUFFSTAT_MOUNTING 1
187#define PUFFSTAT_RUNNING 2 187#define PUFFSTAT_RUNNING 2
188#define PUFFSTAT_DYING 3 /* Do you want your possessions identified? */ 188#define PUFFSTAT_DYING 3 /* Do you want your possessions identified? */
189 189
190 190
191#define PNODE_NOREFS 0x001 /* no backend reference */ 191#define PNODE_NOREFS 0x001 /* no backend reference */
192#define PNODE_DYING 0x002 /* NOREFS + inactive */ 192#define PNODE_DYING 0x002 /* NOREFS + inactive */
193#define PNODE_FAF 0x004 /* issue all operations as FAF */ 193#define PNODE_FAF 0x004 /* issue all operations as FAF */
194#define PNODE_DOINACT 0x008 /* if inactive-on-demand, call inactive */ 194#define PNODE_DOINACT 0x008 /* if inactive-on-demand, call inactive */
195#define PNODE_SOPEXP 0x100 /* Node reclaim postponed in sop thread */ 195#define PNODE_SOPEXP 0x100 /* Node reclaim postponed in sop thread */
 196#define PNODE_RDIRECT 0x200 /* bypass page cache on read */
 197#define PNODE_WDIRECT 0x400 /* bypass page cache on write */
196 198
197#define PNODE_METACACHE_ATIME 0x10 /* cache atime metadata */ 199#define PNODE_METACACHE_ATIME 0x10 /* cache atime metadata */
198#define PNODE_METACACHE_CTIME 0x20 /* cache atime metadata */ 200#define PNODE_METACACHE_CTIME 0x20 /* cache atime metadata */
199#define PNODE_METACACHE_MTIME 0x40 /* cache atime metadata */ 201#define PNODE_METACACHE_MTIME 0x40 /* cache atime metadata */
200#define PNODE_METACACHE_SIZE 0x80 /* cache atime metadata */ 202#define PNODE_METACACHE_SIZE 0x80 /* cache atime metadata */
201#define PNODE_METACACHE_MASK 0xf0 203#define PNODE_METACACHE_MASK 0xf0
202 204
203struct puffs_node { 205struct puffs_node {
204 struct genfs_node pn_gnode; /* genfs glue */ 206 struct genfs_node pn_gnode; /* genfs glue */
205 207
206 kmutex_t pn_mtx; 208 kmutex_t pn_mtx;
207 int pn_refcount; 209 int pn_refcount;
208 int pn_nlookup; 210 int pn_nlookup;

cvs diff -r1.163.2.4 -r1.163.2.5 src/sys/fs/puffs/puffs_vnops.c (expand / switch to unified diff)

--- src/sys/fs/puffs/puffs_vnops.c 2012/08/12 13:13:20 1.163.2.4
+++ src/sys/fs/puffs/puffs_vnops.c 2014/11/03 19:18:09 1.163.2.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: puffs_vnops.c,v 1.163.2.4 2012/08/12 13:13:20 martin Exp $ */ 1/* $NetBSD: puffs_vnops.c,v 1.163.2.5 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by the 6 * Development of this software was supported by the
7 * Google Summer of Code program and the Ulla Tuominen Foundation. 7 * Google Summer of Code program and the Ulla Tuominen Foundation.
8 * The Google SoC project was mentored by Bill Studenmund. 8 * The Google SoC project was mentored by Bill Studenmund.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.4 2012/08/12 13:13:20 martin Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.5 2014/11/03 19:18:09 msaitoh Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/buf.h> 36#include <sys/buf.h>
37#include <sys/lockf.h> 37#include <sys/lockf.h>
38#include <sys/malloc.h> 38#include <sys/malloc.h>
39#include <sys/mount.h> 39#include <sys/mount.h>
40#include <sys/namei.h> 40#include <sys/namei.h>
41#include <sys/vnode.h> 41#include <sys/vnode.h>
42#include <sys/proc.h> 42#include <sys/proc.h>
43#include <sys/kernel.h> /* For hz, hardclock_ticks */ 43#include <sys/kernel.h> /* For hz, hardclock_ticks */
44 44
45#include <uvm/uvm.h> 45#include <uvm/uvm.h>
46 46
@@ -861,46 +861,53 @@ puffs_vnop_mknod(void *v) @@ -861,46 +861,53 @@ puffs_vnop_mknod(void *v)
861 861
862int 862int
863puffs_vnop_open(void *v) 863puffs_vnop_open(void *v)
864{ 864{
865 struct vop_open_args /* { 865 struct vop_open_args /* {
866 const struct vnodeop_desc *a_desc; 866 const struct vnodeop_desc *a_desc;
867 struct vnode *a_vp; 867 struct vnode *a_vp;
868 int a_mode; 868 int a_mode;
869 kauth_cred_t a_cred; 869 kauth_cred_t a_cred;
870 } */ *ap = v; 870 } */ *ap = v;
871 PUFFS_MSG_VARS(vn, open); 871 PUFFS_MSG_VARS(vn, open);
872 struct vnode *vp = ap->a_vp; 872 struct vnode *vp = ap->a_vp;
873 struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount); 873 struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
 874 struct puffs_node *pn = VPTOPP(vp);
874 int mode = ap->a_mode; 875 int mode = ap->a_mode;
875 int error; 876 int error;
876 877
877 DPRINTF(("puffs_open: vp %p, mode 0x%x\n", vp, mode)); 878 DPRINTF(("puffs_open: vp %p, mode 0x%x\n", vp, mode));
878 879
879 if (vp->v_type == VREG && mode & FWRITE && !EXISTSOP(pmp, WRITE)) 880 if (vp->v_type == VREG && mode & FWRITE && !EXISTSOP(pmp, WRITE))
880 ERROUT(EROFS); 881 ERROUT(EROFS);
881 882
882 if (!EXISTSOP(pmp, OPEN)) 883 if (!EXISTSOP(pmp, OPEN))
883 ERROUT(0); 884 ERROUT(0);
884 885
885 PUFFS_MSG_ALLOC(vn, open); 886 PUFFS_MSG_ALLOC(vn, open);
886 open_msg->pvnr_mode = mode; 887 open_msg->pvnr_mode = mode;
887 puffs_credcvt(&open_msg->pvnr_cred, ap->a_cred); 888 puffs_credcvt(&open_msg->pvnr_cred, ap->a_cred);
888 puffs_msg_setinfo(park_open, PUFFSOP_VN, 889 puffs_msg_setinfo(park_open, PUFFSOP_VN,
889 PUFFS_VN_OPEN, VPTOPNC(vp)); 890 PUFFS_VN_OPEN, VPTOPNC(vp));
890 891
891 PUFFS_MSG_ENQUEUEWAIT2(pmp, park_open, vp->v_data, NULL, error); 892 PUFFS_MSG_ENQUEUEWAIT2(pmp, park_open, vp->v_data, NULL, error);
892 error = checkerr(pmp, error, __func__); 893 error = checkerr(pmp, error, __func__);
893 894
 895 if (open_msg->pvnr_oflags & PUFFS_OPEN_IO_DIRECT) {
 896 if (mode & FREAD)
 897 pn->pn_stat |= PNODE_RDIRECT;
 898 if (mode & FWRITE)
 899 pn->pn_stat |= PNODE_WDIRECT;
 900 }
894 out: 901 out:
895 DPRINTF(("puffs_open: returning %d\n", error)); 902 DPRINTF(("puffs_open: returning %d\n", error));
896 PUFFS_MSG_RELEASE(open); 903 PUFFS_MSG_RELEASE(open);
897 return error; 904 return error;
898} 905}
899 906
900int 907int
901puffs_vnop_close(void *v) 908puffs_vnop_close(void *v)
902{ 909{
903 struct vop_close_args /* { 910 struct vop_close_args /* {
904 const struct vnodeop_desc *a_desc; 911 const struct vnodeop_desc *a_desc;
905 struct vnode *a_vp; 912 struct vnode *a_vp;
906 int a_fflag; 913 int a_fflag;
@@ -2155,42 +2162,45 @@ puffs_vnop_rename(void *v) @@ -2155,42 +2162,45 @@ puffs_vnop_rename(void *v)
2155 2162
2156int 2163int
2157puffs_vnop_read(void *v) 2164puffs_vnop_read(void *v)
2158{ 2165{
2159 struct vop_read_args /* {  2166 struct vop_read_args /* {
2160 const struct vnodeop_desc *a_desc; 2167 const struct vnodeop_desc *a_desc;
2161 struct vnode *a_vp; 2168 struct vnode *a_vp;
2162 struct uio *a_uio; 2169 struct uio *a_uio;
2163 int a_ioflag; 2170 int a_ioflag;
2164 kauth_cred_t a_cred; 2171 kauth_cred_t a_cred;
2165 } */ *ap = v; 2172 } */ *ap = v;
2166 PUFFS_MSG_VARS(vn, read); 2173 PUFFS_MSG_VARS(vn, read);
2167 struct vnode *vp = ap->a_vp; 2174 struct vnode *vp = ap->a_vp;
 2175 struct puffs_node *pn = VPTOPP(vp);
2168 struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount); 2176 struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
2169 struct uio *uio = ap->a_uio; 2177 struct uio *uio = ap->a_uio;
2170 size_t tomove, argsize; 2178 size_t tomove, argsize;
2171 vsize_t bytelen; 2179 vsize_t bytelen;
2172 int error; 2180 int error;
2173 2181
2174 read_msg = NULL; 2182 read_msg = NULL;
2175 error = 0; 2183 error = 0;
2176 2184
2177 /* std sanity */ 2185 /* std sanity */
2178 if (uio->uio_resid == 0) 2186 if (uio->uio_resid == 0)
2179 return 0; 2187 return 0;
2180 if (uio->uio_offset < 0) 2188 if (uio->uio_offset < 0)
2181 return EINVAL; 2189 return EINVAL;
2182 2190
2183 if (vp->v_type == VREG && PUFFS_USE_PAGECACHE(pmp)) { 2191 if (vp->v_type == VREG &&
 2192 PUFFS_USE_PAGECACHE(pmp) &&
 2193 !(pn->pn_stat & PNODE_RDIRECT)) {
2184 const int advice = IO_ADV_DECODE(ap->a_ioflag); 2194 const int advice = IO_ADV_DECODE(ap->a_ioflag);
2185 2195
2186 while (uio->uio_resid > 0) { 2196 while (uio->uio_resid > 0) {
2187 if (vp->v_size <= uio->uio_offset) { 2197 if (vp->v_size <= uio->uio_offset) {
2188 break; 2198 break;
2189 } 2199 }
2190 bytelen = MIN(uio->uio_resid, 2200 bytelen = MIN(uio->uio_resid,
2191 vp->v_size - uio->uio_offset); 2201 vp->v_size - uio->uio_offset);
2192 if (bytelen == 0) 2202 if (bytelen == 0)
2193 break; 2203 break;
2194 2204
2195 error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice, 2205 error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
2196 UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp)); 2206 UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
@@ -2275,27 +2285,29 @@ puffs_vnop_write(void *v) @@ -2275,27 +2285,29 @@ puffs_vnop_write(void *v)
2275 struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount); 2285 struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
2276 struct uio *uio = ap->a_uio; 2286 struct uio *uio = ap->a_uio;
2277 size_t tomove, argsize; 2287 size_t tomove, argsize;
2278 off_t oldoff, newoff, origoff; 2288 off_t oldoff, newoff, origoff;
2279 vsize_t bytelen; 2289 vsize_t bytelen;
2280 int error, uflags; 2290 int error, uflags;
2281 int ubcflags; 2291 int ubcflags;
2282 2292
2283 error = uflags = 0; 2293 error = uflags = 0;
2284 write_msg = NULL; 2294 write_msg = NULL;
2285 2295
2286 mutex_enter(&pn->pn_sizemtx); 2296 mutex_enter(&pn->pn_sizemtx);
2287 2297
2288 if (vp->v_type == VREG && PUFFS_USE_PAGECACHE(pmp)) { 2298 if (vp->v_type == VREG &&
 2299 PUFFS_USE_PAGECACHE(pmp) &&
 2300 !(pn->pn_stat & PNODE_WDIRECT)) {
2289 ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp); 2301 ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp);
2290 2302
2291 /* 2303 /*
2292 * userspace *should* be allowed to control this, 2304 * userspace *should* be allowed to control this,
2293 * but with UBC it's a bit unclear how to handle it 2305 * but with UBC it's a bit unclear how to handle it
2294 */ 2306 */
2295 if (ap->a_ioflag & IO_APPEND) 2307 if (ap->a_ioflag & IO_APPEND)
2296 uio->uio_offset = vp->v_size; 2308 uio->uio_offset = vp->v_size;
2297 2309
2298 origoff = uio->uio_offset; 2310 origoff = uio->uio_offset;
2299 while (uio->uio_resid > 0) { 2311 while (uio->uio_resid > 0) {
2300 if (vp->v_mount->mnt_flag & MNT_RELATIME) 2312 if (vp->v_mount->mnt_flag & MNT_RELATIME)
2301 uflags |= PUFFS_UPDATEATIME; 2313 uflags |= PUFFS_UPDATEATIME;

cvs diff -r1.20.2.1 -r1.20.2.2 src/usr.sbin/perfused/msg.c (expand / switch to unified diff)

--- src/usr.sbin/perfused/msg.c 2012/08/12 13:13:21 1.20.2.1
+++ src/usr.sbin/perfused/msg.c 2014/11/03 19:18:09 1.20.2.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: msg.c,v 1.20.2.1 2012/08/12 13:13:21 martin Exp $ */ 1/* $NetBSD: msg.c,v 1.20.2.2 2014/11/03 19:18:09 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved. 4 * Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 *  14 *
@@ -483,27 +483,30 @@ perfused_readframe(struct puffs_usermoun @@ -483,27 +483,30 @@ perfused_readframe(struct puffs_usermoun
483 struct fuse_out_header foh; 483 struct fuse_out_header foh;
484 size_t len; 484 size_t len;
485 ssize_t readen; 485 ssize_t readen;
486 void *data; 486 void *data;
487 487
488 /* 488 /*
489 * Read the header  489 * Read the header
490 */ 490 */
491 len = sizeof(foh); 491 len = sizeof(foh);
492 PUFFS_FRAMEBUF_GETWINDOW(pufbuf, 0, &data, &len); 492 PUFFS_FRAMEBUF_GETWINDOW(pufbuf, 0, &data, &len);
493 493
494 switch (readen = recv(fd, data, len, MSG_NOSIGNAL|MSG_PEEK)) { 494 switch (readen = recv(fd, data, len, MSG_NOSIGNAL|MSG_PEEK)) {
495 case 0: 495 case 0:
496 perfused_panic(); 496 DPRINTF("Filesystem exit\n");
 497 /* NOTREACHED */
 498 exit(0);
 499 break;
497 case -1: 500 case -1:
498 if (errno == EAGAIN) 501 if (errno == EAGAIN)
499 return 0; 502 return 0;
500 DWARN("%s: recv returned -1", __func__); 503 DWARN("%s: recv returned -1", __func__);
501 return errno; 504 return errno;
502 /* NOTREACHED */ 505 /* NOTREACHED */
503 break; 506 break;
504 default: 507 default:
505 break; 508 break;
506 } 509 }
507 510
508#ifdef PERFUSE_DEBUG 511#ifdef PERFUSE_DEBUG
509 if (readen != (ssize_t)len) 512 if (readen != (ssize_t)len)