Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jan 2024 14:32:37 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: c2b07a75af21 - stable/14 - file: Remove the fd parameter to fgetvp_lookup() and fgetvp_lookup_smr()
Message-ID:  <202401111432.40BEWbAg024314@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=c2b07a75af217f11a96de83c31649e4cf567a9d9

commit c2b07a75af217f11a96de83c31649e4cf567a9d9
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-04 13:11:54 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-11 14:19:46 +0000

    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)
---
 sys/kern/kern_descrip.c | 10 +++++++---
 sys/kern/vfs_cache.c    |  2 +-
 sys/kern/vfs_lookup.c   |  2 +-
 sys/sys/file.h          |  4 ++--
 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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401111432.40BEWbAg024314>