Author: mjg
Date: Tue Jun 16 13:09:18 2015
New Revision: 284446
URL: https://svnweb.freebsd.org/changeset/base/284446

Log:
  Replace struct filedesc argument in getvnode with struct thread
  
  This is is a step towards removal of spurious arguments.

Modified:
  head/sys/compat/linux/linux_file.c
  head/sys/compat/svr4/svr4_misc.c
  head/sys/fs/fdescfs/fdesc_vnops.c
  head/sys/i386/ibcs2/ibcs2_misc.c
  head/sys/kern/vfs_acl.c
  head/sys/kern/vfs_extattr.c
  head/sys/kern/vfs_syscalls.c
  head/sys/security/audit/audit_arg.c
  head/sys/sys/filedesc.h
  head/sys/ufs/ffs/ffs_alloc.c

Modified: head/sys/compat/linux/linux_file.c
==============================================================================
--- head/sys/compat/linux/linux_file.c  Tue Jun 16 12:36:29 2015        
(r284445)
+++ head/sys/compat/linux/linux_file.c  Tue Jun 16 13:09:18 2015        
(r284446)
@@ -348,8 +348,7 @@ getdents_common(struct thread *td, struc
        } else
                justone = 0;
 
-       error = getvnode(td->td_proc->p_fd, args->fd,
-           cap_rights_init(&rights, CAP_READ), &fp);
+       error = getvnode(td, args->fd, cap_rights_init(&rights, CAP_READ), &fp);
        if (error != 0)
                return (error);
 

Modified: head/sys/compat/svr4/svr4_misc.c
==============================================================================
--- head/sys/compat/svr4/svr4_misc.c    Tue Jun 16 12:36:29 2015        
(r284445)
+++ head/sys/compat/svr4/svr4_misc.c    Tue Jun 16 13:09:18 2015        
(r284446)
@@ -262,8 +262,7 @@ svr4_sys_getdents64(td, uap)
 
        DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n",
                uap->fd, uap->nbytes));
-       error = getvnode(td->td_proc->p_fd, uap->fd,
-           cap_rights_init(&rights, CAP_READ), &fp);
+       error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
        if (error != 0)
                return (error);
 
@@ -442,8 +441,7 @@ svr4_sys_getdents(td, uap)
        if (uap->nbytes < 0)
                return (EINVAL);
 
-       error = getvnode(td->td_proc->p_fd, uap->fd,
-           cap_rights_init(&rights, CAP_READ), &fp);
+       error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
        if (error != 0)
                return (error);
 
@@ -623,7 +621,6 @@ svr4_sys_fchroot(td, uap)
        struct svr4_sys_fchroot_args *uap;
 {
        cap_rights_t rights;
-       struct filedesc *fdp = td->td_proc->p_fd;
        struct vnode    *vp;
        struct file     *fp;
        int              error;
@@ -631,7 +628,7 @@ svr4_sys_fchroot(td, uap)
        if ((error = priv_check(td, PRIV_VFS_FCHROOT)) != 0)
                return error;
        /* XXX: we have the chroot priv... what cap might we need? all? */
-       if ((error = getvnode(fdp, uap->fd, cap_rights_init(&rights), &fp)) != 
0)
+       if ((error = getvnode(td, uap->fd, cap_rights_init(&rights), &fp)) != 0)
                return error;
        vp = fp->f_vnode;
        VREF(vp);

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==============================================================================
--- head/sys/fs/fdescfs/fdesc_vnops.c   Tue Jun 16 12:36:29 2015        
(r284445)
+++ head/sys/fs/fdescfs/fdesc_vnops.c   Tue Jun 16 13:09:18 2015        
(r284446)
@@ -482,7 +482,7 @@ fdesc_setattr(ap)
        /*
         * Allow setattr where there is an underlying vnode.
         */
-       error = getvnode(td->td_proc->p_fd, fd,
+       error = getvnode(td, fd,
            cap_rights_init(&rights, CAP_EXTATTR_SET), &fp);
        if (error) {
                /*

Modified: head/sys/i386/ibcs2/ibcs2_misc.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_misc.c    Tue Jun 16 12:36:29 2015        
(r284445)
+++ head/sys/i386/ibcs2/ibcs2_misc.c    Tue Jun 16 13:09:18 2015        
(r284446)
@@ -342,8 +342,7 @@ ibcs2_getdents(td, uap)
 #define        BSD_DIRENT(cp)          ((struct dirent *)(cp))
 #define        IBCS2_RECLEN(reclen)    (reclen + sizeof(u_short))
 
-       error = getvnode(td->td_proc->p_fd, uap->fd,
-           cap_rights_init(&rights, CAP_READ), &fp);
+       error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
        if (error != 0)
                return (error);
        if ((fp->f_flag & FREAD) == 0) {
@@ -498,8 +497,7 @@ ibcs2_read(td, uap)
        u_long *cookies = NULL, *cookiep;
        int ncookies;
 
-       error = getvnode(td->td_proc->p_fd, uap->fd,
-           cap_rights_init(&rights, CAP_READ), &fp);
+       error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
        if (error != 0) {
                if (error == EINVAL)
                        return sys_read(td, (struct read_args *)uap);

Modified: head/sys/kern/vfs_acl.c
==============================================================================
--- head/sys/kern/vfs_acl.c     Tue Jun 16 12:36:29 2015        (r284445)
+++ head/sys/kern/vfs_acl.c     Tue Jun 16 13:09:18 2015        (r284446)
@@ -406,7 +406,7 @@ sys___acl_get_fd(struct thread *td, stru
        cap_rights_t rights;
        int error;
 
-       error = getvnode(td->td_proc->p_fd, uap->filedes,
+       error = getvnode(td, uap->filedes,
            cap_rights_init(&rights, CAP_ACL_GET), &fp);
        if (error == 0) {
                error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
@@ -425,7 +425,7 @@ sys___acl_set_fd(struct thread *td, stru
        cap_rights_t rights;
        int error;
 
-       error = getvnode(td->td_proc->p_fd, uap->filedes,
+       error = getvnode(td, uap->filedes,
            cap_rights_init(&rights, CAP_ACL_SET), &fp);
        if (error == 0) {
                error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
@@ -480,7 +480,7 @@ sys___acl_delete_fd(struct thread *td, s
        cap_rights_t rights;
        int error;
 
-       error = getvnode(td->td_proc->p_fd, uap->filedes,
+       error = getvnode(td, uap->filedes,
            cap_rights_init(&rights, CAP_ACL_DELETE), &fp);
        if (error == 0) {
                error = vacl_delete(td, fp->f_vnode, uap->type);
@@ -535,7 +535,7 @@ sys___acl_aclcheck_fd(struct thread *td,
        cap_rights_t rights;
        int error;
 
-       error = getvnode(td->td_proc->p_fd, uap->filedes,
+       error = getvnode(td, uap->filedes,
            cap_rights_init(&rights, CAP_ACL_CHECK), &fp);
        if (error == 0) {
                error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);

Modified: head/sys/kern/vfs_extattr.c
==============================================================================
--- head/sys/kern/vfs_extattr.c Tue Jun 16 12:36:29 2015        (r284445)
+++ head/sys/kern/vfs_extattr.c Tue Jun 16 13:09:18 2015        (r284446)
@@ -226,7 +226,7 @@ sys_extattr_set_fd(td, uap)
                return (error);
        AUDIT_ARG_TEXT(attrname);
 
-       error = getvnode(td->td_proc->p_fd, uap->fd,
+       error = getvnode(td, uap->fd,
            cap_rights_init(&rights, CAP_EXTATTR_SET), &fp);
        if (error)
                return (error);
@@ -401,7 +401,7 @@ sys_extattr_get_fd(td, uap)
                return (error);
        AUDIT_ARG_TEXT(attrname);
 
-       error = getvnode(td->td_proc->p_fd, uap->fd,
+       error = getvnode(td, uap->fd,
            cap_rights_init(&rights, CAP_EXTATTR_GET), &fp);
        if (error)
                return (error);
@@ -545,7 +545,7 @@ sys_extattr_delete_fd(td, uap)
                return (error);
        AUDIT_ARG_TEXT(attrname);
 
-       error = getvnode(td->td_proc->p_fd, uap->fd,
+       error = getvnode(td, uap->fd,
            cap_rights_init(&rights, CAP_EXTATTR_DELETE), &fp);
        if (error)
                return (error);
@@ -697,7 +697,7 @@ sys_extattr_list_fd(td, uap)
 
        AUDIT_ARG_FD(uap->fd);
        AUDIT_ARG_VALUE(uap->attrnamespace);
-       error = getvnode(td->td_proc->p_fd, uap->fd,
+       error = getvnode(td, uap->fd,
            cap_rights_init(&rights, CAP_EXTATTR_LIST), &fp);
        if (error)
                return (error);

Modified: head/sys/kern/vfs_syscalls.c
==============================================================================
--- head/sys/kern/vfs_syscalls.c        Tue Jun 16 12:36:29 2015        
(r284445)
+++ head/sys/kern/vfs_syscalls.c        Tue Jun 16 13:09:18 2015        
(r284446)
@@ -365,8 +365,7 @@ kern_fstatfs(struct thread *td, int fd, 
        int error;
 
        AUDIT_ARG_FD(fd);
-       error = getvnode(td->td_proc->p_fd, fd,
-           cap_rights_init(&rights, CAP_FSTATFS), &fp);
+       error = getvnode(td, fd, cap_rights_init(&rights, CAP_FSTATFS), &fp);
        if (error != 0)
                return (error);
        vp = fp->f_vnode;
@@ -737,7 +736,7 @@ sys_fchdir(td, uap)
        int error;
 
        AUDIT_ARG_FD(uap->fd);
-       error = getvnode(fdp, uap->fd, cap_rights_init(&rights, CAP_FCHDIR),
+       error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_FCHDIR),
            &fp);
        if (error != 0)
                return (error);
@@ -2671,8 +2670,8 @@ sys_fchflags(td, uap)
 
        AUDIT_ARG_FD(uap->fd);
        AUDIT_ARG_FFLAGS(uap->flags);
-       error = getvnode(td->td_proc->p_fd, uap->fd,
-           cap_rights_init(&rights, CAP_FCHFLAGS), &fp);
+       error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_FCHFLAGS),
+           &fp);
        if (error != 0)
                return (error);
 #ifdef AUDIT
@@ -3239,8 +3238,7 @@ kern_futimes(struct thread *td, int fd, 
        error = getutimes(tptr, tptrseg, ts);
        if (error != 0)
                return (error);
-       error = getvnode(td->td_proc->p_fd, fd,
-           cap_rights_init(&rights, CAP_FUTIMES), &fp);
+       error = getvnode(td, fd, cap_rights_init(&rights, CAP_FUTIMES), &fp);
        if (error != 0)
                return (error);
 #ifdef AUDIT
@@ -3275,8 +3273,7 @@ kern_futimens(struct thread *td, int fd,
                return (error);
        if (flags & UTIMENS_EXIT)
                return (0);
-       error = getvnode(td->td_proc->p_fd, fd,
-           cap_rights_init(&rights, CAP_FUTIMES), &fp);
+       error = getvnode(td, fd, cap_rights_init(&rights, CAP_FUTIMES), &fp);
        if (error != 0)
                return (error);
 #ifdef AUDIT
@@ -3470,8 +3467,7 @@ sys_fsync(td, uap)
        int error, lock_flags;
 
        AUDIT_ARG_FD(uap->fd);
-       error = getvnode(td->td_proc->p_fd, uap->fd,
-           cap_rights_init(&rights, CAP_FSYNC), &fp);
+       error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_FSYNC), &fp);
        if (error != 0)
                return (error);
        vp = fp->f_vnode;
@@ -3894,8 +3890,7 @@ kern_ogetdirentries(struct thread *td, s
        /* XXX arbitrary sanity limit on `count'. */
        if (uap->count > 64 * 1024)
                return (EINVAL);
-       error = getvnode(td->td_proc->p_fd, uap->fd,
-           cap_rights_init(&rights, CAP_READ), &fp);
+       error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
        if (error != 0)
                return (error);
        if ((fp->f_flag & FREAD) == 0) {
@@ -4058,8 +4053,7 @@ kern_getdirentries(struct thread *td, in
        if (count > IOSIZE_MAX)
                return (EINVAL);
        auio.uio_resid = count;
-       error = getvnode(td->td_proc->p_fd, fd,
-           cap_rights_init(&rights, CAP_READ), &fp);
+       error = getvnode(td, fd, cap_rights_init(&rights, CAP_READ), &fp);
        if (error != 0)
                return (error);
        if ((fp->f_flag & FREAD) == 0) {
@@ -4225,12 +4219,12 @@ out:
  * entry is held upon returning.
  */
 int
-getvnode(struct filedesc *fdp, int fd, cap_rights_t *rightsp, struct file 
**fpp)
+getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
 {
        struct file *fp;
        int error;
 
-       error = fget_unlocked(fdp, fd, rightsp, &fp, NULL);
+       error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp, NULL);
        if (error != 0)
                return (error);
 
@@ -4247,7 +4241,7 @@ getvnode(struct filedesc *fdp, int fd, c
         * checking f_ops.
         */
        if (fp->f_vnode == NULL || fp->f_ops == &badfileops) {
-               fdrop(fp, curthread);
+               fdrop(fp, td);
                return (EINVAL);
        }
        *fpp = fp;

Modified: head/sys/security/audit/audit_arg.c
==============================================================================
--- head/sys/security/audit/audit_arg.c Tue Jun 16 12:36:29 2015        
(r284445)
+++ head/sys/security/audit/audit_arg.c Tue Jun 16 13:09:18 2015        
(r284446)
@@ -908,7 +908,7 @@ audit_sysclose(struct thread *td, int fd
 
        audit_arg_fd(fd);
 
-       if (getvnode(td->td_proc->p_fd, fd, cap_rights_init(&rights), &fp) != 0)
+       if (getvnode(td, fd, cap_rights_init(&rights), &fp) != 0)
                return;
 
        vp = fp->f_vnode;

Modified: head/sys/sys/filedesc.h
==============================================================================
--- head/sys/sys/filedesc.h     Tue Jun 16 12:36:29 2015        (r284445)
+++ head/sys/sys/filedesc.h     Tue Jun 16 13:09:18 2015        (r284446)
@@ -165,7 +165,7 @@ struct      filedesc *fdshare(struct filedesc
 struct filedesc_to_leader *
        filedesc_to_leader_alloc(struct filedesc_to_leader *old,
            struct filedesc *fdp, struct proc *leader);
-int    getvnode(struct filedesc *fdp, int fd, cap_rights_t *rightsp,
+int    getvnode(struct thread *td, int fd, cap_rights_t *rightsp,
            struct file **fpp);
 void   mountcheckdirs(struct vnode *olddp, struct vnode *newdp);
 

Modified: head/sys/ufs/ffs/ffs_alloc.c
==============================================================================
--- head/sys/ufs/ffs/ffs_alloc.c        Tue Jun 16 12:36:29 2015        
(r284445)
+++ head/sys/ufs/ffs/ffs_alloc.c        Tue Jun 16 13:09:18 2015        
(r284446)
@@ -2766,7 +2766,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
                return (error);
        if (cmd.version != FFS_CMD_VERSION)
                return (ERPCMISMATCH);
-       if ((error = getvnode(td->td_proc->p_fd, cmd.handle,
+       if ((error = getvnode(td, cmd.handle,
            cap_rights_init(&rights, CAP_FSCK), &fp)) != 0)
                return (error);
        vp = fp->f_data;
@@ -3080,7 +3080,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
                            (intmax_t)cmd.value);
                }
 #endif /* DEBUG */
-               if ((error = getvnode(td->td_proc->p_fd, cmd.value,
+               if ((error = getvnode(td, cmd.value,
                    cap_rights_init(&rights, CAP_FSCK), &vfp)) != 0)
                        break;
                if (vfp->f_vnode->v_type != VCHR) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to