diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -606,6 +606,7 @@ .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, .sv_set_fork_retval = linux_set_fork_retval, + .sv_trans_stat = translate_vnhook_major_minor, }; static int diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -823,6 +823,7 @@ .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, .sv_set_fork_retval = linux32_set_fork_retval, + .sv_trans_stat = translate_vnhook_major_minor, }; static int diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -403,6 +403,7 @@ .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, + .sv_trans_stat = translate_vnhook_major_minor, }; static int diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2285,7 +2285,7 @@ int error; error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, - &sb, NULL); + &sb); if (error) return (error); copy_ostat(&sb, &sb32); @@ -2334,7 +2334,7 @@ int error; error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE, - &ub, NULL); + &ub); if (error) return (error); copy_stat(&ub, &ub32); @@ -2351,7 +2351,7 @@ int error; error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, - UIO_USERSPACE, &sb, NULL); + UIO_USERSPACE, &sb); if (error) return (error); copy_ostat(&sb, &sb32); @@ -2470,7 +2470,7 @@ int error; error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, - &sb, NULL); + &sb); if (error != 0) return (error); error = freebsd11_cvtstat32(&sb, &sb32); @@ -2505,7 +2505,7 @@ int error; error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE, - &sb, NULL); + &sb); if (error != 0) return (error); error = freebsd11_cvtstat32(&sb, &sb32); @@ -2523,7 +2523,7 @@ int error; error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, - UIO_USERSPACE, &sb, NULL); + UIO_USERSPACE, &sb); if (error != 0) return (error); error = freebsd11_cvtstat32(&sb, &sb32); @@ -2596,7 +2596,7 @@ int error; error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, - &sb, NULL); + &sb); if (error != 0) return (error); error = freebsd11_cvtnstat32(&sb, &nsb); @@ -2614,7 +2614,7 @@ int error; error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, - UIO_USERSPACE, &sb, NULL); + UIO_USERSPACE, &sb); if (error != 0) return (error); error = freebsd11_cvtnstat32(&sb, &nsb); diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -667,7 +667,7 @@ if (error == EPERM) { /* Introduce POSIX noncompliant behaviour of Linux */ if (kern_statat(td, 0, AT_FDCWD, args->path, - UIO_USERSPACE, &st, NULL) == 0) { + UIO_USERSPACE, &st) == 0) { if (S_ISDIR(st.st_mode)) error = EISDIR; } @@ -691,7 +691,7 @@ if (error == EPERM && !(args->flag & LINUX_AT_REMOVEDIR)) { /* Introduce POSIX noncompliant behaviour of Linux */ if (kern_statat(td, AT_SYMLINK_NOFOLLOW, dfd, path, - pathseg, &st, NULL) == 0 && S_ISDIR(st.st_mode)) + pathseg, &st) == 0 && S_ISDIR(st.st_mode)) error = EISDIR; } return (error); diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -58,8 +58,7 @@ enum uio_seg pathseg, struct stat *sbp) { - return (kern_statat(td, flag, fd, path, pathseg, sbp, - translate_vnhook_major_minor)); + return (kern_statat(td, flag, fd, path, pathseg, sbp)); } #ifdef LINUX_LEGACY_SYSCALLS diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -610,6 +610,7 @@ .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, .sv_set_fork_retval = linux_set_fork_retval, + .sv_trans_stat = translate_vnhook_major_minor, }; INIT_SYSENTVEC(aout_sysvec, &linux_sysvec); @@ -654,6 +655,7 @@ .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, .sv_set_fork_retval = linux_set_fork_retval, + .sv_trans_stat = translate_vnhook_major_minor, }; static int diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c --- a/sys/kern/vfs_mountroot.c +++ b/sys/kern/vfs_mountroot.c @@ -594,7 +594,7 @@ free(tok, M_TEMP); /* Get file status. */ - error = kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &sb, NULL); + error = kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &sb); if (error) goto out; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -75,6 +75,7 @@ #include #include #include +#include #ifdef KTRACE #include #endif @@ -2194,7 +2195,7 @@ int error; error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, - &sb, NULL); + &sb); if (error != 0) return (error); cvtstat(&sb, &osb); @@ -2218,7 +2219,7 @@ int error; error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, - UIO_USERSPACE, &sb, NULL); + UIO_USERSPACE, &sb); if (error != 0) return (error); cvtstat(&sb, &osb); @@ -2337,7 +2338,7 @@ int error; error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, - &sb, NULL); + &sb); if (error != 0) return (error); error = freebsd11_cvtstat(&sb, &osb); @@ -2354,7 +2355,7 @@ int error; error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, - UIO_USERSPACE, &sb, NULL); + UIO_USERSPACE, &sb); if (error != 0) return (error); error = freebsd11_cvtstat(&sb, &osb); @@ -2391,7 +2392,7 @@ int error; error = kern_statat(td, uap->flag, uap->fd, uap->path, - UIO_USERSPACE, &sb, NULL); + UIO_USERSPACE, &sb); if (error != 0) return (error); error = freebsd11_cvtstat(&sb, &osb); @@ -2419,7 +2420,7 @@ int error; error = kern_statat(td, uap->flag, uap->fd, uap->path, - UIO_USERSPACE, &sb, NULL); + UIO_USERSPACE, &sb); if (error == 0) error = copyout(&sb, uap->buf, sizeof (sb)); return (error); @@ -2427,9 +2428,9 @@ int kern_statat(struct thread *td, int flag, int fd, const char *path, - enum uio_seg pathseg, struct stat *sbp, - void (*hook)(struct vnode *vp, struct stat *sbp)) + enum uio_seg pathseg, struct stat *sbp) { + struct proc *p = td->td_proc; struct nameidata nd; int error; @@ -2448,9 +2449,9 @@ return (error); } error = VOP_STAT(nd.ni_vp, sbp, td->td_ucred, NOCRED); - if (__predict_false(hook != NULL)) { + if (__predict_false(p->p_sysent->sv_trans_stat != NULL)) { if (error == 0) { - hook(nd.ni_vp, sbp); + (p->p_sysent->sv_trans_stat)(nd.ni_vp, sbp); } } NDFREE_PNBUF(&nd); @@ -2516,7 +2517,7 @@ int error; error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, - &sb, NULL); + &sb); if (error != 0) return (error); error = freebsd11_cvtnstat(&sb, &nsb); @@ -2542,7 +2543,7 @@ int error; error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, - UIO_USERSPACE, &sb, NULL); + UIO_USERSPACE, &sb); if (error != 0) return (error); error = freebsd11_cvtnstat(&sb, &nsb); diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -319,8 +319,7 @@ union sigval *value); int kern_socket(struct thread *td, int domain, int type, int protocol); int kern_statat(struct thread *td, int flag, int fd, const char *path, - enum uio_seg pathseg, struct stat *sbp, - void (*hook)(struct vnode *vp, struct stat *sbp)); + enum uio_seg pathseg, struct stat *sbp); int kern_specialfd(struct thread *td, int type, void *arg); int kern_statfs(struct thread *td, const char *path, enum uio_seg pathseg, struct statfs *buf); diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -96,6 +96,7 @@ struct image_params; struct proc; struct __sigset; +struct stat; struct trapframe; struct vnode; struct note_info_list; @@ -159,6 +160,7 @@ /* Only used on x86 */ struct regset **sv_regset_begin; struct regset **sv_regset_end; + void (*sv_trans_stat)(struct vnode *, struct stat *); }; #define SV_ILP32 0x000100 /* 32-bit executable. */