vfs: remove thread argument from VOP_STAT

and fo_stat.
This commit is contained in:
Mateusz Guzik 2021-10-02 00:25:39 +02:00
parent b4a58fbf64
commit 2b68eb8e1d
21 changed files with 30 additions and 47 deletions

View File

@ -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

View File

@ -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);

View File

@ -1698,8 +1698,7 @@ linux_file_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size
}
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);

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -1515,8 +1515,7 @@ pipe_poll(struct file *fp, int events, struct ucred *active_cred,
* 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));

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -1924,7 +1924,7 @@ kern_funlinkat(struct thread *td, int dfd, const char *path, int fd,
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);
}

View File

@ -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);

View File

@ -193,7 +193,6 @@ vop_stat {
OUT struct stat *sb;
IN struct ucred *active_cred;
IN struct ucred *file_cred;
IN struct thread *td;
};

View File

@ -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

View File

@ -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,

View File

@ -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; \
})