diff options
author | mjg <mjg@FreeBSD.org> | 2015-06-16 13:09:18 +0000 |
---|---|---|
committer | mjg <mjg@FreeBSD.org> | 2015-06-16 13:09:18 +0000 |
commit | 1a3e7a935ea43cdf9b106244b3742c7babf5083b (patch) | |
tree | 15e657e125a980a05b63ad49c2f534d1a717de10 | |
parent | 6ea7eb1bceba958493920719e4cd9697af18670f (diff) | |
download | FreeBSD-src-1a3e7a935ea43cdf9b106244b3742c7babf5083b.zip FreeBSD-src-1a3e7a935ea43cdf9b106244b3742c7babf5083b.tar.gz |
Replace struct filedesc argument in getvnode with struct thread
This is is a step towards removal of spurious arguments.
-rw-r--r-- | sys/compat/linux/linux_file.c | 3 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_misc.c | 9 | ||||
-rw-r--r-- | sys/fs/fdescfs/fdesc_vnops.c | 2 | ||||
-rw-r--r-- | sys/i386/ibcs2/ibcs2_misc.c | 6 | ||||
-rw-r--r-- | sys/kern/vfs_acl.c | 8 | ||||
-rw-r--r-- | sys/kern/vfs_extattr.c | 8 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 30 | ||||
-rw-r--r-- | sys/security/audit/audit_arg.c | 2 | ||||
-rw-r--r-- | sys/sys/filedesc.h | 2 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 4 |
10 files changed, 31 insertions, 43 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 9251a20..1e5e37a 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -348,8 +348,7 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args, } 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); diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 9ad2a09..ec4504e 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -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); diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 9c98832..15f3bd4 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -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) { /* diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c index c4dba20..ccf5190 100644 --- a/sys/i386/ibcs2/ibcs2_misc.c +++ b/sys/i386/ibcs2/ibcs2_misc.c @@ -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); diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c index e9361e5..56cc6c9 100644 --- a/sys/kern/vfs_acl.c +++ b/sys/kern/vfs_acl.c @@ -406,7 +406,7 @@ sys___acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap) 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, struct __acl_set_fd_args *uap) 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, struct __acl_delete_fd_args *uap) 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, struct __acl_aclcheck_fd_args *uap) 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); diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 24935ce..0f82c2b 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -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); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index d2f0df1..9088017 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -365,8 +365,7 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf) 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, struct timeval *tptr, 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, struct timespec *tptr, 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, struct ogetdirentries_args *uap, /* 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, int fd, char *buf, u_int count, 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, cap_rights_t *rightsp, struct file **fpp) * checking f_ops. */ if (fp->f_vnode == NULL || fp->f_ops == &badfileops) { - fdrop(fp, curthread); + fdrop(fp, td); return (EINVAL); } *fpp = fp; diff --git a/sys/security/audit/audit_arg.c b/sys/security/audit/audit_arg.c index d17445f..c006b90 100644 --- a/sys/security/audit/audit_arg.c +++ b/sys/security/audit/audit_arg.c @@ -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; diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index da80ed9..fe95111 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -165,7 +165,7 @@ struct filedesc *fdshare(struct filedesc *fdp); 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); diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index c384064..2b9c334 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -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) { |