aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2024-01-04 13:11:54 +0000
committerMark Johnston <markj@FreeBSD.org>2024-01-11 14:19:46 +0000
commitc2b07a75af217f11a96de83c31649e4cf567a9d9 (patch)
treed89b0a6fd71cf0e9b2c3d11d16d9523fa76536eb
parent208e68be1faed42ede97431476b33fc88cfd2429 (diff)
downloadsrc-c2b07a75af217f11a96de83c31649e4cf567a9d9.tar.gz
src-c2b07a75af217f11a96de83c31649e4cf567a9d9.zip
file: Remove the fd parameter to fgetvp_lookup() and fgetvp_lookup_smr()
The fd is always obtained from nameidata, so just fetch it from there instead. No functional change intended. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43257 (cherry picked from commit 55edc40e0c7543c6ea08a28d828bcbf0c8b5dad9)
-rw-r--r--sys/kern/kern_descrip.c10
-rw-r--r--sys/kern/vfs_cache.c2
-rw-r--r--sys/kern/vfs_lookup.c2
-rw-r--r--sys/sys/file.h4
4 files changed, 11 insertions, 7 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 6ed824e229d6..fe6928e421db 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -2964,7 +2964,7 @@ fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
#ifdef CAPABILITIES
int
-fgetvp_lookup_smr(int fd, struct nameidata *ndp, struct vnode **vpp, bool *fsearch)
+fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, bool *fsearch)
{
const struct filedescent *fde;
const struct fdescenttbl *fdt;
@@ -2974,9 +2974,11 @@ fgetvp_lookup_smr(int fd, struct nameidata *ndp, struct vnode **vpp, bool *fsear
const cap_rights_t *haverights;
cap_rights_t rights;
seqc_t seq;
+ int fd;
VFS_SMR_ASSERT_ENTERED();
+ fd = ndp->ni_dirfd;
rights = *ndp->ni_rightsneeded;
cap_rights_set_one(&rights, CAP_LOOKUP);
@@ -3030,15 +3032,17 @@ fgetvp_lookup_smr(int fd, struct nameidata *ndp, struct vnode **vpp, bool *fsear
}
#else
int
-fgetvp_lookup_smr(int fd, struct nameidata *ndp, struct vnode **vpp, bool *fsearch)
+fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, bool *fsearch)
{
const struct fdescenttbl *fdt;
struct filedesc *fdp;
struct file *fp;
struct vnode *vp;
+ int fd;
VFS_SMR_ASSERT_ENTERED();
+ fd = ndp->ni_dirfd;
fdp = curproc->p_fd;
fdt = fdp->fd_files;
if (__predict_false((u_int)fd >= fdt->fdt_nfiles))
@@ -3066,7 +3070,7 @@ fgetvp_lookup_smr(int fd, struct nameidata *ndp, struct vnode **vpp, bool *fsear
#endif
int
-fgetvp_lookup(int fd, struct nameidata *ndp, struct vnode **vpp)
+fgetvp_lookup(struct nameidata *ndp, struct vnode **vpp)
{
struct thread *td;
struct file *fp;
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 8917666950c1..e3ab80f94482 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -4422,7 +4422,7 @@ cache_fplookup_dirfd(struct cache_fpl *fpl, struct vnode **vpp)
ndp = fpl->ndp;
cnp = fpl->cnp;
- error = fgetvp_lookup_smr(ndp->ni_dirfd, ndp, vpp, &fsearch);
+ error = fgetvp_lookup_smr(ndp, vpp, &fsearch);
if (__predict_false(error != 0)) {
return (cache_fpl_aborted(fpl));
}
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 922adda33b94..6c83746eaf8b 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -360,7 +360,7 @@ namei_setup(struct nameidata *ndp, struct vnode **dpp, struct pwd **pwdp)
if (cnp->cn_flags & AUDITVNODE2)
AUDIT_ARG_ATFD2(ndp->ni_dirfd);
- error = fgetvp_lookup(ndp->ni_dirfd, ndp, dpp);
+ error = fgetvp_lookup(ndp, dpp);
}
if (error == 0 && (*dpp)->v_type != VDIR &&
(cnp->cn_pnbuf[0] != '\0' ||
diff --git a/sys/sys/file.h b/sys/sys/file.h
index 214e8a31c969..dcc739e2e9de 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -291,8 +291,8 @@ int fgetvp_read(struct thread *td, int fd, cap_rights_t *rightsp,
struct vnode **vpp);
int fgetvp_write(struct thread *td, int fd, cap_rights_t *rightsp,
struct vnode **vpp);
-int fgetvp_lookup_smr(int fd, struct nameidata *ndp, struct vnode **vpp, bool *fsearch);
-int fgetvp_lookup(int fd, struct nameidata *ndp, struct vnode **vpp);
+int fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, bool *fsearch);
+int fgetvp_lookup(struct nameidata *ndp, struct vnode **vpp);
static __inline __result_use_check bool
fhold(struct file *fp)