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.
This commit is contained in:
parent
c2405fa58b
commit
be95d60797
|
@ -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 @@ p2k_node_setextattr(struct puffs_usermount *pu, puffs_cookie_t opc,
|
|||
/*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 @@ p2k_node_listextattr(struct puffs_usermount *pu, puffs_cookie_t opc,
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -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 @@ out:
|
|||
|
||||
/* 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 @@ perfuse_node_listextattr(pu, opc, attrns, attrsize, attrs, resid, pcr)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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_getextattr(struct puffs_usermount *, puffs_cookie_t,
|
|||
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 *);
|
||||
|
||||
|
|
|
@ -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 @@ dispatch(struct puffs_cc *pcc)
|
|||
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 @@ dispatch(struct puffs_cc *pcc)
|
|||
}
|
||||
|
||||
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 =
|
||||
|
|
|
@ -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 @@ struct puffs_usermount;
|
|||
#define PUFFS_FSYNC_DATAONLY 0x0002
|
||||
#define PUFFS_FSYNC_CACHE 0x0100
|
||||
|
||||
#define PUFFS_EXTATTR_LIST_LENPREFIX 1
|
||||
/*
|
||||
* Magic constants
|
||||
*/
|
||||
|
@ -231,7 +232,7 @@ struct puffs_ops {
|
|||
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 @@ enum {
|
|||
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 *);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@ struct puffs_vnmsg_listextattr {
|
|||
size_t pvnr_datasize; /* IN */
|
||||
|
||||
size_t pvnr_resid; /* IN/OUT */
|
||||
int pvnr_flag; /* OUT */
|
||||
uint8_t pvnr_data[0] /* IN */
|
||||
__aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
|
|
@ -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 @@ puffs_vnop_listextattr(void *v)
|
|||
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 @@ puffs_vnop_listextattr(void *v)
|
|||
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 @@ puffs_vnop_listextattr(void *v)
|
|||
&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)
|
||||
|
|
|
@ -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 @@ extattr_delete_vp(struct vnode *vp, int attrnamespace, const char *attrname,
|
|||
*/
|
||||
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 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, void *data, size_t nbytes,
|
|||
} 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 @@ sys_extattr_list_fd(struct lwp *l, const struct sys_extattr_list_fd_args *uap, r
|
|||
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 @@ sys_extattr_list_file(struct lwp *l, const struct sys_extattr_list_file_args *ua
|
|||
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);
|
||||
|
@ -743,7 +746,8 @@ sys_extattr_list_link(struct lwp *l, const struct sys_extattr_list_link_args *ua
|
|||
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);
|
||||
|
@ -1008,7 +1012,7 @@ sys_listxattr(struct lwp *l, const struct sys_listxattr_args *uap, register_t *r
|
|||
size = SCARG(uap, size);
|
||||
|
||||
error = extattr_list_vp(vp, EXTATTR_NAMESPACE_USER,
|
||||
list, size, l, &listsize_usr);
|
||||
list, size, 0, l, &listsize_usr);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
|
@ -1018,7 +1022,7 @@ sys_listxattr(struct lwp *l, const struct sys_listxattr_args *uap, register_t *r
|
|||
size -= listsize_usr;
|
||||
|
||||
error = extattr_list_vp(vp, EXTATTR_NAMESPACE_SYSTEM,
|
||||
list, size, l, &listsize_sys);
|
||||
list, size, 0, l, &listsize_sys);
|
||||
switch (error) {
|
||||
case EPERM:
|
||||
error = 0; /* Ignore and just skip system EA */
|
||||
|
@ -1061,7 +1065,7 @@ sys_llistxattr(struct lwp *l, const struct sys_llistxattr_args *uap, register_t
|
|||
size = SCARG(uap, size);
|
||||
|
||||
error = extattr_list_vp(vp, EXTATTR_NAMESPACE_USER,
|
||||
list, size, l, &listsize_usr);
|
||||
list, size, 0, l, &listsize_usr);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
|
@ -1071,7 +1075,7 @@ sys_llistxattr(struct lwp *l, const struct sys_llistxattr_args *uap, register_t
|
|||
size -= listsize_usr;
|
||||
|
||||
error = extattr_list_vp(vp, EXTATTR_NAMESPACE_SYSTEM,
|
||||
list, size, l, &listsize_sys);
|
||||
list, size, 0, l, &listsize_sys);
|
||||
switch (error) {
|
||||
case EPERM:
|
||||
error = 0; /* Ignore and just skip system EA */
|
||||
|
@ -1114,7 +1118,7 @@ sys_flistxattr(struct lwp *l, const struct sys_flistxattr_args *uap, register_t
|
|||
size = SCARG(uap, size);
|
||||
|
||||
error = extattr_list_vp(vp, EXTATTR_NAMESPACE_USER,
|
||||
list, size, l, &listsize_usr);
|
||||
list, size, 0, l, &listsize_usr);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
|
@ -1124,7 +1128,7 @@ sys_flistxattr(struct lwp *l, const struct sys_flistxattr_args *uap, register_t
|
|||
size -= listsize_usr;
|
||||
|
||||
error = extattr_list_vp(vp, EXTATTR_NAMESPACE_SYSTEM,
|
||||
list, size, l, &listsize_sys);
|
||||
list, size, 0, l, &listsize_sys);
|
||||
switch (error) {
|
||||
case EPERM:
|
||||
error = 0; /* Ignore and just skip system EA */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vnode_if.c,v 1.86 2011/03/06 17:08:36 bouyer Exp $ */
|
||||
/* $NetBSD: vnode_if.c,v 1.87 2011/07/04 08:07:31 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Warning: DO NOT EDIT! This file is automatically generated!
|
||||
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.86 2011/03/06 17:08:36 bouyer Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.87 2011/07/04 08:07:31 manu Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
|
@ -1519,6 +1519,7 @@ VOP_LISTEXTATTR(struct vnode *vp,
|
|||
int attrnamespace,
|
||||
struct uio *uio,
|
||||
size_t *size,
|
||||
int flag,
|
||||
kauth_cred_t cred)
|
||||
{
|
||||
int error;
|
||||
|
@ -1529,6 +1530,7 @@ VOP_LISTEXTATTR(struct vnode *vp,
|
|||
a.a_attrnamespace = attrnamespace;
|
||||
a.a_uio = uio;
|
||||
a.a_size = size;
|
||||
a.a_flag = flag;
|
||||
a.a_cred = cred;
|
||||
mpsafe = (vp->v_vflag & VV_MPSAFE);
|
||||
if (!mpsafe) { KERNEL_LOCK(1, curlwp); }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rumpvnode_if.h,v 1.9 2011/03/06 17:08:37 bouyer Exp $ */
|
||||
/* $NetBSD: rumpvnode_if.h,v 1.10 2011/07/04 08:07:31 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Warning: DO NOT EDIT! This file is automatically generated!
|
||||
|
@ -107,7 +107,7 @@ int RUMP_VOP_CLOSEEXTATTR(struct vnode *, int, struct kauth_cred *);
|
|||
int RUMP_VOP_GETEXTATTR(struct vnode *, int, const char *, struct uio *,
|
||||
size_t *, struct kauth_cred *);
|
||||
int RUMP_VOP_LISTEXTATTR(struct vnode *, int, struct uio *, size_t *,
|
||||
struct kauth_cred *);
|
||||
int, struct kauth_cred *);
|
||||
int RUMP_VOP_OPENEXTATTR(struct vnode *, struct kauth_cred *);
|
||||
int RUMP_VOP_DELETEEXTATTR(struct vnode *, int, const char *,
|
||||
struct kauth_cred *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rumpvnode_if.c,v 1.8 2011/03/06 17:08:37 bouyer Exp $ */
|
||||
/* $NetBSD: rumpvnode_if.c,v 1.9 2011/07/04 08:07:31 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Warning: DO NOT EDIT! This file is automatically generated!
|
||||
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rumpvnode_if.c,v 1.8 2011/03/06 17:08:37 bouyer Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rumpvnode_if.c,v 1.9 2011/07/04 08:07:31 manu Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
|
@ -677,12 +677,13 @@ RUMP_VOP_LISTEXTATTR(struct vnode *vp,
|
|||
int attrnamespace,
|
||||
struct uio *uio,
|
||||
size_t *size,
|
||||
int flag,
|
||||
struct kauth_cred *cred)
|
||||
{
|
||||
int error;
|
||||
|
||||
rump_schedule();
|
||||
error = VOP_LISTEXTATTR(vp, attrnamespace, uio, size, cred);
|
||||
error = VOP_LISTEXTATTR(vp, attrnamespace, uio, size, flag, cred);
|
||||
rump_unschedule();
|
||||
|
||||
return error;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: extattr.h,v 1.5 2011/06/17 14:23:51 manu Exp $ */
|
||||
/* $NetBSD: extattr.h,v 1.6 2011/07/04 08:07:31 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999-2001 Robert N. M. Watson
|
||||
|
@ -54,6 +54,9 @@
|
|||
|
||||
#include <sys/syslimits.h>
|
||||
|
||||
/* VOP_LISTEXTATTR flags */
|
||||
#define EXTATTR_LIST_LENPREFIX 1 /* names with length prefix */
|
||||
|
||||
#define EXTATTR_MAXNAMELEN NAME_MAX
|
||||
struct lwp;
|
||||
struct vnode;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vnode_if.h,v 1.80 2011/03/06 17:08:38 bouyer Exp $ */
|
||||
/* $NetBSD: vnode_if.h,v 1.81 2011/07/04 08:07:31 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Warning: DO NOT EDIT! This file is automatically generated!
|
||||
|
@ -515,10 +515,12 @@ struct vop_listextattr_args {
|
|||
int a_attrnamespace;
|
||||
struct uio *a_uio;
|
||||
size_t *a_size;
|
||||
int a_flag;
|
||||
kauth_cred_t a_cred;
|
||||
};
|
||||
extern const struct vnodeop_desc vop_listextattr_desc;
|
||||
int VOP_LISTEXTATTR(struct vnode *, int, struct uio *, size_t *, kauth_cred_t);
|
||||
int VOP_LISTEXTATTR(struct vnode *, int, struct uio *, size_t *,
|
||||
int, kauth_cred_t);
|
||||
|
||||
#define VOP_OPENEXTATTR_DESCOFFSET 45
|
||||
struct vop_openextattr_args {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ufs_extattr.c,v 1.33 2011/06/27 16:34:47 manu Exp $ */
|
||||
/* $NetBSD: ufs_extattr.c,v 1.34 2011/07/04 08:07:32 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999-2002 Robert N. M. Watson
|
||||
|
@ -48,7 +48,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.33 2011/06/27 16:34:47 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.34 2011/07/04 08:07:32 manu Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ffs.h"
|
||||
|
@ -96,7 +96,7 @@ static int ufs_extattr_get(struct vnode *vp, int attrnamespace,
|
|||
const char *name, struct uio *uio, size_t *size,
|
||||
kauth_cred_t cred, struct lwp *l);
|
||||
static int ufs_extattr_list(struct vnode *vp, int attrnamespace,
|
||||
struct uio *uio, size_t *size,
|
||||
struct uio *uio, size_t *size, int flag,
|
||||
kauth_cred_t cred, struct lwp *l);
|
||||
static int ufs_extattr_set(struct vnode *vp, int attrnamespace,
|
||||
const char *name, struct uio *uio, kauth_cred_t cred,
|
||||
|
@ -1137,6 +1137,7 @@ vop_listextattr {
|
|||
IN int a_attrnamespace;
|
||||
INOUT struct uio *a_uio;
|
||||
OUT size_t *a_size;
|
||||
IN int flag;
|
||||
IN kauth_cred_t a_cred;
|
||||
struct proc *a_p;
|
||||
};
|
||||
|
@ -1149,7 +1150,7 @@ vop_listextattr {
|
|||
ufs_extattr_uepm_lock(ump);
|
||||
|
||||
error = ufs_extattr_list(ap->a_vp, ap->a_attrnamespace,
|
||||
ap->a_uio, ap->a_size, ap->a_cred, curlwp);
|
||||
ap->a_uio, ap->a_size, ap->a_flag, ap->a_cred, curlwp);
|
||||
|
||||
ufs_extattr_uepm_unlock(ump);
|
||||
|
||||
|
@ -1162,7 +1163,8 @@ vop_listextattr {
|
|||
*/
|
||||
static int
|
||||
ufs_extattr_list(struct vnode *vp, int attrnamespace,
|
||||
struct uio *uio, size_t *size, kauth_cred_t cred, struct lwp *l)
|
||||
struct uio *uio, size_t *size, int flag,
|
||||
kauth_cred_t cred, struct lwp *l)
|
||||
{
|
||||
struct ufs_extattr_list_entry *uele;
|
||||
struct ufs_extattr_header ueh;
|
||||
|
@ -1199,13 +1201,33 @@ ufs_extattr_list(struct vnode *vp, int attrnamespace,
|
|||
vn_lock(uele->uele_backing_vnode, LK_SHARED | LK_RETRY);
|
||||
|
||||
/*
|
||||
* +1 for trailing \0
|
||||
* +1 for trailing NUL (listxattr flavor)
|
||||
* or leading name length (extattr_list_file flavor)
|
||||
*/
|
||||
attrnamelen = strlen(uele->uele_attrname) + 1;
|
||||
listsize += attrnamelen;
|
||||
attrnamelen = strlen(uele->uele_attrname);
|
||||
listsize += attrnamelen + 1;
|
||||
|
||||
/* Return data if the caller requested it. */
|
||||
if (uio != NULL) {
|
||||
/*
|
||||
* We support two flavors. Either NUL-terminated
|
||||
* strings (a la listxattr), or non NUL-terminated,
|
||||
* one byte length prefixed strings (for
|
||||
* extattr_list_file). EXTATTR_LIST_LENPREFIX switches
|
||||
* that second behavior.
|
||||
*/
|
||||
if (flag & EXTATTR_LIST_LENPREFIX) {
|
||||
uint8_t len = (uint8_t)attrnamelen;
|
||||
|
||||
/* Copy leading name length */
|
||||
error = uiomove(&len, sizeof(len), uio);
|
||||
if (error != 0)
|
||||
break;
|
||||
} else {
|
||||
/* Include trailing NULL */
|
||||
attrnamelen++;
|
||||
}
|
||||
|
||||
error = uiomove(uele->uele_attrname,
|
||||
(size_t)attrnamelen, uio);
|
||||
if (error != 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: getextattr.c,v 1.6 2011/06/28 07:24:14 manu Exp $ */
|
||||
/* $NetBSD: getextattr.c,v 1.7 2011/07/04 08:07:32 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2003 Networks Associates Technology, Inc.
|
||||
|
@ -237,8 +237,9 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
if (!flag_quiet)
|
||||
printf("%s\t", argv[arg_counter]);
|
||||
for (i = 0; i < error; i += strlen(buf + i) + 1)
|
||||
printf("%s%s", i ? "\t" : "", buf + i);
|
||||
for (i = 0; i < error; i += buf[i] + 1)
|
||||
printf("%s%*.*s", i ? "\t" : "",
|
||||
buf[i], buf[i], buf + i + 1);
|
||||
printf("\n");
|
||||
continue;
|
||||
case EAGET:
|
||||
|
|
Loading…
Reference in New Issue