1 /* $NetBSD: vfs_xattr.c,v 1.19 2008/06/23 11:30:41 ad Exp $ */
4 * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1989, 1993
34 * The Regents of the University of California. All rights reserved.
35 * (c) UNIX System Laboratories, Inc.
36 * All or some portions of this file are derived from material licensed
37 * to the University of California by American Telephone and Telegraph
38 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
39 * the permission of UNIX System Laboratories, Inc.
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * VFS extended attribute support.
70 #include <sys/cdefs.h>
71 __KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.19 2008/06/23 11:30:41 ad Exp $");
73 #include <sys/param.h>
74 #include <sys/systm.h>
75 #include <sys/namei.h>
76 #include <sys/filedesc.h>
77 #include <sys/kernel.h>
79 #include <sys/vnode.h>
80 #include <sys/mount.h>
83 #include <sys/extattr.h>
84 #include <sys/xattr.h>
85 #include <sys/sysctl.h>
86 #include <sys/syscallargs.h>
87 #include <sys/kauth.h>
90 * Credential check based on process requesting service, and per-attribute
93 * NOTE: Vnode must be locked.
96 extattr_check_cred(struct vnode
*vp
, int attrnamespace
,
97 kauth_cred_t cred
, struct lwp
*l
, int access
)
103 switch (attrnamespace
) {
104 case EXTATTR_NAMESPACE_SYSTEM
:
106 * Do we really want to allow this, or just require that
107 * these requests come from kernel code (NOCRED case above)?
109 return (kauth_authorize_generic(cred
, KAUTH_GENERIC_ISSUSER
,
112 case EXTATTR_NAMESPACE_USER
:
113 return (VOP_ACCESS(vp
, access
, cred
));
121 * Default vfs_extattrctl routine for file systems that do not support
126 vfs_stdextattrctl(struct mount
*mp
, int cmt
, struct vnode
*vp
,
127 int attrnamespace
, const char *attrname
)
136 * Push extended attribute configuration information into the file
139 * NOTE: Not all file systems that support extended attributes will
140 * require the use of this system call.
143 sys_extattrctl(struct lwp
*l
, const struct sys_extattrctl_args
*uap
, register_t
*retval
)
146 syscallarg(const char *) path;
148 syscallarg(const char *) filename;
149 syscallarg(int) attrnamespace;
150 syscallarg(const char *) attrname;
152 struct vnode
*path_vp
, *file_vp
;
153 struct nameidata file_nd
;
154 char attrname
[EXTATTR_MAXNAMELEN
];
157 if (SCARG(uap
, attrname
) != NULL
) {
158 error
= copyinstr(SCARG(uap
, attrname
), attrname
,
159 sizeof(attrname
), NULL
);
165 if (SCARG(uap
, filename
) != NULL
) {
166 NDINIT(&file_nd
, LOOKUP
, FOLLOW
| LOCKLEAF
, UIO_USERSPACE
,
167 SCARG(uap
, filename
));
168 error
= namei(&file_nd
);
171 file_vp
= file_nd
.ni_vp
;
174 error
= namei_simple_user(SCARG(uap
, path
),
175 NSM_FOLLOW_NOEMULROOT
, &path_vp
);
182 error
= VFS_EXTATTRCTL(path_vp
->v_mount
, SCARG(uap
, cmd
), file_vp
,
183 SCARG(uap
, attrnamespace
),
184 SCARG(uap
, attrname
) != NULL
? attrname
: NULL
);
189 /* XXX missing in the original code - am *I* missing something? */
195 /*****************************************************************************
196 * Internal routines to manipulate file system extended attributes:
201 *****************************************************************************/
206 * Set a named extended attribute on a file or directory.
209 extattr_set_vp(struct vnode
*vp
, int attrnamespace
, const char *attrname
,
210 const void *data
, size_t nbytes
, struct lwp
*l
, register_t
*retval
)
217 vn_lock(vp
, LK_EXCLUSIVE
| LK_RETRY
);
219 aiov
.iov_base
= __UNCONST(data
); /* XXXUNCONST kills const */
220 aiov
.iov_len
= nbytes
;
221 auio
.uio_iov
= &aiov
;
224 if (nbytes
> INT_MAX
) {
228 auio
.uio_resid
= nbytes
;
229 auio
.uio_rw
= UIO_WRITE
;
230 KASSERT(l
== curlwp
);
231 auio
.uio_vmspace
= l
->l_proc
->p_vmspace
;
234 error
= VOP_SETEXTATTR(vp
, attrnamespace
, attrname
, &auio
, l
->l_cred
);
235 cnt
-= auio
.uio_resid
;
246 * Get a named extended attribute on a file or directory.
249 extattr_get_vp(struct vnode
*vp
, int attrnamespace
, const char *attrname
,
250 void *data
, size_t nbytes
, struct lwp
*l
, register_t
*retval
)
252 struct uio auio
, *auiop
;
258 vn_lock(vp
, LK_EXCLUSIVE
| LK_RETRY
);
261 * Slightly unusual semantics: if the user provides a NULL data
262 * pointer, they don't want to receive the data, just the maximum
269 aiov
.iov_base
= data
;
270 aiov
.iov_len
= nbytes
;
271 auio
.uio_iov
= &aiov
;
273 if (nbytes
> INT_MAX
) {
277 auio
.uio_resid
= nbytes
;
278 auio
.uio_rw
= UIO_READ
;
279 KASSERT(l
== curlwp
);
280 auio
.uio_vmspace
= l
->l_proc
->p_vmspace
;
286 error
= VOP_GETEXTATTR(vp
, attrnamespace
, attrname
, auiop
, sizep
,
290 cnt
-= auio
.uio_resid
;
303 * Delete a named extended attribute on a file or directory.
306 extattr_delete_vp(struct vnode
*vp
, int attrnamespace
, const char *attrname
,
311 vn_lock(vp
, LK_EXCLUSIVE
| LK_RETRY
);
313 error
= VOP_DELETEEXTATTR(vp
, attrnamespace
, attrname
, l
->l_cred
);
314 if (error
== EOPNOTSUPP
)
315 error
= VOP_SETEXTATTR(vp
, attrnamespace
, attrname
, NULL
,
325 * Retrieve a list of extended attributes on a file or directory.
328 extattr_list_vp(struct vnode
*vp
, int attrnamespace
, void *data
, size_t nbytes
,
329 struct lwp
*l
, register_t
*retval
)
331 struct uio auio
, *auiop
;
337 vn_lock(vp
, LK_EXCLUSIVE
| LK_RETRY
);
343 aiov
.iov_base
= data
;
344 aiov
.iov_len
= nbytes
;
345 auio
.uio_iov
= &aiov
;
347 if (nbytes
> INT_MAX
) {
351 auio
.uio_resid
= nbytes
;
352 auio
.uio_rw
= UIO_READ
;
353 KASSERT(l
== curlwp
);
354 auio
.uio_vmspace
= l
->l_proc
->p_vmspace
;
360 error
= VOP_LISTEXTATTR(vp
, attrnamespace
, auiop
, sizep
, l
->l_cred
);
363 cnt
-= auio
.uio_resid
;
373 /*****************************************************************************
374 * BSD <sys/extattr.h> API for file system extended attributes
375 *****************************************************************************/
378 sys_extattr_set_fd(struct lwp
*l
, const struct sys_extattr_set_fd_args
*uap
, register_t
*retval
)
382 syscallarg(int) attrnamespace;
383 syscallarg(const char *) attrname;
384 syscallarg(const void *) data;
385 syscallarg(size_t) nbytes;
389 char attrname
[EXTATTR_MAXNAMELEN
];
392 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
397 error
= fd_getvnode(SCARG(uap
, fd
), &fp
);
400 vp
= (struct vnode
*) fp
->f_data
;
402 error
= extattr_set_vp(vp
, SCARG(uap
, attrnamespace
), attrname
,
403 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
405 fd_putfile(SCARG(uap
, fd
));
410 sys_extattr_set_file(struct lwp
*l
, const struct sys_extattr_set_file_args
*uap
, register_t
*retval
)
413 syscallarg(const char *) path;
414 syscallarg(int) attrnamespace;
415 syscallarg(const char *) attrname;
416 syscallarg(const void *) data;
417 syscallarg(size_t) nbytes;
420 char attrname
[EXTATTR_MAXNAMELEN
];
423 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
428 error
= namei_simple_user(SCARG(uap
, path
),
429 NSM_FOLLOW_NOEMULROOT
, &vp
);
433 error
= extattr_set_vp(vp
, SCARG(uap
, attrnamespace
), attrname
,
434 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
441 sys_extattr_set_link(struct lwp
*l
, const struct sys_extattr_set_link_args
*uap
, register_t
*retval
)
444 syscallarg(const char *) path;
445 syscallarg(int) attrnamespace;
446 syscallarg(const char *) attrname;
447 syscallarg(const void *) data;
448 syscallarg(size_t) nbytes;
451 char attrname
[EXTATTR_MAXNAMELEN
];
454 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
459 error
= namei_simple_user(SCARG(uap
, path
),
460 NSM_NOFOLLOW_NOEMULROOT
, &vp
);
464 error
= extattr_set_vp(vp
, SCARG(uap
, attrnamespace
), attrname
,
465 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
472 sys_extattr_get_fd(struct lwp
*l
, const struct sys_extattr_get_fd_args
*uap
, register_t
*retval
)
476 syscallarg(int) attrnamespace;
477 syscallarg(const char *) attrname;
478 syscallarg(void *) data;
479 syscallarg(size_t) nbytes;
483 char attrname
[EXTATTR_MAXNAMELEN
];
486 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
491 error
= fd_getvnode(SCARG(uap
, fd
), &fp
);
494 vp
= (struct vnode
*) fp
->f_data
;
496 error
= extattr_get_vp(vp
, SCARG(uap
, attrnamespace
), attrname
,
497 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
499 fd_putfile(SCARG(uap
, fd
));
504 sys_extattr_get_file(struct lwp
*l
, const struct sys_extattr_get_file_args
*uap
, register_t
*retval
)
507 syscallarg(const char *) path;
508 syscallarg(int) attrnamespace;
509 syscallarg(const char *) attrname;
510 syscallarg(void *) data;
511 syscallarg(size_t) nbytes;
514 char attrname
[EXTATTR_MAXNAMELEN
];
517 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
522 error
= namei_simple_user(SCARG(uap
, path
),
523 NSM_FOLLOW_NOEMULROOT
, &vp
);
527 error
= extattr_get_vp(vp
, SCARG(uap
, attrnamespace
), attrname
,
528 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
535 sys_extattr_get_link(struct lwp
*l
, const struct sys_extattr_get_link_args
*uap
, register_t
*retval
)
538 syscallarg(const char *) path;
539 syscallarg(int) attrnamespace;
540 syscallarg(const char *) attrname;
541 syscallarg(void *) data;
542 syscallarg(size_t) nbytes;
545 char attrname
[EXTATTR_MAXNAMELEN
];
548 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
553 error
= namei_simple_user(SCARG(uap
, path
),
554 NSM_NOFOLLOW_NOEMULROOT
, &vp
);
558 error
= extattr_get_vp(vp
, SCARG(uap
, attrnamespace
), attrname
,
559 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
566 sys_extattr_delete_fd(struct lwp
*l
, const struct sys_extattr_delete_fd_args
*uap
, register_t
*retval
)
570 syscallarg(int) attrnamespace;
571 syscallarg(const char *) attrname;
575 char attrname
[EXTATTR_MAXNAMELEN
];
578 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
583 error
= fd_getvnode(SCARG(uap
, fd
), &fp
);
586 vp
= (struct vnode
*) fp
->f_data
;
588 error
= extattr_delete_vp(vp
, SCARG(uap
, attrnamespace
), attrname
, l
);
590 fd_putfile(SCARG(uap
, fd
));
595 sys_extattr_delete_file(struct lwp
*l
, const struct sys_extattr_delete_file_args
*uap
, register_t
*retval
)
598 syscallarg(const char *) path;
599 syscallarg(int) attrnamespace;
600 syscallarg(const char *) attrname;
603 char attrname
[EXTATTR_MAXNAMELEN
];
606 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
611 error
= namei_simple_user(SCARG(uap
, path
),
612 NSM_FOLLOW_NOEMULROOT
, &vp
);
616 error
= extattr_delete_vp(vp
, SCARG(uap
, attrnamespace
), attrname
, l
);
623 sys_extattr_delete_link(struct lwp
*l
, const struct sys_extattr_delete_link_args
*uap
, register_t
*retval
)
626 syscallarg(const char *) path;
627 syscallarg(int) attrnamespace;
628 syscallarg(const char *) attrname;
631 char attrname
[EXTATTR_MAXNAMELEN
];
634 error
= copyinstr(SCARG(uap
, attrname
), attrname
, sizeof(attrname
),
639 error
= namei_simple_user(SCARG(uap
, path
),
640 NSM_NOFOLLOW_NOEMULROOT
, &vp
);
644 error
= extattr_delete_vp(vp
, SCARG(uap
, attrnamespace
), attrname
, l
);
651 sys_extattr_list_fd(struct lwp
*l
, const struct sys_extattr_list_fd_args
*uap
, register_t
*retval
)
655 syscallarg(int) attrnamespace;
656 syscallarg(void *) data;
657 syscallarg(size_t) nbytes;
663 error
= fd_getvnode(SCARG(uap
, fd
), &fp
);
666 vp
= (struct vnode
*) fp
->f_data
;
668 error
= extattr_list_vp(vp
, SCARG(uap
, attrnamespace
),
669 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
671 fd_putfile(SCARG(uap
, fd
));
676 sys_extattr_list_file(struct lwp
*l
, const struct sys_extattr_list_file_args
*uap
, register_t
*retval
)
679 syscallarg(const char *) path;
680 syscallarg(int) attrnamespace;
681 syscallarg(void *) data;
682 syscallarg(size_t) nbytes;
687 error
= namei_simple_user(SCARG(uap
, path
),
688 NSM_FOLLOW_NOEMULROOT
, &vp
);
692 error
= extattr_list_vp(vp
, SCARG(uap
, attrnamespace
),
693 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
700 sys_extattr_list_link(struct lwp
*l
, const struct sys_extattr_list_link_args
*uap
, register_t
*retval
)
703 syscallarg(const char *) path;
704 syscallarg(int) attrnamespace;
705 syscallarg(void *) data;
706 syscallarg(size_t) nbytes;
711 error
= namei_simple_user(SCARG(uap
, path
),
712 NSM_NOFOLLOW_NOEMULROOT
, &vp
);
716 error
= extattr_list_vp(vp
, SCARG(uap
, attrnamespace
),
717 SCARG(uap
, data
), SCARG(uap
, nbytes
), l
, retval
);
723 /*****************************************************************************
724 * Linux-compatible <sys/xattr.h> API for file system extended attributes
725 *****************************************************************************/
728 sys_setxattr(struct lwp
*l
, const struct sys_setxattr_args
*uap
, register_t
*retval
)
731 syscallarg(const char *) path;
732 syscallarg(const char *) name;
733 syscallarg(void *) value;
734 syscallarg(size_t) size;
735 syscallarg(int) flags;
738 char attrname
[XATTR_NAME_MAX
];
741 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
746 error
= namei_simple_user(SCARG(uap
, path
),
747 NSM_FOLLOW_NOEMULROOT
, &vp
);
753 error
= extattr_set_vp(vp
, EXTATTR_NAMESPACE_USER
,
754 attrname
, SCARG(uap
, value
), SCARG(uap
, size
), l
, retval
);
761 sys_lsetxattr(struct lwp
*l
, const struct sys_lsetxattr_args
*uap
, register_t
*retval
)
764 syscallarg(const char *) path;
765 syscallarg(const char *) name;
766 syscallarg(void *) value;
767 syscallarg(size_t) size;
768 syscallarg(int) flags;
771 char attrname
[XATTR_NAME_MAX
];
774 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
779 error
= namei_simple_user(SCARG(uap
, path
),
780 NSM_NOFOLLOW_NOEMULROOT
, &vp
);
786 error
= extattr_set_vp(vp
, EXTATTR_NAMESPACE_USER
,
787 attrname
, SCARG(uap
, value
), SCARG(uap
, size
), l
, retval
);
794 sys_fsetxattr(struct lwp
*l
, const struct sys_fsetxattr_args
*uap
, register_t
*retval
)
798 syscallarg(const char *) name;
799 syscallarg(void *) value;
800 syscallarg(size_t) size;
801 syscallarg(int) flags;
805 char attrname
[XATTR_NAME_MAX
];
808 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
813 error
= fd_getvnode(SCARG(uap
, fd
), &fp
);
816 vp
= (struct vnode
*) fp
->f_data
;
820 error
= extattr_set_vp(vp
, EXTATTR_NAMESPACE_USER
,
821 attrname
, SCARG(uap
, value
), SCARG(uap
, size
), l
, retval
);
823 fd_putfile(SCARG(uap
, fd
));
828 sys_getxattr(struct lwp
*l
, const struct sys_getxattr_args
*uap
, register_t
*retval
)
831 syscallarg(const char *) path;
832 syscallarg(const char *) name;
833 syscallarg(void *) value;
834 syscallarg(size_t) size;
837 char attrname
[XATTR_NAME_MAX
];
840 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
845 error
= namei_simple_user(SCARG(uap
, path
),
846 NSM_FOLLOW_NOEMULROOT
, &vp
);
850 error
= extattr_get_vp(vp
, EXTATTR_NAMESPACE_USER
,
851 attrname
, SCARG(uap
, value
), SCARG(uap
, size
), l
, retval
);
858 sys_lgetxattr(struct lwp
*l
, const struct sys_lgetxattr_args
*uap
, register_t
*retval
)
861 syscallarg(const char *) path;
862 syscallarg(const char *) name;
863 syscallarg(void *) value;
864 syscallarg(size_t) size;
867 char attrname
[XATTR_NAME_MAX
];
870 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
875 error
= namei_simple_user(SCARG(uap
, path
),
876 NSM_NOFOLLOW_NOEMULROOT
, &vp
);
880 error
= extattr_get_vp(vp
, EXTATTR_NAMESPACE_USER
,
881 attrname
, SCARG(uap
, value
), SCARG(uap
, size
), l
, retval
);
888 sys_fgetxattr(struct lwp
*l
, const struct sys_fgetxattr_args
*uap
, register_t
*retval
)
892 syscallarg(const char *) name;
893 syscallarg(void *) value;
894 syscallarg(size_t) size;
898 char attrname
[XATTR_NAME_MAX
];
901 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
906 error
= fd_getvnode(SCARG(uap
, fd
), &fp
);
909 vp
= (struct vnode
*) fp
->f_data
;
911 error
= extattr_get_vp(vp
, EXTATTR_NAMESPACE_USER
,
912 attrname
, SCARG(uap
, value
), SCARG(uap
, size
), l
, retval
);
914 fd_putfile(SCARG(uap
, fd
));
919 sys_listxattr(struct lwp
*l
, const struct sys_listxattr_args
*uap
, register_t
*retval
)
922 syscallarg(const char *) path;
923 syscallarg(char *) list;
924 syscallarg(size_t) size;
929 error
= namei_simple_user(SCARG(uap
, path
),
930 NSM_FOLLOW_NOEMULROOT
, &vp
);
934 error
= extattr_list_vp(vp
, EXTATTR_NAMESPACE_USER
,
935 SCARG(uap
, list
), SCARG(uap
, size
), l
, retval
);
942 sys_llistxattr(struct lwp
*l
, const struct sys_llistxattr_args
*uap
, register_t
*retval
)
945 syscallarg(const char *) path;
946 syscallarg(char *) list;
947 syscallarg(size_t) size;
952 error
= namei_simple_user(SCARG(uap
, path
),
953 NSM_NOFOLLOW_NOEMULROOT
, &vp
);
957 error
= extattr_list_vp(vp
, EXTATTR_NAMESPACE_USER
,
958 SCARG(uap
, list
), SCARG(uap
, size
), l
, retval
);
965 sys_flistxattr(struct lwp
*l
, const struct sys_flistxattr_args
*uap
, register_t
*retval
)
969 syscallarg(char *) list;
970 syscallarg(size_t) size;
976 error
= fd_getvnode(SCARG(uap
, fd
), &fp
);
979 vp
= (struct vnode
*) fp
->f_data
;
981 error
= extattr_list_vp(vp
, EXTATTR_NAMESPACE_USER
,
982 SCARG(uap
, list
), SCARG(uap
, size
), l
, retval
);
984 fd_putfile(SCARG(uap
, fd
));
989 sys_removexattr(struct lwp
*l
, const struct sys_removexattr_args
*uap
, register_t
*retval
)
992 syscallarg(const char *) path;
993 syscallarg(const char *) name;
996 char attrname
[XATTR_NAME_MAX
];
999 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
1004 error
= namei_simple_user(SCARG(uap
, path
),
1005 NSM_FOLLOW_NOEMULROOT
, &vp
);
1009 error
= extattr_delete_vp(vp
, EXTATTR_NAMESPACE_USER
,
1017 sys_lremovexattr(struct lwp
*l
, const struct sys_lremovexattr_args
*uap
, register_t
*retval
)
1020 syscallarg(const char *) path;
1021 syscallarg(const char *) name;
1024 char attrname
[XATTR_NAME_MAX
];
1027 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
1032 error
= namei_simple_user(SCARG(uap
, path
),
1033 NSM_NOFOLLOW_NOEMULROOT
, &vp
);
1037 error
= extattr_delete_vp(vp
, EXTATTR_NAMESPACE_USER
,
1045 sys_fremovexattr(struct lwp
*l
, const struct sys_fremovexattr_args
*uap
, register_t
*retval
)
1049 syscallarg(const char *) name;
1053 char attrname
[XATTR_NAME_MAX
];
1056 error
= copyinstr(SCARG(uap
, name
), attrname
, sizeof(attrname
),
1061 error
= fd_getvnode(SCARG(uap
, fd
), &fp
);
1064 vp
= (struct vnode
*) fp
->f_data
;
1066 error
= extattr_delete_vp(vp
, EXTATTR_NAMESPACE_USER
,
1069 fd_putfile(SCARG(uap
, fd
));