Merge nfsd's cut&paste copy of namei with the master one.
This commit is contained in:
parent
8d22bcb871
commit
7f3a76e260
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: vfs_lookup.c,v 1.134 2011/04/11 01:35:00 dholland Exp $ */
|
/* $NetBSD: vfs_lookup.c,v 1.135 2011/04/11 01:35:55 dholland Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1982, 1986, 1989, 1993
|
* Copyright (c) 1982, 1986, 1989, 1993
|
||||||
@ -37,7 +37,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.134 2011/04/11 01:35:00 dholland Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.135 2011/04/11 01:35:55 dholland Exp $");
|
||||||
|
|
||||||
#include "opt_magiclinks.h"
|
#include "opt_magiclinks.h"
|
||||||
|
|
||||||
@ -1372,72 +1372,21 @@ namei(struct nameidata *ndp)
|
|||||||
* called from a different place in a different context. For now I
|
* called from a different place in a different context. For now I
|
||||||
* want to be able to shuffle code in from one call site without
|
* want to be able to shuffle code in from one call site without
|
||||||
* affecting the other.
|
* affecting the other.
|
||||||
|
*
|
||||||
|
* It turns out that the "main" version was a cut and pasted copy of
|
||||||
|
* namei with a few changes; the "index" version on the other hand
|
||||||
|
* always takes a single component and is an elaborate form of calling
|
||||||
|
* VOP_LOOKUP once.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
|
||||||
do_lookup_for_nfsd(struct namei_state *state, struct vnode *forcecwd,
|
|
||||||
int neverfollow, int inhibitmagic)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
|
|
||||||
struct nameidata *ndp = state->ndp;
|
|
||||||
//struct componentname *cnp = state->cnp;
|
|
||||||
|
|
||||||
error = namei_start(state, forcecwd);
|
|
||||||
if (error) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
|
|
||||||
error = do_lookup(state, state->namei_startdir);
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
if (ndp->ni_dvp) {
|
|
||||||
vput(ndp->ni_dvp);
|
|
||||||
}
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check for encountering a symbolic link
|
|
||||||
*/
|
|
||||||
if (namei_atsymlink(state)) {
|
|
||||||
if (neverfollow) {
|
|
||||||
error = EINVAL;
|
|
||||||
} else {
|
|
||||||
error = namei_follow(state, inhibitmagic);
|
|
||||||
}
|
|
||||||
if (error) {
|
|
||||||
KASSERT(ndp->ni_dvp != ndp->ni_vp);
|
|
||||||
vput(state->ndp->ni_vp);
|
|
||||||
vput(state->ndp->ni_dvp);
|
|
||||||
state->ndp->ni_vp = NULL;
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((state->cnp->cn_flags & LOCKPARENT) == 0 && state->ndp->ni_dvp) {
|
|
||||||
if (state->ndp->ni_dvp == state->ndp->ni_vp) {
|
|
||||||
vrele(state->ndp->ni_dvp);
|
|
||||||
} else {
|
|
||||||
vput(state->ndp->ni_dvp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
lookup_for_nfsd(struct nameidata *ndp, struct vnode *dp, int neverfollow)
|
lookup_for_nfsd(struct nameidata *ndp, struct vnode *forcecwd, int neverfollow)
|
||||||
{
|
{
|
||||||
struct namei_state state;
|
struct namei_state state;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
namei_init(&state, ndp);
|
namei_init(&state, ndp);
|
||||||
error = do_lookup_for_nfsd(&state, dp, neverfollow, 1/*inhibitmagic*/);
|
error = do_namei(&state, forcecwd, neverfollow, 1/*inhibitmagic*/);
|
||||||
namei_cleanup(&state);
|
namei_cleanup(&state);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
@ -1450,8 +1399,8 @@ lookup_for_nfsd_index(struct nameidata *ndp, struct vnode *startdir)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: the name sent in here is not/should not be allowed to
|
* Note: the name sent in here (is not|should not be) allowed
|
||||||
* contain a slash.
|
* to contain a slash.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ndp->ni_pathlen = strlen(ndp->ni_pathbuf->pb_path) + 1;
|
ndp->ni_pathlen = strlen(ndp->ni_pathbuf->pb_path) + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user