Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface...
details: https://anonhg.NetBSD.org/src/rev/e77ae3b18467
branches: trunk
changeset: 766921:e77ae3b18467
user: manu <manu%NetBSD.org@localhost>
date: Mon Jul 04 08:07:29 2011 +0000
description:
Add a flag to VOP_LISTEXTATTR(9) so that the vnode interface can tell the
filesystem in which format extended attribute shall be listed.
There are currently two formats:
- NUL-terminated strings, used for listxattr(2), this is the default.
- one byte length-pprefixed, non NUL-terminated strings, used for
extattr_list_file(2), which is obtanined by setting the
EXTATTR_LIST_PREFIXLEN flag to VOP_LISTEXTATTR(9)
This approach avoid the need for converting the list back and forth, except
in libperfuse, since FUSE uses NUL-terminated strings, and the kernel may
have requested EXTATTR_LIST_PREFIXLEN.
diffstat:
lib/libp2k/p2k.c | 9 ++++---
lib/libperfuse/ops.c | 18 +++++++++++++-
lib/libperfuse/perfuse_priv.h | 4 +-
lib/libpuffs/dispatcher.c | 8 ++++--
lib/libpuffs/puffs.h | 7 +++--
lib/libpuffs/puffs_ops.3 | 4 +-
sys/fs/puffs/puffs_msgif.h | 3 +-
sys/fs/puffs/puffs_vnops.c | 7 ++++-
sys/kern/vfs_xattr.c | 30 ++++++++++++++-----------
sys/kern/vnode_if.c | 6 +++-
sys/rump/include/rump/rumpvnode_if.h | 4 +-
sys/rump/librump/rumpvfs/rumpvnode_if.c | 7 +++--
sys/sys/extattr.h | 5 +++-
sys/sys/vnode_if.h | 6 +++-
sys/ufs/ufs/ufs_extattr.c | 38 ++++++++++++++++++++++++++------
usr.bin/extattr/getextattr.c | 7 +++--
16 files changed, 110 insertions(+), 53 deletions(-)
diffs (truncated from 603 to 300 lines):
diff -r 5e0dc80d3918 -r e77ae3b18467 lib/libp2k/p2k.c
--- a/lib/libp2k/p2k.c Mon Jul 04 08:02:34 2011 +0000
+++ b/lib/libp2k/p2k.c Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: p2k.c,v 1.54 2011/01/07 16:02:32 pooka Exp $ */
+/* $NetBSD: p2k.c,v 1.55 2011/07/04 08:07:29 manu Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Antti Kantee. All Rights Reserved.
@@ -1304,8 +1304,8 @@
/*ARGSUSED*/
int
p2k_node_listextattr(struct puffs_usermount *pu, puffs_cookie_t opc,
- int attrnamespace, size_t *attrsize,
- uint8_t *attrs, size_t *resid, const struct puffs_cred *pcr)
+ int attrnamespace, size_t *attrsize, uint8_t *attrs,
+ size_t *resid, int flags, const struct puffs_cred *pcr)
{
struct vnode *vp = OPC2VP(opc);
struct kauth_cred *cred;
@@ -1319,7 +1319,8 @@
cred = cred_create(pcr);
RUMP_VOP_LOCK(vp, LK_EXCLUSIVE);
- rv = RUMP_VOP_LISTEXTATTR(vp, attrnamespace, uio, attrsize, cred);
+ rv = RUMP_VOP_LISTEXTATTR(vp, attrnamespace, uio, attrsize,
+ flags, cred);
RUMP_VOP_UNLOCK(vp);
cred_destroy(cred);
diff -r 5e0dc80d3918 -r e77ae3b18467 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c Mon Jul 04 08:02:34 2011 +0000
+++ b/lib/libperfuse/ops.c Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ops.c,v 1.31 2011/06/28 16:19:16 manu Exp $ */
+/* $NetBSD: ops.c,v 1.32 2011/07/04 08:07:29 manu Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -3040,13 +3040,14 @@
/* ARGSUSED2 */
int
-perfuse_node_listextattr(pu, opc, attrns, attrsize, attrs, resid, pcr)
+perfuse_node_listextattr(pu, opc, attrns, attrsize, attrs, resid, flag, pcr)
struct puffs_usermount *pu;
puffs_cookie_t opc;
int attrns;
size_t *attrsize;
uint8_t *attrs;
size_t *resid;
+ int flag;
const struct puffs_cred *pcr;
{
struct perfuse_state *ps;
@@ -3093,6 +3094,19 @@
puffs_len = foh->len - sizeof(*foh);
if (attrs != NULL) {
+ /*
+ * 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;
+ }
+ }
(void)memcpy(attrs, np, puffs_len);
*resid -= puffs_len;
}
diff -r 5e0dc80d3918 -r e77ae3b18467 lib/libperfuse/perfuse_priv.h
--- a/lib/libperfuse/perfuse_priv.h Mon Jul 04 08:02:34 2011 +0000
+++ b/lib/libperfuse/perfuse_priv.h Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse_priv.h,v 1.19 2011/06/28 16:19:16 manu Exp $ */
+/* $NetBSD: perfuse_priv.h,v 1.20 2011/07/04 08:07:30 manu Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -228,7 +228,7 @@
int perfuse_node_setextattr(struct puffs_usermount *, puffs_cookie_t,
int, const char *, uint8_t *, size_t *, const struct puffs_cred *);
int perfuse_node_listextattr(struct puffs_usermount *, puffs_cookie_t,
- int, size_t *, uint8_t *, size_t *, const struct puffs_cred *);
+ int, size_t *, uint8_t *, size_t *, int, const struct puffs_cred *);
int perfuse_node_deleteextattr(struct puffs_usermount *, puffs_cookie_t,
int, const char *, const struct puffs_cred *);
diff -r 5e0dc80d3918 -r e77ae3b18467 lib/libpuffs/dispatcher.c
--- a/lib/libpuffs/dispatcher.c Mon Jul 04 08:02:34 2011 +0000
+++ b/lib/libpuffs/dispatcher.c Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dispatcher.c,v 1.35 2010/12/06 14:50:34 pooka Exp $ */
+/* $NetBSD: dispatcher.c,v 1.36 2011/07/04 08:07:30 manu Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Antti Kantee. All Rights Reserved.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: dispatcher.c,v 1.35 2010/12/06 14:50:34 pooka Exp $");
+__RCSID("$NetBSD: dispatcher.c,v 1.36 2011/07/04 08:07:30 manu Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -975,6 +975,7 @@
struct puffs_vnmsg_listextattr *auxt = auxbuf;
PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
size_t res, *resp, *sizep;
+ int flag;
uint8_t *data;
if (pops->puffs_node_listextattr == NULL) {
@@ -997,9 +998,10 @@
}
res = auxt->pvnr_resid;
+ flag = auxt->pvnr_flag;
error = pops->puffs_node_listextattr(pu,
opcookie, auxt->pvnr_attrnamespace,
- sizep, data, resp, pcr);
+ sizep, data, resp, flag, pcr);
/* need to move a bit more? */
preq->preq_buflen =
diff -r 5e0dc80d3918 -r e77ae3b18467 lib/libpuffs/puffs.h
--- a/lib/libpuffs/puffs.h Mon Jul 04 08:02:34 2011 +0000
+++ b/lib/libpuffs/puffs.h Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs.h,v 1.117 2010/06/07 11:21:31 pooka Exp $ */
+/* $NetBSD: puffs.h,v 1.118 2011/07/04 08:07:30 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -113,6 +113,7 @@
#define PUFFS_FSYNC_DATAONLY 0x0002
#define PUFFS_FSYNC_CACHE 0x0100
+#define PUFFS_EXTATTR_LIST_LENPREFIX 1
/*
* Magic constants
*/
@@ -231,7 +232,7 @@
int (*puffs_node_setextattr)(struct puffs_usermount *, puffs_cookie_t,
int, const char *, uint8_t *, size_t *, const struct puffs_cred *);
int (*puffs_node_listextattr)(struct puffs_usermount *, puffs_cookie_t,
- int, size_t *, uint8_t *, size_t *, const struct puffs_cred *);
+ int, size_t *, uint8_t *, size_t *, int, const struct puffs_cred *);
int (*puffs_node_deleteextattr)(struct puffs_usermount *,
puffs_cookie_t, int, const char *, const struct puffs_cred *);
@@ -379,7 +380,7 @@
const struct puffs_cred *); \
int fsname##_node_listextattr(struct puffs_usermount *, \
puffs_cookie_t, int, size_t *, uint8_t *, size_t *, \
- const struct puffs_cred *); \
+ int, const struct puffs_cred *); \
int fsname##_node_deleteextattr(struct puffs_usermount *, \
puffs_cookie_t, int, const char *, \
const struct puffs_cred *);
diff -r 5e0dc80d3918 -r e77ae3b18467 lib/libpuffs/puffs_ops.3
--- a/lib/libpuffs/puffs_ops.3 Mon Jul 04 08:02:34 2011 +0000
+++ b/lib/libpuffs/puffs_ops.3 Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: puffs_ops.3,v 1.28 2011/04/19 10:35:24 manu Exp $
+.\" $NetBSD: puffs_ops.3,v 1.29 2011/07/04 08:07:30 manu Exp $
.\"
.\" Copyright (c) 2007 Antti Kantee. All rights reserved.
.\"
@@ -196,7 +196,7 @@
.Ft int
.Fo puffs_node_listextattr
.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int attrnamespace"
-.Fa "size_t *attrssize" "uint8_t *attrs" "size_t *resid"
+.Fa "size_t *attrssize" "uint8_t *attrs" "iint flag" "size_t *resid"
.Fa "const struct puffs_cred *pcr"
.Fc
.Ft int
diff -r 5e0dc80d3918 -r e77ae3b18467 sys/fs/puffs/puffs_msgif.h
--- a/sys/fs/puffs/puffs_msgif.h Mon Jul 04 08:02:34 2011 +0000
+++ b/sys/fs/puffs/puffs_msgif.h Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_msgif.h,v 1.75 2010/07/06 13:47:47 pooka Exp $ */
+/* $NetBSD: puffs_msgif.h,v 1.76 2011/07/04 08:07:30 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -626,6 +626,7 @@
size_t pvnr_datasize; /* IN */
size_t pvnr_resid; /* IN/OUT */
+ int pvnr_flag; /* OUT */
uint8_t pvnr_data[0] /* IN */
__aligned(ALIGNBYTES+1);
};
diff -r 5e0dc80d3918 -r e77ae3b18467 sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c Mon Jul 04 08:02:34 2011 +0000
+++ b/sys/fs/puffs/puffs_vnops.c Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_vnops.c,v 1.153 2011/06/12 03:35:54 rmind Exp $ */
+/* $NetBSD: puffs_vnops.c,v 1.154 2011/07/04 08:07:30 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.153 2011/06/12 03:35:54 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.154 2011/07/04 08:07:30 manu Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -2721,6 +2721,7 @@
int a_attrnamespace;
struct uio *a_uio;
size_t *a_size;
+ int a_flag,
kauth_cred_t a_cred;
}; */ *ap = v;
PUFFS_MSG_VARS(vn, listextattr);
@@ -2729,6 +2730,7 @@
int attrnamespace = ap->a_attrnamespace;
struct uio *uio = ap->a_uio;
size_t *sizep = ap->a_size;
+ int flag = ap->a_flag;
size_t tomove, resid;
int error;
@@ -2747,6 +2749,7 @@
&park_listextattr, (void *)&listextattr_msg, 1);
listextattr_msg->pvnr_attrnamespace = attrnamespace;
+ listextattr_msg->pvnr_flag = flag;
puffs_credcvt(&listextattr_msg->pvnr_cred, ap->a_cred);
listextattr_msg->pvnr_resid = tomove;
if (sizep)
diff -r 5e0dc80d3918 -r e77ae3b18467 sys/kern/vfs_xattr.c
--- a/sys/kern/vfs_xattr.c Mon Jul 04 08:02:34 2011 +0000
+++ b/sys/kern/vfs_xattr.c Mon Jul 04 08:07:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_xattr.c,v 1.26 2011/06/29 08:01:14 manu Exp $ */
+/* $NetBSD: vfs_xattr.c,v 1.27 2011/07/04 08:07:30 manu Exp $ */
/*-
* Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.26 2011/06/29 08:01:14 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.27 2011/07/04 08:07:30 manu Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -355,7 +355,7 @@
*/
static int
extattr_list_vp(struct vnode *vp, int attrnamespace, void *data, size_t nbytes,
- struct lwp *l, register_t *retval)
+ int flag, struct lwp *l, register_t *retval)
{
struct uio auio, *auiop;
size_t size, *sizep;
@@ -386,7 +386,8 @@
} else
sizep = &size;
- error = VOP_LISTEXTATTR(vp, attrnamespace, auiop, sizep, l->l_cred);
+ error = VOP_LISTEXTATTR(vp, attrnamespace, auiop, sizep,
+ flag, l->l_cred);
if (auiop != NULL) {
cnt -= auio.uio_resid;
@@ -695,7 +696,8 @@
vp = (struct vnode *) fp->f_data;
error = extattr_list_vp(vp, SCARG(uap, attrnamespace),
- SCARG(uap, data), SCARG(uap, nbytes), l, retval);
+ SCARG(uap, data), SCARG(uap, nbytes),
+ EXTATTR_LIST_LENPREFIX, l, retval);
fd_putfile(SCARG(uap, fd));
return (error);
@@ -719,7 +721,8 @@
return (error);
error = extattr_list_vp(vp, SCARG(uap, attrnamespace),
- SCARG(uap, data), SCARG(uap, nbytes), l, retval);
+ SCARG(uap, data), SCARG(uap, nbytes),
+ EXTATTR_LIST_LENPREFIX, l, retval);
vrele(vp);
return (error);
Home |
Main Index |
Thread Index |
Old Index