aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/vfs_lookup.c
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-03-01 21:54:28 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-03-01 21:54:28 +0000
commit2f423bce54f2bb026508df7404978cf9cee7abc2 (patch)
tree4ed077a0a8881665fd27751f88b16419194bb686 /sys/kern/vfs_lookup.c
parent8d03b99b9dafe92896f405c79f846667637c0194 (diff)
downloadsrc-2f423bce54f2bb026508df7404978cf9cee7abc2.tar.gz
src-2f423bce54f2bb026508df7404978cf9cee7abc2.zip
Notes
Diffstat (limited to 'sys/kern/vfs_lookup.c')
-rw-r--r--sys/kern/vfs_lookup.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index bdfdaa3d0013..999747539d4f 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -254,7 +254,7 @@ namei_cleanup_cnp(struct componentname *cnp)
}
static int
-namei_handle_root(struct nameidata *ndp, struct vnode **dpp, u_int n)
+namei_handle_root(struct nameidata *ndp, struct vnode **dpp)
{
struct componentname *cnp;
@@ -276,7 +276,7 @@ namei_handle_root(struct nameidata *ndp, struct vnode **dpp, u_int n)
ndp->ni_pathlen--;
}
*dpp = ndp->ni_rootdir;
- vrefactn(*dpp, n);
+ vrefact(*dpp);
return (0);
}
@@ -407,29 +407,15 @@ namei(struct nameidata *ndp)
cnp->cn_nameptr = cnp->cn_pnbuf;
if (cnp->cn_pnbuf[0] == '/') {
ndp->ni_resflags |= NIRES_ABS;
- error = namei_handle_root(ndp, &dp, 2);
- if (error != 0) {
- /*
- * Simplify error handling, we should almost never be
- * here.
- */
- vrefact(ndp->ni_rootdir);
- }
+ error = namei_handle_root(ndp, &dp);
} else {
if (ndp->ni_startdir != NULL) {
- vrefact(ndp->ni_rootdir);
dp = ndp->ni_startdir;
startdir_used = 1;
} else if (ndp->ni_dirfd == AT_FDCWD) {
dp = pwd->pwd_cdir;
- if (dp == ndp->ni_rootdir) {
- vrefactn(dp, 2);
- } else {
- vrefact(ndp->ni_rootdir);
- vrefact(dp);
- }
+ vrefact(dp);
} else {
- vrefact(ndp->ni_rootdir);
rights = ndp->ni_rightsneeded;
cap_rights_set_one(&rights, CAP_LOOKUP);
@@ -530,7 +516,6 @@ namei(struct nameidata *ndp)
* If not a symbolic link, we're done.
*/
if ((cnp->cn_flags & ISSYMLINK) == 0) {
- vrele(ndp->ni_rootdir);
if ((cnp->cn_flags & (SAVENAME | SAVESTART)) == 0) {
namei_cleanup_cnp(cnp);
} else
@@ -605,7 +590,7 @@ namei(struct nameidata *ndp)
cnp->cn_nameptr = cnp->cn_pnbuf;
if (*(cnp->cn_nameptr) == '/') {
vrele(dp);
- error = namei_handle_root(ndp, &dp, 1);
+ error = namei_handle_root(ndp, &dp);
if (error != 0)
goto out;
}
@@ -614,7 +599,6 @@ namei(struct nameidata *ndp)
ndp->ni_vp = NULL;
vrele(ndp->ni_dvp);
out:
- vrele(ndp->ni_rootdir);
MPASS(error != 0);
namei_cleanup_cnp(cnp);
nameicap_cleanup(ndp, true);