Home | History | Annotate | Line # | Download | only in kern
vfs_xattr.c revision 1.23
      1  1.23  dholland /*	$NetBSD: vfs_xattr.c,v 1.23 2010/11/19 06:44:45 dholland Exp $	*/
      2   1.2   thorpej 
      3   1.2   thorpej /*-
      4  1.17        ad  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
      5   1.2   thorpej  * All rights reserved.
      6   1.2   thorpej  *
      7   1.2   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8   1.2   thorpej  * by Jason R. Thorpe.
      9   1.2   thorpej  *
     10   1.2   thorpej  * Redistribution and use in source and binary forms, with or without
     11   1.2   thorpej  * modification, are permitted provided that the following conditions
     12   1.2   thorpej  * are met:
     13   1.2   thorpej  * 1. Redistributions of source code must retain the above copyright
     14   1.2   thorpej  *    notice, this list of conditions and the following disclaimer.
     15   1.2   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.2   thorpej  *    notice, this list of conditions and the following disclaimer in the
     17   1.2   thorpej  *    documentation and/or other materials provided with the distribution.
     18   1.2   thorpej  *
     19   1.2   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.2   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.2   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.2   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.2   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.2   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.2   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.2   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.2   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.2   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.2   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     30   1.2   thorpej  */
     31   1.1   thorpej 
     32   1.1   thorpej /*
     33   1.1   thorpej  * Copyright (c) 1989, 1993
     34   1.1   thorpej  *	The Regents of the University of California.  All rights reserved.
     35   1.1   thorpej  * (c) UNIX System Laboratories, Inc.
     36   1.1   thorpej  * All or some portions of this file are derived from material licensed
     37   1.1   thorpej  * to the University of California by American Telephone and Telegraph
     38   1.1   thorpej  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     39   1.1   thorpej  * the permission of UNIX System Laboratories, Inc.
     40   1.1   thorpej  *
     41   1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     42   1.1   thorpej  * modification, are permitted provided that the following conditions
     43   1.1   thorpej  * are met:
     44   1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     45   1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     46   1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     47   1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     48   1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     49   1.1   thorpej  * 3. Neither the name of the University nor the names of its contributors
     50   1.1   thorpej  *    may be used to endorse or promote products derived from this software
     51   1.1   thorpej  *    without specific prior written permission.
     52   1.1   thorpej  *
     53   1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     54   1.1   thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     55   1.1   thorpej  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     56   1.1   thorpej  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     57   1.1   thorpej  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     58   1.1   thorpej  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     59   1.1   thorpej  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     60   1.1   thorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     61   1.1   thorpej  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     62   1.1   thorpej  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     63   1.1   thorpej  * SUCH DAMAGE.
     64   1.1   thorpej  */
     65   1.1   thorpej 
     66   1.1   thorpej /*
     67   1.1   thorpej  * VFS extended attribute support.
     68   1.1   thorpej  */
     69   1.1   thorpej 
     70   1.1   thorpej #include <sys/cdefs.h>
     71  1.23  dholland __KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.23 2010/11/19 06:44:45 dholland Exp $");
     72   1.1   thorpej 
     73   1.1   thorpej #include <sys/param.h>
     74   1.1   thorpej #include <sys/systm.h>
     75   1.1   thorpej #include <sys/namei.h>
     76   1.1   thorpej #include <sys/filedesc.h>
     77   1.1   thorpej #include <sys/kernel.h>
     78   1.1   thorpej #include <sys/file.h>
     79   1.1   thorpej #include <sys/vnode.h>
     80   1.1   thorpej #include <sys/mount.h>
     81   1.1   thorpej #include <sys/proc.h>
     82   1.1   thorpej #include <sys/uio.h>
     83   1.1   thorpej #include <sys/extattr.h>
     84   1.2   thorpej #include <sys/xattr.h>
     85   1.1   thorpej #include <sys/sysctl.h>
     86   1.1   thorpej #include <sys/syscallargs.h>
     87   1.6      elad #include <sys/kauth.h>
     88   1.1   thorpej 
     89   1.1   thorpej /*
     90   1.3   thorpej  * Credential check based on process requesting service, and per-attribute
     91   1.3   thorpej  * permissions.
     92   1.3   thorpej  *
     93   1.3   thorpej  * NOTE: Vnode must be locked.
     94   1.3   thorpej  */
     95   1.3   thorpej int
     96   1.3   thorpej extattr_check_cred(struct vnode *vp, int attrnamespace,
     97   1.6      elad     kauth_cred_t cred, struct lwp *l, int access)
     98   1.3   thorpej {
     99   1.3   thorpej 
    100   1.3   thorpej 	if (cred == NOCRED)
    101   1.3   thorpej 		return (0);
    102   1.3   thorpej 
    103   1.3   thorpej 	switch (attrnamespace) {
    104   1.3   thorpej 	case EXTATTR_NAMESPACE_SYSTEM:
    105   1.3   thorpej 		/*
    106   1.3   thorpej 		 * Do we really want to allow this, or just require that
    107   1.3   thorpej 		 * these requests come from kernel code (NOCRED case above)?
    108   1.3   thorpej 		 */
    109   1.6      elad 		return (kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
    110  1.10      elad 		    NULL));
    111   1.3   thorpej 
    112   1.3   thorpej 	case EXTATTR_NAMESPACE_USER:
    113  1.13     pooka 		return (VOP_ACCESS(vp, access, cred));
    114   1.3   thorpej 
    115   1.3   thorpej 	default:
    116   1.3   thorpej 		return (EPERM);
    117   1.3   thorpej 	}
    118   1.3   thorpej }
    119   1.3   thorpej 
    120   1.3   thorpej /*
    121   1.3   thorpej  * Default vfs_extattrctl routine for file systems that do not support
    122   1.3   thorpej  * it.
    123   1.3   thorpej  */
    124   1.3   thorpej /*ARGSUSED*/
    125   1.3   thorpej int
    126   1.9      yamt vfs_stdextattrctl(struct mount *mp, int cmt, struct vnode *vp,
    127  1.13     pooka     int attrnamespace, const char *attrname)
    128   1.3   thorpej {
    129   1.3   thorpej 
    130   1.3   thorpej 	if (vp != NULL)
    131  1.22   hannken 		VOP_UNLOCK(vp);
    132   1.3   thorpej 	return (EOPNOTSUPP);
    133   1.3   thorpej }
    134   1.3   thorpej 
    135   1.3   thorpej /*
    136   1.2   thorpej  * Push extended attribute configuration information into the file
    137   1.2   thorpej  * system.
    138   1.1   thorpej  *
    139   1.1   thorpej  * NOTE: Not all file systems that support extended attributes will
    140   1.1   thorpej  * require the use of this system call.
    141   1.1   thorpej  */
    142   1.1   thorpej int
    143  1.15       dsl sys_extattrctl(struct lwp *l, const struct sys_extattrctl_args *uap, register_t *retval)
    144   1.1   thorpej {
    145  1.15       dsl 	/* {
    146   1.1   thorpej 		syscallarg(const char *) path;
    147   1.1   thorpej 		syscallarg(int) cmd;
    148   1.1   thorpej 		syscallarg(const char *) filename;
    149   1.1   thorpej 		syscallarg(int) attrnamespace;
    150   1.1   thorpej 		syscallarg(const char *) attrname;
    151  1.15       dsl 	} */
    152  1.20  dholland 	struct vnode *path_vp, *file_vp;
    153  1.23  dholland 	struct pathbuf *file_pb;
    154  1.20  dholland 	struct nameidata file_nd;
    155   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    156   1.1   thorpej 	int error;
    157   1.1   thorpej 
    158   1.1   thorpej 	if (SCARG(uap, attrname) != NULL) {
    159   1.1   thorpej 		error = copyinstr(SCARG(uap, attrname), attrname,
    160   1.1   thorpej 		    sizeof(attrname), NULL);
    161   1.1   thorpej 		if (error)
    162   1.1   thorpej 			return (error);
    163   1.1   thorpej 	}
    164   1.1   thorpej 
    165  1.21     pooka 	error = namei_simple_user(SCARG(uap, path),
    166  1.21     pooka 				NSM_FOLLOW_NOEMULROOT, &path_vp);
    167  1.21     pooka 	if (error) {
    168  1.21     pooka 		return (error);
    169  1.21     pooka 	}
    170  1.21     pooka 
    171  1.20  dholland 	file_vp = NULL;
    172   1.1   thorpej 	if (SCARG(uap, filename) != NULL) {
    173  1.23  dholland 		error = pathbuf_copyin(SCARG(uap, filename), &file_pb);
    174  1.23  dholland 		if (error) {
    175  1.23  dholland 			vrele(path_vp);
    176  1.23  dholland 			return (error);
    177  1.23  dholland 		}
    178  1.23  dholland 		NDINIT(&file_nd, LOOKUP, FOLLOW | LOCKLEAF, file_pb);
    179  1.20  dholland 		error = namei(&file_nd);
    180  1.21     pooka 		if (error) {
    181  1.23  dholland 			pathbuf_destroy(file_pb);
    182  1.21     pooka 			vrele(path_vp);
    183   1.1   thorpej 			return (error);
    184  1.21     pooka 		}
    185  1.20  dholland 		file_vp = file_nd.ni_vp;
    186  1.23  dholland 		pathbuf_destroy(file_pb);
    187   1.1   thorpej 	}
    188   1.1   thorpej 
    189  1.20  dholland 	error = VFS_EXTATTRCTL(path_vp->v_mount, SCARG(uap, cmd), file_vp,
    190   1.1   thorpej 	    SCARG(uap, attrnamespace),
    191  1.13     pooka 	    SCARG(uap, attrname) != NULL ? attrname : NULL);
    192   1.1   thorpej 
    193  1.20  dholland 	if (file_vp != NULL)
    194  1.20  dholland 		vrele(file_vp);
    195  1.20  dholland 	vrele(path_vp);
    196   1.1   thorpej 
    197   1.1   thorpej 	return (error);
    198   1.1   thorpej }
    199   1.1   thorpej 
    200   1.1   thorpej /*****************************************************************************
    201   1.1   thorpej  * Internal routines to manipulate file system extended attributes:
    202   1.1   thorpej  *	- set
    203   1.1   thorpej  *	- get
    204   1.1   thorpej  *	- delete
    205   1.1   thorpej  *	- list
    206   1.1   thorpej  *****************************************************************************/
    207   1.1   thorpej 
    208   1.1   thorpej /*
    209   1.1   thorpej  * extattr_set_vp:
    210   1.1   thorpej  *
    211   1.1   thorpej  *	Set a named extended attribute on a file or directory.
    212   1.1   thorpej  */
    213   1.1   thorpej static int
    214   1.1   thorpej extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname,
    215   1.4  christos     const void *data, size_t nbytes, struct lwp *l, register_t *retval)
    216   1.1   thorpej {
    217   1.1   thorpej 	struct uio auio;
    218   1.1   thorpej 	struct iovec aiov;
    219   1.1   thorpej 	ssize_t cnt;
    220   1.1   thorpej 	int error;
    221   1.1   thorpej 
    222   1.1   thorpej 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
    223   1.1   thorpej 
    224   1.1   thorpej 	aiov.iov_base = __UNCONST(data);	/* XXXUNCONST kills const */
    225   1.1   thorpej 	aiov.iov_len = nbytes;
    226   1.1   thorpej 	auio.uio_iov = &aiov;
    227   1.1   thorpej 	auio.uio_iovcnt = 1;
    228   1.1   thorpej 	auio.uio_offset = 0;
    229   1.1   thorpej 	if (nbytes > INT_MAX) {
    230   1.1   thorpej 		error = EINVAL;
    231   1.1   thorpej 		goto done;
    232   1.1   thorpej 	}
    233   1.1   thorpej 	auio.uio_resid = nbytes;
    234   1.1   thorpej 	auio.uio_rw = UIO_WRITE;
    235   1.5      yamt 	KASSERT(l == curlwp);
    236   1.5      yamt 	auio.uio_vmspace = l->l_proc->p_vmspace;
    237   1.1   thorpej 	cnt = nbytes;
    238   1.1   thorpej 
    239  1.13     pooka 	error = VOP_SETEXTATTR(vp, attrnamespace, attrname, &auio, l->l_cred);
    240   1.1   thorpej 	cnt -= auio.uio_resid;
    241   1.1   thorpej 	retval[0] = cnt;
    242   1.1   thorpej 
    243   1.1   thorpej  done:
    244  1.22   hannken 	VOP_UNLOCK(vp);
    245   1.1   thorpej 	return (error);
    246   1.1   thorpej }
    247   1.1   thorpej 
    248   1.1   thorpej /*
    249   1.1   thorpej  * extattr_get_vp:
    250   1.1   thorpej  *
    251   1.1   thorpej  *	Get a named extended attribute on a file or directory.
    252   1.1   thorpej  */
    253   1.1   thorpej static int
    254   1.1   thorpej extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname,
    255   1.4  christos     void *data, size_t nbytes, struct lwp *l, register_t *retval)
    256   1.1   thorpej {
    257   1.1   thorpej 	struct uio auio, *auiop;
    258   1.1   thorpej 	struct iovec aiov;
    259   1.1   thorpej 	ssize_t cnt;
    260   1.1   thorpej 	size_t size, *sizep;
    261   1.1   thorpej 	int error;
    262   1.1   thorpej 
    263   1.1   thorpej 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
    264   1.1   thorpej 
    265   1.1   thorpej 	/*
    266   1.1   thorpej 	 * Slightly unusual semantics: if the user provides a NULL data
    267   1.1   thorpej 	 * pointer, they don't want to receive the data, just the maximum
    268   1.1   thorpej 	 * read length.
    269   1.1   thorpej 	 */
    270   1.1   thorpej 	auiop = NULL;
    271   1.1   thorpej 	sizep = NULL;
    272   1.1   thorpej 	cnt = 0;
    273   1.1   thorpej 	if (data != NULL) {
    274   1.1   thorpej 		aiov.iov_base = data;
    275   1.1   thorpej 		aiov.iov_len = nbytes;
    276   1.1   thorpej 		auio.uio_iov = &aiov;
    277   1.1   thorpej 		auio.uio_offset = 0;
    278   1.1   thorpej 		if (nbytes > INT_MAX) {
    279   1.1   thorpej 			error = EINVAL;
    280   1.1   thorpej 			goto done;
    281   1.1   thorpej 		}
    282   1.1   thorpej 		auio.uio_resid = nbytes;
    283   1.1   thorpej 		auio.uio_rw = UIO_READ;
    284   1.5      yamt 		KASSERT(l == curlwp);
    285   1.5      yamt 		auio.uio_vmspace = l->l_proc->p_vmspace;
    286   1.1   thorpej 		auiop = &auio;
    287   1.1   thorpej 		cnt = nbytes;
    288   1.1   thorpej 	} else
    289   1.1   thorpej 		sizep = &size;
    290   1.1   thorpej 
    291   1.1   thorpej 	error = VOP_GETEXTATTR(vp, attrnamespace, attrname, auiop, sizep,
    292  1.13     pooka 	    l->l_cred);
    293   1.1   thorpej 
    294   1.1   thorpej 	if (auiop != NULL) {
    295   1.1   thorpej 		cnt -= auio.uio_resid;
    296   1.1   thorpej 		retval[0] = cnt;
    297   1.1   thorpej 	} else
    298   1.1   thorpej 		retval[0] = size;
    299   1.1   thorpej 
    300   1.1   thorpej  done:
    301  1.22   hannken 	VOP_UNLOCK(vp);
    302   1.1   thorpej 	return (error);
    303   1.1   thorpej }
    304   1.1   thorpej 
    305   1.1   thorpej /*
    306   1.1   thorpej  * extattr_delete_vp:
    307   1.1   thorpej  *
    308   1.1   thorpej  *	Delete a named extended attribute on a file or directory.
    309   1.1   thorpej  */
    310   1.1   thorpej static int
    311   1.1   thorpej extattr_delete_vp(struct vnode *vp, int attrnamespace, const char *attrname,
    312   1.4  christos     struct lwp *l)
    313   1.1   thorpej {
    314   1.1   thorpej 	int error;
    315   1.1   thorpej 
    316   1.1   thorpej 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
    317   1.1   thorpej 
    318  1.13     pooka 	error = VOP_DELETEEXTATTR(vp, attrnamespace, attrname, l->l_cred);
    319   1.1   thorpej 	if (error == EOPNOTSUPP)
    320   1.1   thorpej 		error = VOP_SETEXTATTR(vp, attrnamespace, attrname, NULL,
    321  1.13     pooka 		    l->l_cred);
    322   1.1   thorpej 
    323  1.22   hannken 	VOP_UNLOCK(vp);
    324   1.1   thorpej 	return (error);
    325   1.1   thorpej }
    326   1.1   thorpej 
    327   1.1   thorpej /*
    328   1.1   thorpej  * extattr_list_vp:
    329   1.1   thorpej  *
    330   1.1   thorpej  *	Retrieve a list of extended attributes on a file or directory.
    331   1.1   thorpej  */
    332   1.1   thorpej static int
    333   1.1   thorpej extattr_list_vp(struct vnode *vp, int attrnamespace, void *data, size_t nbytes,
    334   1.4  christos     struct lwp *l, register_t *retval)
    335   1.1   thorpej {
    336   1.1   thorpej 	struct uio auio, *auiop;
    337   1.1   thorpej 	size_t size, *sizep;
    338   1.1   thorpej 	struct iovec aiov;
    339   1.1   thorpej 	ssize_t cnt;
    340   1.1   thorpej 	int error;
    341   1.1   thorpej 
    342   1.1   thorpej 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
    343   1.1   thorpej 
    344   1.1   thorpej 	auiop = NULL;
    345   1.1   thorpej 	sizep = NULL;
    346   1.1   thorpej 	cnt = 0;
    347   1.1   thorpej 	if (data != NULL) {
    348   1.1   thorpej 		aiov.iov_base = data;
    349   1.1   thorpej 		aiov.iov_len = nbytes;
    350   1.1   thorpej 		auio.uio_iov = &aiov;
    351   1.1   thorpej 		auio.uio_offset = 0;
    352   1.1   thorpej 		if (nbytes > INT_MAX) {
    353   1.1   thorpej 			error = EINVAL;
    354   1.1   thorpej 			goto done;
    355   1.1   thorpej 		}
    356   1.1   thorpej 		auio.uio_resid = nbytes;
    357   1.1   thorpej 		auio.uio_rw = UIO_READ;
    358   1.5      yamt 		KASSERT(l == curlwp);
    359   1.5      yamt 		auio.uio_vmspace = l->l_proc->p_vmspace;
    360   1.1   thorpej 		auiop = &auio;
    361   1.1   thorpej 		cnt = nbytes;
    362   1.1   thorpej 	} else
    363   1.1   thorpej 		sizep = &size;
    364   1.1   thorpej 
    365  1.13     pooka 	error = VOP_LISTEXTATTR(vp, attrnamespace, auiop, sizep, l->l_cred);
    366   1.1   thorpej 
    367   1.1   thorpej 	if (auiop != NULL) {
    368   1.1   thorpej 		cnt -= auio.uio_resid;
    369   1.1   thorpej 		retval[0] = cnt;
    370   1.1   thorpej 	} else
    371   1.1   thorpej 		retval[0] = size;
    372   1.1   thorpej 
    373   1.1   thorpej  done:
    374  1.22   hannken 	VOP_UNLOCK(vp);
    375   1.1   thorpej 	return (error);
    376   1.1   thorpej }
    377   1.1   thorpej 
    378   1.1   thorpej /*****************************************************************************
    379   1.1   thorpej  * BSD <sys/extattr.h> API for file system extended attributes
    380   1.1   thorpej  *****************************************************************************/
    381   1.1   thorpej 
    382   1.1   thorpej int
    383  1.15       dsl sys_extattr_set_fd(struct lwp *l, const struct sys_extattr_set_fd_args *uap, register_t *retval)
    384   1.1   thorpej {
    385  1.15       dsl 	/* {
    386   1.1   thorpej 		syscallarg(int) fd;
    387   1.1   thorpej 		syscallarg(int) attrnamespace;
    388   1.1   thorpej 		syscallarg(const char *) attrname;
    389   1.1   thorpej 		syscallarg(const void *) data;
    390   1.1   thorpej 		syscallarg(size_t) nbytes;
    391  1.15       dsl 	} */
    392   1.1   thorpej 	struct file *fp;
    393   1.1   thorpej 	struct vnode *vp;
    394   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    395   1.1   thorpej 	int error;
    396   1.1   thorpej 
    397   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    398   1.1   thorpej 	    NULL);
    399   1.1   thorpej 	if (error)
    400   1.1   thorpej 		return (error);
    401   1.1   thorpej 
    402  1.19        ad 	error = fd_getvnode(SCARG(uap, fd), &fp);
    403   1.1   thorpej 	if (error)
    404   1.1   thorpej 		return (error);
    405   1.1   thorpej 	vp = (struct vnode *) fp->f_data;
    406   1.1   thorpej 
    407   1.1   thorpej 	error = extattr_set_vp(vp, SCARG(uap, attrnamespace), attrname,
    408   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    409   1.1   thorpej 
    410  1.17        ad 	fd_putfile(SCARG(uap, fd));
    411   1.1   thorpej 	return (error);
    412   1.1   thorpej }
    413   1.1   thorpej 
    414   1.1   thorpej int
    415  1.15       dsl sys_extattr_set_file(struct lwp *l, const struct sys_extattr_set_file_args *uap, register_t *retval)
    416   1.1   thorpej {
    417  1.15       dsl 	/* {
    418   1.1   thorpej 		syscallarg(const char *) path;
    419   1.1   thorpej 		syscallarg(int) attrnamespace;
    420   1.1   thorpej 		syscallarg(const char *) attrname;
    421   1.1   thorpej 		syscallarg(const void *) data;
    422   1.1   thorpej 		syscallarg(size_t) nbytes;
    423  1.15       dsl 	} */
    424  1.20  dholland 	struct vnode *vp;
    425   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    426   1.1   thorpej 	int error;
    427   1.1   thorpej 
    428   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    429   1.1   thorpej 	    NULL);
    430   1.1   thorpej 	if (error)
    431   1.1   thorpej 		return (error);
    432   1.1   thorpej 
    433  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    434  1.20  dholland 				NSM_FOLLOW_NOEMULROOT, &vp);
    435   1.1   thorpej 	if (error)
    436   1.1   thorpej 		return (error);
    437   1.1   thorpej 
    438  1.20  dholland 	error = extattr_set_vp(vp, SCARG(uap, attrnamespace), attrname,
    439   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    440   1.1   thorpej 
    441  1.20  dholland 	vrele(vp);
    442   1.1   thorpej 	return (error);
    443   1.1   thorpej }
    444   1.1   thorpej 
    445   1.1   thorpej int
    446  1.15       dsl sys_extattr_set_link(struct lwp *l, const struct sys_extattr_set_link_args *uap, register_t *retval)
    447   1.1   thorpej {
    448  1.15       dsl 	/* {
    449   1.1   thorpej 		syscallarg(const char *) path;
    450   1.1   thorpej 		syscallarg(int) attrnamespace;
    451   1.1   thorpej 		syscallarg(const char *) attrname;
    452   1.1   thorpej 		syscallarg(const void *) data;
    453   1.1   thorpej 		syscallarg(size_t) nbytes;
    454  1.15       dsl 	} */
    455  1.20  dholland 	struct vnode *vp;
    456   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    457   1.1   thorpej 	int error;
    458   1.1   thorpej 
    459   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    460   1.1   thorpej 	    NULL);
    461   1.1   thorpej 	if (error)
    462   1.1   thorpej 		return (error);
    463   1.1   thorpej 
    464  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    465  1.20  dholland 				NSM_NOFOLLOW_NOEMULROOT, &vp);
    466   1.1   thorpej 	if (error)
    467   1.1   thorpej 		return (error);
    468   1.1   thorpej 
    469  1.20  dholland 	error = extattr_set_vp(vp, SCARG(uap, attrnamespace), attrname,
    470   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    471   1.1   thorpej 
    472  1.20  dholland 	vrele(vp);
    473   1.1   thorpej 	return (error);
    474   1.1   thorpej }
    475   1.1   thorpej 
    476   1.1   thorpej int
    477  1.15       dsl sys_extattr_get_fd(struct lwp *l, const struct sys_extattr_get_fd_args *uap, register_t *retval)
    478   1.1   thorpej {
    479  1.15       dsl 	/* {
    480   1.1   thorpej 		syscallarg(int) fd;
    481   1.1   thorpej 		syscallarg(int) attrnamespace;
    482   1.1   thorpej 		syscallarg(const char *) attrname;
    483   1.1   thorpej 		syscallarg(void *) data;
    484   1.1   thorpej 		syscallarg(size_t) nbytes;
    485  1.15       dsl 	} */
    486   1.1   thorpej 	struct file *fp;
    487   1.1   thorpej 	struct vnode *vp;
    488   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    489   1.1   thorpej 	int error;
    490   1.1   thorpej 
    491   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    492   1.1   thorpej 	    NULL);
    493   1.1   thorpej 	if (error)
    494   1.1   thorpej 		return (error);
    495   1.1   thorpej 
    496  1.19        ad 	error = fd_getvnode(SCARG(uap, fd), &fp);
    497   1.1   thorpej 	if (error)
    498   1.1   thorpej 		return (error);
    499   1.1   thorpej 	vp = (struct vnode *) fp->f_data;
    500   1.1   thorpej 
    501   1.1   thorpej 	error = extattr_get_vp(vp, SCARG(uap, attrnamespace), attrname,
    502   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    503   1.1   thorpej 
    504  1.17        ad 	fd_putfile(SCARG(uap, fd));
    505   1.1   thorpej 	return (error);
    506   1.1   thorpej }
    507   1.1   thorpej 
    508   1.1   thorpej int
    509  1.15       dsl sys_extattr_get_file(struct lwp *l, const struct sys_extattr_get_file_args *uap, register_t *retval)
    510   1.1   thorpej {
    511  1.15       dsl 	/* {
    512   1.1   thorpej 		syscallarg(const char *) path;
    513   1.1   thorpej 		syscallarg(int) attrnamespace;
    514   1.1   thorpej 		syscallarg(const char *) attrname;
    515   1.1   thorpej 		syscallarg(void *) data;
    516   1.1   thorpej 		syscallarg(size_t) nbytes;
    517  1.15       dsl 	} */
    518  1.20  dholland 	struct vnode *vp;
    519   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    520   1.1   thorpej 	int error;
    521   1.1   thorpej 
    522   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    523   1.1   thorpej 	    NULL);
    524   1.1   thorpej 	if (error)
    525   1.1   thorpej 		return (error);
    526   1.1   thorpej 
    527  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    528  1.20  dholland 				NSM_FOLLOW_NOEMULROOT, &vp);
    529   1.1   thorpej 	if (error)
    530   1.1   thorpej 		return (error);
    531   1.1   thorpej 
    532  1.20  dholland 	error = extattr_get_vp(vp, SCARG(uap, attrnamespace), attrname,
    533   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    534   1.1   thorpej 
    535  1.20  dholland 	vrele(vp);
    536   1.1   thorpej 	return (error);
    537   1.1   thorpej }
    538   1.1   thorpej 
    539   1.1   thorpej int
    540  1.15       dsl sys_extattr_get_link(struct lwp *l, const struct sys_extattr_get_link_args *uap, register_t *retval)
    541   1.1   thorpej {
    542  1.15       dsl 	/* {
    543   1.1   thorpej 		syscallarg(const char *) path;
    544   1.1   thorpej 		syscallarg(int) attrnamespace;
    545   1.1   thorpej 		syscallarg(const char *) attrname;
    546   1.1   thorpej 		syscallarg(void *) data;
    547   1.1   thorpej 		syscallarg(size_t) nbytes;
    548  1.15       dsl 	} */
    549  1.20  dholland 	struct vnode *vp;
    550   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    551   1.1   thorpej 	int error;
    552   1.1   thorpej 
    553   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    554   1.1   thorpej 	    NULL);
    555   1.1   thorpej 	if (error)
    556   1.1   thorpej 		return (error);
    557   1.1   thorpej 
    558  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    559  1.20  dholland 				NSM_NOFOLLOW_NOEMULROOT, &vp);
    560   1.1   thorpej 	if (error)
    561   1.1   thorpej 		return (error);
    562   1.1   thorpej 
    563  1.20  dholland 	error = extattr_get_vp(vp, SCARG(uap, attrnamespace), attrname,
    564   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    565   1.1   thorpej 
    566  1.20  dholland 	vrele(vp);
    567   1.1   thorpej 	return (error);
    568   1.1   thorpej }
    569   1.1   thorpej 
    570   1.1   thorpej int
    571  1.15       dsl sys_extattr_delete_fd(struct lwp *l, const struct sys_extattr_delete_fd_args *uap, register_t *retval)
    572   1.1   thorpej {
    573  1.15       dsl 	/* {
    574   1.1   thorpej 		syscallarg(int) fd;
    575   1.1   thorpej 		syscallarg(int) attrnamespace;
    576   1.1   thorpej 		syscallarg(const char *) attrname;
    577  1.15       dsl 	} */
    578   1.1   thorpej 	struct file *fp;
    579   1.1   thorpej 	struct vnode *vp;
    580   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    581   1.1   thorpej 	int error;
    582   1.1   thorpej 
    583   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    584   1.1   thorpej 	    NULL);
    585   1.1   thorpej 	if (error)
    586   1.1   thorpej 		return (error);
    587   1.1   thorpej 
    588  1.19        ad 	error = fd_getvnode(SCARG(uap, fd), &fp);
    589   1.1   thorpej 	if (error)
    590   1.1   thorpej 		return (error);
    591   1.1   thorpej 	vp = (struct vnode *) fp->f_data;
    592   1.1   thorpej 
    593   1.4  christos 	error = extattr_delete_vp(vp, SCARG(uap, attrnamespace), attrname, l);
    594   1.1   thorpej 
    595  1.17        ad 	fd_putfile(SCARG(uap, fd));
    596   1.1   thorpej 	return (error);
    597   1.1   thorpej }
    598   1.1   thorpej 
    599   1.1   thorpej int
    600  1.15       dsl sys_extattr_delete_file(struct lwp *l, const struct sys_extattr_delete_file_args *uap, register_t *retval)
    601   1.1   thorpej {
    602  1.15       dsl 	/* {
    603   1.1   thorpej 		syscallarg(const char *) path;
    604   1.1   thorpej 		syscallarg(int) attrnamespace;
    605   1.1   thorpej 		syscallarg(const char *) attrname;
    606  1.15       dsl 	} */
    607  1.20  dholland 	struct vnode *vp;
    608   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    609   1.1   thorpej 	int error;
    610   1.1   thorpej 
    611   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    612   1.1   thorpej 	    NULL);
    613   1.1   thorpej 	if (error)
    614   1.1   thorpej 		return (error);
    615   1.1   thorpej 
    616  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    617  1.20  dholland 				NSM_FOLLOW_NOEMULROOT, &vp);
    618   1.1   thorpej 	if (error)
    619   1.1   thorpej 		return (error);
    620   1.1   thorpej 
    621  1.20  dholland 	error = extattr_delete_vp(vp, SCARG(uap, attrnamespace), attrname, l);
    622   1.1   thorpej 
    623  1.20  dholland 	vrele(vp);
    624   1.1   thorpej 	return (error);
    625   1.1   thorpej }
    626   1.1   thorpej 
    627   1.1   thorpej int
    628  1.15       dsl sys_extattr_delete_link(struct lwp *l, const struct sys_extattr_delete_link_args *uap, register_t *retval)
    629   1.1   thorpej {
    630  1.15       dsl 	/* {
    631   1.1   thorpej 		syscallarg(const char *) path;
    632   1.1   thorpej 		syscallarg(int) attrnamespace;
    633   1.1   thorpej 		syscallarg(const char *) attrname;
    634  1.15       dsl 	} */
    635  1.20  dholland 	struct vnode *vp;
    636   1.1   thorpej 	char attrname[EXTATTR_MAXNAMELEN];
    637   1.1   thorpej 	int error;
    638   1.1   thorpej 
    639   1.1   thorpej 	error = copyinstr(SCARG(uap, attrname), attrname, sizeof(attrname),
    640   1.1   thorpej 	    NULL);
    641   1.1   thorpej 	if (error)
    642   1.1   thorpej 		return (error);
    643   1.1   thorpej 
    644  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    645  1.20  dholland 				NSM_NOFOLLOW_NOEMULROOT, &vp);
    646   1.1   thorpej 	if (error)
    647   1.1   thorpej 		return (error);
    648   1.1   thorpej 
    649  1.20  dholland 	error = extattr_delete_vp(vp, SCARG(uap, attrnamespace), attrname, l);
    650   1.1   thorpej 
    651  1.20  dholland 	vrele(vp);
    652   1.1   thorpej 	return (error);
    653   1.1   thorpej }
    654   1.1   thorpej 
    655   1.1   thorpej int
    656  1.15       dsl sys_extattr_list_fd(struct lwp *l, const struct sys_extattr_list_fd_args *uap, register_t *retval)
    657   1.1   thorpej {
    658  1.15       dsl 	/* {
    659   1.1   thorpej 		syscallarg(int) fd;
    660   1.1   thorpej 		syscallarg(int) attrnamespace;
    661   1.1   thorpej 		syscallarg(void *) data;
    662   1.1   thorpej 		syscallarg(size_t) nbytes;
    663  1.15       dsl 	} */
    664   1.1   thorpej 	struct file *fp;
    665   1.1   thorpej 	struct vnode *vp;
    666   1.1   thorpej 	int error;
    667   1.1   thorpej 
    668  1.19        ad 	error = fd_getvnode(SCARG(uap, fd), &fp);
    669   1.1   thorpej 	if (error)
    670   1.1   thorpej 		return (error);
    671   1.1   thorpej 	vp = (struct vnode *) fp->f_data;
    672   1.1   thorpej 
    673   1.1   thorpej 	error = extattr_list_vp(vp, SCARG(uap, attrnamespace),
    674   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    675   1.1   thorpej 
    676  1.17        ad 	fd_putfile(SCARG(uap, fd));
    677   1.1   thorpej 	return (error);
    678   1.1   thorpej }
    679   1.1   thorpej 
    680   1.1   thorpej int
    681  1.15       dsl sys_extattr_list_file(struct lwp *l, const struct sys_extattr_list_file_args *uap, register_t *retval)
    682   1.1   thorpej {
    683  1.15       dsl 	/* {
    684   1.1   thorpej 		syscallarg(const char *) path;
    685   1.1   thorpej 		syscallarg(int) attrnamespace;
    686   1.1   thorpej 		syscallarg(void *) data;
    687   1.1   thorpej 		syscallarg(size_t) nbytes;
    688  1.15       dsl 	} */
    689  1.20  dholland 	struct vnode *vp;
    690   1.1   thorpej 	int error;
    691   1.1   thorpej 
    692  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    693  1.20  dholland 				NSM_FOLLOW_NOEMULROOT, &vp);
    694   1.1   thorpej 	if (error)
    695   1.1   thorpej 		return (error);
    696   1.1   thorpej 
    697  1.20  dholland 	error = extattr_list_vp(vp, SCARG(uap, attrnamespace),
    698   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    699   1.1   thorpej 
    700  1.20  dholland 	vrele(vp);
    701   1.1   thorpej 	return (error);
    702   1.1   thorpej }
    703   1.1   thorpej 
    704   1.1   thorpej int
    705  1.15       dsl sys_extattr_list_link(struct lwp *l, const struct sys_extattr_list_link_args *uap, register_t *retval)
    706   1.1   thorpej {
    707  1.15       dsl 	/* {
    708   1.1   thorpej 		syscallarg(const char *) path;
    709   1.1   thorpej 		syscallarg(int) attrnamespace;
    710   1.1   thorpej 		syscallarg(void *) data;
    711   1.1   thorpej 		syscallarg(size_t) nbytes;
    712  1.15       dsl 	} */
    713  1.20  dholland 	struct vnode *vp;
    714   1.1   thorpej 	int error;
    715   1.1   thorpej 
    716  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    717  1.20  dholland 				NSM_NOFOLLOW_NOEMULROOT, &vp);
    718   1.1   thorpej 	if (error)
    719   1.1   thorpej 		return (error);
    720   1.1   thorpej 
    721  1.20  dholland 	error = extattr_list_vp(vp, SCARG(uap, attrnamespace),
    722   1.4  christos 	    SCARG(uap, data), SCARG(uap, nbytes), l, retval);
    723   1.1   thorpej 
    724  1.20  dholland 	vrele(vp);
    725   1.1   thorpej 	return (error);
    726   1.1   thorpej }
    727   1.2   thorpej 
    728   1.2   thorpej /*****************************************************************************
    729   1.2   thorpej  * Linux-compatible <sys/xattr.h> API for file system extended attributes
    730   1.2   thorpej  *****************************************************************************/
    731   1.2   thorpej 
    732   1.2   thorpej int
    733  1.15       dsl sys_setxattr(struct lwp *l, const struct sys_setxattr_args *uap, register_t *retval)
    734   1.2   thorpej {
    735  1.15       dsl 	/* {
    736   1.2   thorpej 		syscallarg(const char *) path;
    737   1.2   thorpej 		syscallarg(const char *) name;
    738   1.2   thorpej 		syscallarg(void *) value;
    739   1.2   thorpej 		syscallarg(size_t) size;
    740   1.2   thorpej 		syscallarg(int) flags;
    741  1.15       dsl 	} */
    742  1.20  dholland 	struct vnode *vp;
    743   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
    744   1.2   thorpej 	int error;
    745   1.2   thorpej 
    746   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
    747   1.2   thorpej 	    NULL);
    748   1.2   thorpej 	if (error)
    749   1.2   thorpej 		return (error);
    750   1.2   thorpej 
    751  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    752  1.20  dholland 				NSM_FOLLOW_NOEMULROOT, &vp);
    753   1.2   thorpej 	if (error)
    754   1.2   thorpej 		return (error);
    755   1.2   thorpej 
    756   1.2   thorpej 	/* XXX flags */
    757   1.2   thorpej 
    758  1.20  dholland 	error = extattr_set_vp(vp, EXTATTR_NAMESPACE_USER,
    759   1.4  christos 	    attrname, SCARG(uap, value), SCARG(uap, size), l, retval);
    760   1.2   thorpej 
    761  1.20  dholland 	vrele(vp);
    762   1.2   thorpej 	return (error);
    763   1.2   thorpej }
    764   1.2   thorpej 
    765   1.2   thorpej int
    766  1.15       dsl sys_lsetxattr(struct lwp *l, const struct sys_lsetxattr_args *uap, register_t *retval)
    767   1.2   thorpej {
    768  1.15       dsl 	/* {
    769   1.2   thorpej 		syscallarg(const char *) path;
    770   1.2   thorpej 		syscallarg(const char *) name;
    771   1.2   thorpej 		syscallarg(void *) value;
    772   1.2   thorpej 		syscallarg(size_t) size;
    773   1.2   thorpej 		syscallarg(int) flags;
    774  1.15       dsl 	} */
    775  1.20  dholland 	struct vnode *vp;
    776   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
    777   1.2   thorpej 	int error;
    778   1.2   thorpej 
    779   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
    780   1.2   thorpej 	    NULL);
    781   1.2   thorpej 	if (error)
    782   1.2   thorpej 		return (error);
    783   1.2   thorpej 
    784  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    785  1.20  dholland 				NSM_NOFOLLOW_NOEMULROOT, &vp);
    786   1.2   thorpej 	if (error)
    787   1.2   thorpej 		return (error);
    788   1.2   thorpej 
    789   1.2   thorpej 	/* XXX flags */
    790   1.2   thorpej 
    791  1.20  dholland 	error = extattr_set_vp(vp, EXTATTR_NAMESPACE_USER,
    792   1.4  christos 	    attrname, SCARG(uap, value), SCARG(uap, size), l, retval);
    793   1.2   thorpej 
    794  1.20  dholland 	vrele(vp);
    795   1.2   thorpej 	return (error);
    796   1.2   thorpej }
    797   1.2   thorpej 
    798   1.2   thorpej int
    799  1.15       dsl sys_fsetxattr(struct lwp *l, const struct sys_fsetxattr_args *uap, register_t *retval)
    800   1.2   thorpej {
    801  1.15       dsl 	/* {
    802   1.2   thorpej 		syscallarg(int) fd;
    803   1.2   thorpej 		syscallarg(const char *) name;
    804   1.2   thorpej 		syscallarg(void *) value;
    805   1.2   thorpej 		syscallarg(size_t) size;
    806   1.2   thorpej 		syscallarg(int) flags;
    807  1.15       dsl 	} */
    808   1.2   thorpej 	struct file *fp;
    809   1.2   thorpej 	struct vnode *vp;
    810   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
    811   1.2   thorpej 	int error;
    812   1.2   thorpej 
    813   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
    814   1.2   thorpej 	    NULL);
    815   1.2   thorpej 	if (error)
    816   1.2   thorpej 		return (error);
    817   1.2   thorpej 
    818  1.19        ad 	error = fd_getvnode(SCARG(uap, fd), &fp);
    819   1.2   thorpej 	if (error)
    820   1.2   thorpej 		return (error);
    821   1.2   thorpej 	vp = (struct vnode *) fp->f_data;
    822   1.2   thorpej 
    823   1.2   thorpej 	/* XXX flags */
    824   1.2   thorpej 
    825   1.2   thorpej 	error = extattr_set_vp(vp, EXTATTR_NAMESPACE_USER,
    826   1.4  christos 	    attrname, SCARG(uap, value), SCARG(uap, size), l, retval);
    827   1.2   thorpej 
    828  1.17        ad 	fd_putfile(SCARG(uap, fd));
    829   1.2   thorpej 	return (error);
    830   1.2   thorpej }
    831   1.2   thorpej 
    832   1.2   thorpej int
    833  1.15       dsl sys_getxattr(struct lwp *l, const struct sys_getxattr_args *uap, register_t *retval)
    834   1.2   thorpej {
    835  1.15       dsl 	/* {
    836   1.2   thorpej 		syscallarg(const char *) path;
    837   1.2   thorpej 		syscallarg(const char *) name;
    838   1.2   thorpej 		syscallarg(void *) value;
    839   1.2   thorpej 		syscallarg(size_t) size;
    840  1.15       dsl 	} */
    841  1.20  dholland 	struct vnode *vp;
    842   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
    843   1.2   thorpej 	int error;
    844   1.2   thorpej 
    845   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
    846   1.2   thorpej 	    NULL);
    847   1.2   thorpej 	if (error)
    848   1.2   thorpej 		return (error);
    849   1.2   thorpej 
    850  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    851  1.20  dholland 				NSM_FOLLOW_NOEMULROOT, &vp);
    852   1.2   thorpej 	if (error)
    853   1.2   thorpej 		return (error);
    854   1.2   thorpej 
    855  1.20  dholland 	error = extattr_get_vp(vp, EXTATTR_NAMESPACE_USER,
    856   1.4  christos 	    attrname, SCARG(uap, value), SCARG(uap, size), l, retval);
    857   1.2   thorpej 
    858  1.20  dholland 	vrele(vp);
    859   1.2   thorpej 	return (error);
    860   1.2   thorpej }
    861   1.2   thorpej 
    862   1.2   thorpej int
    863  1.15       dsl sys_lgetxattr(struct lwp *l, const struct sys_lgetxattr_args *uap, register_t *retval)
    864   1.2   thorpej {
    865  1.15       dsl 	/* {
    866   1.2   thorpej 		syscallarg(const char *) path;
    867   1.2   thorpej 		syscallarg(const char *) name;
    868   1.2   thorpej 		syscallarg(void *) value;
    869   1.2   thorpej 		syscallarg(size_t) size;
    870  1.15       dsl 	} */
    871  1.20  dholland 	struct vnode *vp;
    872   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
    873   1.2   thorpej 	int error;
    874   1.2   thorpej 
    875   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
    876   1.2   thorpej 	    NULL);
    877   1.2   thorpej 	if (error)
    878   1.2   thorpej 		return (error);
    879   1.2   thorpej 
    880  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    881  1.20  dholland 				NSM_NOFOLLOW_NOEMULROOT, &vp);
    882   1.2   thorpej 	if (error)
    883   1.2   thorpej 		return (error);
    884   1.2   thorpej 
    885  1.20  dholland 	error = extattr_get_vp(vp, EXTATTR_NAMESPACE_USER,
    886   1.4  christos 	    attrname, SCARG(uap, value), SCARG(uap, size), l, retval);
    887   1.2   thorpej 
    888  1.20  dholland 	vrele(vp);
    889   1.2   thorpej 	return (error);
    890   1.2   thorpej }
    891   1.2   thorpej 
    892   1.2   thorpej int
    893  1.15       dsl sys_fgetxattr(struct lwp *l, const struct sys_fgetxattr_args *uap, register_t *retval)
    894   1.2   thorpej {
    895  1.15       dsl 	/* {
    896   1.2   thorpej 		syscallarg(int) fd;
    897   1.2   thorpej 		syscallarg(const char *) name;
    898   1.2   thorpej 		syscallarg(void *) value;
    899   1.2   thorpej 		syscallarg(size_t) size;
    900  1.15       dsl 	} */
    901   1.2   thorpej 	struct file *fp;
    902   1.2   thorpej 	struct vnode *vp;
    903   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
    904   1.2   thorpej 	int error;
    905   1.2   thorpej 
    906   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
    907   1.2   thorpej 	    NULL);
    908   1.2   thorpej 	if (error)
    909   1.2   thorpej 		return (error);
    910   1.2   thorpej 
    911  1.19        ad 	error = fd_getvnode(SCARG(uap, fd), &fp);
    912   1.2   thorpej 	if (error)
    913   1.2   thorpej 		return (error);
    914   1.2   thorpej 	vp = (struct vnode *) fp->f_data;
    915   1.2   thorpej 
    916   1.2   thorpej 	error = extattr_get_vp(vp, EXTATTR_NAMESPACE_USER,
    917   1.4  christos 	    attrname, SCARG(uap, value), SCARG(uap, size), l, retval);
    918   1.2   thorpej 
    919  1.17        ad 	fd_putfile(SCARG(uap, fd));
    920   1.2   thorpej 	return (error);
    921   1.2   thorpej }
    922   1.2   thorpej 
    923   1.2   thorpej int
    924  1.15       dsl sys_listxattr(struct lwp *l, const struct sys_listxattr_args *uap, register_t *retval)
    925   1.2   thorpej {
    926  1.15       dsl 	/* {
    927   1.2   thorpej 		syscallarg(const char *) path;
    928   1.2   thorpej 		syscallarg(char *) list;
    929   1.2   thorpej 		syscallarg(size_t) size;
    930  1.15       dsl 	} */
    931  1.20  dholland 	struct vnode *vp;
    932   1.2   thorpej 	int error;
    933   1.2   thorpej 
    934  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    935  1.20  dholland 				NSM_FOLLOW_NOEMULROOT, &vp);
    936   1.2   thorpej 	if (error)
    937   1.2   thorpej 		return (error);
    938   1.2   thorpej 
    939  1.20  dholland 	error = extattr_list_vp(vp, EXTATTR_NAMESPACE_USER,
    940   1.4  christos 	    SCARG(uap, list), SCARG(uap, size), l, retval);
    941   1.2   thorpej 
    942  1.20  dholland 	vrele(vp);
    943   1.2   thorpej 	return (error);
    944   1.2   thorpej }
    945   1.2   thorpej 
    946   1.2   thorpej int
    947  1.15       dsl sys_llistxattr(struct lwp *l, const struct sys_llistxattr_args *uap, register_t *retval)
    948   1.2   thorpej {
    949  1.15       dsl 	/* {
    950   1.2   thorpej 		syscallarg(const char *) path;
    951   1.2   thorpej 		syscallarg(char *) list;
    952   1.2   thorpej 		syscallarg(size_t) size;
    953  1.15       dsl 	} */
    954  1.20  dholland 	struct vnode *vp;
    955   1.2   thorpej 	int error;
    956   1.2   thorpej 
    957  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
    958  1.20  dholland 				NSM_NOFOLLOW_NOEMULROOT, &vp);
    959   1.2   thorpej 	if (error)
    960   1.2   thorpej 		return (error);
    961   1.2   thorpej 
    962  1.20  dholland 	error = extattr_list_vp(vp, EXTATTR_NAMESPACE_USER,
    963   1.4  christos 	    SCARG(uap, list), SCARG(uap, size), l, retval);
    964   1.2   thorpej 
    965  1.20  dholland 	vrele(vp);
    966   1.2   thorpej 	return (error);
    967   1.2   thorpej }
    968   1.2   thorpej 
    969   1.2   thorpej int
    970  1.15       dsl sys_flistxattr(struct lwp *l, const struct sys_flistxattr_args *uap, register_t *retval)
    971   1.2   thorpej {
    972  1.15       dsl 	/* {
    973   1.2   thorpej 		syscallarg(int) fd;
    974   1.2   thorpej 		syscallarg(char *) list;
    975   1.2   thorpej 		syscallarg(size_t) size;
    976  1.15       dsl 	} */
    977   1.2   thorpej 	struct file *fp;
    978   1.2   thorpej 	struct vnode *vp;
    979   1.2   thorpej 	int error;
    980   1.2   thorpej 
    981  1.19        ad 	error = fd_getvnode(SCARG(uap, fd), &fp);
    982   1.2   thorpej 	if (error)
    983   1.2   thorpej 		return (error);
    984   1.2   thorpej 	vp = (struct vnode *) fp->f_data;
    985   1.2   thorpej 
    986   1.2   thorpej 	error = extattr_list_vp(vp, EXTATTR_NAMESPACE_USER,
    987   1.4  christos 	    SCARG(uap, list), SCARG(uap, size), l, retval);
    988   1.2   thorpej 
    989  1.17        ad 	fd_putfile(SCARG(uap, fd));
    990   1.2   thorpej 	return (error);
    991   1.2   thorpej }
    992   1.2   thorpej 
    993   1.2   thorpej int
    994  1.15       dsl sys_removexattr(struct lwp *l, const struct sys_removexattr_args *uap, register_t *retval)
    995   1.2   thorpej {
    996  1.15       dsl 	/* {
    997   1.2   thorpej 		syscallarg(const char *) path;
    998   1.2   thorpej 		syscallarg(const char *) name;
    999  1.15       dsl 	} */
   1000  1.20  dholland 	struct vnode *vp;
   1001   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
   1002   1.2   thorpej 	int error;
   1003   1.2   thorpej 
   1004   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
   1005   1.2   thorpej 	    NULL);
   1006   1.2   thorpej 	if (error)
   1007   1.2   thorpej 		return (error);
   1008   1.2   thorpej 
   1009  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
   1010  1.20  dholland 				NSM_FOLLOW_NOEMULROOT, &vp);
   1011   1.2   thorpej 	if (error)
   1012   1.2   thorpej 		return (error);
   1013   1.2   thorpej 
   1014  1.20  dholland 	error = extattr_delete_vp(vp, EXTATTR_NAMESPACE_USER,
   1015   1.4  christos 	    attrname, l);
   1016   1.2   thorpej 
   1017  1.20  dholland 	vrele(vp);
   1018   1.2   thorpej 	return (error);
   1019   1.2   thorpej }
   1020   1.2   thorpej 
   1021   1.2   thorpej int
   1022  1.15       dsl sys_lremovexattr(struct lwp *l, const struct sys_lremovexattr_args *uap, register_t *retval)
   1023   1.2   thorpej {
   1024  1.15       dsl 	/* {
   1025   1.2   thorpej 		syscallarg(const char *) path;
   1026   1.2   thorpej 		syscallarg(const char *) name;
   1027  1.15       dsl 	} */
   1028  1.20  dholland 	struct vnode *vp;
   1029   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
   1030   1.2   thorpej 	int error;
   1031   1.2   thorpej 
   1032   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
   1033   1.2   thorpej 	    NULL);
   1034   1.2   thorpej 	if (error)
   1035   1.2   thorpej 		return (error);
   1036   1.2   thorpej 
   1037  1.20  dholland 	error = namei_simple_user(SCARG(uap, path),
   1038  1.20  dholland 				NSM_NOFOLLOW_NOEMULROOT, &vp);
   1039   1.2   thorpej 	if (error)
   1040   1.2   thorpej 		return (error);
   1041   1.2   thorpej 
   1042  1.20  dholland 	error = extattr_delete_vp(vp, EXTATTR_NAMESPACE_USER,
   1043   1.4  christos 	    attrname, l);
   1044   1.2   thorpej 
   1045  1.20  dholland 	vrele(vp);
   1046   1.2   thorpej 	return (error);
   1047   1.2   thorpej }
   1048   1.2   thorpej 
   1049   1.2   thorpej int
   1050  1.15       dsl sys_fremovexattr(struct lwp *l, const struct sys_fremovexattr_args *uap, register_t *retval)
   1051   1.2   thorpej {
   1052  1.15       dsl 	/* {
   1053   1.2   thorpej 		syscallarg(int) fd;
   1054   1.2   thorpej 		syscallarg(const char *) name;
   1055  1.15       dsl 	} */
   1056   1.2   thorpej 	struct file *fp;
   1057   1.2   thorpej 	struct vnode *vp;
   1058   1.2   thorpej 	char attrname[XATTR_NAME_MAX];
   1059   1.2   thorpej 	int error;
   1060   1.2   thorpej 
   1061   1.2   thorpej 	error = copyinstr(SCARG(uap, name), attrname, sizeof(attrname),
   1062   1.2   thorpej 	    NULL);
   1063   1.2   thorpej 	if (error)
   1064   1.2   thorpej 		return (error);
   1065   1.2   thorpej 
   1066  1.19        ad 	error = fd_getvnode(SCARG(uap, fd), &fp);
   1067   1.2   thorpej 	if (error)
   1068   1.2   thorpej 		return (error);
   1069   1.2   thorpej 	vp = (struct vnode *) fp->f_data;
   1070   1.2   thorpej 
   1071   1.2   thorpej 	error = extattr_delete_vp(vp, EXTATTR_NAMESPACE_USER,
   1072   1.4  christos 	    attrname, l);
   1073   1.2   thorpej 
   1074  1.17        ad 	fd_putfile(SCARG(uap, fd));
   1075   1.2   thorpej 	return (error);
   1076   1.2   thorpej }
   1077