Module Name: src Committed By: dholland Date: Sun Sep 27 17:19:07 UTC 2009
Modified Files: src/share/man/man9: namei.9 src/sys/kern: vfs_lookup.c src/sys/nfs: nfs_serv.c nfs_srvsubs.c src/sys/sys: namei.src Log Message: Rename lookup() to lookup_for_nfsd(), to make it clear just whose private backdoor entry point this is. Also, clone the lookup_for_nfsd() entry point as lookup_for_nfsd_index(), for use by a different call site in nfsd that does different unclean things with nameidata. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/share/man/man9/namei.9 cvs rdiff -u -r1.118 -r1.119 src/sys/kern/vfs_lookup.c cvs rdiff -u -r1.146 -r1.147 src/sys/nfs/nfs_serv.c cvs rdiff -u -r1.3 -r1.4 src/sys/nfs/nfs_srvsubs.c cvs rdiff -u -r1.11 -r1.12 src/sys/sys/namei.src Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man9/namei.9 diff -u src/share/man/man9/namei.9:1.21 src/share/man/man9/namei.9:1.22 --- src/share/man/man9/namei.9:1.21 Mon Jun 29 06:02:09 2009 +++ src/share/man/man9/namei.9 Sun Sep 27 17:19:07 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: namei.9,v 1.21 2009/06/29 06:02:09 wiz Exp $ +.\" $NetBSD: namei.9,v 1.22 2009/09/27 17:19:07 dholland Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -32,7 +32,8 @@ .Os .Sh NAME .Nm namei , -.Nm lookup , +.Nm lookup_for_nfsd , +.Nm lookup_for_nfsd_index , .Nm relookup , .Nm NDINIT , .Nm namei_simple_kernel , @@ -45,7 +46,9 @@ .Ft int .Fn namei "struct nameidata *ndp" .Ft int -.Fn lookup "struct nameidata *ndp" +.Fn lookup_for_nfsd "struct nameidata *ndp" +.Ft int +.Fn lookup_for_nfsd_index "struct nameidata *ndp" .Ft int .Fn relookup "struct vnode *dvp" "struct vnode **vpp" \ "struct componentname *cnp" @@ -249,21 +252,22 @@ occur at the end of the name translation process. Symbolic links are always followed for all other pathname components other than the last. -.It Fn lookup "ndp" -Search for a pathname. -This is a very central and rather complicated routine. .Pp -The pathname is specified by -.Em ndp-\*[Gt]ni_dirp -and is of length -.Em ndp-\*[Gt]ni_pathlen . -The starting directory is taken from -.Em ndp-\*[Gt]ni_startdir . -The pathname is descended until done, or a symbolic link is -encountered. +Historically +.Nm +had a sub-function called +.Fn lookup . +This function processed a pathname until either running out of +material or encountering a symbolic link. +.Nm +worked by first setting up the start directory +.Em ndp-\*[Gt]ni_startdir +and then calling +.Fn lookup +repeatedly. .Pp The semantics of -.Fn lookup +.Nm are altered by the operation specified by .Em ndp-\*[Gt]ni_cnd.cn_nameiop . When @@ -278,6 +282,31 @@ is returned locked in .Em ndp-\*[Gt]ni_vp , otherwise it is returned unlocked. +.Pp +As of this writing the internal function +.Fn do_lookup +is comparable to the historic +.Fn lookup +but this code is slated for refactoring. +.It Fn lookup_for_nfsd "ndp" +This is a private entry point into +.Nm +used by the NFS server code. +Its semantics are similar to the historic +.Fn lookup +function described above. +It should not be used by new code. +.It Fn lookup_for_nfsd_index "ndp" +This is a (second) private entry point into +.Nm +used by the NFS server code. +Its semantics are similar to the historic +.Fn lookup +function described above. +It should not be used by new code. +(For now it differs from the preceding private entry point in that it +has a different call site with a different context and different +custom initialization of what ought to be private namei state.) .It Fn relookup "dvp" "vpp" "cnp" Reacquire a path name component is a directory. This is a quicker way to lookup a pathname component when the parent Index: src/sys/kern/vfs_lookup.c diff -u src/sys/kern/vfs_lookup.c:1.118 src/sys/kern/vfs_lookup.c:1.119 --- src/sys/kern/vfs_lookup.c:1.118 Sun Aug 9 07:27:54 2009 +++ src/sys/kern/vfs_lookup.c Sun Sep 27 17:19:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_lookup.c,v 1.118 2009/08/09 07:27:54 dholland Exp $ */ +/* $NetBSD: vfs_lookup.c,v 1.119 2009/09/27 17:19:07 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.118 2009/08/09 07:27:54 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.119 2009/09/27 17:19:07 dholland Exp $"); #include "opt_magiclinks.h" @@ -546,7 +546,7 @@ } cnp->cn_nameptr = cnp->cn_pnbuf; ndp->ni_startdir = state->namei_startdir; - error = lookup(ndp); + error = do_lookup(state); if (error != 0) { /* XXX this should use namei_end() */ if (ndp->ni_dvp) { @@ -1149,10 +1149,30 @@ } /* - * Externally visible interface used by nfsd (bletch, yuk, XXX) + * Externally visible interfaces used by nfsd (bletch, yuk, XXX) + * + * The "index" version differs from the "main" version in that it's + * 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 + * affecting the other. */ + +int +lookup_for_nfsd(struct nameidata *ndp) +{ + struct namei_state state; + int error; + + /* For now at least we don't have to frob the state */ + namei_init(&state, ndp); + error = do_lookup(&state); + namei_cleanup(&state); + + return error; +} + int -lookup(struct nameidata *ndp) +lookup_for_nfsd_index(struct nameidata *ndp) { struct namei_state state; int error; Index: src/sys/nfs/nfs_serv.c diff -u src/sys/nfs/nfs_serv.c:1.146 src/sys/nfs/nfs_serv.c:1.147 --- src/sys/nfs/nfs_serv.c:1.146 Sat May 23 15:31:21 2009 +++ src/sys/nfs/nfs_serv.c Sun Sep 27 17:19:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_serv.c,v 1.146 2009/05/23 15:31:21 ad Exp $ */ +/* $NetBSD: nfs_serv.c,v 1.147 2009/09/27 17:19:07 dholland Exp $ */ /* * Copyright (c) 1989, 1993 @@ -55,7 +55,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.146 2009/05/23 15:31:21 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.147 2009/09/27 17:19:07 dholland Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -429,7 +429,7 @@ nfs_pub.np_index; ind.ni_startdir = nd.ni_vp; VREF(ind.ni_startdir); - error = lookup(&ind); + error = lookup_for_nfsd_index(&ind); if (!error) { /* * Found an index file. Get rid of Index: src/sys/nfs/nfs_srvsubs.c diff -u src/sys/nfs/nfs_srvsubs.c:1.3 src/sys/nfs/nfs_srvsubs.c:1.4 --- src/sys/nfs/nfs_srvsubs.c:1.3 Mon May 4 06:05:19 2009 +++ src/sys/nfs/nfs_srvsubs.c Sun Sep 27 17:19:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_srvsubs.c,v 1.3 2009/05/04 06:05:19 yamt Exp $ */ +/* $NetBSD: nfs_srvsubs.c,v 1.4 2009/09/27 17:19:07 dholland Exp $ */ /* * Copyright (c) 1989, 1993 @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.3 2009/05/04 06:05:19 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.4 2009/09/27 17:19:07 dholland Exp $"); #include <sys/param.h> #include <sys/proc.h> @@ -264,7 +264,7 @@ /* * And call lookup() to do the real work */ - error = lookup(ndp); + error = lookup_for_nfsd(ndp); if (error) { if (ndp->ni_dvp) { vput(ndp->ni_dvp); Index: src/sys/sys/namei.src diff -u src/sys/sys/namei.src:1.11 src/sys/sys/namei.src:1.12 --- src/sys/sys/namei.src:1.11 Mon Jun 29 05:00:14 2009 +++ src/sys/sys/namei.src Sun Sep 27 17:19:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: namei.src,v 1.11 2009/06/29 05:00:14 dholland Exp $ */ +/* $NetBSD: namei.src,v 1.12 2009/09/27 17:19:07 dholland Exp $ */ /* * Copyright (c) 1985, 1989, 1991, 1993 @@ -228,7 +228,8 @@ int namei(struct nameidata *); uint32_t namei_hash(const char *, const char **); -int lookup(struct nameidata *); +int lookup_for_nfsd(struct nameidata *); +int lookup_for_nfsd_index(struct nameidata *); int relookup(struct vnode *, struct vnode **, struct componentname *); void cache_purge1(struct vnode *, const struct componentname *, int); #define PURGE_PARENTS 1