Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Improve namei_follow to handle the search dir as an...
details: https://anonhg.NetBSD.org/src/rev/41c7c0b6b884
branches: trunk
changeset: 764054:41c7c0b6b884
user: dholland <dholland%NetBSD.org@localhost>
date: Mon Apr 11 01:38:24 2011 +0000
description:
Improve namei_follow to handle the search dir as an argument instead
of in the global state.
diffstat:
sys/kern/vfs_lookup.c | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diffs (75 lines):
diff -r 61c0e2871348 -r 41c7c0b6b884 sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c Mon Apr 11 01:38:10 2011 +0000
+++ b/sys/kern/vfs_lookup.c Mon Apr 11 01:38:24 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_lookup.c,v 1.140 2011/04/11 01:38:10 dholland Exp $ */
+/* $NetBSD: vfs_lookup.c,v 1.141 2011/04/11 01:38:24 dholland Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.140 2011/04/11 01:38:10 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.141 2011/04/11 01:38:24 dholland Exp $");
#include "opt_magiclinks.h"
@@ -650,7 +650,9 @@
* Follow a symlink.
*/
static inline int
-namei_follow(struct namei_state *state, int inhibitmagic)
+namei_follow(struct namei_state *state, int inhibitmagic,
+ struct vnode *searchdir,
+ struct vnode **newsearchdir_ret)
{
struct nameidata *ndp = state->ndp;
struct componentname *cnp = state->cnp;
@@ -715,26 +717,27 @@
memcpy(ndp->ni_pnbuf, cp, ndp->ni_pathlen);
PNBUF_PUT(cp);
vput(ndp->ni_vp);
- state->namei_startdir = ndp->ni_dvp;
+ searchdir = ndp->ni_dvp;
/*
* Check if root directory should replace current directory.
*/
if (ndp->ni_pnbuf[0] == '/') {
- vput(state->namei_startdir);
+ vput(searchdir);
/* Keep absolute symbolic links inside emulation root */
- state->namei_startdir = ndp->ni_erootdir;
- if (state->namei_startdir == NULL ||
+ searchdir = ndp->ni_erootdir;
+ if (searchdir == NULL ||
(ndp->ni_pnbuf[1] == '.'
&& ndp->ni_pnbuf[2] == '.'
&& ndp->ni_pnbuf[3] == '/')) {
ndp->ni_erootdir = NULL;
- state->namei_startdir = ndp->ni_rootdir;
+ searchdir = ndp->ni_rootdir;
}
- vref(state->namei_startdir);
- vn_lock(state->namei_startdir, LK_EXCLUSIVE | LK_RETRY);
+ vref(searchdir);
+ vn_lock(searchdir, LK_EXCLUSIVE | LK_RETRY);
}
+ *newsearchdir_ret = searchdir;
return 0;
}
@@ -1173,7 +1176,9 @@
if (neverfollow) {
error = EINVAL;
} else {
- error = namei_follow(state, inhibitmagic);
+ error = namei_follow(state, inhibitmagic,
+ state->namei_startdir,
+ &state->namei_startdir);
}
if (error) {
KASSERT(ndp->ni_dvp != ndp->ni_vp);
Home |
Main Index |
Thread Index |
Old Index