vfs_syscalls.c (73909) | vfs_syscalls.c (74273) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 |
39 * $FreeBSD: head/sys/kern/vfs_syscalls.c 73909 2001-03-07 02:25:13Z jhb $ | 39 * $FreeBSD: head/sys/kern/vfs_syscalls.c 74273 2001-03-15 02:54:29Z rwatson $ |
40 */ 41 42/* For 4.3 integer FS ID compatibility */ 43#include "opt_compat.h" 44#include "opt_ffs.h" 45 46#include <sys/param.h> 47#include <sys/systm.h> --- 3628 unchanged lines hidden (view full) --- 3676 * 3677 * Currently this is used only by UFS Extended Attributes. 3678 */ 3679int 3680extattrctl(p, uap) 3681 struct proc *p; 3682 struct extattrctl_args *uap; 3683{ | 40 */ 41 42/* For 4.3 integer FS ID compatibility */ 43#include "opt_compat.h" 44#include "opt_ffs.h" 45 46#include <sys/param.h> 47#include <sys/systm.h> --- 3628 unchanged lines hidden (view full) --- 3676 * 3677 * Currently this is used only by UFS Extended Attributes. 3678 */ 3679int 3680extattrctl(p, uap) 3681 struct proc *p; 3682 struct extattrctl_args *uap; 3683{ |
3684 struct vnode *filename_vp; |
|
3684 struct nameidata nd; 3685 struct mount *mp; | 3685 struct nameidata nd; 3686 struct mount *mp; |
3687 char attrname[EXTATTR_MAXNAMELEN]; |
|
3686 int error; 3687 | 3688 int error; 3689 |
3690 /* 3691 * SCARG(uap, attrname) not always defined. We check again later 3692 * when we invoke the VFS call so as to pass in NULL there if needed. 3693 */ 3694 if (SCARG(uap, attrname) != NULL) { 3695 error = copyinstr(SCARG(uap, attrname), attrname, 3696 EXTATTR_MAXNAMELEN, NULL); 3697 if (error) 3698 return (error); 3699 } 3700 3701 /* 3702 * SCARG(uap, filename) not always defined. If it is, grab 3703 * a vnode lock, which VFS_EXTATTRCTL() will later release. 3704 */ 3705 filename_vp = NULL; 3706 if (SCARG(uap, filename) != NULL) { 3707 NDINIT(&nd, LOOKUP | LOCKLEAF, FOLLOW, UIO_USERSPACE, 3708 SCARG(uap, filename), p); 3709 if ((error = namei(&nd)) != 0) 3710 return (error); 3711 filename_vp = nd.ni_vp; 3712 NDFREE(&nd, NDF_NO_VP_RELE | NDF_NO_VP_UNLOCK); 3713 } 3714 3715 /* SCARG(uap, path) always defined. */ |
|
3688 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); 3689 if ((error = namei(&nd)) != 0) 3690 return (error); 3691 error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH); 3692 NDFREE(&nd, 0); | 3716 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); 3717 if ((error = namei(&nd)) != 0) 3718 return (error); 3719 error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH); 3720 NDFREE(&nd, 0); |
3693 if (error) | 3721 if (error) { 3722 if (filename_vp) 3723 vrele(filename_vp); |
3694 return (error); | 3724 return (error); |
3695 error = VFS_EXTATTRCTL(mp, SCARG(uap, cmd), SCARG(uap, attrname), 3696 SCARG(uap, arg), p); | 3725 } 3726 3727 if (SCARG(uap, attrname) != NULL) { 3728 error = VFS_EXTATTRCTL(mp, SCARG(uap, cmd), filename_vp, 3729 SCARG(uap, namespace), attrname, p); 3730 } else { 3731 error = VFS_EXTATTRCTL(mp, SCARG(uap, cmd), filename_vp, 3732 SCARG(uap, namespace), NULL, p); 3733 } 3734 |
3697 vn_finished_write(mp); | 3735 vn_finished_write(mp); |
3736 /* 3737 * VFS_EXTATTRCTL will have unlocked, but not de-ref'd, 3738 * filename_vp, so vrele it if it is defined. 3739 */ 3740 if (filename_vp != NULL) 3741 vrele(filename_vp); 3742 |
|
3698 return (error); 3699} 3700 3701/* 3702 * Syscall to set a named extended attribute on a file or directory. 3703 * Accepts attribute name, and a uio structure pointing to the data to set. 3704 * The uio is consumed in the style of writev(). The real work happens 3705 * in VOP_SETEXTATTR(). --- 45 unchanged lines hidden (view full) --- 3751 if (iov->iov_len > INT_MAX - auio.uio_resid) { 3752 error = EINVAL; 3753 goto done; 3754 } 3755 auio.uio_resid += iov->iov_len; 3756 iov++; 3757 } 3758 cnt = auio.uio_resid; | 3743 return (error); 3744} 3745 3746/* 3747 * Syscall to set a named extended attribute on a file or directory. 3748 * Accepts attribute name, and a uio structure pointing to the data to set. 3749 * The uio is consumed in the style of writev(). The real work happens 3750 * in VOP_SETEXTATTR(). --- 45 unchanged lines hidden (view full) --- 3796 if (iov->iov_len > INT_MAX - auio.uio_resid) { 3797 error = EINVAL; 3798 goto done; 3799 } 3800 auio.uio_resid += iov->iov_len; 3801 iov++; 3802 } 3803 cnt = auio.uio_resid; |
3759 error = VOP_SETEXTATTR(nd.ni_vp, attrname, &auio, p->p_cred->pc_ucred, 3760 p); | 3804 error = VOP_SETEXTATTR(nd.ni_vp, SCARG(uap, namespace), attrname, 3805 &auio, p->p_cred->pc_ucred, p); |
3761 cnt -= auio.uio_resid; 3762 p->p_retval[0] = cnt; 3763done: 3764 if (needfree) 3765 FREE(needfree, M_IOV); 3766 NDFREE(&nd, 0); 3767 vn_finished_write(mp); 3768 return (error); --- 49 unchanged lines hidden (view full) --- 3818 if (iov->iov_len > INT_MAX - auio.uio_resid) { 3819 error = EINVAL; 3820 goto done; 3821 } 3822 auio.uio_resid += iov->iov_len; 3823 iov++; 3824 } 3825 cnt = auio.uio_resid; | 3806 cnt -= auio.uio_resid; 3807 p->p_retval[0] = cnt; 3808done: 3809 if (needfree) 3810 FREE(needfree, M_IOV); 3811 NDFREE(&nd, 0); 3812 vn_finished_write(mp); 3813 return (error); --- 49 unchanged lines hidden (view full) --- 3863 if (iov->iov_len > INT_MAX - auio.uio_resid) { 3864 error = EINVAL; 3865 goto done; 3866 } 3867 auio.uio_resid += iov->iov_len; 3868 iov++; 3869 } 3870 cnt = auio.uio_resid; |
3826 error = VOP_GETEXTATTR(nd.ni_vp, attrname, &auio, p->p_cred->pc_ucred, 3827 p); | 3871 error = VOP_GETEXTATTR(nd.ni_vp, SCARG(uap, namespace), attrname, 3872 &auio, p->p_cred->pc_ucred, p); |
3828 cnt -= auio.uio_resid; 3829 p->p_retval[0] = cnt; 3830done: 3831 if (needfree) 3832 FREE(needfree, M_IOV); 3833 NDFREE(&nd, 0); 3834 return(error); 3835} --- 18 unchanged lines hidden (view full) --- 3854 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 3855 SCARG(uap, path), p); 3856 if ((error = namei(&nd)) != 0) 3857 return(error); 3858 if ((error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH)) != 0) { 3859 NDFREE(&nd, 0); 3860 return (error); 3861 } | 3873 cnt -= auio.uio_resid; 3874 p->p_retval[0] = cnt; 3875done: 3876 if (needfree) 3877 FREE(needfree, M_IOV); 3878 NDFREE(&nd, 0); 3879 return(error); 3880} --- 18 unchanged lines hidden (view full) --- 3899 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, 3900 SCARG(uap, path), p); 3901 if ((error = namei(&nd)) != 0) 3902 return(error); 3903 if ((error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH)) != 0) { 3904 NDFREE(&nd, 0); 3905 return (error); 3906 } |
3862 error = VOP_SETEXTATTR(nd.ni_vp, attrname, NULL, p->p_cred->pc_ucred, 3863 p); | 3907 error = VOP_SETEXTATTR(nd.ni_vp, SCARG(uap, namespace), attrname, 3908 NULL, p->p_cred->pc_ucred, p); |
3864 NDFREE(&nd, 0); 3865 vn_finished_write(mp); 3866 return(error); 3867} | 3909 NDFREE(&nd, 0); 3910 vn_finished_write(mp); 3911 return(error); 3912} |