git: 2b68eb8e1dbb - main - vfs: remove thread argument from VOP_STAT
Date: Mon, 11 Oct 2021 13:22:47 UTC
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=2b68eb8e1dbbdaf6a0df1c83b26f5403ca52d4c3 commit 2b68eb8e1dbbdaf6a0df1c83b26f5403ca52d4c3 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2021-10-01 22:25:39 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2021-10-11 13:22:32 +0000 vfs: remove thread argument from VOP_STAT and fo_stat. --- share/man/man9/VOP_ATTRIB.9 | 6 ++---- sys/compat/linux/linux_event.c | 3 +-- sys/compat/linuxkpi/common/src/linux_compat.c | 5 ++--- sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c | 2 +- sys/fs/devfs/devfs_vnops.c | 4 ++-- sys/kern/kern_descrip.c | 5 ++--- sys/kern/kern_event.c | 3 +-- sys/kern/sys_eventfd.c | 3 +-- sys/kern/sys_pipe.c | 5 ++--- sys/kern/sys_procdesc.c | 3 +-- sys/kern/sys_socket.c | 3 +-- sys/kern/tty_pts.c | 3 +-- sys/kern/uipc_mqueue.c | 3 +-- sys/kern/uipc_sem.c | 3 +-- sys/kern/uipc_shm.c | 3 +-- sys/kern/vfs_syscalls.c | 6 +++--- sys/kern/vfs_vnops.c | 5 ++--- sys/kern/vnode_if.src | 1 - sys/sys/file.h | 7 +++---- sys/sys/param.h | 2 +- sys/sys/vnode.h | 2 +- 21 files changed, 30 insertions(+), 47 deletions(-) diff --git a/share/man/man9/VOP_ATTRIB.9 b/share/man/man9/VOP_ATTRIB.9 index 45f1e2f1652a..ddfee1f5d1f9 100644 --- a/share/man/man9/VOP_ATTRIB.9 +++ b/share/man/man9/VOP_ATTRIB.9 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 8, 2020 +.Dd October 2, 2021 .Dt VOP_ATTRIB 9 .Os .Sh NAME @@ -44,7 +44,7 @@ .Fn VOP_SETATTR "struct vnode *vp" "struct vattr *vap" "struct ucred *cred" .Ft int .Fn VOP_STAT "struct vnode *vp" "struct stat *sb" "struct ucred *active_cred" \ -"struct ucred *file_cred" "struct thread *td" +"struct ucred *file_cred" .Sh DESCRIPTION These entry points manipulate various attributes of a file or directory, including file permissions, owner, group, size, @@ -83,8 +83,6 @@ The attributes of the file. The user credentials of the calling thread. .It Fa file_cred The credentials installed on the file description pointing to the vnode or NOCRED. -.It Fa td -The calling thread. .El .Pp Attributes which are not being modified by diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index 331732eb4234..2539b406618f 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -801,8 +801,7 @@ timerfd_ioctl(struct file *fp, u_long cmd, void *data, } static int -timerfd_stat(struct file *fp, struct stat *st, struct ucred *active_cred, - struct thread *td) +timerfd_stat(struct file *fp, struct stat *st, struct ucred *active_cred) { return (ENXIO); diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 279f7131fc57..7a062ca36eba 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -1698,8 +1698,7 @@ out: } static int -linux_file_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, - struct thread *td) +linux_file_stat(struct file *fp, struct stat *sb, struct ucred *active_cred) { struct linux_file *filp; struct vnode *vp; @@ -1712,7 +1711,7 @@ linux_file_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, vp = filp->f_vnode; vn_lock(vp, LK_SHARED | LK_RETRY); - error = VOP_STAT(vp, sb, td->td_ucred, NOCRED, td); + error = VOP_STAT(vp, sb, curthread->td_ucred, NOCRED); VOP_UNLOCK(vp); return (error); diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c index a3d67aaa11ba..6ff0ffaf1c43 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c @@ -207,7 +207,7 @@ zfs_file_getattr(zfs_file_t *fp, zfs_file_attr_t *zfattr) td = curthread; - rc = fo_stat(fp, &sb, td->td_ucred, td); + rc = fo_stat(fp, &sb, td->td_ucred); if (rc) return (SET_ERROR(rc)); zfattr->zfa_size = sb.st_size; diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 9a327c02ee96..964d288324b4 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -1838,10 +1838,10 @@ devfs_setlabel(struct vop_setlabel_args *ap) #endif static int -devfs_stat_f(struct file *fp, struct stat *sb, struct ucred *cred, struct thread *td) +devfs_stat_f(struct file *fp, struct stat *sb, struct ucred *cred) { - return (vnops.fo_stat(fp, sb, cred, td)); + return (vnops.fo_stat(fp, sb, cred)); } static int diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index b10dcc2f9469..55c2a36955a5 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1527,7 +1527,7 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp) AUDIT_ARG_FILE(td->td_proc, fp); - error = fo_stat(fp, sbp, td->td_ucred, td); + error = fo_stat(fp, sbp, td->td_ucred); fdrop(fp, td); #ifdef __STAT_TIME_T_EXT sbp->st_atim_ext = 0; @@ -4871,8 +4871,7 @@ badfo_kqfilter(struct file *fp, struct knote *kn) } static int -badfo_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, - struct thread *td) +badfo_stat(struct file *fp, struct stat *sb, struct ucred *active_cred) { return (EBADF); diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index c9b50912a22d..ade71a848868 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -2187,8 +2187,7 @@ kqueue_poll(struct file *fp, int events, struct ucred *active_cred, /*ARGSUSED*/ static int -kqueue_stat(struct file *fp, struct stat *st, struct ucred *active_cred, - struct thread *td) +kqueue_stat(struct file *fp, struct stat *st, struct ucred *active_cred) { bzero((void *)st, sizeof *st); diff --git a/sys/kern/sys_eventfd.c b/sys/kern/sys_eventfd.c index 91c045e85faf..8ee8421296e5 100644 --- a/sys/kern/sys_eventfd.c +++ b/sys/kern/sys_eventfd.c @@ -325,8 +325,7 @@ eventfd_ioctl(struct file *fp, u_long cmd, void *data, } static int -eventfd_stat(struct file *fp, struct stat *st, struct ucred *active_cred, - struct thread *td) +eventfd_stat(struct file *fp, struct stat *st, struct ucred *active_cred) { bzero((void *)st, sizeof *st); st->st_mode = S_IFIFO; diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index ee6ccbbad322..7bd7fea28e76 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -1515,8 +1515,7 @@ locked_error: * be a natural race. */ static int -pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred, - struct thread *td) +pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred) { struct pipe *pipe; #ifdef MAC @@ -1537,7 +1536,7 @@ pipe_stat(struct file *fp, struct stat *ub, struct ucred *active_cred, /* For named pipes ask the underlying filesystem. */ if (pipe->pipe_type & PIPE_TYPE_NAMED) { - return (vnops.fo_stat(fp, ub, active_cred, td)); + return (vnops.fo_stat(fp, ub, active_cred)); } bzero(ub, sizeof(*ub)); diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 95a389c582b0..ff1a1502aa71 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -508,8 +508,7 @@ procdesc_kqfilter(struct file *fp, struct knote *kn) } static int -procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, - struct thread *td) +procdesc_stat(struct file *fp, struct stat *sb, struct ucred *active_cred) { struct procdesc *pd; struct timeval pstart, boottime; diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 8cf703ab8ebd..d4200e5618d2 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -301,8 +301,7 @@ soo_poll(struct file *fp, int events, struct ucred *active_cred, } static int -soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred, - struct thread *td) +soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred) { struct socket *so = fp->f_data; int error; diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index dbbf35cf1a12..a912634393f6 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -535,8 +535,7 @@ ptsdev_kqfilter(struct file *fp, struct knote *kn) } static int -ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, - struct thread *td) +ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred) { struct tty *tp = fp->f_data; #ifdef PTS_EXTERNAL diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index a9fb40848fbd..24ed1be6bf65 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -2537,8 +2537,7 @@ mqf_close(struct file *fp, struct thread *td) } static int -mqf_stat(struct file *fp, struct stat *st, struct ucred *active_cred, - struct thread *td) +mqf_stat(struct file *fp, struct stat *st, struct ucred *active_cred) { struct mqfs_node *pn = fp->f_data; diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c index db1d84696df0..e7c7a04f5c54 100644 --- a/sys/kern/uipc_sem.c +++ b/sys/kern/uipc_sem.c @@ -161,8 +161,7 @@ static struct fileops ksem_ops = { FEATURE(posix_sem, "POSIX semaphores"); static int -ksem_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, - struct thread *td) +ksem_stat(struct file *fp, struct stat *sb, struct ucred *active_cred) { struct ksem *ks; #ifdef MAC diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 63c4250f640f..14d808bfc166 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -538,8 +538,7 @@ shm_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred, } static int -shm_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, - struct thread *td) +shm_stat(struct file *fp, struct stat *sb, struct ucred *active_cred) { struct shmfd *shmfd; #ifdef MAC diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 82a8125ece95..29a6b34d083a 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1924,7 +1924,7 @@ restart: if (vp->v_type == VDIR && oldinum == 0) { error = EPERM; /* POSIX */ } else if (oldinum != 0 && - ((error = VOP_STAT(vp, &sb, td->td_ucred, NOCRED, td)) == 0) && + ((error = VOP_STAT(vp, &sb, td->td_ucred, NOCRED)) == 0) && sb.st_ino != oldinum) { error = EIDRM; /* Identifier removed */ } else if (fp != NULL && fp->f_vnode != vp) { @@ -2444,7 +2444,7 @@ kern_statat(struct thread *td, int flag, int fd, const char *path, error = kern_fstat(td, fd, sbp); return (error); } - error = VOP_STAT(nd.ni_vp, sbp, td->td_ucred, NOCRED, td); + error = VOP_STAT(nd.ni_vp, sbp, td->td_ucred, NOCRED); if (error == 0) { if (__predict_false(hook != NULL)) hook(nd.ni_vp, sbp); @@ -4663,7 +4663,7 @@ kern_fhstat(struct thread *td, struct fhandle fh, struct stat *sb) vfs_unbusy(mp); if (error != 0) return (error); - error = VOP_STAT(vp, sb, td->td_ucred, NOCRED, td); + error = VOP_STAT(vp, sb, td->td_ucred, NOCRED); vput(vp); return (error); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 2c25a25da6c6..d6c472995489 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1670,14 +1670,13 @@ vn_truncate_locked(struct vnode *vp, off_t length, bool sync, * File table vnode stat routine. */ int -vn_statfile(struct file *fp, struct stat *sb, struct ucred *active_cred, - struct thread *td) +vn_statfile(struct file *fp, struct stat *sb, struct ucred *active_cred) { struct vnode *vp = fp->f_vnode; int error; vn_lock(vp, LK_SHARED | LK_RETRY); - error = VOP_STAT(vp, sb, active_cred, fp->f_cred, td); + error = VOP_STAT(vp, sb, active_cred, fp->f_cred); VOP_UNLOCK(vp); return (error); diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index ff57d1c9a28e..d10758019b87 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -193,7 +193,6 @@ vop_stat { OUT struct stat *sb; IN struct ucred *active_cred; IN struct ucred *file_cred; - IN struct thread *td; }; diff --git a/sys/sys/file.h b/sys/sys/file.h index 8a790a25fc6b..5a6f0b1d2071 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -108,7 +108,7 @@ typedef int fo_poll_t(struct file *fp, int events, struct ucred *active_cred, struct thread *td); typedef int fo_kqfilter_t(struct file *fp, struct knote *kn); typedef int fo_stat_t(struct file *fp, struct stat *sb, - struct ucred *active_cred, struct thread *td); + struct ucred *active_cred); typedef int fo_close_t(struct file *fp, struct thread *td); typedef int fo_chmod_t(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td); @@ -369,11 +369,10 @@ fo_poll(struct file *fp, int events, struct ucred *active_cred, } static __inline int -fo_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, - struct thread *td) +fo_stat(struct file *fp, struct stat *sb, struct ucred *active_cred) { - return ((*fp->f_ops->fo_stat)(fp, sb, active_cred, td)); + return ((*fp->f_ops->fo_stat)(fp, sb, active_cred)); } static __inline int diff --git a/sys/sys/param.h b/sys/sys/param.h index 9a016e35323e..50d861a61985 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400036 +#define __FreeBSD_version 1400037 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 81f3f3d5489c..a9b57dd4c25d 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -962,7 +962,7 @@ void vop_rename_fail(struct vop_rename_args *ap); #define vop_stat_helper_post(ap, error) ({ \ int _error = (error); \ - if (priv_check_cred_vfs_generation(ap->a_td->td_ucred)) \ + if (priv_check_cred_vfs_generation(ap->a_active_cred)) \ ap->a_sb->st_gen = 0; \ _error; \ })