mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
Replace struct filedesc argument in getvnode with struct thread
This is is a step towards removal of spurious arguments.
This commit is contained in:
parent
0e4cd4a2e0
commit
4da8456f0a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=284446
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
/*
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 @@ sys_revoke(td, uap)
|
||||
* 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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user