Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src Pull up following revision(s) (requested by manu in ticke...
details: https://anonhg.NetBSD.org/src/rev/994279b6d3f4
branches: netbsd-6
changeset: 776746:994279b6d3f4
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Mon Nov 03 19:18:09 2014 +0000
description:
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
diffstat:
lib/libperfuse/ops.c | 146 ++++++++++++++++++++++++++---------------
lib/libperfuse/perfuse.c | 9 +-
lib/libperfuse/perfuse_priv.h | 9 +-
lib/libperfuse/subr.c | 16 ++++-
lib/libpuffs/creds.c | 13 ++-
lib/libpuffs/dispatcher.c | 12 ++-
lib/libpuffs/puffs.h | 8 +-
lib/libpuffs/puffs_ops.3 | 16 ++++-
lib/libpuffs/requests.c | 8 +-
sys/fs/puffs/puffs_msgif.h | 6 +-
sys/fs/puffs/puffs_sys.h | 4 +-
sys/fs/puffs/puffs_vnops.c | 20 ++++-
usr.sbin/perfused/msg.c | 7 +-
13 files changed, 185 insertions(+), 89 deletions(-)
diffs (truncated from 679 to 300 lines):
diff -r 37c7223b4af2 -r 994279b6d3f4 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c Mon Nov 03 16:39:11 2014 +0000
+++ b/lib/libperfuse/ops.c Mon Nov 03 19:18:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ops.c,v 1.50.2.7 2013/07/30 04:05:32 msaitoh Exp $ */
+/* $NetBSD: ops.c,v 1.50.2.8 2014/11/03 19:18:09 msaitoh Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -634,13 +634,23 @@
*/
if (fd->ino == PERFUSE_UNKNOWN_INO) {
struct puffs_node *pn;
-
- if (node_lookup_common(pu, opc, NULL, fd->name,
- NULL, &pn) != 0) {
- DWARNX("node_lookup_common failed");
+ struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc);
+
+ /*
+ * Avoid breaking out of fs
+ * by lookup to .. on root
+ */
+ if ((strcmp(fd->name, "..") == 0) &&
+ (pnd->pnd_nodeid == FUSE_ROOT_ID)) {
+ fd->ino = FUSE_ROOT_ID;
} else {
- fd->ino = pn->pn_va.va_fileid;
- (void)perfuse_node_reclaim(pu, pn);
+ if (node_lookup_common(pu, opc, NULL, fd->name,
+ NULL, &pn) != 0) {
+ DWARNX("node_lookup_common failed");
+ } else {
+ fd->ino = pn->pn_va.va_fileid;
+ (void)perfuse_node_reclaim(pu, pn);
+ }
}
}
@@ -1318,6 +1328,13 @@
perfuse_node_open(struct puffs_usermount *pu, puffs_cookie_t opc, int mode,
const struct puffs_cred *pcr)
{
+ return perfuse_node_open2(pu, opc, mode, pcr, NULL);
+}
+
+int
+perfuse_node_open2(struct puffs_usermount *pu, puffs_cookie_t opc, int mode,
+ const struct puffs_cred *pcr, int *oflags)
+{
struct perfuse_state *ps;
struct perfuse_node_data *pnd;
perfuse_msg_t *pm;
@@ -1419,6 +1436,12 @@
*/
perfuse_new_fh(opc, foo->fh, mode);
+ /*
+ * Set direct I/O if the filesystems forces it
+ */
+ if ((foo->open_flags & FUSE_FOPEN_DIRECT_IO) && (oflags != NULL))
+ *oflags |= PUFFS_OPEN_IO_DIRECT;
+
#ifdef PERFUSE_DEBUG
if (perfuse_diagflags & (PDF_FH|PDF_FILENAME))
DPRINTF("%s: opc = %p, file = \"%s\", "
@@ -1534,7 +1557,7 @@
struct fuse_attr_out *fao;
int error = 0;
- if (pnd->pnd_flags & PND_REMOVED)
+ if ((pnd->pnd_flags & PND_REMOVED) && !(pnd->pnd_flags & PND_OPEN))
return ENOENT;
node_ref(opc);
@@ -1927,17 +1950,6 @@
return error;
}
-/* ARGSUSED0 */
-int
-perfuse_node_mmap(struct puffs_usermount *pu, puffs_cookie_t opc, int flags,
- const struct puffs_cred *pcr)
-{
- /*
- * Not implemented anymore in libfuse
- */
- return ENOSYS;
-}
-
/* ARGSUSED2 */
int
perfuse_node_fsync(struct puffs_usermount *pu, puffs_cookie_t opc,
@@ -2052,14 +2064,6 @@
return error;
}
-/* ARGSUSED0 */
-int
-perfuse_node_seek(struct puffs_usermount *pu, puffs_cookie_t opc,
- off_t oldoff, off_t newoff, const struct puffs_cred *pcr)
-{
- return 0;
-}
-
int
perfuse_node_remove(struct puffs_usermount *pu, puffs_cookie_t opc,
puffs_cookie_t targ, const struct puffs_cn *pcn)
@@ -3011,11 +3015,6 @@
if (vap->va_type == VDIR)
return EISDIR;
- if ((u_quad_t)offset + *resid > vap->va_size)
- DWARNX("%s %p read %lld@%zu beyond EOF %" PRIu64 "\n",
- __func__, (void *)opc, (long long)offset,
- *resid, vap->va_size);
-
do {
size_t max_read;
@@ -3130,8 +3129,6 @@
* we get the latest value.
*/
if (ioflag & PUFFS_IO_APPEND) {
- DWARNX("%s: PUFFS_IO_APPEND set, untested code", __func__);
-
if ((error = perfuse_node_getattr(pu, opc, vap, pcr)) != 0)
goto out;
@@ -3303,6 +3300,10 @@
char *np;
int error;
+ /* system namespace attrs are not accessible to non root users */
+ if (attrns == EXTATTR_NAMESPACE_SYSTEM && !puffs_cred_isjuggernaut(pcr))
+ return EPERM;
+
node_ref(opc);
ps = puffs_getspecific(pu);
attrname = perfuse_native_ns(attrns, attrname, fuse_attrname);
@@ -3339,9 +3340,18 @@
*/
foh = GET_OUTHDR(ps, pm);
np = (char *)(void *)(foh + 1);
+ len = foh->len - sizeof(*foh);
+
+ if (attrsize != NULL)
+ *attrsize = len;
if (resid != NULL) {
- len = MAX(foh->len - sizeof(*foh), *resid);
+ if (*resid < len) {
+ error = ERANGE;
+ ps->ps_destroy_msg(pm);
+ goto out;
+ }
+
(void)memcpy(attr, np, len);
*resid -= len;
}
@@ -3368,6 +3378,10 @@
char *np;
int error;
+ /* system namespace attrs are not accessible to non root users */
+ if (attrns == EXTATTR_NAMESPACE_SYSTEM && !puffs_cred_isjuggernaut(pcr))
+ return EPERM;
+
node_ref(opc);
ps = puffs_getspecific(pu);
attrname = perfuse_native_ns(attrns, attrname, fuse_attrname);
@@ -3408,9 +3422,13 @@
struct fuse_getxattr_out *fgo;
struct fuse_out_header *foh;
char *np;
- size_t len, puffs_len;
+ size_t len, puffs_len, i, attrlen, outlen;
int error;
+ /* system namespace attrs are not accessible to non root users */
+ if (attrns == EXTATTR_NAMESPACE_SYSTEM && !puffs_cred_isjuggernaut(pcr))
+ return EPERM;
+
node_ref(opc);
ps = puffs_getspecific(pu);
@@ -3450,29 +3468,45 @@
np = (char *)(void *)(foh + 1);
puffs_len = foh->len - sizeof(*foh);
+ if (attrsize != NULL)
+ *attrsize = puffs_len;
+
if (attrs != NULL) {
+ if (*resid < puffs_len) {
+ error = ERANGE;
+ ps->ps_destroy_msg(pm);
+ goto out;
+ }
+
+ outlen = 0;
+
+ for (i = 0; i < puffs_len; i += attrlen + 1) {
+ attrlen = strlen(np + i);
+
+ /*
+ * Filter attributes per namespace
+ */
+ if (!perfuse_ns_match(attrns, np + i))
+ continue;
+
#ifdef PUFFS_EXTATTR_LIST_LENPREFIX
- /*
- * Convert the FUSE reply to length prefixed strings
- * if this is what the kernel wants.
- */
- if (flag & PUFFS_EXTATTR_LIST_LENPREFIX) {
- size_t i, attrlen;
-
- for (i = 0; i < puffs_len; i += attrlen + 1) {
- attrlen = strlen(np + i);
- (void)memmove(np + i + 1, np + i, attrlen);
- *(np + i) = (uint8_t)attrlen;
- }
- }
+ /*
+ * Convert the FUSE reply to length prefixed strings
+ * if this is what the kernel wants.
+ */
+ if (flag & PUFFS_EXTATTR_LIST_LENPREFIX) {
+ (void)memcpy(attrs + outlen + 1,
+ np + i, attrlen);
+ *(attrs + outlen) = (uint8_t)attrlen;
+ } else
#endif /* PUFFS_EXTATTR_LIST_LENPREFIX */
- (void)memcpy(attrs, np, puffs_len);
- *resid -= puffs_len;
+ (void)memcpy(attrs + outlen, np + i, attrlen + 1);
+ outlen += attrlen + 1;
+ }
+
+ *resid -= outlen;
}
- if (attrsize != NULL)
- *attrsize = puffs_len;
-
ps->ps_destroy_msg(pm);
error = 0;
@@ -3492,6 +3526,10 @@
char *np;
int error;
+ /* system namespace attrs are not accessible to non root users */
+ if (attrns == EXTATTR_NAMESPACE_SYSTEM && !puffs_cred_isjuggernaut(pcr))
+ return EPERM;
+
node_ref(opc);
ps = puffs_getspecific(pu);
diff -r 37c7223b4af2 -r 994279b6d3f4 lib/libperfuse/perfuse.c
--- a/lib/libperfuse/perfuse.c Mon Nov 03 16:39:11 2014 +0000
+++ b/lib/libperfuse/perfuse.c Mon Nov 03 19:18:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse.c,v 1.25.2.3 2012/09/13 22:31:03 riz Exp $ */
+/* $NetBSD: perfuse.c,v 1.25.2.4 2014/11/03 19:18:09 msaitoh Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -471,11 +471,7 @@
PUFFSOP_SET(pops, perfuse, node, getattr);
PUFFSOP_SET(pops, perfuse, node, setattr);
PUFFSOP_SET(pops, perfuse, node, poll);
-#if 0
- PUFFSOP_SET(pops, perfuse, node, mmap);
-#endif
PUFFSOP_SET(pops, perfuse, node, fsync);
- PUFFSOP_SET(pops, perfuse, node, seek);
PUFFSOP_SET(pops, perfuse, node, remove);
PUFFSOP_SET(pops, perfuse, node, link);
PUFFSOP_SET(pops, perfuse, node, rename);
@@ -503,6 +499,9 @@
#ifdef PUFFS_SETATTR_FAF
PUFFSOP_SET(pops, perfuse, node, write2);
#endif /* PUFFS_SETATTR_FAF */
+#ifdef PUFFS_OPEN_IO_DIRECT
+ PUFFSOP_SET(pops, perfuse, node, open2);
+#endif /* PUFFS_OPEN_IO_DIRECT */
/*
* PUFFS_KFLAG_NOCACHE_NAME is required so that we can see changes
diff -r 37c7223b4af2 -r 994279b6d3f4 lib/libperfuse/perfuse_priv.h
--- a/lib/libperfuse/perfuse_priv.h Mon Nov 03 16:39:11 2014 +0000
+++ b/lib/libperfuse/perfuse_priv.h Mon Nov 03 19:18:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse_priv.h,v 1.25.2.4 2012/08/12 13:13:20 martin Exp $ */
+/* $NetBSD: perfuse_priv.h,v 1.25.2.5 2014/11/03 19:18:09 msaitoh Exp $ */
/*-
Home |
Main Index |
Thread Index |
Old Index