lookup converted to new form
authorJohn Heidemann <heideman@ucbvax.Berkeley.EDU>
Thu, 23 Jan 1992 01:39:42 +0000 (17:39 -0800)
committerJohn Heidemann <heideman@ucbvax.Berkeley.EDU>
Thu, 23 Jan 1992 01:39:42 +0000 (17:39 -0800)
SCCS-vsn: sys/kern/vfs_lookup.c 7.35
SCCS-vsn: sys/kern/vfs_subr.c 7.66
SCCS-vsn: sys/kern/vfs_vnops.c 7.35
SCCS-vsn: sys/kern/vfs_syscalls.c 7.76
SCCS-vsn: sys/kern/uipc_usrreq.c 7.29
SCCS-vsn: sys/kern/vfs_cache.c 7.9
SCCS-vsn: sys/ufs/ffs/ufs_lookup.c 7.37
SCCS-vsn: sys/ufs/ufs/ufs_lookup.c 7.37
SCCS-vsn: sys/ufs/ffs/ufs_vnops.c 7.72
SCCS-vsn: sys/ufs/ufs/ufs_vnops.c 7.72
SCCS-vsn: sys/ufs/ffs/ufs_extern.h 7.3
SCCS-vsn: sys/ufs/ufs/ufs_extern.h 7.3
SCCS-vsn: sys/nfs/nfsnode.h 7.17
SCCS-vsn: sys/nfs/nfs_subs.c 7.46
SCCS-vsn: sys/nfs/nfs_serv.c 7.44
SCCS-vsn: sys/nfs/nfs_node.c 7.37
SCCS-vsn: sys/nfs/nfs_vnops.c 7.66

17 files changed:
usr/src/sys/kern/uipc_usrreq.c
usr/src/sys/kern/vfs_cache.c
usr/src/sys/kern/vfs_lookup.c
usr/src/sys/kern/vfs_subr.c
usr/src/sys/kern/vfs_syscalls.c
usr/src/sys/kern/vfs_vnops.c
usr/src/sys/nfs/nfs_node.c
usr/src/sys/nfs/nfs_serv.c
usr/src/sys/nfs/nfs_subs.c
usr/src/sys/nfs/nfs_vnops.c
usr/src/sys/nfs/nfsnode.h
usr/src/sys/ufs/ffs/ufs_extern.h
usr/src/sys/ufs/ffs/ufs_lookup.c
usr/src/sys/ufs/ffs/ufs_vnops.c
usr/src/sys/ufs/ufs/ufs_extern.h
usr/src/sys/ufs/ufs/ufs_lookup.c
usr/src/sys/ufs/ufs/ufs_vnops.c

index 5c3fd00..71efd72 100644 (file)
@@ -2,7 +2,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)uipc_usrreq.c       7.28 (Berkeley) %G%
+ *     @(#)uipc_usrreq.c       7.29 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -363,7 +363,7 @@ unp_bind(unp, nam, p)
                return (error);
        vp = ndp->ni_vp;
        if (vp != NULL) {
                return (error);
        vp = ndp->ni_vp;
        if (vp != NULL) {
-               VOP_ABORTOP(ndp);
+               VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
@@ -375,7 +375,7 @@ unp_bind(unp, nam, p)
        vattr.va_type = VSOCK;
        vattr.va_mode = 0777;
        LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
        vattr.va_type = VSOCK;
        vattr.va_mode = 0777;
        LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
-       if (error = VOP_CREATE(ndp, &vattr, p))
+       if (error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr))
                return (error);
        vp = ndp->ni_vp;
        vp->v_socket = unp->unp_socket;
                return (error);
        vp = ndp->ni_vp;
        vp->v_socket = unp->unp_socket;
index f4f9b90..7bf70a5 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_cache.c 7.8 (Berkeley) %G%
+ *     @(#)vfs_cache.c 7.9 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -65,38 +65,40 @@ int doingcache = 1;                 /* 1 => enable the cache */
  * the name does not exist (negative cacheing), a status of ENOENT
  * is returned. If the lookup fails, a status of zero is returned.
  */
  * the name does not exist (negative cacheing), a status of ENOENT
  * is returned. If the lookup fails, a status of zero is returned.
  */
-cache_lookup(ndp)
-       register struct nameidata *ndp;
+int
+cache_lookup(dvp, vpp, cnp)      /* converted to CN.  NEEDSWORK: do callers */
+/* old: cache_lookup(ndp) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
 {
 {
-       register struct vnode *dvp;
        register struct namecache *ncp;
        union nchash *nhp;
 
        if (!doingcache)
                return (0);
        register struct namecache *ncp;
        union nchash *nhp;
 
        if (!doingcache)
                return (0);
-       if (ndp->ni_namelen > NCHNAMLEN) {
+       if (cnp->cn_namelen > NCHNAMLEN) {
                nchstats.ncs_long++;
                nchstats.ncs_long++;
-               ndp->ni_makeentry = 0;
+               cnp->cn_flags &= ~MAKEENTRY;
                return (0);
        }
                return (0);
        }
-       dvp = ndp->ni_dvp;
-       nhp = &nchashtbl[ndp->ni_hash & nchash];
+       nhp = &nchashtbl[cnp->cn_hash & nchash];
        for (ncp = nhp->nch_forw; ncp != (struct namecache *)nhp;
            ncp = ncp->nc_forw) {
                if (ncp->nc_dvp == dvp &&
                    ncp->nc_dvpid == dvp->v_id &&
        for (ncp = nhp->nch_forw; ncp != (struct namecache *)nhp;
            ncp = ncp->nc_forw) {
                if (ncp->nc_dvp == dvp &&
                    ncp->nc_dvpid == dvp->v_id &&
-                   ncp->nc_nlen == ndp->ni_namelen &&
-                   !bcmp(ncp->nc_name, ndp->ni_ptr, (unsigned)ncp->nc_nlen))
+                   ncp->nc_nlen == cnp->cn_namelen &&
+                   !bcmp(ncp->nc_name, cnp->cn_nameptr, (unsigned)ncp->nc_nlen))
                        break;
        }
        if (ncp == (struct namecache *)nhp) {
                nchstats.ncs_miss++;
                return (0);
        }
                        break;
        }
        if (ncp == (struct namecache *)nhp) {
                nchstats.ncs_miss++;
                return (0);
        }
-       if (!ndp->ni_makeentry) {
+       if (!(cnp->cn_flags & MAKEENTRY)) {
                nchstats.ncs_badhits++;
        } else if (ncp->nc_vp == NULL) {
                nchstats.ncs_badhits++;
        } else if (ncp->nc_vp == NULL) {
-               if ((ndp->ni_nameiop & OPMASK) != CREATE) {
+               if ((cnp->cn_nameiop & OPMASK) != CREATE) {
                        nchstats.ncs_neghits++;
                        /*
                         * Move this slot to end of LRU chain,
                        nchstats.ncs_neghits++;
                        /*
                         * Move this slot to end of LRU chain,
@@ -131,7 +133,7 @@ cache_lookup(ndp)
                        *nchtail = ncp;
                        nchtail = &ncp->nc_nxt;
                }
                        *nchtail = ncp;
                        nchtail = &ncp->nc_nxt;
                }
-               ndp->ni_vp = ncp->nc_vp;
+               *vpp = ncp->nc_vp;
                return (-1);
        }
 
                return (-1);
        }
 
@@ -162,8 +164,11 @@ cache_lookup(ndp)
 /*
  * Add an entry to the cache
  */
 /*
  * Add an entry to the cache
  */
-cache_enter(ndp)
-       register struct nameidata *ndp;
+cache_enter(dvp, vp, cnp)      /* converted to CN.  NEEDSWORK: do callers */
+/* old: cache_lookup(ndp) */
+       struct vnode *dvp;
+       struct vnode *vp;
+       struct componentname *cnp;
 {
        register struct namecache *ncp;
        union nchash *nhp;
 {
        register struct namecache *ncp;
        union nchash *nhp;
@@ -190,23 +195,23 @@ cache_enter(ndp)
        } else
                return;
        /* grab the vnode we just found */
        } else
                return;
        /* grab the vnode we just found */
-       ncp->nc_vp = ndp->ni_vp;
-       if (ndp->ni_vp)
-               ncp->nc_vpid = ndp->ni_vp->v_id;
+       ncp->nc_vp = vp;
+       if (vp)
+               ncp->nc_vpid = vp->v_id;
        else
                ncp->nc_vpid = 0;
        /* fill in cache info */
        else
                ncp->nc_vpid = 0;
        /* fill in cache info */
-       ncp->nc_dvp = ndp->ni_dvp;
-       ncp->nc_dvpid = ndp->ni_dvp->v_id;
-       ncp->nc_nlen = ndp->ni_namelen;
-       bcopy(ndp->ni_ptr, ncp->nc_name, (unsigned)ncp->nc_nlen);
+       ncp->nc_dvp = dvp;
+       ncp->nc_dvpid = dvp->v_id;
+       ncp->nc_nlen = cnp->cn_namelen;
+       bcopy(cnp->cn_nameptr, ncp->nc_name, (unsigned)ncp->nc_nlen);
        /* link at end of lru chain */
        ncp->nc_nxt = NULL;
        ncp->nc_prev = nchtail;
        *nchtail = ncp;
        nchtail = &ncp->nc_nxt;
        /* and insert on hash chain */
        /* link at end of lru chain */
        ncp->nc_nxt = NULL;
        ncp->nc_prev = nchtail;
        *nchtail = ncp;
        nchtail = &ncp->nc_nxt;
        /* and insert on hash chain */
-       nhp = &nchashtbl[ndp->ni_hash & nchash];
+       nhp = &nchashtbl[cnp->cn_hash & nchash];
        insque(ncp, nhp);
 }
 
        insque(ncp, nhp);
 }
 
index 1b4a768..6a08158 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_lookup.c        7.34 (Berkeley) %G%
+ *     @(#)vfs_lookup.c        7.35 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -109,7 +109,7 @@ namei(ndp, p)
                /*
                 * Check for symbolic link
                 */
                /*
                 * Check for symbolic link
                 */
-               if (ndp->ni_more == 0) {
+               if ((ndp->ni_cnd.cn_flags & ISSYMLINK) == 0) {
                        if ((ndp->ni_nameiop & (SAVENAME | SAVESTART)) == 0)
                                FREE(ndp->ni_pnbuf, M_NAMEI);
                        else
                        if ((ndp->ni_nameiop & (SAVENAME | SAVESTART)) == 0)
                                FREE(ndp->ni_pnbuf, M_NAMEI);
                        else
@@ -203,7 +203,7 @@ namei(ndp, p)
  *         if LOCKPARENT set, return locked parent in ni_dvp
  *         if WANTPARENT set, return unlocked parent in ni_dvp
  */
  *         if LOCKPARENT set, return locked parent in ni_dvp
  *         if WANTPARENT set, return unlocked parent in ni_dvp
  */
-lookup(ndp, p)
+lookup(ndp, p)   /* converted to CN */
        register struct nameidata *ndp;
        struct proc *p;
 {
        register struct nameidata *ndp;
        struct proc *p;
 {
@@ -212,22 +212,44 @@ lookup(ndp, p)
        struct vnode *tdp;              /* saved dp */
        struct mount *mp;               /* mount table entry */
        int docache;                    /* == 0 do not cache last component */
        struct vnode *tdp;              /* saved dp */
        struct mount *mp;               /* mount table entry */
        int docache;                    /* == 0 do not cache last component */
-       int flag;                       /* LOOKUP, CREATE, RENAME or DELETE */
        int wantparent;                 /* 1 => wantparent or lockparent flag */
        int rdonly;                     /* lookup read-only flag bit */
        int error = 0;
        int wantparent;                 /* 1 => wantparent or lockparent flag */
        int rdonly;                     /* lookup read-only flag bit */
        int error = 0;
+       struct componentname *cnp = &ndp->ni_cnd;
+#define COMPAT_HACK
+#ifdef COMPAT_HACK
+       int returncode=0;
+#define RETURN(N) {returncode=(N); goto byebye;}
+#else
+#define RETURN(N) return((N));
+#endif
+
+#ifdef COMPAT_HACK
+       /*
+        * NEEDSWORK: We assume that the caller has the old
+        * defn of nameiop and so doesn't use flags.
+        * Here we correct this view.
+        * (Will go away when conversion is finished.)
+        */
+       cnp->cn_flags = ndp->ni_nameiop & ~OPMASK;
+       cnp->cn_nameiop = ndp->ni_nameiop & OPMASK;
+
+       cnp->cn_proc = p;
+#endif
 
        /*
         * Setup: break out flag bits into variables.
         */
 
        /*
         * Setup: break out flag bits into variables.
         */
-       flag = ndp->ni_nameiop & OPMASK;
-       wantparent = ndp->ni_nameiop & (LOCKPARENT|WANTPARENT);
-       docache = (ndp->ni_nameiop & NOCACHE) ^ NOCACHE;
-       if (flag == DELETE || (wantparent && flag != CREATE))
+       wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
+       docache = (cnp->cn_flags & NOCACHE) ^ NOCACHE;
+       if (cnp->cn_nameiop == DELETE || (wantparent && cnp->cn_nameiop != CREATE))
+       wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
+       docache = (cnp->cn_flags & NOCACHE) ^ NOCACHE;
+       if (cnp->cn_nameiop == DELETE || (wantparent && cnp->cn_nameiop != CREATE))
                docache = 0;
                docache = 0;
-       rdonly = ndp->ni_nameiop & RDONLY;
+       rdonly = cnp->cn_flags & RDONLY;
        ndp->ni_dvp = NULL;
        ndp->ni_dvp = NULL;
-       ndp->ni_more = 0;
+       cnp->cn_flags &= ~ISSYMLINK;
        dp = ndp->ni_startdir;
        ndp->ni_startdir = NULLVP;
        VOP_LOCK(dp);
        dp = ndp->ni_startdir;
        ndp->ni_startdir = NULLVP;
        VOP_LOCK(dp);
@@ -236,41 +258,47 @@ dirloop:
        /*
         * Search a new directory.
         *
        /*
         * Search a new directory.
         *
-        * The ni_hash value is for use by vfs_cache.
+        * The cn_hash value is for use by vfs_cache.
         * The last component of the filename is left accessible via
         * The last component of the filename is left accessible via
-        * ndp->ptr for callers that need the name. Callers needing
+        * cnp->cn_nameptr for callers that need the name. Callers needing
         * the name set the SAVENAME flag. When done, they assume
         * responsibility for freeing the pathname buffer.
         */
         * the name set the SAVENAME flag. When done, they assume
         * responsibility for freeing the pathname buffer.
         */
-       ndp->ni_hash = 0;
-       for (cp = ndp->ni_ptr; *cp != 0 && *cp != '/'; cp++)
-               ndp->ni_hash += (unsigned char)*cp;
-       ndp->ni_namelen = cp - ndp->ni_ptr;
-       if (ndp->ni_namelen >= NAME_MAX) {
+       cnp->cn_hash = 0;
+       for (cp = cnp->cn_nameptr; *cp != 0 && *cp != '/'; cp++)
+               cnp->cn_hash += (unsigned char)*cp;
+       cnp->cn_namelen = cp - cnp->cn_nameptr;
+       if (cnp->cn_namelen >= NAME_MAX) {
                error = ENAMETOOLONG;
                goto bad;
        }
 #ifdef NAMEI_DIAGNOSTIC
        { char c = *cp;
        *cp = '\0';
                error = ENAMETOOLONG;
                goto bad;
        }
 #ifdef NAMEI_DIAGNOSTIC
        { char c = *cp;
        *cp = '\0';
-       printf("{%s}: ", ndp->ni_ptr);
+       printf("{%s}: ", cnp->cn_nameptr);
        *cp = c; }
 #endif
        *cp = c; }
 #endif
-       ndp->ni_pathlen -= ndp->ni_namelen;
+       ndp->ni_pathlen -= cnp->cn_namelen;
        ndp->ni_next = cp;
        ndp->ni_next = cp;
-       ndp->ni_makeentry = 1;
+       cnp->cn_flags |= MAKEENTRY;
        if (*cp == '\0' && docache == 0)
        if (*cp == '\0' && docache == 0)
-               ndp->ni_makeentry = 0;
-       ndp->ni_isdotdot = (ndp->ni_namelen == 2 &&
-               ndp->ni_ptr[1] == '.' && ndp->ni_ptr[0] == '.');
+               cnp->cn_flags &= ~MAKEENTRY;
+       if (cnp->cn_namelen == 2 &&
+                       cnp->cn_nameptr[1] == '.' && cnp->cn_nameptr[0] == '.')
+               cnp->cn_flags |= ISDOTDOT;
+       else cnp->cn_flags &= ~ISDOTDOT;
+       if (*ndp->ni_next == 0)
+               cnp->cn_flags |= ISLASTCN;
+       else cnp->cn_flags &= ~ISLASTCN;
+
 
        /*
         * Check for degenerate name (e.g. / or "")
         * which is a way of talking about a directory,
         * e.g. like "/." or ".".
         */
 
        /*
         * Check for degenerate name (e.g. / or "")
         * which is a way of talking about a directory,
         * e.g. like "/." or ".".
         */
-       if (ndp->ni_ptr[0] == '\0') {
-               if (flag != LOOKUP || wantparent) {
+       if (cnp->cn_nameptr[0] == '\0') {
+               if (cnp->cn_nameiop != LOOKUP || wantparent) {
                        error = EISDIR;
                        goto bad;
                }
                        error = EISDIR;
                        goto bad;
                }
@@ -278,12 +306,12 @@ dirloop:
                        error = ENOTDIR;
                        goto bad;
                }
                        error = ENOTDIR;
                        goto bad;
                }
-               if (!(ndp->ni_nameiop & LOCKLEAF))
+               if (!(cnp->cn_flags & LOCKLEAF))
                        VOP_UNLOCK(dp);
                ndp->ni_vp = dp;
                        VOP_UNLOCK(dp);
                ndp->ni_vp = dp;
-               if (ndp->ni_nameiop & SAVESTART)
+               if (cnp->cn_flags & SAVESTART)
                        panic("lookup: SAVESTART");
                        panic("lookup: SAVESTART");
-               return (0);
+               RETURN (0);
        }
 
        /*
        }
 
        /*
@@ -295,7 +323,7 @@ dirloop:
         *    vnode which was mounted on so we take the
         *    .. in the other file system.
         */
         *    vnode which was mounted on so we take the
         *    .. in the other file system.
         */
-       if (ndp->ni_isdotdot) {
+       if (cnp->cn_flags & ISDOTDOT) {
                for (;;) {
                        if (dp == ndp->ni_rootdir) {
                                ndp->ni_dvp = dp;
                for (;;) {
                        if (dp == ndp->ni_rootdir) {
                                ndp->ni_dvp = dp;
@@ -304,7 +332,7 @@ dirloop:
                                goto nextname;
                        }
                        if ((dp->v_flag & VROOT) == 0 ||
                                goto nextname;
                        }
                        if ((dp->v_flag & VROOT) == 0 ||
-                           (ndp->ni_nameiop & NOCROSSMOUNT))
+                           (cnp->cn_flags & NOCROSSMOUNT))
                                break;
                        tdp = dp;
                        dp = dp->v_mount->mnt_vnodecovered;
                                break;
                        tdp = dp;
                        dp = dp->v_mount->mnt_vnodecovered;
@@ -317,7 +345,8 @@ dirloop:
        /*
         * We now have a segment name to search for, and a directory to search.
         */
        /*
         * We now have a segment name to search for, and a directory to search.
         */
-       if (error = VOP_LOOKUP(dp, ndp, p)) {
+       ndp->ni_dvp = dp;
+       if (error = VOP_LOOKUP(dp, &ndp->ni_vp, cnp)) {
 #ifdef DIAGNOSTIC
                if (ndp->ni_vp != NULL)
                        panic("leaf should be empty");
 #ifdef DIAGNOSTIC
                if (ndp->ni_vp != NULL)
                        panic("leaf should be empty");
@@ -325,7 +354,7 @@ dirloop:
 #ifdef NAMEI_DIAGNOSTIC
                printf("not found\n");
 #endif
 #ifdef NAMEI_DIAGNOSTIC
                printf("not found\n");
 #endif
-               if (flag == LOOKUP || flag == DELETE ||
+               if (cnp->cn_nameiop == LOOKUP || cnp->cn_nameiop == DELETE ||
                    error != ENOENT || *cp != 0)
                        goto bad;
                /*
                    error != ENOENT || *cp != 0)
                        goto bad;
                /*
@@ -341,12 +370,12 @@ dirloop:
                 * doesn't currently exist, leaving a pointer to the
                 * (possibly locked) directory inode in ndp->ni_dvp.
                 */
                 * doesn't currently exist, leaving a pointer to the
                 * (possibly locked) directory inode in ndp->ni_dvp.
                 */
-               if (ndp->ni_nameiop & SAVESTART) {
+               if (cnp->cn_flags & SAVESTART) {
                        ndp->ni_startdir = ndp->ni_dvp;
                        VREF(ndp->ni_startdir);
                        p->p_spare[1]++;
                }
                        ndp->ni_startdir = ndp->ni_dvp;
                        VREF(ndp->ni_startdir);
                        p->p_spare[1]++;
                }
-               return (0);
+               RETURN (0);
        }
 #ifdef NAMEI_DIAGNOSTIC
        printf("found\n");
        }
 #ifdef NAMEI_DIAGNOSTIC
        printf("found\n");
@@ -357,9 +386,9 @@ dirloop:
         * Check for symbolic link
         */
        if ((dp->v_type == VLNK) &&
         * Check for symbolic link
         */
        if ((dp->v_type == VLNK) &&
-           ((ndp->ni_nameiop & FOLLOW) || *ndp->ni_next == '/')) {
-               ndp->ni_more = 1;
-               return (0);
+           ((cnp->cn_flags & FOLLOW) || *ndp->ni_next == '/')) {
+               cnp->cn_flags |= ISSYMLINK;
+               RETURN (0);
        }
 
        /*
        }
 
        /*
@@ -368,7 +397,7 @@ dirloop:
         */
 mntloop:
        while (dp->v_type == VDIR && (mp = dp->v_mountedhere) &&
         */
 mntloop:
        while (dp->v_type == VDIR && (mp = dp->v_mountedhere) &&
-              (ndp->ni_nameiop & NOCROSSMOUNT) == 0) {
+              (cnp->cn_flags & NOCROSSMOUNT) == 0) {
                if (mp->mnt_flag & MNT_MLOCK) {
                        mp->mnt_flag |= MNT_MWAIT;
                        sleep((caddr_t)mp, PVFS);
                if (mp->mnt_flag & MNT_MLOCK) {
                        mp->mnt_flag |= MNT_MWAIT;
                        sleep((caddr_t)mp, PVFS);
@@ -386,9 +415,9 @@ nextname:
         * continue at next component, else return.
         */
        if (*ndp->ni_next == '/') {
         * continue at next component, else return.
         */
        if (*ndp->ni_next == '/') {
-               ndp->ni_ptr = ndp->ni_next;
-               while (*ndp->ni_ptr == '/') {
-                       ndp->ni_ptr++;
+               cnp->cn_nameptr = ndp->ni_next;
+               while (*cnp->cn_nameptr == '/') {
+                       cnp->cn_nameptr++;
                        ndp->ni_pathlen--;
                }
                vrele(ndp->ni_dvp);
                        ndp->ni_pathlen--;
                }
                vrele(ndp->ni_dvp);
@@ -397,7 +426,7 @@ nextname:
        /*
         * Check for read-only file systems.
         */
        /*
         * Check for read-only file systems.
         */
-       if (flag == DELETE || flag == RENAME) {
+       if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) {
                /*
                 * Disallow directory write attempts on read-only
                 * file systems.
                /*
                 * Disallow directory write attempts on read-only
                 * file systems.
@@ -409,23 +438,37 @@ nextname:
                        goto bad2;
                }
        }
                        goto bad2;
                }
        }
-       if (ndp->ni_nameiop & SAVESTART) {
+       if (cnp->cn_flags & SAVESTART) {
                ndp->ni_startdir = ndp->ni_dvp;
                p->p_spare[1]++;
                VREF(ndp->ni_startdir);
        }
        if (!wantparent)
                vrele(ndp->ni_dvp);
                ndp->ni_startdir = ndp->ni_dvp;
                p->p_spare[1]++;
                VREF(ndp->ni_startdir);
        }
        if (!wantparent)
                vrele(ndp->ni_dvp);
-       if ((ndp->ni_nameiop & LOCKLEAF) == 0)
+       if ((cnp->cn_flags & LOCKLEAF) == 0)
                VOP_UNLOCK(dp);
                VOP_UNLOCK(dp);
-       return (0);
+       RETURN (0);
 
 bad2:
 
 bad2:
-       if ((ndp->ni_nameiop & LOCKPARENT) && *ndp->ni_next == '\0')
+       if ((cnp->cn_flags & LOCKPARENT) && *ndp->ni_next == '\0')
                VOP_UNLOCK(ndp->ni_dvp);
        vrele(ndp->ni_dvp);
 bad:
        vput(dp);
        ndp->ni_vp = NULL;
                VOP_UNLOCK(ndp->ni_dvp);
        vrele(ndp->ni_dvp);
 bad:
        vput(dp);
        ndp->ni_vp = NULL;
-       return (error);
+       RETURN (error);
+
+#ifdef COMPAT_HACK
+ byebye:
+       /*
+        * Put flags back into ni_nameiop and bail.
+        */
+       if (cnp->cn_nameiop & ~OPMASK)
+               panic ("lookup: nameiop is contaminated with flags.");
+       ndp->ni_nameiop = (cnp->cn_nameiop & OPMASK) |
+               (cnp->cn_flags & ~OPMASK);
+       return (returncode);
+#endif
 }
 }
+
+
index c9659e9..01e7541 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_subr.c  7.65 (Berkeley) %G%
+ *     @(#)vfs_subr.c  7.66 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -647,6 +647,8 @@ vget(vp)
        return (0);
 }
 
        return (0);
 }
 
+int bug_refs = 0;
+
 /*
  * Vnode reference, just increment the count
  */
 /*
  * Vnode reference, just increment the count
  */
@@ -655,6 +657,12 @@ void vref(vp)
 {
 
        vp->v_usecount++;
 {
 
        vp->v_usecount++;
+       if (vp->v_type!=VBLK && curproc) {   /* NEEDSWORK: debugging */
+               curproc->p_spare[2]++;
+       };
+       if (bug_refs) {
+               vprint ("vref: ");
+       };
 }
 
 /*
 }
 
 /*
@@ -681,6 +689,12 @@ void vrele(vp)
                panic("vrele: null vp");
 #endif
        vp->v_usecount--;
                panic("vrele: null vp");
 #endif
        vp->v_usecount--;
+       if (vp->v_type!=VBLK && curproc) {   /* NEEDSWORK: debugging */
+               curproc->p_spare[2]--;
+       };
+       if (bug_refs) {
+               vprint ("vref: ");
+       };
        if (vp->v_usecount > 0)
                return;
 #ifdef DIAGNOSTIC
        if (vp->v_usecount > 0)
                return;
 #ifdef DIAGNOSTIC
index 990a5bb..9f40c9a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_syscalls.c      7.75 (Berkeley) %G%
+ *     @(#)vfs_syscalls.c      7.76 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 #include "uio.h"
 #include "malloc.h"
 
 #include "uio.h"
 #include "malloc.h"
 
+/* NEEDSWORK: debugging */
+#define CURCOUNT (curproc?curproc->p_spare[2]:0)
+#define CHECKPOINT int oldrefcount=CURCOUNT;
+#define CHECKCHECK(F) if (oldrefcount!=CURCOUNT) { printf("REFCOUNT: %s, old=%d, new=%d\n", (F), oldrefcount, CURCOUNT); }
+
 /*
  * Virtual File System System Calls
  */
 /*
  * Virtual File System System Calls
  */
@@ -655,6 +660,7 @@ mknod(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINT;
        if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
        ndp = &nd;
        if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
        ndp = &nd;
@@ -689,9 +695,9 @@ mknod(p, uap, retval)
 out:
        if (!error) {
                LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
 out:
        if (!error) {
                LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
-               error = VOP_MKNOD(ndp, &vattr, p->p_ucred, p);
+               error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr);
        } else {
        } else {
-               VOP_ABORTOP(ndp);
+               VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
@@ -699,6 +705,7 @@ out:
                if (vp)
                        vrele(vp);
        }
                if (vp)
                        vrele(vp);
        }
+       CHECKCHECK("mknod");
        return (error);
 }
 
        return (error);
 }
 
@@ -729,7 +736,7 @@ mkfifo(p, uap, retval)
        if (error = namei(ndp, p))
                return (error);
        if (ndp->ni_vp != NULL) {
        if (error = namei(ndp, p))
                return (error);
        if (ndp->ni_vp != NULL) {
-               VOP_ABORTOP(ndp);
+               VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                if (ndp->ni_dvp == ndp->ni_vp)
                        vrele(ndp->ni_dvp);
                else
                if (ndp->ni_dvp == ndp->ni_vp)
                        vrele(ndp->ni_dvp);
                else
@@ -741,7 +748,7 @@ mkfifo(p, uap, retval)
        vattr.va_type = VFIFO;
        vattr.va_mode = (uap->fmode & 07777) &~ p->p_fd->fd_cmask;
        LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
        vattr.va_type = VFIFO;
        vattr.va_mode = (uap->fmode & 07777) &~ p->p_fd->fd_cmask;
        LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
-       return (VOP_MKNOD(ndp, &vattr, p->p_ucred, p));
+       return (VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr));
 #endif /* FIFO */
 }
 
 #endif /* FIFO */
 }
 
@@ -762,6 +769,7 @@ link(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINT;
        ndp = &nd;
        ndp->ni_nameiop = LOOKUP | FOLLOW;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp = &nd;
        ndp->ni_nameiop = LOOKUP | FOLLOW;
        ndp->ni_segflg = UIO_USERSPACE;
@@ -788,9 +796,9 @@ out:
        if (!error) {
                LEASE_CHECK(xp, p, p->p_ucred, LEASE_WRITE);
                LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
        if (!error) {
                LEASE_CHECK(xp, p, p->p_ucred, LEASE_WRITE);
                LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
-               error = VOP_LINK(vp, ndp, p);
+               error = VOP_LINK(vp, ndp->ni_dvp, &ndp->ni_cnd);
        } else {
        } else {
-               VOP_ABORTOP(ndp);
+               VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                if (ndp->ni_dvp == ndp->ni_vp)
                        vrele(ndp->ni_dvp);
                else
                if (ndp->ni_dvp == ndp->ni_vp)
                        vrele(ndp->ni_dvp);
                else
@@ -800,6 +808,7 @@ out:
        }
 out1:
        vrele(vp);
        }
 out1:
        vrele(vp);
+       CHECKCHECK("link");
        return (error);
 }
 
        return (error);
 }
 
@@ -821,6 +830,7 @@ symlink(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINT;
        ndp = &nd;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp->ni_dirp = uap->linkname;
        ndp = &nd;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp->ni_dirp = uap->linkname;
@@ -831,7 +841,7 @@ symlink(p, uap, retval)
        if (error = namei(ndp, p))
                goto out;
        if (ndp->ni_vp) {
        if (error = namei(ndp, p))
                goto out;
        if (ndp->ni_vp) {
-               VOP_ABORTOP(ndp);
+               VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                if (ndp->ni_dvp == ndp->ni_vp)
                        vrele(ndp->ni_dvp);
                else
                if (ndp->ni_dvp == ndp->ni_vp)
                        vrele(ndp->ni_dvp);
                else
@@ -843,9 +853,10 @@ symlink(p, uap, retval)
        VATTR_NULL(&vattr);
        vattr.va_mode = 0777 &~ p->p_fd->fd_cmask;
        LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
        VATTR_NULL(&vattr);
        vattr.va_mode = 0777 &~ p->p_fd->fd_cmask;
        LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
-       error = VOP_SYMLINK(ndp, &vattr, target, p);
+       error = VOP_SYMLINK(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr, target);
 out:
        FREE(target, M_NAMEI);
 out:
        FREE(target, M_NAMEI);
+       CHECKCHECK("symlink");
        return (error);
 }
 
        return (error);
 }
 
@@ -865,6 +876,7 @@ unlink(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINT;
        ndp = &nd;
        ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp = &nd;
        ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
        ndp->ni_segflg = UIO_USERSPACE;
@@ -887,15 +899,16 @@ out:
        if (!error) {
                LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
                LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
        if (!error) {
                LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
                LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
-               error = VOP_REMOVE(ndp, p);
+               error = VOP_REMOVE(ndp->ni_dvp, ndp->ni_vp, &ndp->ni_cnd);
        } else {
        } else {
-               VOP_ABORTOP(ndp);
+               VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
                        vput(ndp->ni_dvp);
                vput(vp);
        }
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
                        vput(ndp->ni_dvp);
                vput(vp);
        }
+       CHECKCHECK("unlink");
        return (error);
 }
 
        return (error);
 }
 
@@ -1080,6 +1093,7 @@ readlink(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINT;
        ndp = &nd;
        ndp->ni_nameiop = LOOKUP | LOCKLEAF;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp = &nd;
        ndp->ni_nameiop = LOOKUP | LOCKLEAF;
        ndp->ni_segflg = UIO_USERSPACE;
@@ -1104,6 +1118,7 @@ readlink(p, uap, retval)
 out:
        vput(vp);
        *retval = uap->count - auio.uio_resid;
 out:
        vput(vp);
        *retval = uap->count - auio.uio_resid;
+       CHECKCHECK("readlink");
        return (error);
 }
 
        return (error);
 }
 
@@ -1491,6 +1506,7 @@ rename(p, uap, retval)
        struct nameidata fromnd, tond;
        int error;
 
        struct nameidata fromnd, tond;
        int error;
 
+       CHECKPOINT;
        fromnd.ni_nameiop = DELETE | WANTPARENT | SAVESTART;
        fromnd.ni_segflg = UIO_USERSPACE;
        fromnd.ni_dirp = uap->from;
        fromnd.ni_nameiop = DELETE | WANTPARENT | SAVESTART;
        fromnd.ni_segflg = UIO_USERSPACE;
        fromnd.ni_dirp = uap->from;
@@ -1501,7 +1517,7 @@ rename(p, uap, retval)
        tond.ni_segflg = UIO_USERSPACE;
        tond.ni_dirp = uap->to;
        if (error = namei(&tond, p)) {
        tond.ni_segflg = UIO_USERSPACE;
        tond.ni_dirp = uap->to;
        if (error = namei(&tond, p)) {
-               VOP_ABORTOP(&fromnd);
+               VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
                vrele(fromnd.ni_dvp);
                vrele(fvp);
                goto out1;
                vrele(fromnd.ni_dvp);
                vrele(fvp);
                goto out1;
@@ -1543,16 +1559,23 @@ out:
                        LEASE_CHECK(fromnd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
                if (tvp)
                        LEASE_CHECK(tvp, p, p->p_ucred, LEASE_WRITE);
                        LEASE_CHECK(fromnd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
                if (tvp)
                        LEASE_CHECK(tvp, p, p->p_ucred, LEASE_WRITE);
-               error = VOP_RENAME(&fromnd, &tond, p);
+               if (fromnd.ni_startdir != fromnd.ni_dvp ||
+                   tond.ni_startdir != tond.ni_dvp)   /* NEEDSWORK: debug */
+                       printf ("rename: f.startdir=%x, dvp=%x; t.startdir=%x, dvp=%x\n", fromnd.ni_startdir, fromnd.ni_dvp, tond.ni_startdir, tond.ni_dvp);
+               error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
+                                  tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
+               if (fromnd.ni_startdir != fromnd.ni_dvp ||
+                   tond.ni_startdir != tond.ni_dvp)   /* NEEDSWORK: debug */
+                       printf ("rename: f.startdir=%x, dvp=%x; t.startdir=%x, dvp=%x\n", fromnd.ni_startdir, fromnd.ni_dvp, tond.ni_startdir, tond.ni_dvp);
        } else {
        } else {
-               VOP_ABORTOP(&tond);
+               VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd);
                if (tdvp == tvp)
                        vrele(tdvp);
                else
                        vput(tdvp);
                if (tvp)
                        vput(tvp);
                if (tdvp == tvp)
                        vrele(tdvp);
                else
                        vput(tdvp);
                if (tvp)
                        vput(tvp);
-               VOP_ABORTOP(&fromnd);
+               VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
                vrele(fromnd.ni_dvp);
                vrele(fvp);
        }
                vrele(fromnd.ni_dvp);
                vrele(fvp);
        }
@@ -1563,6 +1586,7 @@ out1:
        p->p_spare[1]--;
        vrele(fromnd.ni_startdir);
        FREE(fromnd.ni_pnbuf, M_NAMEI);
        p->p_spare[1]--;
        vrele(fromnd.ni_startdir);
        FREE(fromnd.ni_pnbuf, M_NAMEI);
+       CHECKCHECK("rename");
        if (error == -1)
                return (0);
        return (error);
        if (error == -1)
                return (0);
        return (error);
@@ -1586,6 +1610,7 @@ mkdir(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINT;
        ndp = &nd;
        ndp->ni_nameiop = CREATE | LOCKPARENT;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp = &nd;
        ndp->ni_nameiop = CREATE | LOCKPARENT;
        ndp->ni_segflg = UIO_USERSPACE;
@@ -1594,21 +1619,23 @@ mkdir(p, uap, retval)
                return (error);
        vp = ndp->ni_vp;
        if (vp != NULL) {
                return (error);
        vp = ndp->ni_vp;
        if (vp != NULL) {
-               VOP_ABORTOP(ndp);
+               VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
                        vput(ndp->ni_dvp);
                vrele(vp);
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
                        vput(ndp->ni_dvp);
                vrele(vp);
+               CHECKCHECK("mkdir1");
                return (EEXIST);
        }
        VATTR_NULL(&vattr);
        vattr.va_type = VDIR;
        vattr.va_mode = (uap->dmode & 0777) &~ p->p_fd->fd_cmask;
        LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
                return (EEXIST);
        }
        VATTR_NULL(&vattr);
        vattr.va_type = VDIR;
        vattr.va_mode = (uap->dmode & 0777) &~ p->p_fd->fd_cmask;
        LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
-       error = VOP_MKDIR(ndp, &vattr, p);
+       error = VOP_MKDIR(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr);
        if (!error)
                vput(ndp->ni_vp);
        if (!error)
                vput(ndp->ni_vp);
+       CHECKCHECK("mkdir2");
        return (error);
 }
 
        return (error);
 }
 
@@ -1628,6 +1655,7 @@ rmdir(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINT;
        ndp = &nd;
        ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp = &nd;
        ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
        ndp->ni_segflg = UIO_USERSPACE;
@@ -1655,15 +1683,16 @@ out:
        if (!error) {
                LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
                LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
        if (!error) {
                LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
                LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
-               error = VOP_RMDIR(ndp, p);
+               error = VOP_RMDIR(ndp->ni_dvp, ndp->ni_vp, &ndp->ni_cnd);
        } else {
        } else {
-               VOP_ABORTOP(ndp);
+               VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
                        vput(ndp->ni_dvp);
                vput(vp);
        }
                if (ndp->ni_dvp == vp)
                        vrele(ndp->ni_dvp);
                else
                        vput(ndp->ni_dvp);
                vput(vp);
        }
+       CHECKCHECK("rmdir");
        return (error);
 }
 
        return (error);
 }
 
index 8985ea4..a1b1450 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_vnops.c 7.34 (Berkeley) %G%
+ *     @(#)vfs_vnops.c 7.35 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -49,12 +49,12 @@ vn_open(ndp, p, fmode, cmode)
                        vap->va_type = VREG;
                        vap->va_mode = cmode;
                        LEASE_CHECK(ndp->ni_dvp, p, cred, LEASE_WRITE);
                        vap->va_type = VREG;
                        vap->va_mode = cmode;
                        LEASE_CHECK(ndp->ni_dvp, p, cred, LEASE_WRITE);
-                       if (error = VOP_CREATE(ndp, vap, p))
+                       if (error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, vap))
                                return (error);
                        fmode &= ~O_TRUNC;
                        vp = ndp->ni_vp;
                } else {
                                return (error);
                        fmode &= ~O_TRUNC;
                        vp = ndp->ni_vp;
                } else {
-                       VOP_ABORTOP(ndp);
+                       VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
                        if (ndp->ni_dvp == ndp->ni_vp)
                                vrele(ndp->ni_dvp);
                        else
                        if (ndp->ni_dvp == ndp->ni_vp)
                                vrele(ndp->ni_dvp);
                        else
index e6d411e..34bac85 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_node.c  7.36 (Berkeley) %G%
+ *     @(#)nfs_node.c  7.37 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -239,11 +239,13 @@ nfs_islocked(vp)
  * done. Currently nothing to do.
  */
 /* ARGSUSED */
  * done. Currently nothing to do.
  */
 /* ARGSUSED */
-nfs_abortop(ndp)
-       struct nameidata *ndp;
+int
+nfs_abortop(dvp, cnp)
+       struct vnode *dvp;
+       struct componentname *cnp;
 {
 
 {
 
-       if ((ndp->ni_nameiop & (HASBUF | SAVESTART)) == HASBUF)
-               FREE(ndp->ni_pnbuf, M_NAMEI);
+       if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
+               FREE(cnp->cn_pnbuf, M_NAMEI);
        return (0);
 }
        return (0);
 }
index 6a81420..3686ca5 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_serv.c  7.43 (Berkeley) %G%
+ *     @(#)nfs_serv.c  7.44 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -601,7 +601,7 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
                        p->p_spare[1]--;
                        vrele(nd.ni_startdir);
                        nqsrv_getl(nd.ni_dvp, NQL_WRITE);
                        p->p_spare[1]--;
                        vrele(nd.ni_startdir);
                        nqsrv_getl(nd.ni_dvp, NQL_WRITE);
-                       if (error = VOP_CREATE(&nd, vap, nfsd->nd_procp))
+                       if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap))
                                nfsm_reply(0);
                        FREE(nd.ni_pnbuf, M_NAMEI);
                } else if (vap->va_type == VCHR || vap->va_type == VBLK ||
                                nfsm_reply(0);
                        FREE(nd.ni_pnbuf, M_NAMEI);
                } else if (vap->va_type == VCHR || vap->va_type == VBLK ||
@@ -610,19 +610,19 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
                                vap->va_type = VFIFO;
                        if (vap->va_type == VFIFO) {
 #ifndef FIFO
                                vap->va_type = VFIFO;
                        if (vap->va_type == VFIFO) {
 #ifndef FIFO
-                               VOP_ABORTOP(&nd);
+                               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                                vput(nd.ni_dvp);
                                error = ENXIO;
                                goto out;
 #endif /* FIFO */
                        } else if (error = suser(cred, (u_short *)0)) {
                                vput(nd.ni_dvp);
                                error = ENXIO;
                                goto out;
 #endif /* FIFO */
                        } else if (error = suser(cred, (u_short *)0)) {
-                               VOP_ABORTOP(&nd);
+                               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                                vput(nd.ni_dvp);
                                goto out;
                        } else
                                vap->va_rdev = (dev_t)rdev;
                        nqsrv_getl(nd.ni_dvp, NQL_WRITE);
                                vput(nd.ni_dvp);
                                goto out;
                        } else
                                vap->va_rdev = (dev_t)rdev;
                        nqsrv_getl(nd.ni_dvp, NQL_WRITE);
-                       if (error = VOP_MKNOD(&nd, vap, cred, nfsd->nd_procp)) {
+                       if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
                                p->p_spare[1]--;
                                vrele(nd.ni_startdir);
                                nfsm_reply(0);
                                p->p_spare[1]--;
                                vrele(nd.ni_startdir);
                                nfsm_reply(0);
@@ -635,15 +635,15 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
                                nfsm_reply(0);
                        }
                        FREE(nd.ni_pnbuf, M_NAMEI);
                                nfsm_reply(0);
                        }
                        FREE(nd.ni_pnbuf, M_NAMEI);
-                       if (nd.ni_more) {
+                       if (nd.ni_nameiop & ISSYMLINK) {
                                vrele(nd.ni_dvp);
                                vput(nd.ni_vp);
                                vrele(nd.ni_dvp);
                                vput(nd.ni_vp);
-                               VOP_ABORTOP(&nd);
+                               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                                error = EINVAL;
                                nfsm_reply(0);
                        }
                } else {
                                error = EINVAL;
                                nfsm_reply(0);
                        }
                } else {
-                       VOP_ABORTOP(&nd);
+                       VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                        vput(nd.ni_dvp);
                        error = ENXIO;
                        goto out;
                        vput(nd.ni_dvp);
                        error = ENXIO;
                        goto out;
@@ -658,7 +658,7 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
                        vrele(nd.ni_dvp);
                else
                        vput(nd.ni_dvp);
                        vrele(nd.ni_dvp);
                else
                        vput(nd.ni_dvp);
-               VOP_ABORTOP(&nd);
+               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                vap->va_size = 0;
                nqsrv_getl(vp, NQL_WRITE);
                if (error = VOP_SETATTR(vp, vap, cred, nfsd->nd_procp)) {
                vap->va_size = 0;
                nqsrv_getl(vp, NQL_WRITE);
                if (error = VOP_SETATTR(vp, vap, cred, nfsd->nd_procp)) {
@@ -682,7 +682,7 @@ nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq)
 nfsmout:
        if (nd.ni_nameiop)
                p->p_spare[1]--, vrele(nd.ni_startdir);
 nfsmout:
        if (nd.ni_nameiop)
                p->p_spare[1]--, vrele(nd.ni_startdir);
-       VOP_ABORTOP(&nd);
+       VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
        if (nd.ni_dvp == nd.ni_vp)
                vrele(nd.ni_dvp);
        else
        if (nd.ni_dvp == nd.ni_vp)
                vrele(nd.ni_dvp);
        else
@@ -744,9 +744,9 @@ out:
        if (!error) {
                nqsrv_getl(nd.ni_dvp, NQL_WRITE);
                nqsrv_getl(vp, NQL_WRITE);
        if (!error) {
                nqsrv_getl(nd.ni_dvp, NQL_WRITE);
                nqsrv_getl(vp, NQL_WRITE);
-               error = VOP_REMOVE(&nd, nfsd->nd_procp);
+               error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
        } else {
        } else {
-               VOP_ABORTOP(&nd);
+               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                if (nd.ni_dvp == vp)
                        vrele(nd.ni_dvp);
                else
                if (nd.ni_dvp == vp)
                        vrele(nd.ni_dvp);
                else
@@ -803,7 +803,7 @@ nfsrv_rename(nfsd, mrep, md, dpos, cred, nam, mrq)
        tond.ni_nameiop = RENAME | LOCKPARENT | LOCKLEAF | NOCACHE
                | SAVESTART;
        if (error = nfs_namei(&tond, tfhp, len2, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) {
        tond.ni_nameiop = RENAME | LOCKPARENT | LOCKLEAF | NOCACHE
                | SAVESTART;
        if (error = nfs_namei(&tond, tfhp, len2, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) {
-               VOP_ABORTOP(&fromnd);
+               VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
                vrele(fromnd.ni_dvp);
                vrele(fvp);
                goto out1;
                vrele(fromnd.ni_dvp);
                vrele(fvp);
                goto out1;
@@ -848,16 +848,17 @@ out:
                nqsrv_getl(tdvp, NQL_WRITE);
                if (tvp)
                        nqsrv_getl(tvp, NQL_WRITE);
                nqsrv_getl(tdvp, NQL_WRITE);
                if (tvp)
                        nqsrv_getl(tvp, NQL_WRITE);
-               error = VOP_RENAME(&fromnd, &tond, nfsd->nd_procp);
+               error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
+                                  tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
        } else {
        } else {
-               VOP_ABORTOP(&tond);
+               VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd);
                if (tdvp == tvp)
                        vrele(tdvp);
                else
                        vput(tdvp);
                if (tvp)
                        vput(tvp);
                if (tdvp == tvp)
                        vrele(tdvp);
                else
                        vput(tdvp);
                if (tvp)
                        vput(tvp);
-               VOP_ABORTOP(&fromnd);
+               VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
                vrele(fromnd.ni_dvp);
                vrele(fvp);
        }
                vrele(fromnd.ni_dvp);
                vrele(fvp);
        }
@@ -881,7 +882,7 @@ nfsmout:
                p->p_spare[1]--;
                vrele(fromnd.ni_startdir);
                FREE(fromnd.ni_pnbuf, M_NAMEI);
                p->p_spare[1]--;
                vrele(fromnd.ni_startdir);
                FREE(fromnd.ni_pnbuf, M_NAMEI);
-               VOP_ABORTOP(&fromnd);
+               VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
                vrele(fromnd.ni_dvp);
                vrele(fvp);
        }
                vrele(fromnd.ni_dvp);
                vrele(fvp);
        }
@@ -935,9 +936,9 @@ out:
        if (!error) {
                nqsrv_getl(vp, NQL_WRITE);
                nqsrv_getl(xp, NQL_WRITE);
        if (!error) {
                nqsrv_getl(vp, NQL_WRITE);
                nqsrv_getl(xp, NQL_WRITE);
-               error = VOP_LINK(vp, &nd, nfsd->nd_procp);
+               error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd);
        } else {
        } else {
-               VOP_ABORTOP(&nd);
+               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                if (nd.ni_dvp == nd.ni_vp)
                        vrele(nd.ni_dvp);
                else
                if (nd.ni_dvp == nd.ni_vp)
                        vrele(nd.ni_dvp);
                else
@@ -1000,7 +1001,7 @@ nfsrv_symlink(nfsd, mrep, md, dpos, cred, nam, mrq)
        nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR);
        *(pathcp + len2) = '\0';
        if (nd.ni_vp) {
        nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR);
        *(pathcp + len2) = '\0';
        if (nd.ni_vp) {
-               VOP_ABORTOP(&nd);
+               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                if (nd.ni_dvp == nd.ni_vp)
                        vrele(nd.ni_dvp);
                else
                if (nd.ni_dvp == nd.ni_vp)
                        vrele(nd.ni_dvp);
                else
@@ -1012,14 +1013,14 @@ nfsrv_symlink(nfsd, mrep, md, dpos, cred, nam, mrq)
        VATTR_NULL(vap);
        vap->va_mode = fxdr_unsigned(u_short, sp->sa_mode);
        nqsrv_getl(nd.ni_dvp, NQL_WRITE);
        VATTR_NULL(vap);
        vap->va_mode = fxdr_unsigned(u_short, sp->sa_mode);
        nqsrv_getl(nd.ni_dvp, NQL_WRITE);
-       error = VOP_SYMLINK(&nd, vap, pathcp, nfsd->nd_procp);
+       error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap, pathcp);
 out:
        if (pathcp)
                FREE(pathcp, M_TEMP);
        nfsm_reply(0);
        return (error);
 nfsmout:
 out:
        if (pathcp)
                FREE(pathcp, M_TEMP);
        nfsm_reply(0);
        return (error);
 nfsmout:
-       VOP_ABORTOP(&nd);
+       VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
        if (nd.ni_dvp == nd.ni_vp)
                vrele(nd.ni_dvp);
        else
        if (nd.ni_dvp == nd.ni_vp)
                vrele(nd.ni_dvp);
        else
@@ -1070,7 +1071,7 @@ nfsrv_mkdir(nfsd, mrep, md, dpos, cred, nam, mrq)
        vap->va_mode = nfstov_mode(*tl++);
        vp = nd.ni_vp;
        if (vp != NULL) {
        vap->va_mode = nfstov_mode(*tl++);
        vp = nd.ni_vp;
        if (vp != NULL) {
-               VOP_ABORTOP(&nd);
+               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                if (nd.ni_dvp == vp)
                        vrele(nd.ni_dvp);
                else
                if (nd.ni_dvp == vp)
                        vrele(nd.ni_dvp);
                else
@@ -1080,7 +1081,7 @@ nfsrv_mkdir(nfsd, mrep, md, dpos, cred, nam, mrq)
                nfsm_reply(0);
        }
        nqsrv_getl(nd.ni_dvp, NQL_WRITE);
                nfsm_reply(0);
        }
        nqsrv_getl(nd.ni_dvp, NQL_WRITE);
-       if (error = VOP_MKDIR(&nd, vap, nfsd->nd_procp))
+       if (error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap))
                nfsm_reply(0);
        vp = nd.ni_vp;
        bzero((caddr_t)fhp, sizeof(nfh));
                nfsm_reply(0);
        vp = nd.ni_vp;
        bzero((caddr_t)fhp, sizeof(nfh));
@@ -1097,7 +1098,7 @@ nfsrv_mkdir(nfsd, mrep, md, dpos, cred, nam, mrq)
        nfsm_srvfillattr;
        return (error);
 nfsmout:
        nfsm_srvfillattr;
        return (error);
 nfsmout:
-       VOP_ABORTOP(&nd);
+       VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
        if (nd.ni_dvp == nd.ni_vp)
                vrele(nd.ni_dvp);
        else
        if (nd.ni_dvp == nd.ni_vp)
                vrele(nd.ni_dvp);
        else
@@ -1157,9 +1158,9 @@ out:
        if (!error) {
                nqsrv_getl(nd.ni_dvp, NQL_WRITE);
                nqsrv_getl(vp, NQL_WRITE);
        if (!error) {
                nqsrv_getl(nd.ni_dvp, NQL_WRITE);
                nqsrv_getl(vp, NQL_WRITE);
-               error = VOP_RMDIR(&nd, nfsd->nd_procp);
+               error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
        } else {
        } else {
-               VOP_ABORTOP(&nd);
+               VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                if (nd.ni_dvp == nd.ni_vp)
                        vrele(nd.ni_dvp);
                else
                if (nd.ni_dvp == nd.ni_vp)
                        vrele(nd.ni_dvp);
                else
index b8322cf..6dc0d9b 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_subs.c  7.45 (Berkeley) %G%
+ *     @(#)nfs_subs.c  7.46 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -863,7 +863,7 @@ nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, p)
        /*
         * Check for encountering a symbolic link
         */
        /*
         * Check for encountering a symbolic link
         */
-       if (ndp->ni_more) {
+       if (ndp->ni_nameiop & ISSYMLINK) {
                if ((ndp->ni_nameiop & LOCKPARENT) && ndp->ni_pathlen == 1)
                        vput(ndp->ni_dvp);
                else
                if ((ndp->ni_nameiop & LOCKPARENT) && ndp->ni_pathlen == 1)
                        vput(ndp->ni_dvp);
                else
index 42c29db..a539444 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfs_vnops.c 7.65 (Berkeley) %G%
+ *     @(#)nfs_vnops.c 7.66 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -197,6 +197,7 @@ int nfs_numasync = 0;
 /*
  * nfs null call from vfs.
  */
 /*
  * nfs null call from vfs.
  */
+int
 nfs_null(vp, cred, procp)
        struct vnode *vp;
        struct ucred *cred;
 nfs_null(vp, cred, procp)
        struct vnode *vp;
        struct ucred *cred;
@@ -216,6 +217,7 @@ nfs_null(vp, cred, procp)
  * nfs access vnode op.
  * Essentially just get vattr and then imitate iaccess()
  */
  * nfs access vnode op.
  * Essentially just get vattr and then imitate iaccess()
  */
+int
 nfs_access(vp, mode, cred, procp)
        struct vnode *vp;
        int mode;
 nfs_access(vp, mode, cred, procp)
        struct vnode *vp;
        int mode;
@@ -263,6 +265,7 @@ found:
  * and that deletion is not in progress.
  */
 /* ARGSUSED */
  * and that deletion is not in progress.
  */
 /* ARGSUSED */
+int
 nfs_open(vp, mode, cred, procp)
        register struct vnode *vp;
        int mode;
 nfs_open(vp, mode, cred, procp)
        register struct vnode *vp;
        int mode;
@@ -282,6 +285,7 @@ nfs_open(vp, mode, cred, procp)
  * For reg files, invalidate any buffer cache entries.
  */
 /* ARGSUSED */
  * For reg files, invalidate any buffer cache entries.
  */
 /* ARGSUSED */
+int
 nfs_close(vp, fflags, cred, procp)
        register struct vnode *vp;
        int fflags;
 nfs_close(vp, fflags, cred, procp)
        register struct vnode *vp;
        int fflags;
@@ -308,6 +312,7 @@ nfs_close(vp, fflags, cred, procp)
 /*
  * nfs getattr call from vfs.
  */
 /*
  * nfs getattr call from vfs.
  */
+int
 nfs_getattr(vp, vap, cred, procp)
        register struct vnode *vp;
        struct vattr *vap;
 nfs_getattr(vp, vap, cred, procp)
        register struct vnode *vp;
        struct vattr *vap;
@@ -334,6 +339,7 @@ nfs_getattr(vp, vap, cred, procp)
 /*
  * nfs setattr call.
  */
 /*
  * nfs setattr call.
  */
+int
 nfs_setattr(vp, vap, cred, procp)
        register struct vnode *vp;
        register struct vattr *vap;
 nfs_setattr(vp, vap, cred, procp)
        register struct vnode *vp;
        register struct vattr *vap;
@@ -398,10 +404,12 @@ nfs_setattr(vp, vap, cred, procp)
  * First look in cache
  * If not found, unlock the directory nfsnode and do the rpc
  */
  * First look in cache
  * If not found, unlock the directory nfsnode and do the rpc
  */
-nfs_lookup(vp, ndp, procp)
-       register struct vnode *vp;
-       register struct nameidata *ndp;
-       struct proc *procp;
+int
+nfs_lookup(dvp, vpp, cnp)   /* converted to CN */
+/* old: nfs_lookup(vp, ndp, procp) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
 {
        register struct vnode *vdp;
        register u_long *tl;
 {
        register struct vnode *vdp;
        register u_long *tl;
@@ -416,30 +424,28 @@ nfs_lookup(vp, ndp, procp)
        long len;
        nfsv2fh_t *fhp;
        struct nfsnode *np;
        long len;
        nfsv2fh_t *fhp;
        struct nfsnode *np;
-       int lockparent, wantparent, flag, error = 0;
+       int lockparent, wantparent, error = 0;
        int nqlflag, cachable;
        u_quad_t frev;
 
        int nqlflag, cachable;
        u_quad_t frev;
 
-       ndp->ni_dvp = vp;
-       ndp->ni_vp = NULL;
-       if (vp->v_type != VDIR)
+       *vpp = NULL;
+       if (dvp->v_type != VDIR)
                return (ENOTDIR);
                return (ENOTDIR);
-       lockparent = ndp->ni_nameiop & LOCKPARENT;
-       flag = ndp->ni_nameiop & OPMASK;
-       wantparent = ndp->ni_nameiop & (LOCKPARENT|WANTPARENT);
-       nmp = VFSTONFS(vp->v_mount);
-       np = VTONFS(vp);
-       if ((error = cache_lookup(ndp)) && error != ENOENT) {
+       lockparent = cnp->cn_flags & LOCKPARENT;
+       wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
+       nmp = VFSTONFS(dvp->v_mount);
+       np = VTONFS(dvp);
+       if ((error = cache_lookup(dvp, vpp, cnp)) && error != ENOENT) {
                struct vattr vattr;
                int vpid;
 
                struct vattr vattr;
                int vpid;
 
-               vdp = ndp->ni_vp;
+               vdp = *vpp;
                vpid = vdp->v_id;
                /*
                 * See the comment starting `Step through' in ufs/ufs_lookup.c
                 * for an explanation of the locking protocol
                 */
                vpid = vdp->v_id;
                /*
                 * See the comment starting `Step through' in ufs/ufs_lookup.c
                 * for an explanation of the locking protocol
                 */
-               if (vp == vdp) {
+               if (dvp == vdp) {
                        VREF(vdp);
                        error = 0;
                } else
                        VREF(vdp);
                        error = 0;
                } else
@@ -447,40 +453,40 @@ nfs_lookup(vp, ndp, procp)
                if (!error) {
                        if (vpid == vdp->v_id) {
                           if (nmp->nm_flag & NFSMNT_NQNFS) {
                if (!error) {
                        if (vpid == vdp->v_id) {
                           if (nmp->nm_flag & NFSMNT_NQNFS) {
-                               if (NQNFS_CKCACHABLE(vp, NQL_READ)) {
+                               if (NQNFS_CKCACHABLE(dvp, NQL_READ)) {
                                        if (QUADNE(np->n_lrev, np->n_brev) ||
                                            (np->n_flag & NMODIFIED)) {
                                                np->n_direofoffset = 0;
                                        if (QUADNE(np->n_lrev, np->n_brev) ||
                                            (np->n_flag & NMODIFIED)) {
                                                np->n_direofoffset = 0;
-                                               cache_purge(vp);
+                                               cache_purge(dvp);
                                                np->n_flag &= ~NMODIFIED;
                                                np->n_flag &= ~NMODIFIED;
-                                               vinvalbuf(vp, FALSE);
+                                               vinvalbuf(dvp, FALSE);
                                                np->n_brev = np->n_lrev;
                                        } else {
                                                nfsstats.lookupcache_hits++;
                                                np->n_brev = np->n_lrev;
                                        } else {
                                                nfsstats.lookupcache_hits++;
-                                               if (flag != LOOKUP &&
-                                                   *ndp->ni_next == '\0')
-                                                   ndp->ni_nameiop |= SAVENAME;
+                                               if (cnp->cn_nameiop != LOOKUP &&
+                                                   (cnp->cn_flags&ISLASTCN))
+                                                   cnp->cn_flags |= SAVENAME;
                                                return (0);
                                        }
                                }
                                                return (0);
                                        }
                                }
-                          } else if (!nfs_getattr(vdp, &vattr, ndp->ni_cred, procp) &&
+                          } else if (!nfs_getattr(vdp, &vattr, cnp->cn_cred, cnp->cn_proc) &&
                               vattr.va_ctime.tv_sec == VTONFS(vdp)->n_ctime) {
                                nfsstats.lookupcache_hits++;
                               vattr.va_ctime.tv_sec == VTONFS(vdp)->n_ctime) {
                                nfsstats.lookupcache_hits++;
-                               if (flag != LOOKUP && *ndp->ni_next == '\0')
-                                       ndp->ni_nameiop |= SAVENAME;
+                               if (cnp->cn_nameiop != LOOKUP && (cnp->cn_flags&ISLASTCN))
+                                       cnp->cn_flags |= SAVENAME;
                                return (0);
                           }
                           cache_purge(vdp);
                        }
                        vrele(vdp);
                }
                                return (0);
                           }
                           cache_purge(vdp);
                        }
                        vrele(vdp);
                }
-               ndp->ni_vp = NULLVP;
+               *vpp = NULLVP;
        }
        error = 0;
        nfsstats.lookupcache_misses++;
        nfsstats.rpccnt[NFSPROC_LOOKUP]++;
        }
        error = 0;
        nfsstats.lookupcache_misses++;
        nfsstats.rpccnt[NFSPROC_LOOKUP]++;
-       len = ndp->ni_namelen;
-       nfsm_reqhead(vp, NFSPROC_LOOKUP, NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len));
+       len = cnp->cn_namelen;
+       nfsm_reqhead(dvp, NFSPROC_LOOKUP, NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len));
 
        /*
         * For nqnfs optionally piggyback a getlease request for the name
 
        /*
         * For nqnfs optionally piggyback a getlease request for the name
@@ -488,7 +494,7 @@ nfs_lookup(vp, ndp, procp)
         */
        if (nmp->nm_flag & NFSMNT_NQNFS) {
                if ((nmp->nm_flag & NFSMNT_NQLOOKLEASE) &&
         */
        if (nmp->nm_flag & NFSMNT_NQNFS) {
                if ((nmp->nm_flag & NFSMNT_NQLOOKLEASE) &&
-                   (ndp->ni_makeentry && (flag != DELETE || *ndp->ni_next))) {
+                   ((cnp->cn_flags&MAKEENTRY) && (cnp->cn_nameiop != DELETE || !(cnp->cn_flags&ISLASTCN)))) {
                        nfsm_build(tl, u_long *, 2*NFSX_UNSIGNED);
                        *tl++ = txdr_unsigned(NQL_READ);
                        *tl = txdr_unsigned(nmp->nm_leaseterm);
                        nfsm_build(tl, u_long *, 2*NFSX_UNSIGNED);
                        *tl++ = txdr_unsigned(NQL_READ);
                        *tl = txdr_unsigned(nmp->nm_leaseterm);
@@ -497,14 +503,14 @@ nfs_lookup(vp, ndp, procp)
                        *tl = 0;
                }
        }
                        *tl = 0;
                }
        }
-       nfsm_fhtom(vp);
-       nfsm_strtom(ndp->ni_ptr, len, NFS_MAXNAMLEN);
+       nfsm_fhtom(dvp);
+       nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN);
        reqtime = time.tv_sec;
        reqtime = time.tv_sec;
-       nfsm_request(vp, NFSPROC_LOOKUP, procp, ndp->ni_cred);
+       nfsm_request(dvp, NFSPROC_LOOKUP, cnp->cn_proc, cnp->cn_cred);
 nfsmout:
        if (error) {
 nfsmout:
        if (error) {
-               if (flag != LOOKUP && *ndp->ni_next == '\0')
-                       ndp->ni_nameiop |= SAVENAME;
+               if (cnp->cn_nameiop != LOOKUP && (cnp->cn_flags&ISLASTCN))
+                       cnp->cn_flags |= SAVENAME;
                return (error);
        }
        if (nmp->nm_flag & NFSMNT_NQNFS) {
                return (error);
        }
        if (nmp->nm_flag & NFSMNT_NQNFS) {
@@ -523,12 +529,12 @@ nfsmout:
        /*
         * Handle RENAME case...
         */
        /*
         * Handle RENAME case...
         */
-       if (flag == RENAME && wantparent && *ndp->ni_next == 0) {
+       if (cnp->cn_nameiop == RENAME && wantparent && (cnp->cn_flags&ISLASTCN)) {
                if (!bcmp(np->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) {
                        m_freem(mrep);
                        return (EISDIR);
                }
                if (!bcmp(np->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) {
                        m_freem(mrep);
                        return (EISDIR);
                }
-               if (error = nfs_nget(vp->v_mount, fhp, &np)) {
+               if (error = nfs_nget(dvp->v_mount, fhp, &np)) {
                        m_freem(mrep);
                        return (error);
                }
                        m_freem(mrep);
                        return (error);
                }
@@ -539,17 +545,17 @@ nfsmout:
                        m_freem(mrep);
                        return (error);
                }
                        m_freem(mrep);
                        return (error);
                }
-               ndp->ni_vp = newvp;
+               *vpp = newvp;
                m_freem(mrep);
                m_freem(mrep);
-               ndp->ni_nameiop |= SAVENAME;
+               cnp->cn_flags |= SAVENAME;
                return (0);
        }
 
        if (!bcmp(np->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) {
                return (0);
        }
 
        if (!bcmp(np->n_fh.fh_bytes, (caddr_t)fhp, NFSX_FH)) {
-               VREF(vp);
-               newvp = vp;
+               VREF(dvp);
+               newvp = dvp;
        } else {
        } else {
-               if (error = nfs_nget(vp->v_mount, fhp, &np)) {
+               if (error = nfs_nget(dvp->v_mount, fhp, &np)) {
                        m_freem(mrep);
                        return (error);
                }
                        m_freem(mrep);
                        return (error);
                }
@@ -561,10 +567,10 @@ nfsmout:
                return (error);
        }
        m_freem(mrep);
                return (error);
        }
        m_freem(mrep);
-       ndp->ni_vp = newvp;
-       if (flag != LOOKUP && *ndp->ni_next == '\0')
-               ndp->ni_nameiop |= SAVENAME;
-       if (ndp->ni_makeentry && (flag != DELETE || *ndp->ni_next)) {
+       *vpp = newvp;
+       if (cnp->cn_nameiop != LOOKUP && (cnp->cn_flags&ISLASTCN))
+               cnp->cn_flags |= SAVENAME;
+       if ((cnp->cn_flags&MAKEENTRY) && (cnp->cn_nameiop != DELETE || !(cnp->cn_flags&ISLASTCN))) {
                if ((nmp->nm_flag & NFSMNT_NQNFS) == 0)
                        np->n_ctime = np->n_vattr.va_ctime.tv_sec;
                else if (nqlflag && reqtime > time.tv_sec) {
                if ((nmp->nm_flag & NFSMNT_NQNFS) == 0)
                        np->n_ctime = np->n_vattr.va_ctime.tv_sec;
                else if (nqlflag && reqtime > time.tv_sec) {
@@ -605,7 +611,7 @@ nfsmout:
                        else
                                np->n_tnext->n_tprev = np;
                }
                        else
                                np->n_tnext->n_tprev = np;
                }
-               cache_enter(ndp);
+               cache_enter(dvp, *vpp, cnp);
        }
        return (0);
 }
        }
        return (0);
 }
@@ -614,6 +620,7 @@ nfsmout:
  * nfs read call.
  * Just call nfs_bioread() to do the work.
  */
  * nfs read call.
  * Just call nfs_bioread() to do the work.
  */
+int
 nfs_read(vp, uiop, ioflag, cred)
        register struct vnode *vp;
        struct uio *uiop;
 nfs_read(vp, uiop, ioflag, cred)
        register struct vnode *vp;
        struct uio *uiop;
@@ -628,6 +635,7 @@ nfs_read(vp, uiop, ioflag, cred)
 /*
  * nfs readlink call
  */
 /*
  * nfs readlink call
  */
+int
 nfs_readlink(vp, uiop, cred)
        struct vnode *vp;
        struct uio *uiop;
 nfs_readlink(vp, uiop, cred)
        struct vnode *vp;
        struct uio *uiop;
@@ -642,6 +650,7 @@ nfs_readlink(vp, uiop, cred)
  * Do a readlink rpc.
  * Called by nfs_doio() from below the buffer cache.
  */
  * Do a readlink rpc.
  * Called by nfs_doio() from below the buffer cache.
  */
+int
 nfs_readlinkrpc(vp, uiop, cred)
        register struct vnode *vp;
        struct uio *uiop;
 nfs_readlinkrpc(vp, uiop, cred)
        register struct vnode *vp;
        struct uio *uiop;
@@ -669,6 +678,7 @@ nfs_readlinkrpc(vp, uiop, cred)
  * nfs read rpc call
  * Ditto above
  */
  * nfs read rpc call
  * Ditto above
  */
+int
 nfs_readrpc(vp, uiop, cred)
        register struct vnode *vp;
        struct uio *uiop;
 nfs_readrpc(vp, uiop, cred)
        register struct vnode *vp;
        struct uio *uiop;
@@ -711,6 +721,7 @@ nfsmout:
 /*
  * nfs write call
  */
 /*
  * nfs write call
  */
+int
 nfs_writerpc(vp, uiop, cred)
        register struct vnode *vp;
        struct uio *uiop;
 nfs_writerpc(vp, uiop, cred)
        register struct vnode *vp;
        struct uio *uiop;
@@ -765,11 +776,13 @@ nfsmout:
  * set to specify the file type and the size field for rdev.
  */
 /* ARGSUSED */
  * set to specify the file type and the size field for rdev.
  */
 /* ARGSUSED */
-nfs_mknod(ndp, vap, cred, procp)
-       struct nameidata *ndp;
-       struct ucred *cred;
-       register struct vattr *vap;
-       struct proc *procp;
+int
+nfs_mknod(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* old: nfs_mknod(ndp, vap, cred, procp) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
+       struct vattr *vap;
 {
        register struct nfsv2_sattr *sp;
        register u_long *tl;
 {
        register struct nfsv2_sattr *sp;
        register u_long *tl;
@@ -787,38 +800,41 @@ nfs_mknod(ndp, vap, cred, procp)
                rdev = 0xffffffff;
 #endif /* FIFO */
        else {
                rdev = 0xffffffff;
 #endif /* FIFO */
        else {
-               VOP_ABORTOP(ndp);
-               vput(ndp->ni_dvp);
+               VOP_ABORTOP(dvp, cnp);
+               vput(dvp);
                return (EOPNOTSUPP);
        }
        nfsstats.rpccnt[NFSPROC_CREATE]++;
                return (EOPNOTSUPP);
        }
        nfsstats.rpccnt[NFSPROC_CREATE]++;
-       nfsm_reqhead(ndp->ni_dvp, NFSPROC_CREATE,
-         NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_namelen)+NFSX_SATTR);
-       nfsm_fhtom(ndp->ni_dvp);
-       nfsm_strtom(ndp->ni_ptr, ndp->ni_namelen, NFS_MAXNAMLEN);
+       nfsm_reqhead(dvp, NFSPROC_CREATE,
+         NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(cnp->cn_namelen)+NFSX_SATTR);
+       nfsm_fhtom(dvp);
+       nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
-       sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
-       sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
+       sp->sa_uid = txdr_unsigned(cnp->cn_cred->cr_uid);
+       sp->sa_gid = txdr_unsigned(cnp->cn_cred->cr_gid);
        sp->sa_size = rdev;
        /* or should these be VNOVAL ?? */
        txdr_time(&vap->va_atime, &sp->sa_atime);
        txdr_time(&vap->va_mtime, &sp->sa_mtime);
        sp->sa_size = rdev;
        /* or should these be VNOVAL ?? */
        txdr_time(&vap->va_atime, &sp->sa_atime);
        txdr_time(&vap->va_mtime, &sp->sa_mtime);
-       nfsm_request(ndp->ni_dvp, NFSPROC_CREATE, procp, cred);
+       nfsm_request(dvp, NFSPROC_CREATE, cnp->cn_proc, cnp->cn_cred);
        nfsm_reqdone;
        nfsm_reqdone;
-       FREE(ndp->ni_pnbuf, M_NAMEI);
-       VTONFS(ndp->ni_dvp)->n_flag |= NMODIFIED;
-       vrele(ndp->ni_dvp);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
+       VTONFS(dvp)->n_flag |= NMODIFIED;
+       vrele(dvp);
        return (error);
 }
 
 /*
  * nfs file create call
  */
        return (error);
 }
 
 /*
  * nfs file create call
  */
-nfs_create(ndp, vap, procp)
-       register struct nameidata *ndp;
-       register struct vattr *vap;
-       struct proc *procp;
+int
+nfs_create(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* old: nfs_create(ndp, vap, procp) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
+       struct vattr *vap;
 {
        register struct nfsv2_sattr *sp;
        register u_long *tl;
 {
        register struct nfsv2_sattr *sp;
        register u_long *tl;
@@ -829,24 +845,24 @@ nfs_create(ndp, vap, procp)
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
        nfsstats.rpccnt[NFSPROC_CREATE]++;
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
        nfsstats.rpccnt[NFSPROC_CREATE]++;
-       nfsm_reqhead(ndp->ni_dvp, NFSPROC_CREATE,
-         NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_namelen)+NFSX_SATTR);
-       nfsm_fhtom(ndp->ni_dvp);
-       nfsm_strtom(ndp->ni_ptr, ndp->ni_namelen, NFS_MAXNAMLEN);
+       nfsm_reqhead(dvp, NFSPROC_CREATE,
+         NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(cnp->cn_namelen)+NFSX_SATTR);
+       nfsm_fhtom(dvp);
+       nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
-       sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
-       sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
+       sp->sa_uid = txdr_unsigned(cnp->cn_cred->cr_uid);
+       sp->sa_gid = txdr_unsigned(cnp->cn_cred->cr_gid);
        sp->sa_size = txdr_unsigned(0);
        /* or should these be VNOVAL ?? */
        txdr_time(&vap->va_atime, &sp->sa_atime);
        txdr_time(&vap->va_mtime, &sp->sa_mtime);
        sp->sa_size = txdr_unsigned(0);
        /* or should these be VNOVAL ?? */
        txdr_time(&vap->va_atime, &sp->sa_atime);
        txdr_time(&vap->va_mtime, &sp->sa_mtime);
-       nfsm_request(ndp->ni_dvp, NFSPROC_CREATE, procp, ndp->ni_cred);
-       nfsm_mtofh(ndp->ni_dvp, ndp->ni_vp);
+       nfsm_request(dvp, NFSPROC_CREATE, cnp->cn_proc, cnp->cn_cred);
+       nfsm_mtofh(dvp, *vpp);
        nfsm_reqdone;
        nfsm_reqdone;
-       FREE(ndp->ni_pnbuf, M_NAMEI);
-       VTONFS(ndp->ni_dvp)->n_flag |= NMODIFIED;
-       vrele(ndp->ni_dvp);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
+       VTONFS(dvp)->n_flag |= NMODIFIED;
+       vrele(dvp);
        return (error);
 }
 
        return (error);
 }
 
@@ -861,12 +877,13 @@ nfs_create(ndp, vap, procp)
  *     else
  *       do the remove rpc
  */
  *     else
  *       do the remove rpc
  */
-nfs_remove(ndp, procp)
-       register struct nameidata *ndp;
-       struct proc *procp;
+int
+nfs_remove(dvp, vp, cnp)   /* converted to CN.   */
+/* old: ufs_remove(ndp, p) */
+       struct vnode *dvp, *vp;
+       struct componentname *cnp;
 {
 {
-       register struct vnode *vp = ndp->ni_vp;
-       register struct nfsnode *np = VTONFS(ndp->ni_vp);
+       register struct nfsnode *np = VTONFS(vp);
        register u_long *tl;
        register caddr_t cp;
        register long t2;
        register u_long *tl;
        register caddr_t cp;
        register long t2;
@@ -876,7 +893,7 @@ nfs_remove(ndp, procp)
 
        if (vp->v_usecount > 1) {
                if (!np->n_sillyrename)
 
        if (vp->v_usecount > 1) {
                if (!np->n_sillyrename)
-                       error = nfs_sillyrename(ndp, procp);
+                       error = nfs_sillyrename(dvp, vp, cnp);   /* NEEDSWORK */
        } else {
                /*
                 * Purge the name cache so that the chance of a lookup for
        } else {
                /*
                 * Purge the name cache so that the chance of a lookup for
@@ -893,14 +910,14 @@ nfs_remove(ndp, procp)
                vinvalbuf(vp, FALSE);
                /* Do the rpc */
                nfsstats.rpccnt[NFSPROC_REMOVE]++;
                vinvalbuf(vp, FALSE);
                /* Do the rpc */
                nfsstats.rpccnt[NFSPROC_REMOVE]++;
-               nfsm_reqhead(ndp->ni_dvp, NFSPROC_REMOVE,
-                       NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_namelen));
-               nfsm_fhtom(ndp->ni_dvp);
-               nfsm_strtom(ndp->ni_ptr, ndp->ni_namelen, NFS_MAXNAMLEN);
-               nfsm_request(ndp->ni_dvp, NFSPROC_REMOVE, procp, ndp->ni_cred);
+               nfsm_reqhead(dvp, NFSPROC_REMOVE,
+                       NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(cnp->cn_namelen));
+               nfsm_fhtom(dvp);
+               nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
+               nfsm_request(dvp, NFSPROC_REMOVE, cnp->cn_proc, cnp->cn_cred);
                nfsm_reqdone;
                nfsm_reqdone;
-               FREE(ndp->ni_pnbuf, M_NAMEI);
-               VTONFS(ndp->ni_dvp)->n_flag |= NMODIFIED;
+               FREE(cnp->cn_pnbuf, M_NAMEI);
+               VTONFS(dvp)->n_flag |= NMODIFIED;
                /*
                 * Kludge City: If the first reply to the remove rpc is lost..
                 *   the reply to the retransmitted request will be ENOENT
                /*
                 * Kludge City: If the first reply to the remove rpc is lost..
                 *   the reply to the retransmitted request will be ENOENT
@@ -911,7 +928,7 @@ nfs_remove(ndp, procp)
                        error = 0;
        }
        np->n_attrstamp = 0;
                        error = 0;
        }
        np->n_attrstamp = 0;
-       vrele(ndp->ni_dvp);
+       vrele(dvp);
        vrele(vp);
        return (error);
 }
        vrele(vp);
        return (error);
 }
@@ -919,6 +936,7 @@ nfs_remove(ndp, procp)
 /*
  * nfs file remove rpc called from nfs_inactive
  */
 /*
  * nfs file remove rpc called from nfs_inactive
  */
+int
 nfs_removeit(sp, procp)
        register struct sillyrename *sp;
        struct proc *procp;
 nfs_removeit(sp, procp)
        register struct sillyrename *sp;
        struct proc *procp;
@@ -944,9 +962,14 @@ nfs_removeit(sp, procp)
 /*
  * nfs file rename call
  */
 /*
  * nfs file rename call
  */
-nfs_rename(sndp, tndp, procp)
-       register struct nameidata *sndp, *tndp;
-       struct proc *procp;
+int
+nfs_rename(fdvp, fvp, fcnp,
+          tdvp, tvp, tcnp)   /* converted to CN.   */
+/* old: nfs_rename(sndp, tndp, procp) */
+       struct vnode *fdvp, *fvp;
+       struct componentname *fcnp;
+       struct vnode *tdvp, *tvp;
+       struct componentname *tcnp;
 {
        register u_long *tl;
        register caddr_t cp;
 {
        register u_long *tl;
        register caddr_t cp;
@@ -956,30 +979,30 @@ nfs_rename(sndp, tndp, procp)
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
        nfsstats.rpccnt[NFSPROC_RENAME]++;
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
        nfsstats.rpccnt[NFSPROC_RENAME]++;
-       nfsm_reqhead(sndp->ni_dvp, NFSPROC_RENAME,
-               (NFSX_FH+NFSX_UNSIGNED)*2+nfsm_rndup(sndp->ni_namelen)+
-               nfsm_rndup(tndp->ni_namelen)); /* or sndp->ni_cred?*/
-       nfsm_fhtom(sndp->ni_dvp);
-       nfsm_strtom(sndp->ni_ptr, sndp->ni_namelen, NFS_MAXNAMLEN);
-       nfsm_fhtom(tndp->ni_dvp);
-       nfsm_strtom(tndp->ni_ptr, tndp->ni_namelen, NFS_MAXNAMLEN);
-       nfsm_request(sndp->ni_dvp, NFSPROC_RENAME, procp, tndp->ni_cred);
+       nfsm_reqhead(fdvp, NFSPROC_RENAME,
+               (NFSX_FH+NFSX_UNSIGNED)*2+nfsm_rndup(fcnp->cn_namelen)+
+               nfsm_rndup(fcnp->cn_namelen)); /* or fcnp->cn_cred?*/
+       nfsm_fhtom(fdvp);
+       nfsm_strtom(fcnp->cn_nameptr, fcnp->cn_namelen, NFS_MAXNAMLEN);
+       nfsm_fhtom(tdvp);
+       nfsm_strtom(tcnp->cn_nameptr, tcnp->cn_namelen, NFS_MAXNAMLEN);
+       nfsm_request(fdvp, NFSPROC_RENAME, tcnp->cn_proc, tcnp->cn_cred);
        nfsm_reqdone;
        nfsm_reqdone;
-       VTONFS(sndp->ni_dvp)->n_flag |= NMODIFIED;
-       VTONFS(tndp->ni_dvp)->n_flag |= NMODIFIED;
-       if (sndp->ni_vp->v_type == VDIR) {
-               if (tndp->ni_vp != NULL && tndp->ni_vp->v_type == VDIR)
-                       cache_purge(tndp->ni_dvp);
-               cache_purge(sndp->ni_dvp);
+       VTONFS(fdvp)->n_flag |= NMODIFIED;
+       VTONFS(tdvp)->n_flag |= NMODIFIED;
+       if (fvp->v_type == VDIR) {
+               if (tvp != NULL && tvp->v_type == VDIR)
+                       cache_purge(tdvp);
+               cache_purge(fdvp);
        }
        }
-       if (tndp->ni_dvp == tndp->ni_vp)
-               vrele(tndp->ni_dvp);
+       if (tdvp == tvp)
+               vrele(tdvp);
        else
        else
-               vput(tndp->ni_dvp);
-       if (tndp->ni_vp)
-               vput(tndp->ni_vp);
-       vrele(sndp->ni_dvp);
-       vrele(sndp->ni_vp);
+               vput(tdvp);
+       if (tvp)
+               vput(tvp);
+       vrele(fdvp);
+       vrele(fvp);
        /*
         * Kludge: Map ENOENT => 0 assuming that it is a reply to a retry.
         */
        /*
         * Kludge: Map ENOENT => 0 assuming that it is a reply to a retry.
         */
@@ -991,10 +1014,11 @@ nfs_rename(sndp, tndp, procp)
 /*
  * nfs file rename rpc called from nfs_remove() above
  */
 /*
  * nfs file rename rpc called from nfs_remove() above
  */
-nfs_renameit(sndp, sp, procp)
-       register struct nameidata *sndp;
+int
+nfs_renameit(sdvp, scnp, sp)
+       struct vnode *sdvp;
+       struct componentname *scnp;
        register struct sillyrename *sp;
        register struct sillyrename *sp;
-       struct proc *procp;
 {
        register u_long *tl;
        register caddr_t cp;
 {
        register u_long *tl;
        register caddr_t cp;
@@ -1004,27 +1028,29 @@ nfs_renameit(sndp, sp, procp)
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
        nfsstats.rpccnt[NFSPROC_RENAME]++;
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
        nfsstats.rpccnt[NFSPROC_RENAME]++;
-       nfsm_reqhead(sndp->ni_dvp, NFSPROC_RENAME,
-               (NFSX_FH+NFSX_UNSIGNED)*2+nfsm_rndup(sndp->ni_namelen)+
+       nfsm_reqhead(sdvp, NFSPROC_RENAME,
+               (NFSX_FH+NFSX_UNSIGNED)*2+nfsm_rndup(scnp->cn_namelen)+
                nfsm_rndup(sp->s_namlen));
                nfsm_rndup(sp->s_namlen));
-       nfsm_fhtom(sndp->ni_dvp);
-       nfsm_strtom(sndp->ni_ptr, sndp->ni_namelen, NFS_MAXNAMLEN);
-       nfsm_fhtom(sp->s_dvp);
+       nfsm_fhtom(sdvp);
+       nfsm_strtom(scnp->cn_nameptr, scnp->cn_namelen, NFS_MAXNAMLEN);
+       nfsm_fhtom(sdvp);
        nfsm_strtom(sp->s_name, sp->s_namlen, NFS_MAXNAMLEN);
        nfsm_strtom(sp->s_name, sp->s_namlen, NFS_MAXNAMLEN);
-       nfsm_request(sndp->ni_dvp, NFSPROC_RENAME, procp, sndp->ni_cred);
+       nfsm_request(sdvp, NFSPROC_RENAME, scnp->cn_proc, scnp->cn_cred);
        nfsm_reqdone;
        nfsm_reqdone;
-       FREE(sndp->ni_pnbuf, M_NAMEI);
-       VTONFS(sndp->ni_dvp)->n_flag |= NMODIFIED;
+       FREE(scnp->cn_pnbuf, M_NAMEI);
+       VTONFS(sdvp)->n_flag |= NMODIFIED;
        return (error);
 }
 
 /*
  * nfs hard link create call
  */
        return (error);
 }
 
 /*
  * nfs hard link create call
  */
-nfs_link(vp, ndp, procp)
-       register struct vnode *vp;
-       register struct nameidata *ndp;
-       struct proc *procp;
+int
+nfs_link(vp, tdvp, cnp)   /* converted to CN.   */
+/* old: nfs_link(vp, ndp, procp) */
+       register struct vnode *vp;   /* source vnode */
+       struct vnode *tdvp;
+       struct componentname *cnp;
 {
        register u_long *tl;
        register caddr_t cp;
 {
        register u_long *tl;
        register caddr_t cp;
@@ -1035,16 +1061,16 @@ nfs_link(vp, ndp, procp)
 
        nfsstats.rpccnt[NFSPROC_LINK]++;
        nfsm_reqhead(vp, NFSPROC_LINK,
 
        nfsstats.rpccnt[NFSPROC_LINK]++;
        nfsm_reqhead(vp, NFSPROC_LINK,
-               NFSX_FH*2+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_namelen));
+               NFSX_FH*2+NFSX_UNSIGNED+nfsm_rndup(cnp->cn_namelen));
        nfsm_fhtom(vp);
        nfsm_fhtom(vp);
-       nfsm_fhtom(ndp->ni_dvp);
-       nfsm_strtom(ndp->ni_ptr, ndp->ni_namelen, NFS_MAXNAMLEN);
-       nfsm_request(vp, NFSPROC_LINK, procp, ndp->ni_cred);
+       nfsm_fhtom(tdvp);
+       nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
+       nfsm_request(vp, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred);
        nfsm_reqdone;
        nfsm_reqdone;
-       FREE(ndp->ni_pnbuf, M_NAMEI);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
        VTONFS(vp)->n_attrstamp = 0;
        VTONFS(vp)->n_attrstamp = 0;
-       VTONFS(ndp->ni_dvp)->n_flag |= NMODIFIED;
-       vrele(ndp->ni_dvp);
+       VTONFS(tdvp)->n_flag |= NMODIFIED;
+       vrele(tdvp);
        /*
         * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
         */
        /*
         * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
         */
@@ -1056,11 +1082,15 @@ nfs_link(vp, ndp, procp)
 /*
  * nfs symbolic link create call
  */
 /*
  * nfs symbolic link create call
  */
-nfs_symlink(ndp, vap, nm, procp)
-       struct nameidata *ndp;
+/* start here */
+int
+nfs_symlink(dvp, vpp, cnp, vap, nm)   /* converted to CN.   */
+/* old: nfs_symlink(ndp, vap, nm, procp) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        char *nm;
        struct vattr *vap;
        char *nm;
-       struct proc *procp;
 {
        register struct nfsv2_sattr *sp;
        register u_long *tl;
 {
        register struct nfsv2_sattr *sp;
        register u_long *tl;
@@ -1072,26 +1102,29 @@ nfs_symlink(ndp, vap, nm, procp)
 
        nfsstats.rpccnt[NFSPROC_SYMLINK]++;
        slen = strlen(nm);
 
        nfsstats.rpccnt[NFSPROC_SYMLINK]++;
        slen = strlen(nm);
-       nfsm_reqhead(ndp->ni_dvp, NFSPROC_SYMLINK,
-        NFSX_FH+2*NFSX_UNSIGNED+nfsm_rndup(ndp->ni_namelen)+nfsm_rndup(slen)+NFSX_SATTR);
-       nfsm_fhtom(ndp->ni_dvp);
-       nfsm_strtom(ndp->ni_ptr, ndp->ni_namelen, NFS_MAXNAMLEN);
+       nfsm_reqhead(dvp, NFSPROC_SYMLINK,
+        NFSX_FH+2*NFSX_UNSIGNED+nfsm_rndup(cnp->cn_namelen)+nfsm_rndup(slen)+NFSX_SATTR);
+       nfsm_fhtom(dvp);
+       nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
        nfsm_strtom(nm, slen, NFS_MAXPATHLEN);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        sp->sa_mode = vtonfs_mode(VLNK, vap->va_mode);
        nfsm_strtom(nm, slen, NFS_MAXPATHLEN);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        sp->sa_mode = vtonfs_mode(VLNK, vap->va_mode);
-       sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
-       sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
+       sp->sa_uid = txdr_unsigned(cnp->cn_cred->cr_uid);
+       sp->sa_gid = txdr_unsigned(cnp->cn_cred->cr_gid);
        sp->sa_size = txdr_unsigned(VNOVAL);
        txdr_time(&vap->va_atime, &sp->sa_atime);       /* or VNOVAL ?? */
        txdr_time(&vap->va_mtime, &sp->sa_mtime);       /* or VNOVAL ?? */
        sp->sa_size = txdr_unsigned(VNOVAL);
        txdr_time(&vap->va_atime, &sp->sa_atime);       /* or VNOVAL ?? */
        txdr_time(&vap->va_mtime, &sp->sa_mtime);       /* or VNOVAL ?? */
-       nfsm_request(ndp->ni_dvp, NFSPROC_SYMLINK, procp, ndp->ni_cred);
+       nfsm_request(dvp, NFSPROC_SYMLINK, cnp->cn_proc, cnp->cn_cred);
        nfsm_reqdone;
        nfsm_reqdone;
-       FREE(ndp->ni_pnbuf, M_NAMEI);
-       VTONFS(ndp->ni_dvp)->n_flag |= NMODIFIED;
-       vrele(ndp->ni_dvp);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
+       VTONFS(dvp)->n_flag |= NMODIFIED;
+       vrele(dvp);
        /*
         * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
         */
        /*
         * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
         */
+       /*
+        * NEEDSWORK: what about *vpp?
+        */
        if (error == EEXIST)
                error = 0;
        return (error);
        if (error == EEXIST)
                error = 0;
        return (error);
@@ -1100,10 +1133,13 @@ nfs_symlink(ndp, vap, nm, procp)
 /*
  * nfs make dir call
  */
 /*
  * nfs make dir call
  */
-nfs_mkdir(ndp, vap, procp)
-       register struct nameidata *ndp;
+int
+nfs_mkdir(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* old: nfs_mkdir(ndp, vap, procp) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        struct vattr *vap;
-       struct proc *procp;
 {
        register struct nfsv2_sattr *sp;
        register u_long *tl;
 {
        register struct nfsv2_sattr *sp;
        register u_long *tl;
@@ -1114,23 +1150,23 @@ nfs_mkdir(ndp, vap, procp)
        int error = 0, firsttry = 1;
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
        int error = 0, firsttry = 1;
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
-       len = ndp->ni_namelen;
+       len = cnp->cn_namelen;
        nfsstats.rpccnt[NFSPROC_MKDIR]++;
        nfsstats.rpccnt[NFSPROC_MKDIR]++;
-       nfsm_reqhead(ndp->ni_dvp, NFSPROC_MKDIR,
+       nfsm_reqhead(dvp, NFSPROC_MKDIR,
          NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len)+NFSX_SATTR);
          NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len)+NFSX_SATTR);
-       nfsm_fhtom(ndp->ni_dvp);
-       nfsm_strtom(ndp->ni_ptr, len, NFS_MAXNAMLEN);
+       nfsm_fhtom(dvp);
+       nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        sp->sa_mode = vtonfs_mode(VDIR, vap->va_mode);
        nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
        sp->sa_mode = vtonfs_mode(VDIR, vap->va_mode);
-       sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
-       sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
+       sp->sa_uid = txdr_unsigned(cnp->cn_cred->cr_uid);
+       sp->sa_gid = txdr_unsigned(cnp->cn_cred->cr_gid);
        sp->sa_size = txdr_unsigned(VNOVAL);
        txdr_time(&vap->va_atime, &sp->sa_atime);       /* or VNOVAL ?? */
        txdr_time(&vap->va_mtime, &sp->sa_mtime);       /* or VNOVAL ?? */
        sp->sa_size = txdr_unsigned(VNOVAL);
        txdr_time(&vap->va_atime, &sp->sa_atime);       /* or VNOVAL ?? */
        txdr_time(&vap->va_mtime, &sp->sa_mtime);       /* or VNOVAL ?? */
-       nfsm_request(ndp->ni_dvp, NFSPROC_MKDIR, procp, ndp->ni_cred);
-       nfsm_mtofh(ndp->ni_dvp, ndp->ni_vp);
+       nfsm_request(dvp, NFSPROC_MKDIR, cnp->cn_proc, cnp->cn_cred);
+       nfsm_mtofh(dvp, *vpp);
        nfsm_reqdone;
        nfsm_reqdone;
-       VTONFS(ndp->ni_dvp)->n_flag |= NMODIFIED;
+       VTONFS(dvp)->n_flag |= NMODIFIED;
        /*
         * Kludge: Map EEXIST => 0 assuming that you have a reply to a retry
         * if we can succeed in looking up the directory.
        /*
         * Kludge: Map EEXIST => 0 assuming that you have a reply to a retry
         * if we can succeed in looking up the directory.
@@ -1141,30 +1177,32 @@ nfs_mkdir(ndp, vap, procp)
                firsttry = 0;
                error = 0;
                nfsstats.rpccnt[NFSPROC_LOOKUP]++;
                firsttry = 0;
                error = 0;
                nfsstats.rpccnt[NFSPROC_LOOKUP]++;
-               ndp->ni_vp = NULL;
-               nfsm_reqhead(ndp->ni_dvp, NFSPROC_LOOKUP,
+               *vpp = NULL;
+               nfsm_reqhead(dvp, NFSPROC_LOOKUP,
                    NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len));
                    NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(len));
-               nfsm_fhtom(ndp->ni_dvp);
-               nfsm_strtom(ndp->ni_ptr, len, NFS_MAXNAMLEN);
-               nfsm_request(ndp->ni_dvp, NFSPROC_LOOKUP, procp, ndp->ni_cred);
-               nfsm_mtofh(ndp->ni_dvp, ndp->ni_vp);
-               if (ndp->ni_vp->v_type != VDIR) {
-                       vput(ndp->ni_vp);
+               nfsm_fhtom(dvp);
+               nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN);
+               nfsm_request(dvp, NFSPROC_LOOKUP, cnp->cn_proc, cnp->cn_cred);
+               nfsm_mtofh(dvp, *vpp);
+               if ((*vpp)->v_type != VDIR) {
+                       vput(*vpp);
                        error = EEXIST;
                }
                m_freem(mrep);
        }
                        error = EEXIST;
                }
                m_freem(mrep);
        }
-       FREE(ndp->ni_pnbuf, M_NAMEI);
-       vrele(ndp->ni_dvp);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
+       vrele(dvp);
        return (error);
 }
 
 /*
  * nfs remove directory call
  */
        return (error);
 }
 
 /*
  * nfs remove directory call
  */
-nfs_rmdir(ndp, procp)
-       register struct nameidata *ndp;
-       struct proc *procp;
+int
+nfs_rmdir(dvp, vp, cnp)   /* converted to CN.   */
+/* old: nfs_rmdir(ndp, procp) */
+       struct vnode *dvp, *vp;
+       struct componentname *cnp;
 {
        register u_long *tl;
        register caddr_t cp;
 {
        register u_long *tl;
        register caddr_t cp;
@@ -1173,25 +1211,25 @@ nfs_rmdir(ndp, procp)
        int error = 0;
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
        int error = 0;
        struct mbuf *mreq, *mrep, *md, *mb, *mb2;
 
-       if (ndp->ni_dvp == ndp->ni_vp) {
-               vrele(ndp->ni_dvp);
-               vrele(ndp->ni_dvp);
-               FREE(ndp->ni_pnbuf, M_NAMEI);
+       if (dvp == vp) {
+               vrele(dvp);
+               vrele(dvp);
+               FREE(cnp->cn_pnbuf, M_NAMEI);
                return (EINVAL);
        }
        nfsstats.rpccnt[NFSPROC_RMDIR]++;
                return (EINVAL);
        }
        nfsstats.rpccnt[NFSPROC_RMDIR]++;
-       nfsm_reqhead(ndp->ni_dvp, NFSPROC_RMDIR,
-               NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(ndp->ni_namelen));
-       nfsm_fhtom(ndp->ni_dvp);
-       nfsm_strtom(ndp->ni_ptr, ndp->ni_namelen, NFS_MAXNAMLEN);
-       nfsm_request(ndp->ni_dvp, NFSPROC_RMDIR, procp, ndp->ni_cred);
+       nfsm_reqhead(dvp, NFSPROC_RMDIR,
+               NFSX_FH+NFSX_UNSIGNED+nfsm_rndup(cnp->cn_namelen));
+       nfsm_fhtom(dvp);
+       nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
+       nfsm_request(dvp, NFSPROC_RMDIR, cnp->cn_proc, cnp->cn_cred);
        nfsm_reqdone;
        nfsm_reqdone;
-       FREE(ndp->ni_pnbuf, M_NAMEI);
-       VTONFS(ndp->ni_dvp)->n_flag |= NMODIFIED;
-       cache_purge(ndp->ni_dvp);
-       cache_purge(ndp->ni_vp);
-       vrele(ndp->ni_vp);
-       vrele(ndp->ni_dvp);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
+       VTONFS(dvp)->n_flag |= NMODIFIED;
+       cache_purge(dvp);
+       cache_purge(vp);
+       vrele(vp);
+       vrele(dvp);
        /*
         * Kludge: Map ENOENT => 0 assuming that you have a reply to a retry.
         */
        /*
         * Kludge: Map ENOENT => 0 assuming that you have a reply to a retry.
         */
@@ -1206,6 +1244,7 @@ nfs_rmdir(ndp, procp)
  * order so that it looks more sensible. This appears consistent with the
  * Ultrix implementation of NFS.
  */
  * order so that it looks more sensible. This appears consistent with the
  * Ultrix implementation of NFS.
  */
+int
 nfs_readdir(vp, uiop, cred, eofflagp)
        register struct vnode *vp;
        struct uio *uiop;
 nfs_readdir(vp, uiop, cred, eofflagp)
        register struct vnode *vp;
        struct uio *uiop;
@@ -1255,6 +1294,7 @@ nfs_readdir(vp, uiop, cred, eofflagp)
  * Readdir rpc call.
  * Called from below the buffer cache by nfs_doio().
  */
  * Readdir rpc call.
  * Called from below the buffer cache by nfs_doio().
  */
+int
 nfs_readdirrpc(vp, uiop, cred)
        register struct vnode *vp;
        struct uio *uiop;
 nfs_readdirrpc(vp, uiop, cred)
        register struct vnode *vp;
        struct uio *uiop;
@@ -1397,6 +1437,7 @@ nfsmout:
  * Nqnfs readdir_and_lookup RPC. Used in place of nfs_readdirrpc() when
  * the "rdirlook" mount option is specified.
  */
  * Nqnfs readdir_and_lookup RPC. Used in place of nfs_readdirrpc() when
  * the "rdirlook" mount option is specified.
  */
+int
 nfs_readdirlookrpc(vp, uiop, cred)
        struct vnode *vp;
        register struct uio *uiop;
 nfs_readdirlookrpc(vp, uiop, cred)
        struct vnode *vp;
        register struct uio *uiop;
@@ -1598,29 +1639,31 @@ static char hextoasc[] = "0123456789abcdef";
  * to create the same funny name between the nfs_lookitup() fails and the
  * nfs_rename() completes, but...
  */
  * to create the same funny name between the nfs_lookitup() fails and the
  * nfs_rename() completes, but...
  */
-nfs_sillyrename(ndp, p)
-       register struct nameidata *ndp;
-       struct proc *p;
+int
+nfs_sillyrename(dvp, vp, cnp)   /* NEEDSWORK */
+/* old: nfs_sillyrename(ndp, p) */
+       struct vnode *dvp, *vp;
+       struct componentname *cnp;
 {
        register struct nfsnode *np;
        register struct sillyrename *sp;
        int error;
        short pid;
 
 {
        register struct nfsnode *np;
        register struct sillyrename *sp;
        int error;
        short pid;
 
-       cache_purge(ndp->ni_dvp);
-       np = VTONFS(ndp->ni_vp);
+       cache_purge(dvp);
+       np = VTONFS(vp);
 #ifdef SILLYSEPARATE
        MALLOC(sp, struct sillyrename *, sizeof (struct sillyrename),
                M_NFSREQ, M_WAITOK);
 #else
        sp = &np->n_silly;
 #endif
 #ifdef SILLYSEPARATE
        MALLOC(sp, struct sillyrename *, sizeof (struct sillyrename),
                M_NFSREQ, M_WAITOK);
 #else
        sp = &np->n_silly;
 #endif
-       sp->s_cred = crdup(ndp->ni_cred);
-       sp->s_dvp = ndp->ni_dvp;
-       VREF(sp->s_dvp);
+       sp->s_cred = crdup(cnp->cn_cred);
+       sp->s_dvp = dvp;
+       VREF(dvp);
 
        /* Fudge together a funny name */
 
        /* Fudge together a funny name */
-       pid = p->p_pid;
+       pid = cnp->cn_proc->p_pid;
        bcopy(".nfsAxxxx4.4", sp->s_name, 13);
        sp->s_namlen = 12;
        sp->s_name[8] = hextoasc[pid & 0xf];
        bcopy(".nfsAxxxx4.4", sp->s_name, 13);
        sp->s_namlen = 12;
        sp->s_name[8] = hextoasc[pid & 0xf];
@@ -1629,16 +1672,16 @@ nfs_sillyrename(ndp, p)
        sp->s_name[5] = hextoasc[(pid >> 12) & 0xf];
 
        /* Try lookitups until we get one that isn't there */
        sp->s_name[5] = hextoasc[(pid >> 12) & 0xf];
 
        /* Try lookitups until we get one that isn't there */
-       while (nfs_lookitup(sp, (nfsv2fh_t *)0, p) == 0) {
+       while (nfs_lookitup(sp, (nfsv2fh_t *)0, cnp->cn_proc) == 0) {
                sp->s_name[4]++;
                if (sp->s_name[4] > 'z') {
                        error = EINVAL;
                        goto bad;
                }
        }
                sp->s_name[4]++;
                if (sp->s_name[4] > 'z') {
                        error = EINVAL;
                        goto bad;
                }
        }
-       if (error = nfs_renameit(ndp, sp, p))
+       if (error = nfs_renameit(dvp, cnp, sp))
                goto bad;
                goto bad;
-       nfs_lookitup(sp, &np->n_fh, p);
+       nfs_lookitup(sp, &np->n_fh, cnp->cn_proc);
        np->n_sillyrename = sp;
        return (0);
 bad:
        np->n_sillyrename = sp;
        return (0);
 bad:
@@ -1656,6 +1699,7 @@ bad:
  * into the nfsnode table.
  * If fhp != NULL it copies the returned file handle out
  */
  * into the nfsnode table.
  * If fhp != NULL it copies the returned file handle out
  */
+int
 nfs_lookitup(sp, fhp, procp)
        register struct sillyrename *sp;
        nfsv2fh_t *fhp;
 nfs_lookitup(sp, fhp, procp)
        register struct sillyrename *sp;
        nfsv2fh_t *fhp;
@@ -1696,6 +1740,7 @@ nfs_lookitup(sp, fhp, procp)
  *    a lot more work than bcopy() and also it currently happens in the
  *    context of the swapper process (2).
  */
  *    a lot more work than bcopy() and also it currently happens in the
  *    context of the swapper process (2).
  */
+int
 nfs_bmap(vp, bn, vpp, bnp)
        struct vnode *vp;
        daddr_t bn;
 nfs_bmap(vp, bn, vpp, bnp)
        struct vnode *vp;
        daddr_t bn;
@@ -1714,6 +1759,7 @@ nfs_bmap(vp, bn, vpp, bnp)
  * If the biod's are running, queue a request
  * otherwise just call nfs_doio() to get it done
  */
  * If the biod's are running, queue a request
  * otherwise just call nfs_doio() to get it done
  */
+int
 nfs_strategy(bp)
        register struct buf *bp;
 {
 nfs_strategy(bp)
        register struct buf *bp;
 {
@@ -1772,6 +1818,7 @@ nfs_strategy(bp)
  * otherwise it is called by the nfsiods to do what would normally be
  * partially disk interrupt driven.
  */
  * otherwise it is called by the nfsiods to do what would normally be
  * partially disk interrupt driven.
  */
+int
 nfs_doio(bp)
        register struct buf *bp;
 {
 nfs_doio(bp)
        register struct buf *bp;
 {
@@ -1884,6 +1931,7 @@ nfs_doio(bp)
  * NB Currently unsupported.
  */
 /* ARGSUSED */
  * NB Currently unsupported.
  */
 /* ARGSUSED */
+int
 nfs_mmap(vp, fflags, cred, p)
        struct vnode *vp;
        int fflags;
 nfs_mmap(vp, fflags, cred, p)
        struct vnode *vp;
        int fflags;
@@ -1900,6 +1948,7 @@ nfs_mmap(vp, fflags, cred, p)
  *     associated with the vnode.
  */
 /* ARGSUSED */
  *     associated with the vnode.
  */
 /* ARGSUSED */
+int
 nfs_fsync(vp, fflags, cred, waitfor, p)
        register struct vnode *vp;
        int fflags;
 nfs_fsync(vp, fflags, cred, waitfor, p)
        register struct vnode *vp;
        int fflags;
@@ -1923,6 +1972,7 @@ nfs_fsync(vp, fflags, cred, waitfor, p)
  * NFS advisory byte-level locks.
  * Currently unsupported.
  */
  * NFS advisory byte-level locks.
  * Currently unsupported.
  */
+int
 nfs_advlock(vp, id, op, fl, flags)
        struct vnode *vp;
        caddr_t id;
 nfs_advlock(vp, id, op, fl, flags)
        struct vnode *vp;
        caddr_t id;
@@ -1937,6 +1987,7 @@ nfs_advlock(vp, id, op, fl, flags)
 /*
  * Print out the contents of an nfsnode.
  */
 /*
  * Print out the contents of an nfsnode.
  */
+int
 nfs_print(vp)
        struct vnode *vp;
 {
 nfs_print(vp)
        struct vnode *vp;
 {
@@ -1955,6 +2006,7 @@ nfs_print(vp)
  * NFS directory offset lookup.
  * Currently unsupported.
  */
  * NFS directory offset lookup.
  * Currently unsupported.
  */
+int
 nfs_blkatoff(vp, offset, res, bpp)
        struct vnode *vp;
        off_t offset;
 nfs_blkatoff(vp, offset, res, bpp)
        struct vnode *vp;
        off_t offset;
@@ -1969,6 +2021,7 @@ nfs_blkatoff(vp, offset, res, bpp)
  * NFS flat namespace lookup.
  * Currently unsupported.
  */
  * NFS flat namespace lookup.
  * Currently unsupported.
  */
+int
 nfs_vget(mp, ino, vpp)
        struct mount *mp;
        ino_t ino;
 nfs_vget(mp, ino, vpp)
        struct mount *mp;
        ino_t ino;
@@ -1982,6 +2035,7 @@ nfs_vget(mp, ino, vpp)
  * NFS flat namespace allocation.
  * Currently unsupported.
  */
  * NFS flat namespace allocation.
  * Currently unsupported.
  */
+int
 nfs_valloc(pvp, mode, cred, vpp)
        struct vnode *pvp;
        int mode;
 nfs_valloc(pvp, mode, cred, vpp)
        struct vnode *pvp;
        int mode;
@@ -2009,6 +2063,7 @@ nfs_vfree(pvp, ino, mode)
 /*
  * NFS file truncation.
  */
 /*
  * NFS file truncation.
  */
+int
 nfs_truncate(vp, length, flags)
        struct vnode *vp;
        u_long length;
 nfs_truncate(vp, length, flags)
        struct vnode *vp;
        u_long length;
@@ -2023,6 +2078,7 @@ nfs_truncate(vp, length, flags)
 /*
  * NFS update.
  */
 /*
  * NFS update.
  */
+int
 nfs_update(vp, ta, tm, waitfor)
        struct vnode *vp;
        struct timeval *ta;
 nfs_update(vp, ta, tm, waitfor)
        struct vnode *vp;
        struct timeval *ta;
index 67f6989..8280525 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nfsnode.h   7.16 (Berkeley) %G%
+ *     @(#)nfsnode.h   7.17 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -88,18 +88,19 @@ struct nfsnode {
  * Prototypes for NFS vnode operations
  */
 int    nfs_lookup __P((
  * Prototypes for NFS vnode operations
  */
 int    nfs_lookup __P((
-               struct vnode *vp,
-               struct nameidata *ndp,
-               struct proc *p));
+               struct vnode *dvp,
+               struct vnode **vpp,
+               struct componentname *cnp));
 int    nfs_create __P((
 int    nfs_create __P((
-               struct nameidata *ndp,
-               struct vattr *vap,
-               struct proc *p));
+               struct vnode *dvp,
+               struct vnode **vpp,
+               struct componentname *cnp,
+               struct vattr *vap));
 int    nfs_mknod __P((
 int    nfs_mknod __P((
-               struct nameidata *ndp,
-               struct vattr *vap,
-               struct ucred *cred,
-               struct proc *p));
+               struct vnode *dvp,
+               struct vnode **vpp,
+               struct componentname *cnp,
+               struct vattr *vap));
 int    nfs_open __P((
                struct vnode *vp,
                int mode,
 int    nfs_open __P((
                struct vnode *vp,
                int mode,
@@ -165,28 +166,35 @@ int       nfs_fsync __P((
                off_t newoff, \
                struct ucred *cred))) nullop)
 int    nfs_remove __P((
                off_t newoff, \
                struct ucred *cred))) nullop)
 int    nfs_remove __P((
-               struct nameidata *ndp,
-               struct proc *p));
-int    nfs_link __P((
+               struct vnode *dvp,
                struct vnode *vp,
                struct vnode *vp,
-               struct nameidata *ndp,
-               struct proc *p));
+               struct componentname *cnp));
+int    nfs_link __P((
+               register struct vnode *vp,
+               struct vnode *tdvp,
+               struct componentname *cnp));
 int    nfs_rename __P((
 int    nfs_rename __P((
-               struct nameidata *fndp,
-               struct nameidata *tdnp,
-               struct proc *p));
+               struct vnode *fdvp,
+               struct vnode *fvp,
+               struct componentname *fcnp,
+               struct vnode *tdvp,
+               struct vnode *tvp,
+               struct componentname *tcnp));
 int    nfs_mkdir __P((
 int    nfs_mkdir __P((
-               struct nameidata *ndp,
-               struct vattr *vap,
-               struct proc *p));
+               struct vnode *dvp,
+               struct vnode **vpp,
+               struct componentname *cnp,
+               struct vattr *vap));
 int    nfs_rmdir __P((
 int    nfs_rmdir __P((
-               struct nameidata *ndp,
-               struct proc *p));
+               struct vnode *dvp,
+               struct vnode *vp,
+               struct componentname *cnp));
 int    nfs_symlink __P((
 int    nfs_symlink __P((
-               struct nameidata *ndp,
+               struct vnode *dvp,
+               struct vnode **vpp,
+               struct componentname *cnp,
                struct vattr *vap,
                struct vattr *vap,
-               char *target,
-               struct proc *p));
+               char *nm));
 int    nfs_readdir __P((
                struct vnode *vp,
                struct uio *uio,
 int    nfs_readdir __P((
                struct vnode *vp,
                struct uio *uio,
@@ -197,7 +205,8 @@ int nfs_readlink __P((
                struct uio *uio,
                struct ucred *cred));
 int    nfs_abortop __P((
                struct uio *uio,
                struct ucred *cred));
 int    nfs_abortop __P((
-               struct nameidata *ndp));
+               struct vnode *,
+               struct componentname *));
 int    nfs_inactive __P((
                struct vnode *vp,
                struct proc *p));
 int    nfs_inactive __P((
                struct vnode *vp,
                struct proc *p));
index a6ffc0a..51bdcd9 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_extern.h        7.2 (Berkeley) %G%
+ *     @(#)ufs_extern.h        7.3 (Berkeley) %G%
  */
 
 struct buf;
  */
 
 struct buf;
@@ -30,7 +30,7 @@ char  *readdisklabel __P((dev_t, int (*)(), struct disklabel *));
 int     setdisklabel __P((struct disklabel *, struct disklabel *, u_long));
 int     writedisklabel __P((dev_t, int (*)(), struct disklabel *));
 
 int     setdisklabel __P((struct disklabel *, struct disklabel *, u_long));
 int     writedisklabel __P((dev_t, int (*)(), struct disklabel *));
 
-int     ufs_abortop __P((struct nameidata *));
+int     ufs_abortop __P((struct vnode *, struct componentname *));
 int     ufs_access __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_advlock __P((struct vnode *, caddr_t, int, struct flock *, int));
 void    ufs_bufstats __P((void));
 int     ufs_access __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_advlock __P((struct vnode *, caddr_t, int, struct flock *, int));
 void    ufs_bufstats __P((void));
@@ -38,14 +38,15 @@ int  ufs_checkpath __P((struct inode *, struct inode *, struct ucred *));
 int     ufs_chmod __P((struct vnode *, int, struct proc *));
 int     ufs_chown __P((struct vnode *, u_int, u_int, struct proc *));
 int     ufs_close __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_chmod __P((struct vnode *, int, struct proc *));
 int     ufs_chown __P((struct vnode *, u_int, u_int, struct proc *));
 int     ufs_close __P((struct vnode *, int, struct ucred *, struct proc *));
-int     ufs_create __P((struct nameidata *, struct vattr *, struct proc *));
+int     ufs_create __P((struct vnode *, struct vnode **,
+                        struct componentname *, struct vattr *));
 void    ufs_dirbad __P((struct inode *, off_t, char *));
 int     ufs_dirbadentry __P((struct direct *, int));
 int     ufs_dirempty __P((struct inode *, ino_t, struct ucred *));
 void    ufs_dirbad __P((struct inode *, off_t, char *));
 int     ufs_dirbadentry __P((struct direct *, int));
 int     ufs_dirempty __P((struct inode *, ino_t, struct ucred *));
-int     ufs_direnter __P((struct inode *, struct nameidata *));
-int     ufs_dirremove __P((struct nameidata *));
+int     ufs_direnter __P((struct inode *, struct vnode *,struct componentname *));
+int     ufs_dirremove __P((struct vnode *, struct componentname*));
 int     ufs_dirrewrite
 int     ufs_dirrewrite
-           __P((struct inode *, struct inode *, struct nameidata *));
+           __P((struct inode *, struct inode *, struct componentname *));
 int     ufs_getattr __P((struct vnode *,
            struct vattr *, struct ucred *, struct proc *));
 struct vnode *
 int     ufs_getattr __P((struct vnode *,
            struct vattr *, struct ucred *, struct proc *));
 struct vnode *
@@ -59,13 +60,14 @@ int  ufs_ioctl __P((struct vnode *,
 void    ufs_iput __P((struct inode *));
 int     ufs_islocked __P((struct vnode *));
 void    ufs_iunlock __P((struct inode *));
 void    ufs_iput __P((struct inode *));
 int     ufs_islocked __P((struct vnode *));
 void    ufs_iunlock __P((struct inode *));
-int     ufs_link __P((struct vnode *, struct nameidata *, struct proc *));
+int     ufs_link __P((struct vnode *, struct vnode *, struct componentname *));
 int     ufs_lock __P((struct vnode *));
 int     ufs_lock __P((struct vnode *));
-int     ufs_lookup __P((struct vnode *, struct nameidata *, struct proc *));
-int     ufs_makeinode __P((int mode, struct nameidata *, struct vnode **));
-int     ufs_mkdir __P((struct nameidata *, struct vattr *, struct proc *));
-int     ufs_mknod __P((struct nameidata *,
-           struct vattr *, struct ucred *, struct proc *));
+int     ufs_lookup __P((struct vnode *, struct vnode **, struct componentname *));
+int     ufs_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *));
+int     ufs_mkdir __P((struct vnode *, struct vnode **,
+                       struct componentname *, struct vattr *));
+int     ufs_mknod __P((struct vnode *, struct vnode **,
+                       struct componentname *, struct vattr *));
 int     ufs_mmap __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_mountedon __P((struct vnode *));
 int     ufs_open __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_mmap __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_mountedon __P((struct vnode *));
 int     ufs_open __P((struct vnode *, int, struct ucred *, struct proc *));
@@ -73,10 +75,11 @@ int  ufs_print __P((struct vnode *));
 int     ufs_readdir __P((struct vnode *, struct uio *, struct ucred *, int *));
 int     ufs_readlink __P((struct vnode *, struct uio *, struct ucred *));
 int     ufs_reclaim __P((struct vnode *));
 int     ufs_readdir __P((struct vnode *, struct uio *, struct ucred *, int *));
 int     ufs_readlink __P((struct vnode *, struct uio *, struct ucred *));
 int     ufs_reclaim __P((struct vnode *));
-int     ufs_remove __P((struct nameidata *, struct proc *));
+int     ufs_remove __P((struct vnode *, struct vnode *, struct componentname *));
 int     ufs_rename
 int     ufs_rename
-           __P((struct nameidata *, struct nameidata *, struct proc *));
-int     ufs_rmdir __P((struct nameidata *, struct proc *));
+           __P((struct vnode *, struct vnode *, struct componentname *,
+                struct vnode *, struct vnode *, struct componentname *));
+int     ufs_rmdir __P((struct vnode *, struct vnode *, struct componentname *));
 int     ufs_seek __P((struct vnode *, off_t, off_t, struct ucred *));
 int     ufs_select
            __P((struct vnode *, int, int, struct ucred *, struct proc *));
 int     ufs_seek __P((struct vnode *, off_t, off_t, struct ucred *));
 int     ufs_select
            __P((struct vnode *, int, int, struct ucred *, struct proc *));
@@ -85,7 +88,7 @@ int    ufs_setattr __P((struct vnode *,
 int     ufs_start __P((struct mount *, int, struct proc *));
 int     ufs_strategy __P((struct buf *));
 int     ufs_symlink
 int     ufs_start __P((struct mount *, int, struct proc *));
 int     ufs_strategy __P((struct buf *));
 int     ufs_symlink
-           __P((struct nameidata *, struct vattr *, char *, struct proc *));
+           __P((struct vnode *, struct vnode **, struct componentname *, struct vattr *, char *));
 int     ufs_unlock __P((struct vnode *));
 int     ufs_vinit __P((struct mount *,
            struct vnodeops *, struct vnodeops *, struct vnode **));
 int     ufs_unlock __P((struct vnode *));
 int     ufs_vinit __P((struct mount *,
            struct vnodeops *, struct vnodeops *, struct vnode **));
index 124a0ca..6bb1639 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_lookup.c        7.36 (Berkeley) %G%
+ *     @(#)ufs_lookup.c        7.37 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -33,7 +33,7 @@ int   dirchk = 0;
  * If the file system is not maintained in a strict tree hierarchy,
  * this can result in a deadlock situation (see comments in code below).
  *
  * If the file system is not maintained in a strict tree hierarchy,
  * this can result in a deadlock situation (see comments in code below).
  *
- * The flag argument is LOOKUP, CREATE, RENAME, or DELETE depending on
+ * The cnp->cn_nameiop argument is LOOKUP, CREATE, RENAME, or DELETE depending on
  * whether the name is to be looked up, created, renamed, or deleted.
  * When CREATE, RENAME, or DELETE is specified, information usable in
  * creating, renaming, or deleting a directory entry may be calculated.
  * whether the name is to be looked up, created, renamed, or deleted.
  * When CREATE, RENAME, or DELETE is specified, information usable in
  * creating, renaming, or deleting a directory entry may be calculated.
@@ -63,10 +63,10 @@ int dirchk = 0;
  * NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode unlocked.
  */
 int
  * NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode unlocked.
  */
 int
-ufs_lookup(vdp, ndp, p)
-       register struct vnode *vdp;
-       register struct nameidata *ndp;
-       struct proc *p;
+ufs_lookup(dvp, vpp, cnp)   /* converted to CN */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
 {
        register struct inode *dp;      /* the directory we are searching */
        struct buf *bp;                 /* a buffer of directory entries */
 {
        register struct inode *dp;      /* the directory we are searching */
        struct buf *bp;                 /* a buffer of directory entries */
@@ -84,26 +84,24 @@ ufs_lookup(vdp, ndp, p)
        struct vnode *tdp;              /* returned by VOP_VGET */
        off_t enduseful;                /* pointer past last used dir slot */
        u_long bmask;                   /* block offset mask */
        struct vnode *tdp;              /* returned by VOP_VGET */
        off_t enduseful;                /* pointer past last used dir slot */
        u_long bmask;                   /* block offset mask */
-       int flag;                       /* LOOKUP, CREATE, RENAME, or DELETE */
        int lockparent;                 /* 1 => lockparent flag is set */
        int wantparent;                 /* 1 => wantparent or lockparent flag */
        int error;
        int lockparent;                 /* 1 => lockparent flag is set */
        int wantparent;                 /* 1 => wantparent or lockparent flag */
        int error;
+       struct vnode *vdp = dvp;        /* saved for one special case */
 
        bp = NULL;
        slotoffset = -1;
 
        bp = NULL;
        slotoffset = -1;
-       ndp->ni_dvp = vdp;
-       ndp->ni_vp = NULL;
-       dp = VTOI(vdp);
-       lockparent = ndp->ni_nameiop & LOCKPARENT;
-       flag = ndp->ni_nameiop & OPMASK;
-       wantparent = ndp->ni_nameiop & (LOCKPARENT|WANTPARENT);
+       *vpp = NULL;
+       dp = VTOI(dvp);
+       lockparent = cnp->cn_flags & LOCKPARENT;
+       wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
 
        /*
         * Check accessiblity of directory.
         */
        if ((dp->i_mode&IFMT) != IFDIR)
                return (ENOTDIR);
 
        /*
         * Check accessiblity of directory.
         */
        if ((dp->i_mode&IFMT) != IFDIR)
                return (ENOTDIR);
-       if (error = ufs_access(vdp, VEXEC, ndp->ni_cred, p))
+       if (error = ufs_access(dvp, VEXEC, cnp->cn_cred, cnp->cn_proc))
                return (error);
 
        /*
                return (error);
 
        /*
@@ -113,13 +111,13 @@ ufs_lookup(vdp, ndp, p)
         * check the name cache to see if the directory/name pair
         * we are looking for is known already.
         */
         * check the name cache to see if the directory/name pair
         * we are looking for is known already.
         */
-       if (error = cache_lookup(ndp)) {
+       if (error = cache_lookup(dvp, vpp, cnp)) {
                int vpid;       /* capability number of vnode */
 
                if (error == ENOENT)
                        return (error);
 #ifdef PARANOID
                int vpid;       /* capability number of vnode */
 
                if (error == ENOENT)
                        return (error);
 #ifdef PARANOID
-               if (vdp == ndp->ni_rdir && ndp->ni_isdotdot)
+               if (dvp == ndp->ni_rdir && (cnp->cn_flags&ISDOTDOT))
                        panic("ufs_lookup: .. through root");
 #endif
                /*
                        panic("ufs_lookup: .. through root");
 #endif
                /*
@@ -127,21 +125,27 @@ ufs_lookup(vdp, ndp, p)
                 * See comment below starting `Step through' for
                 * an explaination of the locking protocol.
                 */
                 * See comment below starting `Step through' for
                 * an explaination of the locking protocol.
                 */
+               /*
+                * NEEDSWORK: The borrowing of variables
+                * here is quite confusing.  Usually, dvp/dp
+                * is the directory being searched.
+                * Here it's the target returned from the cache.
+                */
                pdp = dp;
                pdp = dp;
-               dp = VTOI(ndp->ni_vp);
-               vdp = ndp->ni_vp;
-               vpid = vdp->v_id;
-               if (pdp == dp) {
-                       VREF(vdp);
+               dp = VTOI(*vpp);
+               dvp = *vpp;
+               vpid = dvp->v_id;
+               if (pdp == dp) {   /* lookup on "." */
+                       VREF(dvp);
                        error = 0;
                        error = 0;
-               } else if (ndp->ni_isdotdot) {
+               } else if (cnp->cn_flags&ISDOTDOT) {
                        IUNLOCK(pdp);
                        IUNLOCK(pdp);
-                       error = vget(vdp);
-                       if (!error && lockparent && *ndp->ni_next == '\0')
+                       error = vget(dvp);
+                       if (!error && lockparent && (cnp->cn_flags&ISLASTCN))
                                ILOCK(pdp);
                } else {
                                ILOCK(pdp);
                } else {
-                       error = vget(vdp);
-                       if (!lockparent || error || *ndp->ni_next != '\0')
+                       error = vget(dvp);
+                       if (!lockparent || error || !(cnp->cn_flags&ISLASTCN))
                                IUNLOCK(pdp);
                }
                /*
                                IUNLOCK(pdp);
                }
                /*
@@ -149,16 +153,16 @@ ufs_lookup(vdp, ndp, p)
                 * while we were waiting for the lock.
                 */
                if (!error) {
                 * while we were waiting for the lock.
                 */
                if (!error) {
-                       if (vpid == vdp->v_id)
+                       if (vpid == dvp->v_id)
                                return (0);
                        ufs_iput(dp);
                                return (0);
                        ufs_iput(dp);
-                       if (lockparent && pdp != dp && *ndp->ni_next == '\0')
+                       if (lockparent && pdp != dp && (cnp->cn_flags&ISLASTCN))
                                IUNLOCK(pdp);
                }
                ILOCK(pdp);
                dp = pdp;
                                IUNLOCK(pdp);
                }
                ILOCK(pdp);
                dp = pdp;
-               vdp = ITOV(dp);
-               ndp->ni_vp = NULL;
+               dvp = ITOV(dp);
+               *vpp = NULL;
        }
 
        /*
        }
 
        /*
@@ -168,11 +172,11 @@ ufs_lookup(vdp, ndp, p)
         * case it doesn't already exist.
         */
        slotstatus = FOUND;
         * case it doesn't already exist.
         */
        slotstatus = FOUND;
-       if ((flag == CREATE || flag == RENAME) && *ndp->ni_next == 0) {
+       if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) && (cnp->cn_flags&ISLASTCN)) {
                slotstatus = NONE;
                slotfreespace = 0;
                slotneeded = ((sizeof (struct direct) - (MAXNAMLEN + 1)) +
                slotstatus = NONE;
                slotfreespace = 0;
                slotneeded = ((sizeof (struct direct) - (MAXNAMLEN + 1)) +
-                       ((ndp->ni_namelen + 1 + 3) &~ 3));
+                       ((cnp->cn_namelen + 1 + 3) &~ 3));
        }
 
        /*
        }
 
        /*
@@ -186,14 +190,14 @@ ufs_lookup(vdp, ndp, p)
         * profiling time and hence has been removed in the interest
         * of simplicity.
         */
         * profiling time and hence has been removed in the interest
         * of simplicity.
         */
-       bmask = VFSTOUFS(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
-       if (flag != LOOKUP || dp->i_diroff == 0 || dp->i_diroff > dp->i_size) {
-               ndp->ni_ufs.ufs_offset = 0;
+       bmask = VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
+       if (cnp->cn_nameiop != LOOKUP || dp->i_diroff == 0 || dp->i_diroff > dp->i_size) {
+               cnp->cn_ufs.ufs_offset = 0;
                numdirpasses = 1;
        } else {
                numdirpasses = 1;
        } else {
-               ndp->ni_ufs.ufs_offset = dp->i_diroff;
-               if ((entryoffsetinblock = ndp->ni_ufs.ufs_offset & bmask) &&
-                   (error = VOP_BLKATOFF(vdp, ndp->ni_ufs.ufs_offset, NULL,
+               cnp->cn_ufs.ufs_offset = dp->i_diroff;
+               if ((entryoffsetinblock = cnp->cn_ufs.ufs_offset & bmask) &&
+                   (error = VOP_BLKATOFF(dvp, cnp->cn_ufs.ufs_offset, NULL,
                     &bp)))
                        return (error);
                numdirpasses = 2;
                     &bp)))
                        return (error);
                numdirpasses = 2;
@@ -203,15 +207,15 @@ ufs_lookup(vdp, ndp, p)
        enduseful = 0;
 
 searchloop:
        enduseful = 0;
 
 searchloop:
-       while (ndp->ni_ufs.ufs_offset < endsearch) {
+       while (cnp->cn_ufs.ufs_offset < endsearch) {
                /*
                 * If offset is on a block boundary, read the next directory
                 * block.  Release previous if it exists.
                 */
                /*
                 * If offset is on a block boundary, read the next directory
                 * block.  Release previous if it exists.
                 */
-               if ((ndp->ni_ufs.ufs_offset & bmask) == 0) {
+               if ((cnp->cn_ufs.ufs_offset & bmask) == 0) {
                        if (bp != NULL)
                                brelse(bp);
                        if (bp != NULL)
                                brelse(bp);
-                       if (error = VOP_BLKATOFF(vdp, ndp->ni_ufs.ufs_offset,
+                       if (error = VOP_BLKATOFF(dvp, cnp->cn_ufs.ufs_offset,
                            NULL, &bp))
                                return (error);
                        entryoffsetinblock = 0;
                            NULL, &bp))
                                return (error);
                        entryoffsetinblock = 0;
@@ -237,9 +241,9 @@ searchloop:
                    dirchk && ufs_dirbadentry(ep, entryoffsetinblock)) {
                        int i;
 
                    dirchk && ufs_dirbadentry(ep, entryoffsetinblock)) {
                        int i;
 
-                       ufs_dirbad(dp, ndp->ni_ufs.ufs_offset, "mangled entry");
+                       ufs_dirbad(dp, cnp->cn_ufs.ufs_offset, "mangled entry");
                        i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1));
                        i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1));
-                       ndp->ni_ufs.ufs_offset += i;
+                       cnp->cn_ufs.ufs_offset += i;
                        entryoffsetinblock += i;
                        continue;
                }
                        entryoffsetinblock += i;
                        continue;
                }
@@ -258,17 +262,17 @@ searchloop:
                        if (size > 0) {
                                if (size >= slotneeded) {
                                        slotstatus = FOUND;
                        if (size > 0) {
                                if (size >= slotneeded) {
                                        slotstatus = FOUND;
-                                       slotoffset = ndp->ni_ufs.ufs_offset;
+                                       slotoffset = cnp->cn_ufs.ufs_offset;
                                        slotsize = ep->d_reclen;
                                } else if (slotstatus == NONE) {
                                        slotfreespace += size;
                                        if (slotoffset == -1)
                                                slotoffset =
                                        slotsize = ep->d_reclen;
                                } else if (slotstatus == NONE) {
                                        slotfreespace += size;
                                        if (slotoffset == -1)
                                                slotoffset =
-                                                     ndp->ni_ufs.ufs_offset;
+                                                     cnp->cn_ufs.ufs_offset;
                                        if (slotfreespace >= slotneeded) {
                                                slotstatus = COMPACT;
                                                slotsize =
                                        if (slotfreespace >= slotneeded) {
                                                slotstatus = COMPACT;
                                                slotsize =
-                                                     ndp->ni_ufs.ufs_offset +
+                                                     cnp->cn_ufs.ufs_offset +
                                                      ep->d_reclen - slotoffset;
                                        }
                                }
                                                      ep->d_reclen - slotoffset;
                                        }
                                }
@@ -279,25 +283,25 @@ searchloop:
                 * Check for a name match.
                 */
                if (ep->d_ino) {
                 * Check for a name match.
                 */
                if (ep->d_ino) {
-                       if (ep->d_namlen == ndp->ni_namelen &&
-                           !bcmp(ndp->ni_ptr, ep->d_name,
+                       if (ep->d_namlen == cnp->cn_namelen &&
+                           !bcmp(cnp->cn_nameptr, ep->d_name,
                                (unsigned)ep->d_namlen)) {
                                /*
                                 * Save directory entry's inode number and
                                 * reclen in ndp->ni_ufs area, and release
                                 * directory buffer.
                                 */
                                (unsigned)ep->d_namlen)) {
                                /*
                                 * Save directory entry's inode number and
                                 * reclen in ndp->ni_ufs area, and release
                                 * directory buffer.
                                 */
-                               ndp->ni_ufs.ufs_ino = ep->d_ino;
-                               ndp->ni_ufs.ufs_reclen = ep->d_reclen;
+                               cnp->cn_ufs.ufs_ino = ep->d_ino;
+                               cnp->cn_ufs.ufs_reclen = ep->d_reclen;
                                brelse(bp);
                                goto found;
                        }
                }
                                brelse(bp);
                                goto found;
                        }
                }
-               prevoff = ndp->ni_ufs.ufs_offset;
-               ndp->ni_ufs.ufs_offset += ep->d_reclen;
+               prevoff = cnp->cn_ufs.ufs_offset;
+               cnp->cn_ufs.ufs_offset += ep->d_reclen;
                entryoffsetinblock += ep->d_reclen;
                if (ep->d_ino)
                entryoffsetinblock += ep->d_reclen;
                if (ep->d_ino)
-                       enduseful = ndp->ni_ufs.ufs_offset;
+                       enduseful = cnp->cn_ufs.ufs_offset;
        }
 /* notfound: */
        /*
        }
 /* notfound: */
        /*
@@ -306,7 +310,7 @@ searchloop:
         */
        if (numdirpasses == 2) {
                numdirpasses--;
         */
        if (numdirpasses == 2) {
                numdirpasses--;
-               ndp->ni_ufs.ufs_offset = 0;
+               cnp->cn_ufs.ufs_offset = 0;
                endsearch = dp->i_diroff;
                goto searchloop;
        }
                endsearch = dp->i_diroff;
                goto searchloop;
        }
@@ -317,13 +321,13 @@ searchloop:
         * directory has not been removed, then can consider
         * allowing file to be created.
         */
         * directory has not been removed, then can consider
         * allowing file to be created.
         */
-       if ((flag == CREATE || flag == RENAME) &&
-           *ndp->ni_next == 0 && dp->i_nlink != 0) {
+       if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) &&
+           (cnp->cn_flags&ISLASTCN) && dp->i_nlink != 0) {
                /*
                 * Access for write is interpreted as allowing
                 * creation of files in the directory.
                 */
                /*
                 * Access for write is interpreted as allowing
                 * creation of files in the directory.
                 */
-               if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p))
+               if (error = ufs_access(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc))
                        return (error);
                /*
                 * Return an indication of where the new directory
                        return (error);
                /*
                 * Return an indication of where the new directory
@@ -335,16 +339,16 @@ searchloop:
                 * to ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count.
                 */
                if (slotstatus == NONE) {
                 * to ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count.
                 */
                if (slotstatus == NONE) {
-                       ndp->ni_ufs.ufs_offset = roundup(dp->i_size, DIRBLKSIZ);
-                       ndp->ni_ufs.ufs_count = 0;
-                       enduseful = ndp->ni_ufs.ufs_offset;
+                       cnp->cn_ufs.ufs_offset = roundup(dp->i_size, DIRBLKSIZ);
+                       cnp->cn_ufs.ufs_count = 0;
+                       enduseful = cnp->cn_ufs.ufs_offset;
                } else {
                } else {
-                       ndp->ni_ufs.ufs_offset = slotoffset;
-                       ndp->ni_ufs.ufs_count = slotsize;
+                       cnp->cn_ufs.ufs_offset = slotoffset;
+                       cnp->cn_ufs.ufs_count = slotsize;
                        if (enduseful < slotoffset + slotsize)
                                enduseful = slotoffset + slotsize;
                }
                        if (enduseful < slotoffset + slotsize)
                                enduseful = slotoffset + slotsize;
                }
-               ndp->ni_ufs.ufs_endoff = roundup(enduseful, DIRBLKSIZ);
+               cnp->cn_ufs.ufs_endoff = roundup(enduseful, DIRBLKSIZ);
                dp->i_flag |= IUPD|ICHG;
                /*
                 * We return with the directory locked, so that
                dp->i_flag |= IUPD|ICHG;
                /*
                 * We return with the directory locked, so that
@@ -359,15 +363,15 @@ searchloop:
                 * NB - if the directory is unlocked, then this
                 * information cannot be used.
                 */
                 * NB - if the directory is unlocked, then this
                 * information cannot be used.
                 */
-               ndp->ni_nameiop |= SAVENAME;
+               cnp->cn_flags |= SAVENAME;
                if (!lockparent)
                        IUNLOCK(dp);
        }
        /*
         * Insert name into cache (as non-existent) if appropriate.
         */
                if (!lockparent)
                        IUNLOCK(dp);
        }
        /*
         * Insert name into cache (as non-existent) if appropriate.
         */
-       if (ndp->ni_makeentry && flag != CREATE)
-               cache_enter(ndp);
+       if ((cnp->cn_flags&MAKEENTRY) && cnp->cn_nameiop != CREATE)
+               cache_enter(dvp, *vpp, cnp);
        return (ENOENT);
 
 found:
        return (ENOENT);
 
 found:
@@ -378,7 +382,7 @@ found:
         * of this entry.
         */
        if (entryoffsetinblock + DIRSIZ(ep) > dp->i_size) {
         * of this entry.
         */
        if (entryoffsetinblock + DIRSIZ(ep) > dp->i_size) {
-               ufs_dirbad(dp, ndp->ni_ufs.ufs_offset, "i_size too small");
+               ufs_dirbad(dp, cnp->cn_ufs.ufs_offset, "i_size too small");
                dp->i_size = entryoffsetinblock + DIRSIZ(ep);
                dp->i_flag |= IUPD|ICHG;
        }
                dp->i_size = entryoffsetinblock + DIRSIZ(ep);
                dp->i_flag |= IUPD|ICHG;
        }
@@ -388,8 +392,8 @@ found:
         * If the final component of path name, save information
         * in the cache as to where the entry was found.
         */
         * If the final component of path name, save information
         * in the cache as to where the entry was found.
         */
-       if (*ndp->ni_next == '\0' && flag == LOOKUP)
-               dp->i_diroff = ndp->ni_ufs.ufs_offset &~ (DIRBLKSIZ - 1);
+       if ((cnp->cn_flags&ISLASTCN) && cnp->cn_nameiop == LOOKUP)
+               dp->i_diroff = cnp->cn_ufs.ufs_offset &~ (DIRBLKSIZ - 1);
 
        /*
         * If deleting, and at end of pathname, return
 
        /*
         * If deleting, and at end of pathname, return
@@ -398,29 +402,29 @@ found:
         * the directory (in ndp->ni_dvp), otherwise we go
         * on and lock the inode, being careful with ".".
         */
         * the directory (in ndp->ni_dvp), otherwise we go
         * on and lock the inode, being careful with ".".
         */
-       if (flag == DELETE && *ndp->ni_next == 0) {
+       if (cnp->cn_nameiop == DELETE && (cnp->cn_flags&ISLASTCN)) {
                /*
                 * Write access to directory required to delete files.
                 */
                /*
                 * Write access to directory required to delete files.
                 */
-               if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p))
+               if (error = ufs_access(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc))
                        return (error);
                /*
                        return (error);
                /*
-                * Return pointer to current entry in ndp->ni_ufs.ufs_offset,
+                * Return pointer to current entry in cnp->cn_ufs.ufs_offset,
                 * and distance past previous entry (if there
                 * is a previous entry in this block) in ndp->ni_ufs.ufs_count.
                 * Save directory inode pointer in ndp->ni_dvp for dirremove().
                 */
                 * and distance past previous entry (if there
                 * is a previous entry in this block) in ndp->ni_ufs.ufs_count.
                 * Save directory inode pointer in ndp->ni_dvp for dirremove().
                 */
-               if ((ndp->ni_ufs.ufs_offset&(DIRBLKSIZ-1)) == 0)
-                       ndp->ni_ufs.ufs_count = 0;
+               if ((cnp->cn_ufs.ufs_offset&(DIRBLKSIZ-1)) == 0)
+                       cnp->cn_ufs.ufs_count = 0;
                else
                else
-                       ndp->ni_ufs.ufs_count =
-                           ndp->ni_ufs.ufs_offset - prevoff;
-               if (dp->i_number == ndp->ni_ufs.ufs_ino) {
-                       VREF(vdp);
-                       ndp->ni_vp = vdp;
+                       cnp->cn_ufs.ufs_count =
+                           cnp->cn_ufs.ufs_offset - prevoff;
+               if (dp->i_number == cnp->cn_ufs.ufs_ino) {
+                       VREF(vdp);   /* NEEDSWORK: is vdp necessary? */
+                       *vpp = vdp;
                        return (0);
                }
                        return (0);
                }
-               if (error = VOP_VGET(vdp, ndp->ni_ufs.ufs_ino, &tdp))
+               if (error = VOP_VGET(dvp, cnp->cn_ufs.ufs_ino, &tdp))
                        return (error);
                /*
                 * If directory is "sticky", then user must own
                        return (error);
                /*
                 * If directory is "sticky", then user must own
@@ -429,13 +433,13 @@ found:
                 * implements append-only directories.
                 */
                if ((dp->i_mode & ISVTX) &&
                 * implements append-only directories.
                 */
                if ((dp->i_mode & ISVTX) &&
-                   ndp->ni_cred->cr_uid != 0 &&
-                   ndp->ni_cred->cr_uid != dp->i_uid &&
-                   VTOI(tdp)->i_uid != ndp->ni_cred->cr_uid) {
+                   cnp->cn_cred->cr_uid != 0 &&
+                   cnp->cn_cred->cr_uid != dp->i_uid &&
+                   VTOI(tdp)->i_uid != cnp->cn_cred->cr_uid) {
                        vput(tdp);
                        return (EPERM);
                }
                        vput(tdp);
                        return (EPERM);
                }
-               ndp->ni_vp = tdp;
+               *vpp = tdp;
                if (!lockparent)
                        IUNLOCK(dp);
                return (0);
                if (!lockparent)
                        IUNLOCK(dp);
                return (0);
@@ -447,19 +451,19 @@ found:
         * Must get inode of directory entry to verify it's a
         * regular file, or empty directory.
         */
         * Must get inode of directory entry to verify it's a
         * regular file, or empty directory.
         */
-       if (flag == RENAME && wantparent && *ndp->ni_next == 0) {
-               if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p))
+       if (cnp->cn_nameiop == RENAME && wantparent && (cnp->cn_flags&ISLASTCN)) {
+               if (error = ufs_access(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc))
                        return (error);
                /*
                 * Careful about locking second inode.
                 * This can only occur if the target is ".".
                 */
                        return (error);
                /*
                 * Careful about locking second inode.
                 * This can only occur if the target is ".".
                 */
-               if (dp->i_number == ndp->ni_ufs.ufs_ino)
+               if (dp->i_number == cnp->cn_ufs.ufs_ino)
                        return (EISDIR);
                        return (EISDIR);
-               if (error = VOP_VGET(vdp, ndp->ni_ufs.ufs_ino, &tdp))
+               if (error = VOP_VGET(dvp, cnp->cn_ufs.ufs_ino, &tdp))
                        return (error);
                        return (error);
-               ndp->ni_vp = tdp;
-               ndp->ni_nameiop |= SAVENAME;
+               *vpp = tdp;
+               cnp->cn_flags |= SAVENAME;
                if (!lockparent)
                        IUNLOCK(dp);
                return (0);
                if (!lockparent)
                        IUNLOCK(dp);
                return (0);
@@ -485,31 +489,31 @@ found:
         * that point backwards in the directory structure.
         */
        pdp = dp;
         * that point backwards in the directory structure.
         */
        pdp = dp;
-       if (ndp->ni_isdotdot) {
+       if (cnp->cn_flags&ISDOTDOT) {
                IUNLOCK(pdp);   /* race to get the inode */
                IUNLOCK(pdp);   /* race to get the inode */
-               if (error = VOP_VGET(vdp, ndp->ni_ufs.ufs_ino, &tdp)) {
+               if (error = VOP_VGET(dvp, cnp->cn_ufs.ufs_ino, &tdp)) {
                        ILOCK(pdp);
                        return (error);
                }
                        ILOCK(pdp);
                        return (error);
                }
-               if (lockparent && *ndp->ni_next == '\0')
+               if (lockparent && (cnp->cn_flags&ISLASTCN))
                        ILOCK(pdp);
                        ILOCK(pdp);
-               ndp->ni_vp = tdp;
-       } else if (dp->i_number == ndp->ni_ufs.ufs_ino) {
-               VREF(vdp);      /* we want ourself, ie "." */
-               ndp->ni_vp = vdp;
+               *vpp = tdp;
+       } else if (dp->i_number == cnp->cn_ufs.ufs_ino) {
+               VREF(dvp);      /* we want ourself, ie "." */
+               *vpp = dvp;
        } else {
        } else {
-               if (error = VOP_VGET(vdp, ndp->ni_ufs.ufs_ino, &tdp))
+               if (error = VOP_VGET(dvp, cnp->cn_ufs.ufs_ino, &tdp))
                        return (error);
                        return (error);
-               if (!lockparent || *ndp->ni_next != '\0')
+               if (!lockparent || !(cnp->cn_flags&ISLASTCN))
                        IUNLOCK(pdp);
                        IUNLOCK(pdp);
-               ndp->ni_vp = tdp;
+               *vpp = tdp;
        }
 
        /*
         * Insert name into cache if appropriate.
         */
        }
 
        /*
         * Insert name into cache if appropriate.
         */
-       if (ndp->ni_makeentry)
-               cache_enter(ndp);
+       if (cnp->cn_flags & MAKEENTRY)
+               cache_enter(dvp, *vpp, cnp);
        return (0);
 }
 
        return (0);
 }
 
@@ -574,13 +578,14 @@ printf("ufs_dirbadentry: jumping out: reclen: %d namlen %d ino %d name %s\n",
  * indicate how the space for the new entry is to be obtained.
  */
 int
  * indicate how the space for the new entry is to be obtained.
  */
 int
-ufs_direnter(ip, ndp)
+ufs_direnter(ip, dvp, cnp)   /* converted to CN.  */
+/* old: ufs_direnter(ip, ndp) */
        struct inode *ip;
        struct inode *ip;
-       register struct nameidata *ndp;
+       struct vnode *dvp;
+       register struct componentname *cnp;
 {
        register struct direct *ep, *nep;
        register struct inode *dp;
 {
        register struct direct *ep, *nep;
        register struct inode *dp;
-       register struct vnode *dvp;
        struct buf *bp;
        struct direct newdir;
        struct iovec aiov;
        struct buf *bp;
        struct direct newdir;
        struct iovec aiov;
@@ -590,25 +595,24 @@ ufs_direnter(ip, ndp)
        char *dirbuf;
 
 #ifdef DIAGNOSTIC
        char *dirbuf;
 
 #ifdef DIAGNOSTIC
-       if ((ndp->ni_nameiop & SAVENAME) == 0)
+       if ((cnp->cn_flags & SAVENAME) == 0)
                panic("direnter: missing name");
 #endif
                panic("direnter: missing name");
 #endif
-       dvp = ndp->ni_dvp;
        dp = VTOI(dvp);
        newdir.d_ino = ip->i_number;
        dp = VTOI(dvp);
        newdir.d_ino = ip->i_number;
-       newdir.d_namlen = ndp->ni_namelen;
-       bcopy(ndp->ni_ptr, newdir.d_name, (unsigned)ndp->ni_namelen + 1);
+       newdir.d_namlen = cnp->cn_namelen;
+       bcopy(cnp->cn_nameptr, newdir.d_name, (unsigned)cnp->cn_namelen + 1);
        newentrysize = DIRSIZ(&newdir);
        newentrysize = DIRSIZ(&newdir);
-       if (ndp->ni_ufs.ufs_count == 0) {
+       if (cnp->cn_ufs.ufs_count == 0) {
                /*
                /*
-                * If ndp->ni_ufs.ufs_count is 0, then namei could find no
+                * If cnp->cn_ufs.ufs_count is 0, then namei could find no
                 * space in the directory. Here, ndp->ni_ufs.ufs_offset will
                 * be on a directory block boundary and we will write the
                 * new entry into a fresh block.
                 */
                 * space in the directory. Here, ndp->ni_ufs.ufs_offset will
                 * be on a directory block boundary and we will write the
                 * new entry into a fresh block.
                 */
-               if (ndp->ni_ufs.ufs_offset & (DIRBLKSIZ - 1))
+               if (cnp->cn_ufs.ufs_offset & (DIRBLKSIZ - 1))
                        panic("wdir: newblk");
                        panic("wdir: newblk");
-               auio.uio_offset = ndp->ni_ufs.ufs_offset;
+               auio.uio_offset = cnp->cn_ufs.ufs_offset;
                newdir.d_reclen = DIRBLKSIZ;
                auio.uio_resid = newentrysize;
                aiov.iov_len = newentrysize;
                newdir.d_reclen = DIRBLKSIZ;
                auio.uio_resid = newentrysize;
                aiov.iov_len = newentrysize;
@@ -618,7 +622,7 @@ ufs_direnter(ip, ndp)
                auio.uio_rw = UIO_WRITE;
                auio.uio_segflg = UIO_SYSSPACE;
                auio.uio_procp = (struct proc *)0;
                auio.uio_rw = UIO_WRITE;
                auio.uio_segflg = UIO_SYSSPACE;
                auio.uio_procp = (struct proc *)0;
-               error = VOP_WRITE(dvp, &auio, IO_SYNC, ndp->ni_cred);
+               error = VOP_WRITE(dvp, &auio, IO_SYNC, cnp->cn_cred);
                if (DIRBLKSIZ >
                    VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize)
                        /* XXX should grow with balloc() */
                if (DIRBLKSIZ >
                    VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize)
                        /* XXX should grow with balloc() */
@@ -631,9 +635,9 @@ ufs_direnter(ip, ndp)
        }
 
        /*
        }
 
        /*
-        * If ndp->ni_ufs.ufs_count is non-zero, then namei found space
-        * for the new entry in the range ndp->ni_ufs.ufs_offset to
-        * ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count in the directory.
+        * If cnp->cn_ufs.ufs_count is non-zero, then namei found space
+        * for the new entry in the range cnp->cn_ufs.ufs_offset to
+        * cnp->cn_ufs.ufs_offset + cnp->cn_ufs.ufs_count in the directory.
         * To use this space, we may have to compact the entries located
         * there, by copying them together towards the beginning of the
         * block, leaving the free space in one usable chunk at the end.
         * To use this space, we may have to compact the entries located
         * there, by copying them together towards the beginning of the
         * block, leaving the free space in one usable chunk at the end.
@@ -646,24 +650,24 @@ ufs_direnter(ip, ndp)
         *
         * N.B. - THIS IS AN ARTIFACT OF 4.2 AND SHOULD NEVER HAPPEN.
         */
         *
         * N.B. - THIS IS AN ARTIFACT OF 4.2 AND SHOULD NEVER HAPPEN.
         */
-       if (ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count > dp->i_size)
-               dp->i_size = ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count;
+       if (cnp->cn_ufs.ufs_offset + cnp->cn_ufs.ufs_count > dp->i_size)
+               dp->i_size = cnp->cn_ufs.ufs_offset + cnp->cn_ufs.ufs_count;
        /*
         * Get the block containing the space for the new directory entry.
         */
        /*
         * Get the block containing the space for the new directory entry.
         */
-       if (error = VOP_BLKATOFF(dvp, ndp->ni_ufs.ufs_offset, &dirbuf, &bp))
+       if (error = VOP_BLKATOFF(dvp, cnp->cn_ufs.ufs_offset, &dirbuf, &bp))
                return (error);
        /*
         * Find space for the new entry. In the simple case, the entry at
         * offset base will have the space. If it does not, then namei
                return (error);
        /*
         * Find space for the new entry. In the simple case, the entry at
         * offset base will have the space. If it does not, then namei
-        * arranged that compacting the region ndp->ni_ufs.ufs_offset to
-        * ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count would yield the
+        * arranged that compacting the region cnp->cn_ufs.ufs_offset to
+        * cnp->cn_ufs.ufs_offset + cnp->cn_ufs.ufs_count would yield the
         * space.
         */
        ep = (struct direct *)dirbuf;
        dsize = DIRSIZ(ep);
        spacefree = ep->d_reclen - dsize;
         * space.
         */
        ep = (struct direct *)dirbuf;
        dsize = DIRSIZ(ep);
        spacefree = ep->d_reclen - dsize;
-       for (loc = ep->d_reclen; loc < ndp->ni_ufs.ufs_count; ) {
+       for (loc = ep->d_reclen; loc < cnp->cn_ufs.ufs_count; ) {
                nep = (struct direct *)(dirbuf + loc);
                if (ep->d_ino) {
                        /* trim the existing slot */
                nep = (struct direct *)(dirbuf + loc);
                if (ep->d_ino) {
                        /* trim the existing slot */
@@ -696,9 +700,9 @@ ufs_direnter(ip, ndp)
        bcopy((caddr_t)&newdir, (caddr_t)ep, (u_int)newentrysize);
        error = VOP_BWRITE(bp);
        dp->i_flag |= IUPD|ICHG;
        bcopy((caddr_t)&newdir, (caddr_t)ep, (u_int)newentrysize);
        error = VOP_BWRITE(bp);
        dp->i_flag |= IUPD|ICHG;
-       if (!error && ndp->ni_ufs.ufs_endoff &&
-           ndp->ni_ufs.ufs_endoff < dp->i_size)
-               error = VOP_TRUNCATE(dvp, (u_long)ndp->ni_ufs.ufs_endoff,
+       if (!error && cnp->cn_ufs.ufs_endoff &&
+           cnp->cn_ufs.ufs_endoff < dp->i_size)
+               error = VOP_TRUNCATE(dvp, (u_long)cnp->cn_ufs.ufs_endoff,
                    IO_SYNC);
        return (error);
 }
                    IO_SYNC);
        return (error);
 }
@@ -716,20 +720,22 @@ ufs_direnter(ip, ndp)
  * to the size of the previous entry.
  */
 int
  * to the size of the previous entry.
  */
 int
-ufs_dirremove(ndp)
-       register struct nameidata *ndp;
+ufs_dirremove(dvp, cnp)   /* converted to CN.  */
+       struct vnode *dvp;
+       struct componentname *cnp;
+/* old: ufs_dirremove(ndp) */
 {
        register struct inode *dp;
        struct direct *ep;
        struct buf *bp;
        int error;
 
 {
        register struct inode *dp;
        struct direct *ep;
        struct buf *bp;
        int error;
 
-       dp = VTOI(ndp->ni_dvp);
-       if (ndp->ni_ufs.ufs_count == 0) {
+       dp = VTOI(dvp);
+       if (cnp->cn_ufs.ufs_count == 0) {
                /*
                 * First entry in block: set d_ino to zero.
                 */
                /*
                 * First entry in block: set d_ino to zero.
                 */
-               if (error = VOP_BLKATOFF(ndp->ni_dvp, ndp->ni_ufs.ufs_offset,
+               if (error = VOP_BLKATOFF(dvp, cnp->cn_ufs.ufs_offset,
                    (char **)&ep, &bp))
                        return (error);
                ep->d_ino = 0;
                    (char **)&ep, &bp))
                        return (error);
                ep->d_ino = 0;
@@ -740,10 +746,10 @@ ufs_dirremove(ndp)
        /*
         * Collapse new free space into previous entry.
         */
        /*
         * Collapse new free space into previous entry.
         */
-       if (error = VOP_BLKATOFF(ndp->ni_dvp,
-           ndp->ni_ufs.ufs_offset - ndp->ni_ufs.ufs_count, (char **)&ep, &bp))
+       if (error = VOP_BLKATOFF(dvp,
+           cnp->cn_ufs.ufs_offset - cnp->cn_ufs.ufs_count, (char **)&ep, &bp))
                return (error);
                return (error);
-       ep->d_reclen += ndp->ni_ufs.ufs_reclen;
+       ep->d_reclen += cnp->cn_ufs.ufs_reclen;
        error = VOP_BWRITE(bp);
        dp->i_flag |= IUPD|ICHG;
        return (error);
        error = VOP_BWRITE(bp);
        dp->i_flag |= IUPD|ICHG;
        return (error);
@@ -755,15 +761,16 @@ ufs_dirremove(ndp)
  * set up by a call to namei.
  */
 int
  * set up by a call to namei.
  */
 int
-ufs_dirrewrite(dp, ip, ndp)
+ufs_dirrewrite(dp, ip, cnp)
+/* old: ufs_dirrewrite(dp, ip, ndp) */
        struct inode *dp, *ip;
        struct inode *dp, *ip;
-       struct nameidata *ndp;
+       struct componentname *cnp;
 {
        struct buf *bp;
        struct direct *ep;
        int error;
 
 {
        struct buf *bp;
        struct direct *ep;
        int error;
 
-       if (error = VOP_BLKATOFF(ITOV(dp), ndp->ni_ufs.ufs_offset,
+       if (error = VOP_BLKATOFF(ITOV(dp), cnp->cn_ufs.ufs_offset,
            (char **)&ep, &bp))
                return (error);
        ep->d_ino = ip->i_number;
            (char **)&ep, &bp))
                return (error);
        ep->d_ino = ip->i_number;
index 7ba9d4e..f7f51d5 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_vnops.c 7.71 (Berkeley) %G%
+ *     @(#)ufs_vnops.c 7.72 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -67,18 +67,18 @@ union _qcvt {
  * Create a regular file
  */
 int
  * Create a regular file
  */
 int
-ufs_create(ndp, vap, p)
-       struct nameidata *ndp;
+ufs_create(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* was: ufs_create(ndp, vap, p) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        struct vattr *vap;
-       struct proc *p;
 {
 {
-       struct vnode *vp;
        int error;
 
        if (error =
        int error;
 
        if (error =
-           ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), ndp, &vp))
+           ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), dvp, vpp, cnp))
                return (error);
                return (error);
-       ndp->ni_vp = vp;
        return (0);
 }
 
        return (0);
 }
 
@@ -87,20 +87,20 @@ ufs_create(ndp, vap, p)
  */
 /* ARGSUSED */
 int
  */
 /* ARGSUSED */
 int
-ufs_mknod(ndp, vap, cred, p)
-       struct nameidata *ndp;
+ufs_mknod(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* was: ufs_mknod(ndp, vap, cred, p) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        struct vattr *vap;
-       struct ucred *cred;
-       struct proc *p;
 {
        register struct inode *ip;
 {
        register struct inode *ip;
-       struct vnode *vp;
        int error;
 
        if (error =
        int error;
 
        if (error =
-           ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), ndp, &vp))
+           ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), dvp, vpp, cnp))
                return (error);
                return (error);
-       ip = VTOI(vp);
+       ip = VTOI(*vpp);
        ip->i_flag |= IACC|IUPD|ICHG;
        if (vap->va_rdev != VNOVAL) {
                /*
        ip->i_flag |= IACC|IUPD|ICHG;
        if (vap->va_rdev != VNOVAL) {
                /*
@@ -114,9 +114,10 @@ ufs_mknod(ndp, vap, cred, p)
         * checked to see if it is an alias of an existing entry
         * in the inode cache.
         */
         * checked to see if it is an alias of an existing entry
         * in the inode cache.
         */
-       vput(vp);
-       vp->v_type = VNON;
-       vgone(vp);
+       vput(*vpp);
+       (*vpp)->v_type = VNON;
+       vgone(*vpp);
+       *vpp = 0;
        return (0);
 }
 
        return (0);
 }
 
@@ -537,16 +538,17 @@ ufs_seek(vp, oldoff, newoff, cred)
  * in unlinking directories.
  */
 int
  * in unlinking directories.
  */
 int
-ufs_remove(ndp, p)
-       struct nameidata *ndp;
-       struct proc *p;
+ufs_remove(dvp, vp, cnp)   /* converted to CN.   */
+/* old: ufs_remove(ndp, p) */
+       struct vnode *dvp, *vp;
+       struct componentname *cnp;
 {
        register struct inode *ip, *dp;
        int error;
 
 {
        register struct inode *ip, *dp;
        int error;
 
-       ip = VTOI(ndp->ni_vp);
-       dp = VTOI(ndp->ni_dvp);
-       error = ufs_dirremove(ndp);
+       ip = VTOI(vp);
+       dp = VTOI(dvp);
+       error = ufs_dirremove(dvp, cnp);
        if (!error) {
                ip->i_nlink--;
                ip->i_flag |= ICHG;
        if (!error) {
                ip->i_nlink--;
                ip->i_flag |= ICHG;
@@ -563,34 +565,35 @@ ufs_remove(ndp, p)
  * link vnode call
  */
 int
  * link vnode call
  */
 int
-ufs_link(vp, ndp, p)
-       register struct vnode *vp;
-       register struct nameidata *ndp;
-       struct proc *p;
+ufs_link(vp, tdvp, cnp)   /* converted to CN.   */
+/* old: ufs_link(vp, ndp, p) */
+       register struct vnode *vp;   /* source vnode */
+       struct vnode *tdvp;
+       struct componentname *cnp;
 {
        register struct inode *ip;
        int error;
 
 #ifdef DIANOSTIC
 {
        register struct inode *ip;
        int error;
 
 #ifdef DIANOSTIC
-       if ((ndp->ni_nameiop & HASBUF) == 0)
+       if ((cnp->cn_flags & HASBUF) == 0)
                panic("ufs_link: no name");
 #endif
        ip = VTOI(vp);
        if ((unsigned short)ip->i_nlink >= LINK_MAX) {
                panic("ufs_link: no name");
 #endif
        ip = VTOI(vp);
        if ((unsigned short)ip->i_nlink >= LINK_MAX) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+               free(cnp->cn_pnbuf, M_NAMEI);
                return (EMLINK);
        }
                return (EMLINK);
        }
-       if (ndp->ni_dvp != vp)
+       if (tdvp != vp)
                ILOCK(ip);
        ip->i_nlink++;
        ip->i_flag |= ICHG;
        error = VOP_UPDATE(vp, &time, &time, 1);
        if (!error)
                ILOCK(ip);
        ip->i_nlink++;
        ip->i_flag |= ICHG;
        error = VOP_UPDATE(vp, &time, &time, 1);
        if (!error)
-               error = ufs_direnter(ip, ndp);
-       if (ndp->ni_dvp != vp)
+               error = ufs_direnter(ip, tdvp, cnp);
+       if (tdvp != vp)
                IUNLOCK(ip);
                IUNLOCK(ip);
-       FREE(ndp->ni_pnbuf, M_NAMEI);
-       vput(ndp->ni_dvp);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
+       vput(tdvp);
        if (error) {
                ip->i_nlink--;
                ip->i_flag |= ICHG;
        if (error) {
                ip->i_nlink--;
                ip->i_flag |= ICHG;
@@ -598,6 +601,288 @@ ufs_link(vp, ndp, p)
        return (error);
 }
 
        return (error);
 }
 
+
+
+/*
+ * relookup - lookup a path name component
+ *    Used by lookup to re-aquire things.
+ */
+int
+relookup(dvp, vpp, cnp)   /* converted to CN */
+       struct vnode *dvp, **vpp;
+       struct componentname *cnp;
+{
+       register char *cp;              /* pointer into pathname argument */
+       register struct vnode *dp = 0;  /* the directory we are searching */
+       struct vnode *tdp;              /* saved dp */
+       struct mount *mp;               /* mount table entry */
+       int docache;                    /* == 0 do not cache last component */
+       int wantparent;                 /* 1 => wantparent or lockparent flag */
+       int rdonly;                     /* lookup read-only flag bit */
+       int error = 0;
+       int newhash;
+
+       /*
+        * Setup: break out flag bits into variables.
+        */
+       wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
+       docache = (cnp->cn_flags & NOCACHE) ^ NOCACHE;
+       if (cnp->cn_nameiop == DELETE || (wantparent && cnp->cn_nameiop != CREATE))
+               docache = 0;
+       rdonly = cnp->cn_flags & RDONLY;
+       cnp->cn_flags &= ~ISSYMLINK;
+       dp = dvp;
+       VOP_LOCK(dp);
+
+/* dirloop: */
+       /*
+        * Search a new directory.
+        *
+        * The cn_hash value is for use by vfs_cache.
+        * The last component of the filename is left accessible via
+        * cnp->cn_nameptr for callers that need the name. Callers needing
+        * the name set the SAVENAME flag. When done, they assume
+        * responsibility for freeing the pathname buffer.
+        */
+/* NEEDWORK: is hash computed needed */
+       newhash = 0;
+       for (cp = cnp->cn_nameptr; *cp != 0 && *cp != '/'; cp++)
+               newhash += (unsigned char)*cp;
+       if (newhash != cnp->cn_hash)
+               panic("relookup: bad hash");
+       if (cnp->cn_namelen != cp - cnp->cn_nameptr)
+               panic ("relookup: bad len");
+       if (cnp->cn_namelen >= NAME_MAX) {
+               error = ENAMETOOLONG;
+               goto bad;
+       }
+#ifdef NAMEI_DIAGNOSTIC   /* NEEDSWORK: should go */
+       { char c = *cp;
+       *cp = '\0';
+       printf("{%s}: ", cnp->cn_nameptr);
+       *cp = c; }
+#endif
+#if 0
+       cnp->cn_pathlen -= cnp->cn_namelen;
+       ndp->ni_next = cp;
+#endif
+#if 0
+       cnp->cn_flags |= MAKEENTRY;
+       if (*cp == '\0' && docache == 0)
+               cnp->cn_flags &= ~MAKEENTRY;
+       if (cnp->cn_namelen == 2 &&
+                       cnp->ni_nameptr[1] == '.' && cnp->cn_nameptr[0] == '.')
+               cnp->cn_flags |= ISDOTDOT;
+       else cnp->cn_flags &= ~ISDOTDOT;
+#endif
+
+       /*
+        * Check for degenerate name (e.g. / or "")
+        * which is a way of talking about a directory,
+        * e.g. like "/." or ".".
+        */
+       if (cnp->cn_nameptr[0] == '\0') {
+               if (cnp->cn_nameiop != LOOKUP || wantparent) {
+                       error = EISDIR;
+                       goto bad;
+               }
+               if (dp->v_type != VDIR) {
+                       error = ENOTDIR;
+                       goto bad;
+               }
+               if (!(cnp->cn_flags & LOCKLEAF))
+                       VOP_UNLOCK(dp);
+               *vpp = dp;
+               if (cnp->cn_flags & SAVESTART)
+                       panic("lookup: SAVESTART");
+               return (0);
+       }
+
+       /*
+        * Handle "..": two special cases.
+        * 1. If at root directory (e.g. after chroot)
+        *    then ignore it so can't get out.
+        * 2. If this vnode is the root of a mounted
+        *    filesystem, then replace it with the
+        *    vnode which was mounted on so we take the
+        *    .. in the other file system.
+        */
+#if 0
+       /* This shouldn't happen because rename throws out .. */
+       /* NEEDSWORK: what to do about this? */
+       if (cnp->cn_flags & ISDOTDOT) {
+               for (;;) {
+                       if (dp == ndp->ni_rootdir) {
+                               ndp->ni_dvp = dp;
+                               ndp->ni_vp = dp;
+                               VREF(dp);
+                               goto nextname;
+                       }
+                       if ((dp->v_flag & VROOT) == 0 ||
+                           (cnp->cn_flags & NOCROSSMOUNT))
+                               break;
+                       tdp = dp;
+                       dp = dp->v_mount->mnt_vnodecovered;
+                       vput(tdp);
+                       VREF(dp);
+                       VOP_LOCK(dp);
+               }
+       }
+#endif
+       if (cnp->cn_flags & ISDOTDOT)
+               panic ("relookup: lookup on dot-dot");
+
+       /*
+        * We now have a segment name to search for, and a directory to search.
+        */
+       if (error = VOP_LOOKUP(dp, vpp, cnp)) {
+#ifdef DIAGNOSTIC
+               if (*vpp != NULL)
+                       panic("leaf should be empty");
+#endif
+#ifdef NAMEI_DIAGNOSTIC
+               printf("not found\n");
+#endif
+               if (cnp->cn_nameiop == LOOKUP || cnp->cn_nameiop == DELETE ||
+                   error != ENOENT || *cp != 0)
+                       goto bad;
+               /*
+                * If creating and at end of pathname, then can consider
+                * allowing file to be created.
+                */
+               if (rdonly || (dvp->v_mount->mnt_flag & MNT_RDONLY)) {
+                       error = EROFS;
+                       goto bad;
+               }
+               /*
+                * We return with ni_vp NULL to indicate that the entry
+                * doesn't currently exist, leaving a pointer to the
+                * (possibly locked) directory inode in ndp->ni_dvp.
+                */
+#ifdef JOHNH
+               /*
+                * no need because we don't need to do another lookup.
+                * NEEDSWORK: don't do release.
+                * but wait...let's try it a different way.
+                */
+               if (cnp->cn_flags & SAVESTART) {
+#if 0
+                       ndp->ni_startdir = ndp->ni_dvp;
+                       VREF(ndp->ni_startdir);
+#else
+                       /*
+                        * startdir == dvp, always
+                        */
+                       VREF(dvp);
+#endif
+               }
+#endif
+               return (0);
+       }
+#ifdef NAMEI_DIAGNOSTIC
+       printf("found\n");
+#endif
+
+       dp = *vpp;
+       /*
+        * Check for symbolic link
+        */
+#if 0
+       if ((dp->v_type == VLNK) &&
+           ((cnp->cn_flags & FOLLOW) || *ndp->ni_next == '/')) {
+               cnp->cn_flags |= ISSYMLINK;
+               return (0);
+       }
+#endif
+       if (dp->v_type == VLNK) {
+               panic ("relookup: symlink found.\n");
+       };
+
+       /*
+        * Check to see if the vnode has been mounted on;
+        * if so find the root of the mounted file system.
+        */
+#if 0
+       /* NEEDSWORK: mounts should not be crossed in cnlookup */
+       /*
+        * Checked for in rename (returns EXDEV).
+        */
+mntloop:
+       while (dp->v_type == VDIR && (mp = dp->v_mountedhere) &&
+              (cnp->cn_flags & NOCROSSMOUNT) == 0) {
+               if (mp->mnt_flag & MNT_MLOCK) {
+                       mp->mnt_flag |= MNT_MWAIT;
+                       sleep((caddr_t)mp, PVFS);
+                       goto mntloop;
+               }
+               if (error = VFS_ROOT(dp->v_mountedhere, &tdp))
+                       goto bad2;
+               vput(dp);
+               ndp->ni_vp = dp = tdp;
+       }
+#endif
+       if (dp->v_type == VDIR && (dp->v_mountedhere))
+           panic ("relookup: mount point encountered.");
+
+
+nextname:
+       /*
+        * Not a symbolic link.  If more pathname,
+        * continue at next component, else return.
+        */
+#if 0  
+       if (*ndp->ni_next == '/') {
+               cnp->cn_nameptr = ndp->ni_next;
+               while (*cnp->cn_nameptr == '/') {
+                       ndp->ni_nameptr++;
+                       ndp->ni_pathlen--;
+               }
+               vrele(ndp->ni_dvp);
+               goto dirloop;
+       }
+#endif
+
+       /*
+        * Check for read-only file systems.
+        */
+       if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) {
+               /*
+                * Disallow directory write attempts on read-only
+                * file systems.
+                */
+               if (rdonly || (dp->v_mount->mnt_flag & MNT_RDONLY) ||
+                   (wantparent &&
+                    (dvp->v_mount->mnt_flag & MNT_RDONLY))) {
+                       error = EROFS;
+                       goto bad2;
+               }
+       }
+       if (cnp->cn_flags & SAVESTART) {
+#if 0
+               ndp->ni_startdir = ndp->ni_dvp;
+               VREF(ndp->ni_startdir);
+#endif
+               /* ASSERT(dvp==ndp->ni_startdir) */
+               VREF(dvp);
+       }
+       
+       if (!wantparent)
+               vrele(dvp);
+       if ((cnp->cn_flags & LOCKLEAF) == 0)
+               VOP_UNLOCK(dp);
+       return (0);
+
+bad2:
+       if ((cnp->cn_flags & LOCKPARENT) && (cnp->cn_flags & ISLASTCN))
+               VOP_UNLOCK(dvp);
+       vrele(dvp);
+bad:
+       vput(dp);
+       *vpp = NULL;
+       return (error);
+}
+
+
 /*
  * Rename system call.
  *     rename("foo", "bar");
 /*
  * Rename system call.
  *     rename("foo", "bar");
@@ -623,33 +908,38 @@ ufs_link(vp, ndp, p)
  *    directory.
  */
 int
  *    directory.
  */
 int
-ufs_rename(fndp, tndp, p)
-       register struct nameidata *fndp, *tndp;
-       struct proc *p;
+ufs_rename(fdvp, fvp, fcnp,
+          tdvp, tvp, tcnp)   /* converted to CN.   */
+/* old: ufs_rename(fndp, tndp, p) */
+       struct vnode *fdvp, *fvp;
+       struct componentname *fcnp;
+       struct vnode *tdvp, *tvp;
+       struct componentname *tcnp;
 {
        register struct inode *ip, *xp, *dp;
        struct dirtemplate dirbuf;
        int doingdirectory = 0, oldparent = 0, newparent = 0;
        int error = 0;
 {
        register struct inode *ip, *xp, *dp;
        struct dirtemplate dirbuf;
        int doingdirectory = 0, oldparent = 0, newparent = 0;
        int error = 0;
+       int fdvpneedsrele = 1, tdvpneedsrele = 1;
 
 #ifdef DIANOSTIC
 
 #ifdef DIANOSTIC
-       if ((tndp->ni_nameiop & HASBUF) == 0 ||
-           (fndp->ni_nameiop & HASBUF) == 0)
+       if ((tcnp->cn_flags & HASBUF) == 0 ||
+           (fcnp->cn_flags & HASBUF) == 0)
                panic("ufs_rename: no name");
 #endif
                panic("ufs_rename: no name");
 #endif
-       dp = VTOI(fndp->ni_dvp);
-       ip = VTOI(fndp->ni_vp);
+       dp = VTOI(fdvp);
+       ip = VTOI(fvp);
        /*
         * Check if just deleting a link name.
         */
        /*
         * Check if just deleting a link name.
         */
-       if (fndp->ni_vp == tndp->ni_vp) {
-               VOP_ABORTOP(tndp);
-               vput(tndp->ni_dvp);
-               vput(tndp->ni_vp);
-               vrele(fndp->ni_dvp);
+       if (fvp == tvp) {
+               VOP_ABORTOP(tdvp, tcnp);
+               vput(tdvp);
+               vput(tvp);
+               vrele(fdvp);
                if ((ip->i_mode&IFMT) == IFDIR) {
                if ((ip->i_mode&IFMT) == IFDIR) {
-                       VOP_ABORTOP(fndp);
-                       vrele(fndp->ni_vp);
+                       VOP_ABORTOP(fdvp, fcnp);
+                       vrele(fvp);
                        return (EINVAL);
                }
                doingdirectory = 0;
                        return (EINVAL);
                }
                doingdirectory = 0;
@@ -660,22 +950,22 @@ ufs_rename(fndp, tndp, p)
                /*
                 * Avoid ".", "..", and aliases of "." for obvious reasons.
                 */
                /*
                 * Avoid ".", "..", and aliases of "." for obvious reasons.
                 */
-               if ((fndp->ni_namelen == 1 && fndp->ni_ptr[0] == '.') ||
-                   dp == ip || fndp->ni_isdotdot || (ip->i_flag & IRENAME)) {
-                       VOP_ABORTOP(tndp);
-                       vput(tndp->ni_dvp);
-                       if (tndp->ni_vp)
-                               vput(tndp->ni_vp);
-                       VOP_ABORTOP(fndp);
-                       vrele(fndp->ni_dvp);
-                       vput(fndp->ni_vp);
+               if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||
+                   dp == ip || (fcnp->cn_flags&ISDOTDOT) || (ip->i_flag & IRENAME)) {
+                       VOP_ABORTOP(tdvp, tcnp);
+                       vput(tdvp);
+                       if (tvp)
+                               vput(tvp);
+                       VOP_ABORTOP(fdvp, fcnp);
+                       vrele(fdvp);
+                       vput(fvp);
                        return (EINVAL);
                }
                ip->i_flag |= IRENAME;
                oldparent = dp->i_number;
                doingdirectory++;
        }
                        return (EINVAL);
                }
                ip->i_flag |= IRENAME;
                oldparent = dp->i_number;
                doingdirectory++;
        }
-       vrele(fndp->ni_dvp);
+       vrele(fdvp);
 
        /*
         * 1) Bump link count while we're moving stuff
 
        /*
         * 1) Bump link count while we're moving stuff
@@ -685,17 +975,17 @@ ufs_rename(fndp, tndp, p)
         */
        ip->i_nlink++;
        ip->i_flag |= ICHG;
         */
        ip->i_nlink++;
        ip->i_flag |= ICHG;
-       error = VOP_UPDATE(fndp->ni_vp, &time, &time, 1);
+       error = VOP_UPDATE(fvp, &time, &time, 1);
        IUNLOCK(ip);
 
        /*
         * When the target exists, both the directory
         * and target vnodes are returned locked.
         */
        IUNLOCK(ip);
 
        /*
         * When the target exists, both the directory
         * and target vnodes are returned locked.
         */
-       dp = VTOI(tndp->ni_dvp);
+       dp = VTOI(tdvp);
        xp = NULL;
        xp = NULL;
-       if (tndp->ni_vp)
-               xp = VTOI(tndp->ni_vp);
+       if (tvp)
+               xp = VTOI(tvp);
        /*
         * If ".." must be changed (ie the directory gets a new
         * parent) then the source directory must not be in the
        /*
         * If ".." must be changed (ie the directory gets a new
         * parent) then the source directory must not be in the
@@ -709,24 +999,24 @@ ufs_rename(fndp, tndp, p)
        if (oldparent != dp->i_number)
                newparent = dp->i_number;
        if (doingdirectory && newparent) {
        if (oldparent != dp->i_number)
                newparent = dp->i_number;
        if (doingdirectory && newparent) {
-               VOP_LOCK(fndp->ni_vp);
-               error = ufs_access(fndp->ni_vp, VWRITE, tndp->ni_cred, p);
-               VOP_UNLOCK(fndp->ni_vp);
+               VOP_LOCK(fvp);
+               error = ufs_access(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
+               VOP_UNLOCK(fvp);
                if (error)
                        goto bad;
                if (xp != NULL)
                        ufs_iput(xp);
                if (error)
                        goto bad;
                if (xp != NULL)
                        ufs_iput(xp);
-               if (error = ufs_checkpath(ip, dp, tndp->ni_cred))
+               if (error = ufs_checkpath(ip, dp, tcnp->cn_cred))
                        goto out;
                        goto out;
-               if ((tndp->ni_nameiop & SAVESTART) == 0)
+               if ((tcnp->cn_flags & SAVESTART) == 0)
                        panic("ufs_rename: lost to startdir");
                p->p_spare[1]--;
                        panic("ufs_rename: lost to startdir");
                p->p_spare[1]--;
-               if (error = lookup(tndp, p))
+               if (error = relookup(tdvp, &tvp, tcnp))
                        goto out;
                        goto out;
-               dp = VTOI(tndp->ni_dvp);
+               dp = VTOI(tdvp);
                xp = NULL;
                xp = NULL;
-               if (tndp->ni_vp)
-                       xp = VTOI(tndp->ni_vp);
+               if (tvp)
+                       xp = VTOI(tvp);
        }
        /*
         * 2) If target doesn't exist, link the target
        }
        /*
         * 2) If target doesn't exist, link the target
@@ -753,7 +1043,7 @@ ufs_rename(fndp, tndp, p)
                        if (error = VOP_UPDATE(ITOV(dp), &time, &time, 1))
                                goto bad;
                }
                        if (error = VOP_UPDATE(ITOV(dp), &time, &time, 1))
                                goto bad;
                }
-               if (error = ufs_direnter(ip, tndp)) {
+               if (error = ufs_direnter(ip, tdvp, tcnp)) {
                        if (doingdirectory && newparent) {
                                dp->i_nlink--;
                                dp->i_flag |= ICHG;
                        if (doingdirectory && newparent) {
                                dp->i_nlink--;
                                dp->i_flag |= ICHG;
@@ -776,9 +1066,9 @@ ufs_rename(fndp, tndp, p)
                 * otherwise the destination may not be changed (except by
                 * root). This implements append-only directories.
                 */
                 * otherwise the destination may not be changed (except by
                 * root). This implements append-only directories.
                 */
-               if ((dp->i_mode & ISVTX) && tndp->ni_cred->cr_uid != 0 &&
-                   tndp->ni_cred->cr_uid != dp->i_uid &&
-                   xp->i_uid != tndp->ni_cred->cr_uid) {
+               if ((dp->i_mode & ISVTX) && tcnp->cn_cred->cr_uid != 0 &&
+                   tcnp->cn_cred->cr_uid != dp->i_uid &&
+                   xp->i_uid != tcnp->cn_cred->cr_uid) {
                        error = EPERM;
                        goto bad;
                }
                        error = EPERM;
                        goto bad;
                }
@@ -788,7 +1078,7 @@ ufs_rename(fndp, tndp, p)
                 * (both directories, or both not directories).
                 */
                if ((xp->i_mode&IFMT) == IFDIR) {
                 * (both directories, or both not directories).
                 */
                if ((xp->i_mode&IFMT) == IFDIR) {
-                       if (!ufs_dirempty(xp, dp->i_number, tndp->ni_cred) || 
+                       if (!ufs_dirempty(xp, dp->i_number, tcnp->cn_cred) || 
                            xp->i_nlink > 2) {
                                error = ENOTEMPTY;
                                goto bad;
                            xp->i_nlink > 2) {
                                error = ENOTEMPTY;
                                goto bad;
@@ -802,7 +1092,7 @@ ufs_rename(fndp, tndp, p)
                        error = EISDIR;
                        goto bad;
                }
                        error = EISDIR;
                        goto bad;
                }
-               if (error = ufs_dirrewrite(dp, ip, tndp))
+               if (error = ufs_dirrewrite(dp, ip, tcnp))
                        goto bad;
                /*
                 * If the target directory is in the same
                        goto bad;
                /*
                 * If the target directory is in the same
@@ -840,15 +1130,15 @@ ufs_rename(fndp, tndp, p)
         * 3) Unlink the source.
         */
 unlinkit:
         * 3) Unlink the source.
         */
 unlinkit:
-       fndp->ni_nameiop &= ~MODMASK;
-       fndp->ni_nameiop |= LOCKPARENT | LOCKLEAF;
-       if ((fndp->ni_nameiop & SAVESTART) == 0)
+       fcnp->cn_flags &= ~MODMASK;
+       fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
+       if ((fcnp->cn_flags & SAVESTART) == 0)
                panic("ufs_rename: lost from startdir");
        p->p_spare[1]--;
                panic("ufs_rename: lost from startdir");
        p->p_spare[1]--;
-       (void) lookup(fndp, p);
-       if (fndp->ni_vp != NULL) {
-               xp = VTOI(fndp->ni_vp);
-               dp = VTOI(fndp->ni_dvp);
+       (void) relookup(fdvp, &fvp, fcnp);   /* NEEDSWORK: startdir stuff */
+       if (fvp != NULL) {
+               xp = VTOI(fvp);
+               dp = VTOI(fdvp);
        } else {
                /*
                 * From name has disappeared.
        } else {
                /*
                 * From name has disappeared.
@@ -884,7 +1174,7 @@ unlinkit:
                        error = vn_rdwr(UIO_READ, ITOV(xp), (caddr_t)&dirbuf,
                                sizeof (struct dirtemplate), (off_t)0,
                                UIO_SYSSPACE, IO_NODELOCKED, 
                        error = vn_rdwr(UIO_READ, ITOV(xp), (caddr_t)&dirbuf,
                                sizeof (struct dirtemplate), (off_t)0,
                                UIO_SYSSPACE, IO_NODELOCKED, 
-                               tndp->ni_cred, (int *)0, (struct proc *)0);
+                               tcnp->cn_cred, (int *)0, (struct proc *)0);
                        if (error == 0) {
                                if (dirbuf.dotdot_namlen != 2 ||
                                    dirbuf.dotdot_name[0] != '.' ||
                        if (error == 0) {
                                if (dirbuf.dotdot_namlen != 2 ||
                                    dirbuf.dotdot_name[0] != '.' ||
@@ -898,13 +1188,13 @@ unlinkit:
                                            sizeof (struct dirtemplate),
                                            (off_t)0, UIO_SYSSPACE,
                                            IO_NODELOCKED|IO_SYNC,
                                            sizeof (struct dirtemplate),
                                            (off_t)0, UIO_SYSSPACE,
                                            IO_NODELOCKED|IO_SYNC,
-                                           tndp->ni_cred, (int *)0,
+                                           tcnp->cn_cred, (int *)0,
                                            (struct proc *)0);
                                        cache_purge(ITOV(dp));
                                }
                        }
                }
                                            (struct proc *)0);
                                        cache_purge(ITOV(dp));
                                }
                        }
                }
-               error = ufs_dirremove(fndp);
+               error = ufs_dirremove(fdvp, fcnp);
                if (!error) {
                        xp->i_nlink--;
                        xp->i_flag |= ICHG;
                if (!error) {
                        xp->i_nlink--;
                        xp->i_flag |= ICHG;
@@ -941,26 +1231,26 @@ static struct dirtemplate mastertemplate = {
  * Mkdir system call
  */
 int
  * Mkdir system call
  */
 int
-ufs_mkdir(ndp, vap, p)
-       struct nameidata *ndp;
+ufs_mkdir(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* was: ufs_mkdir(cnp, vap) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        struct vattr *vap;
-       struct proc *p;
 {
        register struct inode *ip, *dp;
        struct vnode *tvp;
 {
        register struct inode *ip, *dp;
        struct vnode *tvp;
-       struct vnode *dvp;
        struct dirtemplate dirtemplate;
        int error;
        int dmode;
 
 #ifdef DIANOSTIC
        struct dirtemplate dirtemplate;
        int error;
        int dmode;
 
 #ifdef DIANOSTIC
-       if ((ndp->ni_nameiop & HASBUF) == 0)
+       if ((cnp->cn_flags & HASBUF) == 0)
                panic("ufs_mkdir: no name");
 #endif
                panic("ufs_mkdir: no name");
 #endif
-       dvp = ndp->ni_dvp;
        dp = VTOI(dvp);
        if ((unsigned short)dp->i_nlink >= LINK_MAX) {
        dp = VTOI(dvp);
        if ((unsigned short)dp->i_nlink >= LINK_MAX) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+               free(cnp->cn_pnbuf, M_NAMEI);
                ufs_iput(dp);
                return (EMLINK);
        }
                ufs_iput(dp);
                return (EMLINK);
        }
@@ -971,18 +1261,18 @@ ufs_mkdir(ndp, vap, p)
         * not have it entered in the parent directory. The entry is made
         * later after writing "." and ".." entries.
         */
         * not have it entered in the parent directory. The entry is made
         * later after writing "." and ".." entries.
         */
-       if (error = VOP_VALLOC(dvp, dmode, ndp->ni_cred, &tvp)) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+       if (error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp)) {
+               free(cnp->cn_pnbuf, M_NAMEI);
                ufs_iput(dp);
                return (error);
        }
        ip = VTOI(tvp);
                ufs_iput(dp);
                return (error);
        }
        ip = VTOI(tvp);
-       ip->i_uid = ndp->ni_cred->cr_uid;
+       ip->i_uid = cnp->cn_cred->cr_uid;
        ip->i_gid = dp->i_gid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
        ip->i_gid = dp->i_gid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
-           (error = chkiq(ip, 1, ndp->ni_cred, 0))) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+           (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
+               free(cnp->cn_pnbuf, M_NAMEI);
                VOP_VFREE(tvp, ip->i_number, dmode);
                ufs_iput(ip);
                ufs_iput(dp);
                VOP_VFREE(tvp, ip->i_number, dmode);
                ufs_iput(ip);
                ufs_iput(dp);
@@ -1012,7 +1302,7 @@ ufs_mkdir(ndp, vap, p)
        dirtemplate.dotdot_ino = dp->i_number;
        error = vn_rdwr(UIO_WRITE, ITOV(ip), (caddr_t)&dirtemplate,
            sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE,
        dirtemplate.dotdot_ino = dp->i_number;
        error = vn_rdwr(UIO_WRITE, ITOV(ip), (caddr_t)&dirtemplate,
            sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE,
-           IO_NODELOCKED|IO_SYNC, ndp->ni_cred, (int *)0, (struct proc *)0);
+           IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (int *)0, (struct proc *)0);
        if (error) {
                dp->i_nlink--;
                dp->i_flag |= ICHG;
        if (error) {
                dp->i_nlink--;
                dp->i_flag |= ICHG;
@@ -1026,7 +1316,7 @@ ufs_mkdir(ndp, vap, p)
        }
 
        /* Directory set up, now install it's entry in the parent directory. */
        }
 
        /* Directory set up, now install it's entry in the parent directory. */
-       if (error = ufs_direnter(ip, ndp)) {
+       if (error = ufs_direnter(ip, dvp, cnp)) {
                dp->i_nlink--;
                dp->i_flag |= ICHG;
        }
                dp->i_nlink--;
                dp->i_flag |= ICHG;
        }
@@ -1040,8 +1330,8 @@ bad:
                ip->i_flag |= ICHG;
                ufs_iput(ip);
        } else
                ip->i_flag |= ICHG;
                ufs_iput(ip);
        } else
-               ndp->ni_vp = ITOV(ip);
-       FREE(ndp->ni_pnbuf, M_NAMEI);
+               *vpp = ITOV(ip);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
        ufs_iput(dp);
        return (error);
 }
        ufs_iput(dp);
        return (error);
 }
@@ -1050,20 +1340,21 @@ bad:
  * Rmdir system call.
  */
 int
  * Rmdir system call.
  */
 int
-ufs_rmdir(ndp, p)
-       register struct nameidata *ndp;
-       struct proc *p;
+ufs_rmdir(dvp, vp, cnp)   /* converted to CN.   */
+/* old: ufs_rmdir(ndp, p) */
+       struct vnode *dvp, *vp;
+       struct componentname *cnp;
 {
        register struct inode *ip, *dp;
        int error;
 
 {
        register struct inode *ip, *dp;
        int error;
 
-       ip = VTOI(ndp->ni_vp);
-       dp = VTOI(ndp->ni_dvp);
+       ip = VTOI(vp);
+       dp = VTOI(dvp);
        /*
         * No rmdir "." please.
         */
        if (dp == ip) {
        /*
         * No rmdir "." please.
         */
        if (dp == ip) {
-               vrele(ndp->ni_dvp);
+               vrele(dvp);
                ufs_iput(ip);
                return (EINVAL);
        }
                ufs_iput(ip);
                return (EINVAL);
        }
@@ -1076,7 +1367,7 @@ ufs_rmdir(ndp, p)
         */
        error = 0;
        if (ip->i_nlink != 2 ||
         */
        error = 0;
        if (ip->i_nlink != 2 ||
-           !ufs_dirempty(ip, dp->i_number, ndp->ni_cred)) {
+           !ufs_dirempty(ip, dp->i_number, cnp->cn_cred)) {
                error = ENOTEMPTY;
                goto out;
        }
                error = ENOTEMPTY;
                goto out;
        }
@@ -1085,13 +1376,13 @@ ufs_rmdir(ndp, p)
         * inode.  If we crash in between, the directory
         * will be reattached to lost+found,
         */
         * inode.  If we crash in between, the directory
         * will be reattached to lost+found,
         */
-       if (error = ufs_dirremove(ndp))
+       if (error = ufs_dirremove(dvp, cnp))
                goto out;
        dp->i_nlink--;
        dp->i_flag |= ICHG;
                goto out;
        dp->i_nlink--;
        dp->i_flag |= ICHG;
-       cache_purge(ndp->ni_dvp);
+       cache_purge(dvp);
        ufs_iput(dp);
        ufs_iput(dp);
-       ndp->ni_dvp = NULL;
+       dvp = NULL;
        /*
         * Truncate inode.  The only stuff left
         * in the directory is "." and "..".  The
        /*
         * Truncate inode.  The only stuff left
         * in the directory is "." and "..".  The
@@ -1104,10 +1395,10 @@ ufs_rmdir(ndp, p)
         * worry about them later.
         */
        ip->i_nlink -= 2;
         * worry about them later.
         */
        ip->i_nlink -= 2;
-       error = VOP_TRUNCATE(ndp->ni_vp, (u_long)0, IO_SYNC);
+       error = VOP_TRUNCATE(vp, (u_long)0, IO_SYNC);
        cache_purge(ITOV(ip));
 out:
        cache_purge(ITOV(ip));
 out:
-       if (ndp->ni_dvp)
+       if (dvp)
                ufs_iput(dp);
        ufs_iput(ip);
        return (error);
                ufs_iput(dp);
        ufs_iput(ip);
        return (error);
@@ -1117,21 +1408,22 @@ out:
  * symlink -- make a symbolic link
  */
 int
  * symlink -- make a symbolic link
  */
 int
-ufs_symlink(ndp, vap, target, p)
-       struct nameidata *ndp;
+ufs_symlink(dvp, vpp, cnp, vap, target)   /* converted to CN.   */
+/* old: ufs_symlink(ndp, vap, target, p) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        char *target;
        struct vattr *vap;
        char *target;
-       struct proc *p;
 {
 {
-       struct vnode *vp;
        int error;
 
        int error;
 
-       if (error = ufs_makeinode(IFLNK | vap->va_mode, ndp, &vp))
+       if (error = ufs_makeinode(IFLNK | vap->va_mode, dvp, vpp, cnp))
                return (error);
                return (error);
-       error = vn_rdwr(UIO_WRITE, vp, target, strlen(target), (off_t)0,
-               UIO_SYSSPACE, IO_NODELOCKED, ndp->ni_cred, (int *)0,
+       error = vn_rdwr(UIO_WRITE, *vpp, target, strlen(target), (off_t)0,
+               UIO_SYSSPACE, IO_NODELOCKED, cnp->cn_cred, (int *)0,
                (struct proc *)0);
                (struct proc *)0);
-       vput(vp);
+       vput(*vpp);
        return (error);
 }
 
        return (error);
 }
 
@@ -1182,12 +1474,12 @@ ufs_readlink(vp, uiop, cred)
  */
 /* ARGSUSED */
 int
  */
 /* ARGSUSED */
 int
-ufs_abortop(ndp)
-       struct nameidata *ndp;
+ufs_abortop(dvp, cnp)    /* converted to CN.   */
+       struct vnode *dvp;
+       struct componentname *cnp;
 {
 {
-
-       if ((ndp->ni_nameiop & (HASBUF | SAVESTART)) == HASBUF)
-               FREE(ndp->ni_pnbuf, M_NAMEI);
+       if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
+               FREE(cnp->cn_pnbuf, M_NAMEI);
        return (0);
 }
 
        return (0);
 }
 
@@ -1557,36 +1849,38 @@ ufs_vinit(mntp, specops, fifoops, vpp)
  * Allocate a new inode.
  */
 int
  * Allocate a new inode.
  */
 int
-ufs_makeinode(mode, ndp, vpp)
+ufs_makeinode(mode, dvp, vpp, cnp)   /* converted to CN */
+/* OLD: ufs_makeinode(mode, ndp, vpp) */
        int mode;
        int mode;
-       register struct nameidata *ndp;
+       struct vnode *dvp;
        struct vnode **vpp;
        struct vnode **vpp;
+       struct componentname *cnp;
 {
        register struct inode *ip, *pdir;
        struct vnode *tvp;
        int error;
 
 {
        register struct inode *ip, *pdir;
        struct vnode *tvp;
        int error;
 
-       pdir = VTOI(ndp->ni_dvp);
+       pdir = VTOI(dvp);
 #ifdef DIANOSTIC
 #ifdef DIANOSTIC
-       if ((ndp->ni_nameiop & HASBUF) == 0)
+       if ((cnp->cn_flags & HASBUF) == 0)
                panic("ufs_makeinode: no name");
 #endif
        *vpp = NULL;
        if ((mode & IFMT) == 0)
                mode |= IFREG;
 
                panic("ufs_makeinode: no name");
 #endif
        *vpp = NULL;
        if ((mode & IFMT) == 0)
                mode |= IFREG;
 
-       if (error = VOP_VALLOC(ndp->ni_dvp, mode, ndp->ni_cred, &tvp)) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+       if (error = VOP_VALLOC(dvp, mode, cnp->cn_cred, &tvp)) {
+               free(cnp->cn_pnbuf, M_NAMEI);
                ufs_iput(pdir);
                return (error);
        }
        ip = VTOI(tvp);
                ufs_iput(pdir);
                return (error);
        }
        ip = VTOI(tvp);
-       ip->i_uid = ndp->ni_cred->cr_uid;
+       ip->i_uid = cnp->cn_cred->cr_uid;
        ip->i_gid = pdir->i_gid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
        ip->i_gid = pdir->i_gid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
-           (error = chkiq(ip, 1, ndp->ni_cred, 0))) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+           (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
+               free(cnp->cn_pnbuf, M_NAMEI);
                VOP_VFREE(tvp, ip->i_number, mode);
                ufs_iput(ip);
                ufs_iput(pdir);
                VOP_VFREE(tvp, ip->i_number, mode);
                ufs_iput(ip);
                ufs_iput(pdir);
@@ -1597,8 +1891,8 @@ ufs_makeinode(mode, ndp, vpp)
        ip->i_mode = mode;
        tvp->v_type = IFTOVT(mode);     /* Rest init'd in iget() */
        ip->i_nlink = 1;
        ip->i_mode = mode;
        tvp->v_type = IFTOVT(mode);     /* Rest init'd in iget() */
        ip->i_nlink = 1;
-       if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, ndp->ni_cred) &&
-           suser(ndp->ni_cred, NULL))
+       if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) &&
+           suser(cnp->cn_cred, NULL))
                ip->i_mode &= ~ISGID;
 
        /*
                ip->i_mode &= ~ISGID;
 
        /*
@@ -1606,10 +1900,10 @@ ufs_makeinode(mode, ndp, vpp)
         */
        if (error = VOP_UPDATE(tvp, &time, &time, 1))
                goto bad;
         */
        if (error = VOP_UPDATE(tvp, &time, &time, 1))
                goto bad;
-       if (error = ufs_direnter(ip, ndp))
+       if (error = ufs_direnter(ip, dvp, cnp))
                goto bad;
                goto bad;
-       if ((ndp->ni_nameiop & SAVESTART) == 0)
-               FREE(ndp->ni_pnbuf, M_NAMEI);
+       if ((cnp->cn_flags & SAVESTART) == 0)
+               FREE(cnp->cn_pnbuf, M_NAMEI);
        ufs_iput(pdir);
        *vpp = tvp;
        return (0);
        ufs_iput(pdir);
        *vpp = tvp;
        return (0);
@@ -1619,10 +1913,28 @@ bad:
         * Write error occurred trying to update the inode
         * or the directory so must deallocate the inode.
         */
         * Write error occurred trying to update the inode
         * or the directory so must deallocate the inode.
         */
-       free(ndp->ni_pnbuf, M_NAMEI);
+       free(cnp->cn_pnbuf, M_NAMEI);
        ufs_iput(pdir);
        ip->i_nlink = 0;
        ip->i_flag |= ICHG;
        ufs_iput(ip);
        return (error);
 }
        ufs_iput(pdir);
        ip->i_nlink = 0;
        ip->i_flag |= ICHG;
        ufs_iput(ip);
        return (error);
 }
+
+
+#if defined(JOHNH) && 0
+/*
+ * A hack to get the kernel to compile.
+ */
+int
+hang_addrlist()
+{
+    return 0;
+}
+int
+free_addrlist()
+{
+    return 0;
+}
+#endif
+
index a6ffc0a..51bdcd9 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_extern.h        7.2 (Berkeley) %G%
+ *     @(#)ufs_extern.h        7.3 (Berkeley) %G%
  */
 
 struct buf;
  */
 
 struct buf;
@@ -30,7 +30,7 @@ char  *readdisklabel __P((dev_t, int (*)(), struct disklabel *));
 int     setdisklabel __P((struct disklabel *, struct disklabel *, u_long));
 int     writedisklabel __P((dev_t, int (*)(), struct disklabel *));
 
 int     setdisklabel __P((struct disklabel *, struct disklabel *, u_long));
 int     writedisklabel __P((dev_t, int (*)(), struct disklabel *));
 
-int     ufs_abortop __P((struct nameidata *));
+int     ufs_abortop __P((struct vnode *, struct componentname *));
 int     ufs_access __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_advlock __P((struct vnode *, caddr_t, int, struct flock *, int));
 void    ufs_bufstats __P((void));
 int     ufs_access __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_advlock __P((struct vnode *, caddr_t, int, struct flock *, int));
 void    ufs_bufstats __P((void));
@@ -38,14 +38,15 @@ int  ufs_checkpath __P((struct inode *, struct inode *, struct ucred *));
 int     ufs_chmod __P((struct vnode *, int, struct proc *));
 int     ufs_chown __P((struct vnode *, u_int, u_int, struct proc *));
 int     ufs_close __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_chmod __P((struct vnode *, int, struct proc *));
 int     ufs_chown __P((struct vnode *, u_int, u_int, struct proc *));
 int     ufs_close __P((struct vnode *, int, struct ucred *, struct proc *));
-int     ufs_create __P((struct nameidata *, struct vattr *, struct proc *));
+int     ufs_create __P((struct vnode *, struct vnode **,
+                        struct componentname *, struct vattr *));
 void    ufs_dirbad __P((struct inode *, off_t, char *));
 int     ufs_dirbadentry __P((struct direct *, int));
 int     ufs_dirempty __P((struct inode *, ino_t, struct ucred *));
 void    ufs_dirbad __P((struct inode *, off_t, char *));
 int     ufs_dirbadentry __P((struct direct *, int));
 int     ufs_dirempty __P((struct inode *, ino_t, struct ucred *));
-int     ufs_direnter __P((struct inode *, struct nameidata *));
-int     ufs_dirremove __P((struct nameidata *));
+int     ufs_direnter __P((struct inode *, struct vnode *,struct componentname *));
+int     ufs_dirremove __P((struct vnode *, struct componentname*));
 int     ufs_dirrewrite
 int     ufs_dirrewrite
-           __P((struct inode *, struct inode *, struct nameidata *));
+           __P((struct inode *, struct inode *, struct componentname *));
 int     ufs_getattr __P((struct vnode *,
            struct vattr *, struct ucred *, struct proc *));
 struct vnode *
 int     ufs_getattr __P((struct vnode *,
            struct vattr *, struct ucred *, struct proc *));
 struct vnode *
@@ -59,13 +60,14 @@ int  ufs_ioctl __P((struct vnode *,
 void    ufs_iput __P((struct inode *));
 int     ufs_islocked __P((struct vnode *));
 void    ufs_iunlock __P((struct inode *));
 void    ufs_iput __P((struct inode *));
 int     ufs_islocked __P((struct vnode *));
 void    ufs_iunlock __P((struct inode *));
-int     ufs_link __P((struct vnode *, struct nameidata *, struct proc *));
+int     ufs_link __P((struct vnode *, struct vnode *, struct componentname *));
 int     ufs_lock __P((struct vnode *));
 int     ufs_lock __P((struct vnode *));
-int     ufs_lookup __P((struct vnode *, struct nameidata *, struct proc *));
-int     ufs_makeinode __P((int mode, struct nameidata *, struct vnode **));
-int     ufs_mkdir __P((struct nameidata *, struct vattr *, struct proc *));
-int     ufs_mknod __P((struct nameidata *,
-           struct vattr *, struct ucred *, struct proc *));
+int     ufs_lookup __P((struct vnode *, struct vnode **, struct componentname *));
+int     ufs_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *));
+int     ufs_mkdir __P((struct vnode *, struct vnode **,
+                       struct componentname *, struct vattr *));
+int     ufs_mknod __P((struct vnode *, struct vnode **,
+                       struct componentname *, struct vattr *));
 int     ufs_mmap __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_mountedon __P((struct vnode *));
 int     ufs_open __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_mmap __P((struct vnode *, int, struct ucred *, struct proc *));
 int     ufs_mountedon __P((struct vnode *));
 int     ufs_open __P((struct vnode *, int, struct ucred *, struct proc *));
@@ -73,10 +75,11 @@ int  ufs_print __P((struct vnode *));
 int     ufs_readdir __P((struct vnode *, struct uio *, struct ucred *, int *));
 int     ufs_readlink __P((struct vnode *, struct uio *, struct ucred *));
 int     ufs_reclaim __P((struct vnode *));
 int     ufs_readdir __P((struct vnode *, struct uio *, struct ucred *, int *));
 int     ufs_readlink __P((struct vnode *, struct uio *, struct ucred *));
 int     ufs_reclaim __P((struct vnode *));
-int     ufs_remove __P((struct nameidata *, struct proc *));
+int     ufs_remove __P((struct vnode *, struct vnode *, struct componentname *));
 int     ufs_rename
 int     ufs_rename
-           __P((struct nameidata *, struct nameidata *, struct proc *));
-int     ufs_rmdir __P((struct nameidata *, struct proc *));
+           __P((struct vnode *, struct vnode *, struct componentname *,
+                struct vnode *, struct vnode *, struct componentname *));
+int     ufs_rmdir __P((struct vnode *, struct vnode *, struct componentname *));
 int     ufs_seek __P((struct vnode *, off_t, off_t, struct ucred *));
 int     ufs_select
            __P((struct vnode *, int, int, struct ucred *, struct proc *));
 int     ufs_seek __P((struct vnode *, off_t, off_t, struct ucred *));
 int     ufs_select
            __P((struct vnode *, int, int, struct ucred *, struct proc *));
@@ -85,7 +88,7 @@ int    ufs_setattr __P((struct vnode *,
 int     ufs_start __P((struct mount *, int, struct proc *));
 int     ufs_strategy __P((struct buf *));
 int     ufs_symlink
 int     ufs_start __P((struct mount *, int, struct proc *));
 int     ufs_strategy __P((struct buf *));
 int     ufs_symlink
-           __P((struct nameidata *, struct vattr *, char *, struct proc *));
+           __P((struct vnode *, struct vnode **, struct componentname *, struct vattr *, char *));
 int     ufs_unlock __P((struct vnode *));
 int     ufs_vinit __P((struct mount *,
            struct vnodeops *, struct vnodeops *, struct vnode **));
 int     ufs_unlock __P((struct vnode *));
 int     ufs_vinit __P((struct mount *,
            struct vnodeops *, struct vnodeops *, struct vnode **));
index 124a0ca..6bb1639 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_lookup.c        7.36 (Berkeley) %G%
+ *     @(#)ufs_lookup.c        7.37 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -33,7 +33,7 @@ int   dirchk = 0;
  * If the file system is not maintained in a strict tree hierarchy,
  * this can result in a deadlock situation (see comments in code below).
  *
  * If the file system is not maintained in a strict tree hierarchy,
  * this can result in a deadlock situation (see comments in code below).
  *
- * The flag argument is LOOKUP, CREATE, RENAME, or DELETE depending on
+ * The cnp->cn_nameiop argument is LOOKUP, CREATE, RENAME, or DELETE depending on
  * whether the name is to be looked up, created, renamed, or deleted.
  * When CREATE, RENAME, or DELETE is specified, information usable in
  * creating, renaming, or deleting a directory entry may be calculated.
  * whether the name is to be looked up, created, renamed, or deleted.
  * When CREATE, RENAME, or DELETE is specified, information usable in
  * creating, renaming, or deleting a directory entry may be calculated.
@@ -63,10 +63,10 @@ int dirchk = 0;
  * NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode unlocked.
  */
 int
  * NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode unlocked.
  */
 int
-ufs_lookup(vdp, ndp, p)
-       register struct vnode *vdp;
-       register struct nameidata *ndp;
-       struct proc *p;
+ufs_lookup(dvp, vpp, cnp)   /* converted to CN */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
 {
        register struct inode *dp;      /* the directory we are searching */
        struct buf *bp;                 /* a buffer of directory entries */
 {
        register struct inode *dp;      /* the directory we are searching */
        struct buf *bp;                 /* a buffer of directory entries */
@@ -84,26 +84,24 @@ ufs_lookup(vdp, ndp, p)
        struct vnode *tdp;              /* returned by VOP_VGET */
        off_t enduseful;                /* pointer past last used dir slot */
        u_long bmask;                   /* block offset mask */
        struct vnode *tdp;              /* returned by VOP_VGET */
        off_t enduseful;                /* pointer past last used dir slot */
        u_long bmask;                   /* block offset mask */
-       int flag;                       /* LOOKUP, CREATE, RENAME, or DELETE */
        int lockparent;                 /* 1 => lockparent flag is set */
        int wantparent;                 /* 1 => wantparent or lockparent flag */
        int error;
        int lockparent;                 /* 1 => lockparent flag is set */
        int wantparent;                 /* 1 => wantparent or lockparent flag */
        int error;
+       struct vnode *vdp = dvp;        /* saved for one special case */
 
        bp = NULL;
        slotoffset = -1;
 
        bp = NULL;
        slotoffset = -1;
-       ndp->ni_dvp = vdp;
-       ndp->ni_vp = NULL;
-       dp = VTOI(vdp);
-       lockparent = ndp->ni_nameiop & LOCKPARENT;
-       flag = ndp->ni_nameiop & OPMASK;
-       wantparent = ndp->ni_nameiop & (LOCKPARENT|WANTPARENT);
+       *vpp = NULL;
+       dp = VTOI(dvp);
+       lockparent = cnp->cn_flags & LOCKPARENT;
+       wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
 
        /*
         * Check accessiblity of directory.
         */
        if ((dp->i_mode&IFMT) != IFDIR)
                return (ENOTDIR);
 
        /*
         * Check accessiblity of directory.
         */
        if ((dp->i_mode&IFMT) != IFDIR)
                return (ENOTDIR);
-       if (error = ufs_access(vdp, VEXEC, ndp->ni_cred, p))
+       if (error = ufs_access(dvp, VEXEC, cnp->cn_cred, cnp->cn_proc))
                return (error);
 
        /*
                return (error);
 
        /*
@@ -113,13 +111,13 @@ ufs_lookup(vdp, ndp, p)
         * check the name cache to see if the directory/name pair
         * we are looking for is known already.
         */
         * check the name cache to see if the directory/name pair
         * we are looking for is known already.
         */
-       if (error = cache_lookup(ndp)) {
+       if (error = cache_lookup(dvp, vpp, cnp)) {
                int vpid;       /* capability number of vnode */
 
                if (error == ENOENT)
                        return (error);
 #ifdef PARANOID
                int vpid;       /* capability number of vnode */
 
                if (error == ENOENT)
                        return (error);
 #ifdef PARANOID
-               if (vdp == ndp->ni_rdir && ndp->ni_isdotdot)
+               if (dvp == ndp->ni_rdir && (cnp->cn_flags&ISDOTDOT))
                        panic("ufs_lookup: .. through root");
 #endif
                /*
                        panic("ufs_lookup: .. through root");
 #endif
                /*
@@ -127,21 +125,27 @@ ufs_lookup(vdp, ndp, p)
                 * See comment below starting `Step through' for
                 * an explaination of the locking protocol.
                 */
                 * See comment below starting `Step through' for
                 * an explaination of the locking protocol.
                 */
+               /*
+                * NEEDSWORK: The borrowing of variables
+                * here is quite confusing.  Usually, dvp/dp
+                * is the directory being searched.
+                * Here it's the target returned from the cache.
+                */
                pdp = dp;
                pdp = dp;
-               dp = VTOI(ndp->ni_vp);
-               vdp = ndp->ni_vp;
-               vpid = vdp->v_id;
-               if (pdp == dp) {
-                       VREF(vdp);
+               dp = VTOI(*vpp);
+               dvp = *vpp;
+               vpid = dvp->v_id;
+               if (pdp == dp) {   /* lookup on "." */
+                       VREF(dvp);
                        error = 0;
                        error = 0;
-               } else if (ndp->ni_isdotdot) {
+               } else if (cnp->cn_flags&ISDOTDOT) {
                        IUNLOCK(pdp);
                        IUNLOCK(pdp);
-                       error = vget(vdp);
-                       if (!error && lockparent && *ndp->ni_next == '\0')
+                       error = vget(dvp);
+                       if (!error && lockparent && (cnp->cn_flags&ISLASTCN))
                                ILOCK(pdp);
                } else {
                                ILOCK(pdp);
                } else {
-                       error = vget(vdp);
-                       if (!lockparent || error || *ndp->ni_next != '\0')
+                       error = vget(dvp);
+                       if (!lockparent || error || !(cnp->cn_flags&ISLASTCN))
                                IUNLOCK(pdp);
                }
                /*
                                IUNLOCK(pdp);
                }
                /*
@@ -149,16 +153,16 @@ ufs_lookup(vdp, ndp, p)
                 * while we were waiting for the lock.
                 */
                if (!error) {
                 * while we were waiting for the lock.
                 */
                if (!error) {
-                       if (vpid == vdp->v_id)
+                       if (vpid == dvp->v_id)
                                return (0);
                        ufs_iput(dp);
                                return (0);
                        ufs_iput(dp);
-                       if (lockparent && pdp != dp && *ndp->ni_next == '\0')
+                       if (lockparent && pdp != dp && (cnp->cn_flags&ISLASTCN))
                                IUNLOCK(pdp);
                }
                ILOCK(pdp);
                dp = pdp;
                                IUNLOCK(pdp);
                }
                ILOCK(pdp);
                dp = pdp;
-               vdp = ITOV(dp);
-               ndp->ni_vp = NULL;
+               dvp = ITOV(dp);
+               *vpp = NULL;
        }
 
        /*
        }
 
        /*
@@ -168,11 +172,11 @@ ufs_lookup(vdp, ndp, p)
         * case it doesn't already exist.
         */
        slotstatus = FOUND;
         * case it doesn't already exist.
         */
        slotstatus = FOUND;
-       if ((flag == CREATE || flag == RENAME) && *ndp->ni_next == 0) {
+       if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) && (cnp->cn_flags&ISLASTCN)) {
                slotstatus = NONE;
                slotfreespace = 0;
                slotneeded = ((sizeof (struct direct) - (MAXNAMLEN + 1)) +
                slotstatus = NONE;
                slotfreespace = 0;
                slotneeded = ((sizeof (struct direct) - (MAXNAMLEN + 1)) +
-                       ((ndp->ni_namelen + 1 + 3) &~ 3));
+                       ((cnp->cn_namelen + 1 + 3) &~ 3));
        }
 
        /*
        }
 
        /*
@@ -186,14 +190,14 @@ ufs_lookup(vdp, ndp, p)
         * profiling time and hence has been removed in the interest
         * of simplicity.
         */
         * profiling time and hence has been removed in the interest
         * of simplicity.
         */
-       bmask = VFSTOUFS(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
-       if (flag != LOOKUP || dp->i_diroff == 0 || dp->i_diroff > dp->i_size) {
-               ndp->ni_ufs.ufs_offset = 0;
+       bmask = VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
+       if (cnp->cn_nameiop != LOOKUP || dp->i_diroff == 0 || dp->i_diroff > dp->i_size) {
+               cnp->cn_ufs.ufs_offset = 0;
                numdirpasses = 1;
        } else {
                numdirpasses = 1;
        } else {
-               ndp->ni_ufs.ufs_offset = dp->i_diroff;
-               if ((entryoffsetinblock = ndp->ni_ufs.ufs_offset & bmask) &&
-                   (error = VOP_BLKATOFF(vdp, ndp->ni_ufs.ufs_offset, NULL,
+               cnp->cn_ufs.ufs_offset = dp->i_diroff;
+               if ((entryoffsetinblock = cnp->cn_ufs.ufs_offset & bmask) &&
+                   (error = VOP_BLKATOFF(dvp, cnp->cn_ufs.ufs_offset, NULL,
                     &bp)))
                        return (error);
                numdirpasses = 2;
                     &bp)))
                        return (error);
                numdirpasses = 2;
@@ -203,15 +207,15 @@ ufs_lookup(vdp, ndp, p)
        enduseful = 0;
 
 searchloop:
        enduseful = 0;
 
 searchloop:
-       while (ndp->ni_ufs.ufs_offset < endsearch) {
+       while (cnp->cn_ufs.ufs_offset < endsearch) {
                /*
                 * If offset is on a block boundary, read the next directory
                 * block.  Release previous if it exists.
                 */
                /*
                 * If offset is on a block boundary, read the next directory
                 * block.  Release previous if it exists.
                 */
-               if ((ndp->ni_ufs.ufs_offset & bmask) == 0) {
+               if ((cnp->cn_ufs.ufs_offset & bmask) == 0) {
                        if (bp != NULL)
                                brelse(bp);
                        if (bp != NULL)
                                brelse(bp);
-                       if (error = VOP_BLKATOFF(vdp, ndp->ni_ufs.ufs_offset,
+                       if (error = VOP_BLKATOFF(dvp, cnp->cn_ufs.ufs_offset,
                            NULL, &bp))
                                return (error);
                        entryoffsetinblock = 0;
                            NULL, &bp))
                                return (error);
                        entryoffsetinblock = 0;
@@ -237,9 +241,9 @@ searchloop:
                    dirchk && ufs_dirbadentry(ep, entryoffsetinblock)) {
                        int i;
 
                    dirchk && ufs_dirbadentry(ep, entryoffsetinblock)) {
                        int i;
 
-                       ufs_dirbad(dp, ndp->ni_ufs.ufs_offset, "mangled entry");
+                       ufs_dirbad(dp, cnp->cn_ufs.ufs_offset, "mangled entry");
                        i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1));
                        i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1));
-                       ndp->ni_ufs.ufs_offset += i;
+                       cnp->cn_ufs.ufs_offset += i;
                        entryoffsetinblock += i;
                        continue;
                }
                        entryoffsetinblock += i;
                        continue;
                }
@@ -258,17 +262,17 @@ searchloop:
                        if (size > 0) {
                                if (size >= slotneeded) {
                                        slotstatus = FOUND;
                        if (size > 0) {
                                if (size >= slotneeded) {
                                        slotstatus = FOUND;
-                                       slotoffset = ndp->ni_ufs.ufs_offset;
+                                       slotoffset = cnp->cn_ufs.ufs_offset;
                                        slotsize = ep->d_reclen;
                                } else if (slotstatus == NONE) {
                                        slotfreespace += size;
                                        if (slotoffset == -1)
                                                slotoffset =
                                        slotsize = ep->d_reclen;
                                } else if (slotstatus == NONE) {
                                        slotfreespace += size;
                                        if (slotoffset == -1)
                                                slotoffset =
-                                                     ndp->ni_ufs.ufs_offset;
+                                                     cnp->cn_ufs.ufs_offset;
                                        if (slotfreespace >= slotneeded) {
                                                slotstatus = COMPACT;
                                                slotsize =
                                        if (slotfreespace >= slotneeded) {
                                                slotstatus = COMPACT;
                                                slotsize =
-                                                     ndp->ni_ufs.ufs_offset +
+                                                     cnp->cn_ufs.ufs_offset +
                                                      ep->d_reclen - slotoffset;
                                        }
                                }
                                                      ep->d_reclen - slotoffset;
                                        }
                                }
@@ -279,25 +283,25 @@ searchloop:
                 * Check for a name match.
                 */
                if (ep->d_ino) {
                 * Check for a name match.
                 */
                if (ep->d_ino) {
-                       if (ep->d_namlen == ndp->ni_namelen &&
-                           !bcmp(ndp->ni_ptr, ep->d_name,
+                       if (ep->d_namlen == cnp->cn_namelen &&
+                           !bcmp(cnp->cn_nameptr, ep->d_name,
                                (unsigned)ep->d_namlen)) {
                                /*
                                 * Save directory entry's inode number and
                                 * reclen in ndp->ni_ufs area, and release
                                 * directory buffer.
                                 */
                                (unsigned)ep->d_namlen)) {
                                /*
                                 * Save directory entry's inode number and
                                 * reclen in ndp->ni_ufs area, and release
                                 * directory buffer.
                                 */
-                               ndp->ni_ufs.ufs_ino = ep->d_ino;
-                               ndp->ni_ufs.ufs_reclen = ep->d_reclen;
+                               cnp->cn_ufs.ufs_ino = ep->d_ino;
+                               cnp->cn_ufs.ufs_reclen = ep->d_reclen;
                                brelse(bp);
                                goto found;
                        }
                }
                                brelse(bp);
                                goto found;
                        }
                }
-               prevoff = ndp->ni_ufs.ufs_offset;
-               ndp->ni_ufs.ufs_offset += ep->d_reclen;
+               prevoff = cnp->cn_ufs.ufs_offset;
+               cnp->cn_ufs.ufs_offset += ep->d_reclen;
                entryoffsetinblock += ep->d_reclen;
                if (ep->d_ino)
                entryoffsetinblock += ep->d_reclen;
                if (ep->d_ino)
-                       enduseful = ndp->ni_ufs.ufs_offset;
+                       enduseful = cnp->cn_ufs.ufs_offset;
        }
 /* notfound: */
        /*
        }
 /* notfound: */
        /*
@@ -306,7 +310,7 @@ searchloop:
         */
        if (numdirpasses == 2) {
                numdirpasses--;
         */
        if (numdirpasses == 2) {
                numdirpasses--;
-               ndp->ni_ufs.ufs_offset = 0;
+               cnp->cn_ufs.ufs_offset = 0;
                endsearch = dp->i_diroff;
                goto searchloop;
        }
                endsearch = dp->i_diroff;
                goto searchloop;
        }
@@ -317,13 +321,13 @@ searchloop:
         * directory has not been removed, then can consider
         * allowing file to be created.
         */
         * directory has not been removed, then can consider
         * allowing file to be created.
         */
-       if ((flag == CREATE || flag == RENAME) &&
-           *ndp->ni_next == 0 && dp->i_nlink != 0) {
+       if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) &&
+           (cnp->cn_flags&ISLASTCN) && dp->i_nlink != 0) {
                /*
                 * Access for write is interpreted as allowing
                 * creation of files in the directory.
                 */
                /*
                 * Access for write is interpreted as allowing
                 * creation of files in the directory.
                 */
-               if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p))
+               if (error = ufs_access(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc))
                        return (error);
                /*
                 * Return an indication of where the new directory
                        return (error);
                /*
                 * Return an indication of where the new directory
@@ -335,16 +339,16 @@ searchloop:
                 * to ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count.
                 */
                if (slotstatus == NONE) {
                 * to ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count.
                 */
                if (slotstatus == NONE) {
-                       ndp->ni_ufs.ufs_offset = roundup(dp->i_size, DIRBLKSIZ);
-                       ndp->ni_ufs.ufs_count = 0;
-                       enduseful = ndp->ni_ufs.ufs_offset;
+                       cnp->cn_ufs.ufs_offset = roundup(dp->i_size, DIRBLKSIZ);
+                       cnp->cn_ufs.ufs_count = 0;
+                       enduseful = cnp->cn_ufs.ufs_offset;
                } else {
                } else {
-                       ndp->ni_ufs.ufs_offset = slotoffset;
-                       ndp->ni_ufs.ufs_count = slotsize;
+                       cnp->cn_ufs.ufs_offset = slotoffset;
+                       cnp->cn_ufs.ufs_count = slotsize;
                        if (enduseful < slotoffset + slotsize)
                                enduseful = slotoffset + slotsize;
                }
                        if (enduseful < slotoffset + slotsize)
                                enduseful = slotoffset + slotsize;
                }
-               ndp->ni_ufs.ufs_endoff = roundup(enduseful, DIRBLKSIZ);
+               cnp->cn_ufs.ufs_endoff = roundup(enduseful, DIRBLKSIZ);
                dp->i_flag |= IUPD|ICHG;
                /*
                 * We return with the directory locked, so that
                dp->i_flag |= IUPD|ICHG;
                /*
                 * We return with the directory locked, so that
@@ -359,15 +363,15 @@ searchloop:
                 * NB - if the directory is unlocked, then this
                 * information cannot be used.
                 */
                 * NB - if the directory is unlocked, then this
                 * information cannot be used.
                 */
-               ndp->ni_nameiop |= SAVENAME;
+               cnp->cn_flags |= SAVENAME;
                if (!lockparent)
                        IUNLOCK(dp);
        }
        /*
         * Insert name into cache (as non-existent) if appropriate.
         */
                if (!lockparent)
                        IUNLOCK(dp);
        }
        /*
         * Insert name into cache (as non-existent) if appropriate.
         */
-       if (ndp->ni_makeentry && flag != CREATE)
-               cache_enter(ndp);
+       if ((cnp->cn_flags&MAKEENTRY) && cnp->cn_nameiop != CREATE)
+               cache_enter(dvp, *vpp, cnp);
        return (ENOENT);
 
 found:
        return (ENOENT);
 
 found:
@@ -378,7 +382,7 @@ found:
         * of this entry.
         */
        if (entryoffsetinblock + DIRSIZ(ep) > dp->i_size) {
         * of this entry.
         */
        if (entryoffsetinblock + DIRSIZ(ep) > dp->i_size) {
-               ufs_dirbad(dp, ndp->ni_ufs.ufs_offset, "i_size too small");
+               ufs_dirbad(dp, cnp->cn_ufs.ufs_offset, "i_size too small");
                dp->i_size = entryoffsetinblock + DIRSIZ(ep);
                dp->i_flag |= IUPD|ICHG;
        }
                dp->i_size = entryoffsetinblock + DIRSIZ(ep);
                dp->i_flag |= IUPD|ICHG;
        }
@@ -388,8 +392,8 @@ found:
         * If the final component of path name, save information
         * in the cache as to where the entry was found.
         */
         * If the final component of path name, save information
         * in the cache as to where the entry was found.
         */
-       if (*ndp->ni_next == '\0' && flag == LOOKUP)
-               dp->i_diroff = ndp->ni_ufs.ufs_offset &~ (DIRBLKSIZ - 1);
+       if ((cnp->cn_flags&ISLASTCN) && cnp->cn_nameiop == LOOKUP)
+               dp->i_diroff = cnp->cn_ufs.ufs_offset &~ (DIRBLKSIZ - 1);
 
        /*
         * If deleting, and at end of pathname, return
 
        /*
         * If deleting, and at end of pathname, return
@@ -398,29 +402,29 @@ found:
         * the directory (in ndp->ni_dvp), otherwise we go
         * on and lock the inode, being careful with ".".
         */
         * the directory (in ndp->ni_dvp), otherwise we go
         * on and lock the inode, being careful with ".".
         */
-       if (flag == DELETE && *ndp->ni_next == 0) {
+       if (cnp->cn_nameiop == DELETE && (cnp->cn_flags&ISLASTCN)) {
                /*
                 * Write access to directory required to delete files.
                 */
                /*
                 * Write access to directory required to delete files.
                 */
-               if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p))
+               if (error = ufs_access(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc))
                        return (error);
                /*
                        return (error);
                /*
-                * Return pointer to current entry in ndp->ni_ufs.ufs_offset,
+                * Return pointer to current entry in cnp->cn_ufs.ufs_offset,
                 * and distance past previous entry (if there
                 * is a previous entry in this block) in ndp->ni_ufs.ufs_count.
                 * Save directory inode pointer in ndp->ni_dvp for dirremove().
                 */
                 * and distance past previous entry (if there
                 * is a previous entry in this block) in ndp->ni_ufs.ufs_count.
                 * Save directory inode pointer in ndp->ni_dvp for dirremove().
                 */
-               if ((ndp->ni_ufs.ufs_offset&(DIRBLKSIZ-1)) == 0)
-                       ndp->ni_ufs.ufs_count = 0;
+               if ((cnp->cn_ufs.ufs_offset&(DIRBLKSIZ-1)) == 0)
+                       cnp->cn_ufs.ufs_count = 0;
                else
                else
-                       ndp->ni_ufs.ufs_count =
-                           ndp->ni_ufs.ufs_offset - prevoff;
-               if (dp->i_number == ndp->ni_ufs.ufs_ino) {
-                       VREF(vdp);
-                       ndp->ni_vp = vdp;
+                       cnp->cn_ufs.ufs_count =
+                           cnp->cn_ufs.ufs_offset - prevoff;
+               if (dp->i_number == cnp->cn_ufs.ufs_ino) {
+                       VREF(vdp);   /* NEEDSWORK: is vdp necessary? */
+                       *vpp = vdp;
                        return (0);
                }
                        return (0);
                }
-               if (error = VOP_VGET(vdp, ndp->ni_ufs.ufs_ino, &tdp))
+               if (error = VOP_VGET(dvp, cnp->cn_ufs.ufs_ino, &tdp))
                        return (error);
                /*
                 * If directory is "sticky", then user must own
                        return (error);
                /*
                 * If directory is "sticky", then user must own
@@ -429,13 +433,13 @@ found:
                 * implements append-only directories.
                 */
                if ((dp->i_mode & ISVTX) &&
                 * implements append-only directories.
                 */
                if ((dp->i_mode & ISVTX) &&
-                   ndp->ni_cred->cr_uid != 0 &&
-                   ndp->ni_cred->cr_uid != dp->i_uid &&
-                   VTOI(tdp)->i_uid != ndp->ni_cred->cr_uid) {
+                   cnp->cn_cred->cr_uid != 0 &&
+                   cnp->cn_cred->cr_uid != dp->i_uid &&
+                   VTOI(tdp)->i_uid != cnp->cn_cred->cr_uid) {
                        vput(tdp);
                        return (EPERM);
                }
                        vput(tdp);
                        return (EPERM);
                }
-               ndp->ni_vp = tdp;
+               *vpp = tdp;
                if (!lockparent)
                        IUNLOCK(dp);
                return (0);
                if (!lockparent)
                        IUNLOCK(dp);
                return (0);
@@ -447,19 +451,19 @@ found:
         * Must get inode of directory entry to verify it's a
         * regular file, or empty directory.
         */
         * Must get inode of directory entry to verify it's a
         * regular file, or empty directory.
         */
-       if (flag == RENAME && wantparent && *ndp->ni_next == 0) {
-               if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p))
+       if (cnp->cn_nameiop == RENAME && wantparent && (cnp->cn_flags&ISLASTCN)) {
+               if (error = ufs_access(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc))
                        return (error);
                /*
                 * Careful about locking second inode.
                 * This can only occur if the target is ".".
                 */
                        return (error);
                /*
                 * Careful about locking second inode.
                 * This can only occur if the target is ".".
                 */
-               if (dp->i_number == ndp->ni_ufs.ufs_ino)
+               if (dp->i_number == cnp->cn_ufs.ufs_ino)
                        return (EISDIR);
                        return (EISDIR);
-               if (error = VOP_VGET(vdp, ndp->ni_ufs.ufs_ino, &tdp))
+               if (error = VOP_VGET(dvp, cnp->cn_ufs.ufs_ino, &tdp))
                        return (error);
                        return (error);
-               ndp->ni_vp = tdp;
-               ndp->ni_nameiop |= SAVENAME;
+               *vpp = tdp;
+               cnp->cn_flags |= SAVENAME;
                if (!lockparent)
                        IUNLOCK(dp);
                return (0);
                if (!lockparent)
                        IUNLOCK(dp);
                return (0);
@@ -485,31 +489,31 @@ found:
         * that point backwards in the directory structure.
         */
        pdp = dp;
         * that point backwards in the directory structure.
         */
        pdp = dp;
-       if (ndp->ni_isdotdot) {
+       if (cnp->cn_flags&ISDOTDOT) {
                IUNLOCK(pdp);   /* race to get the inode */
                IUNLOCK(pdp);   /* race to get the inode */
-               if (error = VOP_VGET(vdp, ndp->ni_ufs.ufs_ino, &tdp)) {
+               if (error = VOP_VGET(dvp, cnp->cn_ufs.ufs_ino, &tdp)) {
                        ILOCK(pdp);
                        return (error);
                }
                        ILOCK(pdp);
                        return (error);
                }
-               if (lockparent && *ndp->ni_next == '\0')
+               if (lockparent && (cnp->cn_flags&ISLASTCN))
                        ILOCK(pdp);
                        ILOCK(pdp);
-               ndp->ni_vp = tdp;
-       } else if (dp->i_number == ndp->ni_ufs.ufs_ino) {
-               VREF(vdp);      /* we want ourself, ie "." */
-               ndp->ni_vp = vdp;
+               *vpp = tdp;
+       } else if (dp->i_number == cnp->cn_ufs.ufs_ino) {
+               VREF(dvp);      /* we want ourself, ie "." */
+               *vpp = dvp;
        } else {
        } else {
-               if (error = VOP_VGET(vdp, ndp->ni_ufs.ufs_ino, &tdp))
+               if (error = VOP_VGET(dvp, cnp->cn_ufs.ufs_ino, &tdp))
                        return (error);
                        return (error);
-               if (!lockparent || *ndp->ni_next != '\0')
+               if (!lockparent || !(cnp->cn_flags&ISLASTCN))
                        IUNLOCK(pdp);
                        IUNLOCK(pdp);
-               ndp->ni_vp = tdp;
+               *vpp = tdp;
        }
 
        /*
         * Insert name into cache if appropriate.
         */
        }
 
        /*
         * Insert name into cache if appropriate.
         */
-       if (ndp->ni_makeentry)
-               cache_enter(ndp);
+       if (cnp->cn_flags & MAKEENTRY)
+               cache_enter(dvp, *vpp, cnp);
        return (0);
 }
 
        return (0);
 }
 
@@ -574,13 +578,14 @@ printf("ufs_dirbadentry: jumping out: reclen: %d namlen %d ino %d name %s\n",
  * indicate how the space for the new entry is to be obtained.
  */
 int
  * indicate how the space for the new entry is to be obtained.
  */
 int
-ufs_direnter(ip, ndp)
+ufs_direnter(ip, dvp, cnp)   /* converted to CN.  */
+/* old: ufs_direnter(ip, ndp) */
        struct inode *ip;
        struct inode *ip;
-       register struct nameidata *ndp;
+       struct vnode *dvp;
+       register struct componentname *cnp;
 {
        register struct direct *ep, *nep;
        register struct inode *dp;
 {
        register struct direct *ep, *nep;
        register struct inode *dp;
-       register struct vnode *dvp;
        struct buf *bp;
        struct direct newdir;
        struct iovec aiov;
        struct buf *bp;
        struct direct newdir;
        struct iovec aiov;
@@ -590,25 +595,24 @@ ufs_direnter(ip, ndp)
        char *dirbuf;
 
 #ifdef DIAGNOSTIC
        char *dirbuf;
 
 #ifdef DIAGNOSTIC
-       if ((ndp->ni_nameiop & SAVENAME) == 0)
+       if ((cnp->cn_flags & SAVENAME) == 0)
                panic("direnter: missing name");
 #endif
                panic("direnter: missing name");
 #endif
-       dvp = ndp->ni_dvp;
        dp = VTOI(dvp);
        newdir.d_ino = ip->i_number;
        dp = VTOI(dvp);
        newdir.d_ino = ip->i_number;
-       newdir.d_namlen = ndp->ni_namelen;
-       bcopy(ndp->ni_ptr, newdir.d_name, (unsigned)ndp->ni_namelen + 1);
+       newdir.d_namlen = cnp->cn_namelen;
+       bcopy(cnp->cn_nameptr, newdir.d_name, (unsigned)cnp->cn_namelen + 1);
        newentrysize = DIRSIZ(&newdir);
        newentrysize = DIRSIZ(&newdir);
-       if (ndp->ni_ufs.ufs_count == 0) {
+       if (cnp->cn_ufs.ufs_count == 0) {
                /*
                /*
-                * If ndp->ni_ufs.ufs_count is 0, then namei could find no
+                * If cnp->cn_ufs.ufs_count is 0, then namei could find no
                 * space in the directory. Here, ndp->ni_ufs.ufs_offset will
                 * be on a directory block boundary and we will write the
                 * new entry into a fresh block.
                 */
                 * space in the directory. Here, ndp->ni_ufs.ufs_offset will
                 * be on a directory block boundary and we will write the
                 * new entry into a fresh block.
                 */
-               if (ndp->ni_ufs.ufs_offset & (DIRBLKSIZ - 1))
+               if (cnp->cn_ufs.ufs_offset & (DIRBLKSIZ - 1))
                        panic("wdir: newblk");
                        panic("wdir: newblk");
-               auio.uio_offset = ndp->ni_ufs.ufs_offset;
+               auio.uio_offset = cnp->cn_ufs.ufs_offset;
                newdir.d_reclen = DIRBLKSIZ;
                auio.uio_resid = newentrysize;
                aiov.iov_len = newentrysize;
                newdir.d_reclen = DIRBLKSIZ;
                auio.uio_resid = newentrysize;
                aiov.iov_len = newentrysize;
@@ -618,7 +622,7 @@ ufs_direnter(ip, ndp)
                auio.uio_rw = UIO_WRITE;
                auio.uio_segflg = UIO_SYSSPACE;
                auio.uio_procp = (struct proc *)0;
                auio.uio_rw = UIO_WRITE;
                auio.uio_segflg = UIO_SYSSPACE;
                auio.uio_procp = (struct proc *)0;
-               error = VOP_WRITE(dvp, &auio, IO_SYNC, ndp->ni_cred);
+               error = VOP_WRITE(dvp, &auio, IO_SYNC, cnp->cn_cred);
                if (DIRBLKSIZ >
                    VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize)
                        /* XXX should grow with balloc() */
                if (DIRBLKSIZ >
                    VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize)
                        /* XXX should grow with balloc() */
@@ -631,9 +635,9 @@ ufs_direnter(ip, ndp)
        }
 
        /*
        }
 
        /*
-        * If ndp->ni_ufs.ufs_count is non-zero, then namei found space
-        * for the new entry in the range ndp->ni_ufs.ufs_offset to
-        * ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count in the directory.
+        * If cnp->cn_ufs.ufs_count is non-zero, then namei found space
+        * for the new entry in the range cnp->cn_ufs.ufs_offset to
+        * cnp->cn_ufs.ufs_offset + cnp->cn_ufs.ufs_count in the directory.
         * To use this space, we may have to compact the entries located
         * there, by copying them together towards the beginning of the
         * block, leaving the free space in one usable chunk at the end.
         * To use this space, we may have to compact the entries located
         * there, by copying them together towards the beginning of the
         * block, leaving the free space in one usable chunk at the end.
@@ -646,24 +650,24 @@ ufs_direnter(ip, ndp)
         *
         * N.B. - THIS IS AN ARTIFACT OF 4.2 AND SHOULD NEVER HAPPEN.
         */
         *
         * N.B. - THIS IS AN ARTIFACT OF 4.2 AND SHOULD NEVER HAPPEN.
         */
-       if (ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count > dp->i_size)
-               dp->i_size = ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count;
+       if (cnp->cn_ufs.ufs_offset + cnp->cn_ufs.ufs_count > dp->i_size)
+               dp->i_size = cnp->cn_ufs.ufs_offset + cnp->cn_ufs.ufs_count;
        /*
         * Get the block containing the space for the new directory entry.
         */
        /*
         * Get the block containing the space for the new directory entry.
         */
-       if (error = VOP_BLKATOFF(dvp, ndp->ni_ufs.ufs_offset, &dirbuf, &bp))
+       if (error = VOP_BLKATOFF(dvp, cnp->cn_ufs.ufs_offset, &dirbuf, &bp))
                return (error);
        /*
         * Find space for the new entry. In the simple case, the entry at
         * offset base will have the space. If it does not, then namei
                return (error);
        /*
         * Find space for the new entry. In the simple case, the entry at
         * offset base will have the space. If it does not, then namei
-        * arranged that compacting the region ndp->ni_ufs.ufs_offset to
-        * ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count would yield the
+        * arranged that compacting the region cnp->cn_ufs.ufs_offset to
+        * cnp->cn_ufs.ufs_offset + cnp->cn_ufs.ufs_count would yield the
         * space.
         */
        ep = (struct direct *)dirbuf;
        dsize = DIRSIZ(ep);
        spacefree = ep->d_reclen - dsize;
         * space.
         */
        ep = (struct direct *)dirbuf;
        dsize = DIRSIZ(ep);
        spacefree = ep->d_reclen - dsize;
-       for (loc = ep->d_reclen; loc < ndp->ni_ufs.ufs_count; ) {
+       for (loc = ep->d_reclen; loc < cnp->cn_ufs.ufs_count; ) {
                nep = (struct direct *)(dirbuf + loc);
                if (ep->d_ino) {
                        /* trim the existing slot */
                nep = (struct direct *)(dirbuf + loc);
                if (ep->d_ino) {
                        /* trim the existing slot */
@@ -696,9 +700,9 @@ ufs_direnter(ip, ndp)
        bcopy((caddr_t)&newdir, (caddr_t)ep, (u_int)newentrysize);
        error = VOP_BWRITE(bp);
        dp->i_flag |= IUPD|ICHG;
        bcopy((caddr_t)&newdir, (caddr_t)ep, (u_int)newentrysize);
        error = VOP_BWRITE(bp);
        dp->i_flag |= IUPD|ICHG;
-       if (!error && ndp->ni_ufs.ufs_endoff &&
-           ndp->ni_ufs.ufs_endoff < dp->i_size)
-               error = VOP_TRUNCATE(dvp, (u_long)ndp->ni_ufs.ufs_endoff,
+       if (!error && cnp->cn_ufs.ufs_endoff &&
+           cnp->cn_ufs.ufs_endoff < dp->i_size)
+               error = VOP_TRUNCATE(dvp, (u_long)cnp->cn_ufs.ufs_endoff,
                    IO_SYNC);
        return (error);
 }
                    IO_SYNC);
        return (error);
 }
@@ -716,20 +720,22 @@ ufs_direnter(ip, ndp)
  * to the size of the previous entry.
  */
 int
  * to the size of the previous entry.
  */
 int
-ufs_dirremove(ndp)
-       register struct nameidata *ndp;
+ufs_dirremove(dvp, cnp)   /* converted to CN.  */
+       struct vnode *dvp;
+       struct componentname *cnp;
+/* old: ufs_dirremove(ndp) */
 {
        register struct inode *dp;
        struct direct *ep;
        struct buf *bp;
        int error;
 
 {
        register struct inode *dp;
        struct direct *ep;
        struct buf *bp;
        int error;
 
-       dp = VTOI(ndp->ni_dvp);
-       if (ndp->ni_ufs.ufs_count == 0) {
+       dp = VTOI(dvp);
+       if (cnp->cn_ufs.ufs_count == 0) {
                /*
                 * First entry in block: set d_ino to zero.
                 */
                /*
                 * First entry in block: set d_ino to zero.
                 */
-               if (error = VOP_BLKATOFF(ndp->ni_dvp, ndp->ni_ufs.ufs_offset,
+               if (error = VOP_BLKATOFF(dvp, cnp->cn_ufs.ufs_offset,
                    (char **)&ep, &bp))
                        return (error);
                ep->d_ino = 0;
                    (char **)&ep, &bp))
                        return (error);
                ep->d_ino = 0;
@@ -740,10 +746,10 @@ ufs_dirremove(ndp)
        /*
         * Collapse new free space into previous entry.
         */
        /*
         * Collapse new free space into previous entry.
         */
-       if (error = VOP_BLKATOFF(ndp->ni_dvp,
-           ndp->ni_ufs.ufs_offset - ndp->ni_ufs.ufs_count, (char **)&ep, &bp))
+       if (error = VOP_BLKATOFF(dvp,
+           cnp->cn_ufs.ufs_offset - cnp->cn_ufs.ufs_count, (char **)&ep, &bp))
                return (error);
                return (error);
-       ep->d_reclen += ndp->ni_ufs.ufs_reclen;
+       ep->d_reclen += cnp->cn_ufs.ufs_reclen;
        error = VOP_BWRITE(bp);
        dp->i_flag |= IUPD|ICHG;
        return (error);
        error = VOP_BWRITE(bp);
        dp->i_flag |= IUPD|ICHG;
        return (error);
@@ -755,15 +761,16 @@ ufs_dirremove(ndp)
  * set up by a call to namei.
  */
 int
  * set up by a call to namei.
  */
 int
-ufs_dirrewrite(dp, ip, ndp)
+ufs_dirrewrite(dp, ip, cnp)
+/* old: ufs_dirrewrite(dp, ip, ndp) */
        struct inode *dp, *ip;
        struct inode *dp, *ip;
-       struct nameidata *ndp;
+       struct componentname *cnp;
 {
        struct buf *bp;
        struct direct *ep;
        int error;
 
 {
        struct buf *bp;
        struct direct *ep;
        int error;
 
-       if (error = VOP_BLKATOFF(ITOV(dp), ndp->ni_ufs.ufs_offset,
+       if (error = VOP_BLKATOFF(ITOV(dp), cnp->cn_ufs.ufs_offset,
            (char **)&ep, &bp))
                return (error);
        ep->d_ino = ip->i_number;
            (char **)&ep, &bp))
                return (error);
        ep->d_ino = ip->i_number;
index 7ba9d4e..f7f51d5 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_vnops.c 7.71 (Berkeley) %G%
+ *     @(#)ufs_vnops.c 7.72 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -67,18 +67,18 @@ union _qcvt {
  * Create a regular file
  */
 int
  * Create a regular file
  */
 int
-ufs_create(ndp, vap, p)
-       struct nameidata *ndp;
+ufs_create(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* was: ufs_create(ndp, vap, p) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        struct vattr *vap;
-       struct proc *p;
 {
 {
-       struct vnode *vp;
        int error;
 
        if (error =
        int error;
 
        if (error =
-           ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), ndp, &vp))
+           ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), dvp, vpp, cnp))
                return (error);
                return (error);
-       ndp->ni_vp = vp;
        return (0);
 }
 
        return (0);
 }
 
@@ -87,20 +87,20 @@ ufs_create(ndp, vap, p)
  */
 /* ARGSUSED */
 int
  */
 /* ARGSUSED */
 int
-ufs_mknod(ndp, vap, cred, p)
-       struct nameidata *ndp;
+ufs_mknod(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* was: ufs_mknod(ndp, vap, cred, p) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        struct vattr *vap;
-       struct ucred *cred;
-       struct proc *p;
 {
        register struct inode *ip;
 {
        register struct inode *ip;
-       struct vnode *vp;
        int error;
 
        if (error =
        int error;
 
        if (error =
-           ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), ndp, &vp))
+           ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode), dvp, vpp, cnp))
                return (error);
                return (error);
-       ip = VTOI(vp);
+       ip = VTOI(*vpp);
        ip->i_flag |= IACC|IUPD|ICHG;
        if (vap->va_rdev != VNOVAL) {
                /*
        ip->i_flag |= IACC|IUPD|ICHG;
        if (vap->va_rdev != VNOVAL) {
                /*
@@ -114,9 +114,10 @@ ufs_mknod(ndp, vap, cred, p)
         * checked to see if it is an alias of an existing entry
         * in the inode cache.
         */
         * checked to see if it is an alias of an existing entry
         * in the inode cache.
         */
-       vput(vp);
-       vp->v_type = VNON;
-       vgone(vp);
+       vput(*vpp);
+       (*vpp)->v_type = VNON;
+       vgone(*vpp);
+       *vpp = 0;
        return (0);
 }
 
        return (0);
 }
 
@@ -537,16 +538,17 @@ ufs_seek(vp, oldoff, newoff, cred)
  * in unlinking directories.
  */
 int
  * in unlinking directories.
  */
 int
-ufs_remove(ndp, p)
-       struct nameidata *ndp;
-       struct proc *p;
+ufs_remove(dvp, vp, cnp)   /* converted to CN.   */
+/* old: ufs_remove(ndp, p) */
+       struct vnode *dvp, *vp;
+       struct componentname *cnp;
 {
        register struct inode *ip, *dp;
        int error;
 
 {
        register struct inode *ip, *dp;
        int error;
 
-       ip = VTOI(ndp->ni_vp);
-       dp = VTOI(ndp->ni_dvp);
-       error = ufs_dirremove(ndp);
+       ip = VTOI(vp);
+       dp = VTOI(dvp);
+       error = ufs_dirremove(dvp, cnp);
        if (!error) {
                ip->i_nlink--;
                ip->i_flag |= ICHG;
        if (!error) {
                ip->i_nlink--;
                ip->i_flag |= ICHG;
@@ -563,34 +565,35 @@ ufs_remove(ndp, p)
  * link vnode call
  */
 int
  * link vnode call
  */
 int
-ufs_link(vp, ndp, p)
-       register struct vnode *vp;
-       register struct nameidata *ndp;
-       struct proc *p;
+ufs_link(vp, tdvp, cnp)   /* converted to CN.   */
+/* old: ufs_link(vp, ndp, p) */
+       register struct vnode *vp;   /* source vnode */
+       struct vnode *tdvp;
+       struct componentname *cnp;
 {
        register struct inode *ip;
        int error;
 
 #ifdef DIANOSTIC
 {
        register struct inode *ip;
        int error;
 
 #ifdef DIANOSTIC
-       if ((ndp->ni_nameiop & HASBUF) == 0)
+       if ((cnp->cn_flags & HASBUF) == 0)
                panic("ufs_link: no name");
 #endif
        ip = VTOI(vp);
        if ((unsigned short)ip->i_nlink >= LINK_MAX) {
                panic("ufs_link: no name");
 #endif
        ip = VTOI(vp);
        if ((unsigned short)ip->i_nlink >= LINK_MAX) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+               free(cnp->cn_pnbuf, M_NAMEI);
                return (EMLINK);
        }
                return (EMLINK);
        }
-       if (ndp->ni_dvp != vp)
+       if (tdvp != vp)
                ILOCK(ip);
        ip->i_nlink++;
        ip->i_flag |= ICHG;
        error = VOP_UPDATE(vp, &time, &time, 1);
        if (!error)
                ILOCK(ip);
        ip->i_nlink++;
        ip->i_flag |= ICHG;
        error = VOP_UPDATE(vp, &time, &time, 1);
        if (!error)
-               error = ufs_direnter(ip, ndp);
-       if (ndp->ni_dvp != vp)
+               error = ufs_direnter(ip, tdvp, cnp);
+       if (tdvp != vp)
                IUNLOCK(ip);
                IUNLOCK(ip);
-       FREE(ndp->ni_pnbuf, M_NAMEI);
-       vput(ndp->ni_dvp);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
+       vput(tdvp);
        if (error) {
                ip->i_nlink--;
                ip->i_flag |= ICHG;
        if (error) {
                ip->i_nlink--;
                ip->i_flag |= ICHG;
@@ -598,6 +601,288 @@ ufs_link(vp, ndp, p)
        return (error);
 }
 
        return (error);
 }
 
+
+
+/*
+ * relookup - lookup a path name component
+ *    Used by lookup to re-aquire things.
+ */
+int
+relookup(dvp, vpp, cnp)   /* converted to CN */
+       struct vnode *dvp, **vpp;
+       struct componentname *cnp;
+{
+       register char *cp;              /* pointer into pathname argument */
+       register struct vnode *dp = 0;  /* the directory we are searching */
+       struct vnode *tdp;              /* saved dp */
+       struct mount *mp;               /* mount table entry */
+       int docache;                    /* == 0 do not cache last component */
+       int wantparent;                 /* 1 => wantparent or lockparent flag */
+       int rdonly;                     /* lookup read-only flag bit */
+       int error = 0;
+       int newhash;
+
+       /*
+        * Setup: break out flag bits into variables.
+        */
+       wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
+       docache = (cnp->cn_flags & NOCACHE) ^ NOCACHE;
+       if (cnp->cn_nameiop == DELETE || (wantparent && cnp->cn_nameiop != CREATE))
+               docache = 0;
+       rdonly = cnp->cn_flags & RDONLY;
+       cnp->cn_flags &= ~ISSYMLINK;
+       dp = dvp;
+       VOP_LOCK(dp);
+
+/* dirloop: */
+       /*
+        * Search a new directory.
+        *
+        * The cn_hash value is for use by vfs_cache.
+        * The last component of the filename is left accessible via
+        * cnp->cn_nameptr for callers that need the name. Callers needing
+        * the name set the SAVENAME flag. When done, they assume
+        * responsibility for freeing the pathname buffer.
+        */
+/* NEEDWORK: is hash computed needed */
+       newhash = 0;
+       for (cp = cnp->cn_nameptr; *cp != 0 && *cp != '/'; cp++)
+               newhash += (unsigned char)*cp;
+       if (newhash != cnp->cn_hash)
+               panic("relookup: bad hash");
+       if (cnp->cn_namelen != cp - cnp->cn_nameptr)
+               panic ("relookup: bad len");
+       if (cnp->cn_namelen >= NAME_MAX) {
+               error = ENAMETOOLONG;
+               goto bad;
+       }
+#ifdef NAMEI_DIAGNOSTIC   /* NEEDSWORK: should go */
+       { char c = *cp;
+       *cp = '\0';
+       printf("{%s}: ", cnp->cn_nameptr);
+       *cp = c; }
+#endif
+#if 0
+       cnp->cn_pathlen -= cnp->cn_namelen;
+       ndp->ni_next = cp;
+#endif
+#if 0
+       cnp->cn_flags |= MAKEENTRY;
+       if (*cp == '\0' && docache == 0)
+               cnp->cn_flags &= ~MAKEENTRY;
+       if (cnp->cn_namelen == 2 &&
+                       cnp->ni_nameptr[1] == '.' && cnp->cn_nameptr[0] == '.')
+               cnp->cn_flags |= ISDOTDOT;
+       else cnp->cn_flags &= ~ISDOTDOT;
+#endif
+
+       /*
+        * Check for degenerate name (e.g. / or "")
+        * which is a way of talking about a directory,
+        * e.g. like "/." or ".".
+        */
+       if (cnp->cn_nameptr[0] == '\0') {
+               if (cnp->cn_nameiop != LOOKUP || wantparent) {
+                       error = EISDIR;
+                       goto bad;
+               }
+               if (dp->v_type != VDIR) {
+                       error = ENOTDIR;
+                       goto bad;
+               }
+               if (!(cnp->cn_flags & LOCKLEAF))
+                       VOP_UNLOCK(dp);
+               *vpp = dp;
+               if (cnp->cn_flags & SAVESTART)
+                       panic("lookup: SAVESTART");
+               return (0);
+       }
+
+       /*
+        * Handle "..": two special cases.
+        * 1. If at root directory (e.g. after chroot)
+        *    then ignore it so can't get out.
+        * 2. If this vnode is the root of a mounted
+        *    filesystem, then replace it with the
+        *    vnode which was mounted on so we take the
+        *    .. in the other file system.
+        */
+#if 0
+       /* This shouldn't happen because rename throws out .. */
+       /* NEEDSWORK: what to do about this? */
+       if (cnp->cn_flags & ISDOTDOT) {
+               for (;;) {
+                       if (dp == ndp->ni_rootdir) {
+                               ndp->ni_dvp = dp;
+                               ndp->ni_vp = dp;
+                               VREF(dp);
+                               goto nextname;
+                       }
+                       if ((dp->v_flag & VROOT) == 0 ||
+                           (cnp->cn_flags & NOCROSSMOUNT))
+                               break;
+                       tdp = dp;
+                       dp = dp->v_mount->mnt_vnodecovered;
+                       vput(tdp);
+                       VREF(dp);
+                       VOP_LOCK(dp);
+               }
+       }
+#endif
+       if (cnp->cn_flags & ISDOTDOT)
+               panic ("relookup: lookup on dot-dot");
+
+       /*
+        * We now have a segment name to search for, and a directory to search.
+        */
+       if (error = VOP_LOOKUP(dp, vpp, cnp)) {
+#ifdef DIAGNOSTIC
+               if (*vpp != NULL)
+                       panic("leaf should be empty");
+#endif
+#ifdef NAMEI_DIAGNOSTIC
+               printf("not found\n");
+#endif
+               if (cnp->cn_nameiop == LOOKUP || cnp->cn_nameiop == DELETE ||
+                   error != ENOENT || *cp != 0)
+                       goto bad;
+               /*
+                * If creating and at end of pathname, then can consider
+                * allowing file to be created.
+                */
+               if (rdonly || (dvp->v_mount->mnt_flag & MNT_RDONLY)) {
+                       error = EROFS;
+                       goto bad;
+               }
+               /*
+                * We return with ni_vp NULL to indicate that the entry
+                * doesn't currently exist, leaving a pointer to the
+                * (possibly locked) directory inode in ndp->ni_dvp.
+                */
+#ifdef JOHNH
+               /*
+                * no need because we don't need to do another lookup.
+                * NEEDSWORK: don't do release.
+                * but wait...let's try it a different way.
+                */
+               if (cnp->cn_flags & SAVESTART) {
+#if 0
+                       ndp->ni_startdir = ndp->ni_dvp;
+                       VREF(ndp->ni_startdir);
+#else
+                       /*
+                        * startdir == dvp, always
+                        */
+                       VREF(dvp);
+#endif
+               }
+#endif
+               return (0);
+       }
+#ifdef NAMEI_DIAGNOSTIC
+       printf("found\n");
+#endif
+
+       dp = *vpp;
+       /*
+        * Check for symbolic link
+        */
+#if 0
+       if ((dp->v_type == VLNK) &&
+           ((cnp->cn_flags & FOLLOW) || *ndp->ni_next == '/')) {
+               cnp->cn_flags |= ISSYMLINK;
+               return (0);
+       }
+#endif
+       if (dp->v_type == VLNK) {
+               panic ("relookup: symlink found.\n");
+       };
+
+       /*
+        * Check to see if the vnode has been mounted on;
+        * if so find the root of the mounted file system.
+        */
+#if 0
+       /* NEEDSWORK: mounts should not be crossed in cnlookup */
+       /*
+        * Checked for in rename (returns EXDEV).
+        */
+mntloop:
+       while (dp->v_type == VDIR && (mp = dp->v_mountedhere) &&
+              (cnp->cn_flags & NOCROSSMOUNT) == 0) {
+               if (mp->mnt_flag & MNT_MLOCK) {
+                       mp->mnt_flag |= MNT_MWAIT;
+                       sleep((caddr_t)mp, PVFS);
+                       goto mntloop;
+               }
+               if (error = VFS_ROOT(dp->v_mountedhere, &tdp))
+                       goto bad2;
+               vput(dp);
+               ndp->ni_vp = dp = tdp;
+       }
+#endif
+       if (dp->v_type == VDIR && (dp->v_mountedhere))
+           panic ("relookup: mount point encountered.");
+
+
+nextname:
+       /*
+        * Not a symbolic link.  If more pathname,
+        * continue at next component, else return.
+        */
+#if 0  
+       if (*ndp->ni_next == '/') {
+               cnp->cn_nameptr = ndp->ni_next;
+               while (*cnp->cn_nameptr == '/') {
+                       ndp->ni_nameptr++;
+                       ndp->ni_pathlen--;
+               }
+               vrele(ndp->ni_dvp);
+               goto dirloop;
+       }
+#endif
+
+       /*
+        * Check for read-only file systems.
+        */
+       if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) {
+               /*
+                * Disallow directory write attempts on read-only
+                * file systems.
+                */
+               if (rdonly || (dp->v_mount->mnt_flag & MNT_RDONLY) ||
+                   (wantparent &&
+                    (dvp->v_mount->mnt_flag & MNT_RDONLY))) {
+                       error = EROFS;
+                       goto bad2;
+               }
+       }
+       if (cnp->cn_flags & SAVESTART) {
+#if 0
+               ndp->ni_startdir = ndp->ni_dvp;
+               VREF(ndp->ni_startdir);
+#endif
+               /* ASSERT(dvp==ndp->ni_startdir) */
+               VREF(dvp);
+       }
+       
+       if (!wantparent)
+               vrele(dvp);
+       if ((cnp->cn_flags & LOCKLEAF) == 0)
+               VOP_UNLOCK(dp);
+       return (0);
+
+bad2:
+       if ((cnp->cn_flags & LOCKPARENT) && (cnp->cn_flags & ISLASTCN))
+               VOP_UNLOCK(dvp);
+       vrele(dvp);
+bad:
+       vput(dp);
+       *vpp = NULL;
+       return (error);
+}
+
+
 /*
  * Rename system call.
  *     rename("foo", "bar");
 /*
  * Rename system call.
  *     rename("foo", "bar");
@@ -623,33 +908,38 @@ ufs_link(vp, ndp, p)
  *    directory.
  */
 int
  *    directory.
  */
 int
-ufs_rename(fndp, tndp, p)
-       register struct nameidata *fndp, *tndp;
-       struct proc *p;
+ufs_rename(fdvp, fvp, fcnp,
+          tdvp, tvp, tcnp)   /* converted to CN.   */
+/* old: ufs_rename(fndp, tndp, p) */
+       struct vnode *fdvp, *fvp;
+       struct componentname *fcnp;
+       struct vnode *tdvp, *tvp;
+       struct componentname *tcnp;
 {
        register struct inode *ip, *xp, *dp;
        struct dirtemplate dirbuf;
        int doingdirectory = 0, oldparent = 0, newparent = 0;
        int error = 0;
 {
        register struct inode *ip, *xp, *dp;
        struct dirtemplate dirbuf;
        int doingdirectory = 0, oldparent = 0, newparent = 0;
        int error = 0;
+       int fdvpneedsrele = 1, tdvpneedsrele = 1;
 
 #ifdef DIANOSTIC
 
 #ifdef DIANOSTIC
-       if ((tndp->ni_nameiop & HASBUF) == 0 ||
-           (fndp->ni_nameiop & HASBUF) == 0)
+       if ((tcnp->cn_flags & HASBUF) == 0 ||
+           (fcnp->cn_flags & HASBUF) == 0)
                panic("ufs_rename: no name");
 #endif
                panic("ufs_rename: no name");
 #endif
-       dp = VTOI(fndp->ni_dvp);
-       ip = VTOI(fndp->ni_vp);
+       dp = VTOI(fdvp);
+       ip = VTOI(fvp);
        /*
         * Check if just deleting a link name.
         */
        /*
         * Check if just deleting a link name.
         */
-       if (fndp->ni_vp == tndp->ni_vp) {
-               VOP_ABORTOP(tndp);
-               vput(tndp->ni_dvp);
-               vput(tndp->ni_vp);
-               vrele(fndp->ni_dvp);
+       if (fvp == tvp) {
+               VOP_ABORTOP(tdvp, tcnp);
+               vput(tdvp);
+               vput(tvp);
+               vrele(fdvp);
                if ((ip->i_mode&IFMT) == IFDIR) {
                if ((ip->i_mode&IFMT) == IFDIR) {
-                       VOP_ABORTOP(fndp);
-                       vrele(fndp->ni_vp);
+                       VOP_ABORTOP(fdvp, fcnp);
+                       vrele(fvp);
                        return (EINVAL);
                }
                doingdirectory = 0;
                        return (EINVAL);
                }
                doingdirectory = 0;
@@ -660,22 +950,22 @@ ufs_rename(fndp, tndp, p)
                /*
                 * Avoid ".", "..", and aliases of "." for obvious reasons.
                 */
                /*
                 * Avoid ".", "..", and aliases of "." for obvious reasons.
                 */
-               if ((fndp->ni_namelen == 1 && fndp->ni_ptr[0] == '.') ||
-                   dp == ip || fndp->ni_isdotdot || (ip->i_flag & IRENAME)) {
-                       VOP_ABORTOP(tndp);
-                       vput(tndp->ni_dvp);
-                       if (tndp->ni_vp)
-                               vput(tndp->ni_vp);
-                       VOP_ABORTOP(fndp);
-                       vrele(fndp->ni_dvp);
-                       vput(fndp->ni_vp);
+               if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||
+                   dp == ip || (fcnp->cn_flags&ISDOTDOT) || (ip->i_flag & IRENAME)) {
+                       VOP_ABORTOP(tdvp, tcnp);
+                       vput(tdvp);
+                       if (tvp)
+                               vput(tvp);
+                       VOP_ABORTOP(fdvp, fcnp);
+                       vrele(fdvp);
+                       vput(fvp);
                        return (EINVAL);
                }
                ip->i_flag |= IRENAME;
                oldparent = dp->i_number;
                doingdirectory++;
        }
                        return (EINVAL);
                }
                ip->i_flag |= IRENAME;
                oldparent = dp->i_number;
                doingdirectory++;
        }
-       vrele(fndp->ni_dvp);
+       vrele(fdvp);
 
        /*
         * 1) Bump link count while we're moving stuff
 
        /*
         * 1) Bump link count while we're moving stuff
@@ -685,17 +975,17 @@ ufs_rename(fndp, tndp, p)
         */
        ip->i_nlink++;
        ip->i_flag |= ICHG;
         */
        ip->i_nlink++;
        ip->i_flag |= ICHG;
-       error = VOP_UPDATE(fndp->ni_vp, &time, &time, 1);
+       error = VOP_UPDATE(fvp, &time, &time, 1);
        IUNLOCK(ip);
 
        /*
         * When the target exists, both the directory
         * and target vnodes are returned locked.
         */
        IUNLOCK(ip);
 
        /*
         * When the target exists, both the directory
         * and target vnodes are returned locked.
         */
-       dp = VTOI(tndp->ni_dvp);
+       dp = VTOI(tdvp);
        xp = NULL;
        xp = NULL;
-       if (tndp->ni_vp)
-               xp = VTOI(tndp->ni_vp);
+       if (tvp)
+               xp = VTOI(tvp);
        /*
         * If ".." must be changed (ie the directory gets a new
         * parent) then the source directory must not be in the
        /*
         * If ".." must be changed (ie the directory gets a new
         * parent) then the source directory must not be in the
@@ -709,24 +999,24 @@ ufs_rename(fndp, tndp, p)
        if (oldparent != dp->i_number)
                newparent = dp->i_number;
        if (doingdirectory && newparent) {
        if (oldparent != dp->i_number)
                newparent = dp->i_number;
        if (doingdirectory && newparent) {
-               VOP_LOCK(fndp->ni_vp);
-               error = ufs_access(fndp->ni_vp, VWRITE, tndp->ni_cred, p);
-               VOP_UNLOCK(fndp->ni_vp);
+               VOP_LOCK(fvp);
+               error = ufs_access(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
+               VOP_UNLOCK(fvp);
                if (error)
                        goto bad;
                if (xp != NULL)
                        ufs_iput(xp);
                if (error)
                        goto bad;
                if (xp != NULL)
                        ufs_iput(xp);
-               if (error = ufs_checkpath(ip, dp, tndp->ni_cred))
+               if (error = ufs_checkpath(ip, dp, tcnp->cn_cred))
                        goto out;
                        goto out;
-               if ((tndp->ni_nameiop & SAVESTART) == 0)
+               if ((tcnp->cn_flags & SAVESTART) == 0)
                        panic("ufs_rename: lost to startdir");
                p->p_spare[1]--;
                        panic("ufs_rename: lost to startdir");
                p->p_spare[1]--;
-               if (error = lookup(tndp, p))
+               if (error = relookup(tdvp, &tvp, tcnp))
                        goto out;
                        goto out;
-               dp = VTOI(tndp->ni_dvp);
+               dp = VTOI(tdvp);
                xp = NULL;
                xp = NULL;
-               if (tndp->ni_vp)
-                       xp = VTOI(tndp->ni_vp);
+               if (tvp)
+                       xp = VTOI(tvp);
        }
        /*
         * 2) If target doesn't exist, link the target
        }
        /*
         * 2) If target doesn't exist, link the target
@@ -753,7 +1043,7 @@ ufs_rename(fndp, tndp, p)
                        if (error = VOP_UPDATE(ITOV(dp), &time, &time, 1))
                                goto bad;
                }
                        if (error = VOP_UPDATE(ITOV(dp), &time, &time, 1))
                                goto bad;
                }
-               if (error = ufs_direnter(ip, tndp)) {
+               if (error = ufs_direnter(ip, tdvp, tcnp)) {
                        if (doingdirectory && newparent) {
                                dp->i_nlink--;
                                dp->i_flag |= ICHG;
                        if (doingdirectory && newparent) {
                                dp->i_nlink--;
                                dp->i_flag |= ICHG;
@@ -776,9 +1066,9 @@ ufs_rename(fndp, tndp, p)
                 * otherwise the destination may not be changed (except by
                 * root). This implements append-only directories.
                 */
                 * otherwise the destination may not be changed (except by
                 * root). This implements append-only directories.
                 */
-               if ((dp->i_mode & ISVTX) && tndp->ni_cred->cr_uid != 0 &&
-                   tndp->ni_cred->cr_uid != dp->i_uid &&
-                   xp->i_uid != tndp->ni_cred->cr_uid) {
+               if ((dp->i_mode & ISVTX) && tcnp->cn_cred->cr_uid != 0 &&
+                   tcnp->cn_cred->cr_uid != dp->i_uid &&
+                   xp->i_uid != tcnp->cn_cred->cr_uid) {
                        error = EPERM;
                        goto bad;
                }
                        error = EPERM;
                        goto bad;
                }
@@ -788,7 +1078,7 @@ ufs_rename(fndp, tndp, p)
                 * (both directories, or both not directories).
                 */
                if ((xp->i_mode&IFMT) == IFDIR) {
                 * (both directories, or both not directories).
                 */
                if ((xp->i_mode&IFMT) == IFDIR) {
-                       if (!ufs_dirempty(xp, dp->i_number, tndp->ni_cred) || 
+                       if (!ufs_dirempty(xp, dp->i_number, tcnp->cn_cred) || 
                            xp->i_nlink > 2) {
                                error = ENOTEMPTY;
                                goto bad;
                            xp->i_nlink > 2) {
                                error = ENOTEMPTY;
                                goto bad;
@@ -802,7 +1092,7 @@ ufs_rename(fndp, tndp, p)
                        error = EISDIR;
                        goto bad;
                }
                        error = EISDIR;
                        goto bad;
                }
-               if (error = ufs_dirrewrite(dp, ip, tndp))
+               if (error = ufs_dirrewrite(dp, ip, tcnp))
                        goto bad;
                /*
                 * If the target directory is in the same
                        goto bad;
                /*
                 * If the target directory is in the same
@@ -840,15 +1130,15 @@ ufs_rename(fndp, tndp, p)
         * 3) Unlink the source.
         */
 unlinkit:
         * 3) Unlink the source.
         */
 unlinkit:
-       fndp->ni_nameiop &= ~MODMASK;
-       fndp->ni_nameiop |= LOCKPARENT | LOCKLEAF;
-       if ((fndp->ni_nameiop & SAVESTART) == 0)
+       fcnp->cn_flags &= ~MODMASK;
+       fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
+       if ((fcnp->cn_flags & SAVESTART) == 0)
                panic("ufs_rename: lost from startdir");
        p->p_spare[1]--;
                panic("ufs_rename: lost from startdir");
        p->p_spare[1]--;
-       (void) lookup(fndp, p);
-       if (fndp->ni_vp != NULL) {
-               xp = VTOI(fndp->ni_vp);
-               dp = VTOI(fndp->ni_dvp);
+       (void) relookup(fdvp, &fvp, fcnp);   /* NEEDSWORK: startdir stuff */
+       if (fvp != NULL) {
+               xp = VTOI(fvp);
+               dp = VTOI(fdvp);
        } else {
                /*
                 * From name has disappeared.
        } else {
                /*
                 * From name has disappeared.
@@ -884,7 +1174,7 @@ unlinkit:
                        error = vn_rdwr(UIO_READ, ITOV(xp), (caddr_t)&dirbuf,
                                sizeof (struct dirtemplate), (off_t)0,
                                UIO_SYSSPACE, IO_NODELOCKED, 
                        error = vn_rdwr(UIO_READ, ITOV(xp), (caddr_t)&dirbuf,
                                sizeof (struct dirtemplate), (off_t)0,
                                UIO_SYSSPACE, IO_NODELOCKED, 
-                               tndp->ni_cred, (int *)0, (struct proc *)0);
+                               tcnp->cn_cred, (int *)0, (struct proc *)0);
                        if (error == 0) {
                                if (dirbuf.dotdot_namlen != 2 ||
                                    dirbuf.dotdot_name[0] != '.' ||
                        if (error == 0) {
                                if (dirbuf.dotdot_namlen != 2 ||
                                    dirbuf.dotdot_name[0] != '.' ||
@@ -898,13 +1188,13 @@ unlinkit:
                                            sizeof (struct dirtemplate),
                                            (off_t)0, UIO_SYSSPACE,
                                            IO_NODELOCKED|IO_SYNC,
                                            sizeof (struct dirtemplate),
                                            (off_t)0, UIO_SYSSPACE,
                                            IO_NODELOCKED|IO_SYNC,
-                                           tndp->ni_cred, (int *)0,
+                                           tcnp->cn_cred, (int *)0,
                                            (struct proc *)0);
                                        cache_purge(ITOV(dp));
                                }
                        }
                }
                                            (struct proc *)0);
                                        cache_purge(ITOV(dp));
                                }
                        }
                }
-               error = ufs_dirremove(fndp);
+               error = ufs_dirremove(fdvp, fcnp);
                if (!error) {
                        xp->i_nlink--;
                        xp->i_flag |= ICHG;
                if (!error) {
                        xp->i_nlink--;
                        xp->i_flag |= ICHG;
@@ -941,26 +1231,26 @@ static struct dirtemplate mastertemplate = {
  * Mkdir system call
  */
 int
  * Mkdir system call
  */
 int
-ufs_mkdir(ndp, vap, p)
-       struct nameidata *ndp;
+ufs_mkdir(dvp, vpp, cnp, vap)   /* converted to CN.   */
+/* was: ufs_mkdir(cnp, vap) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        struct vattr *vap;
-       struct proc *p;
 {
        register struct inode *ip, *dp;
        struct vnode *tvp;
 {
        register struct inode *ip, *dp;
        struct vnode *tvp;
-       struct vnode *dvp;
        struct dirtemplate dirtemplate;
        int error;
        int dmode;
 
 #ifdef DIANOSTIC
        struct dirtemplate dirtemplate;
        int error;
        int dmode;
 
 #ifdef DIANOSTIC
-       if ((ndp->ni_nameiop & HASBUF) == 0)
+       if ((cnp->cn_flags & HASBUF) == 0)
                panic("ufs_mkdir: no name");
 #endif
                panic("ufs_mkdir: no name");
 #endif
-       dvp = ndp->ni_dvp;
        dp = VTOI(dvp);
        if ((unsigned short)dp->i_nlink >= LINK_MAX) {
        dp = VTOI(dvp);
        if ((unsigned short)dp->i_nlink >= LINK_MAX) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+               free(cnp->cn_pnbuf, M_NAMEI);
                ufs_iput(dp);
                return (EMLINK);
        }
                ufs_iput(dp);
                return (EMLINK);
        }
@@ -971,18 +1261,18 @@ ufs_mkdir(ndp, vap, p)
         * not have it entered in the parent directory. The entry is made
         * later after writing "." and ".." entries.
         */
         * not have it entered in the parent directory. The entry is made
         * later after writing "." and ".." entries.
         */
-       if (error = VOP_VALLOC(dvp, dmode, ndp->ni_cred, &tvp)) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+       if (error = VOP_VALLOC(dvp, dmode, cnp->cn_cred, &tvp)) {
+               free(cnp->cn_pnbuf, M_NAMEI);
                ufs_iput(dp);
                return (error);
        }
        ip = VTOI(tvp);
                ufs_iput(dp);
                return (error);
        }
        ip = VTOI(tvp);
-       ip->i_uid = ndp->ni_cred->cr_uid;
+       ip->i_uid = cnp->cn_cred->cr_uid;
        ip->i_gid = dp->i_gid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
        ip->i_gid = dp->i_gid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
-           (error = chkiq(ip, 1, ndp->ni_cred, 0))) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+           (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
+               free(cnp->cn_pnbuf, M_NAMEI);
                VOP_VFREE(tvp, ip->i_number, dmode);
                ufs_iput(ip);
                ufs_iput(dp);
                VOP_VFREE(tvp, ip->i_number, dmode);
                ufs_iput(ip);
                ufs_iput(dp);
@@ -1012,7 +1302,7 @@ ufs_mkdir(ndp, vap, p)
        dirtemplate.dotdot_ino = dp->i_number;
        error = vn_rdwr(UIO_WRITE, ITOV(ip), (caddr_t)&dirtemplate,
            sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE,
        dirtemplate.dotdot_ino = dp->i_number;
        error = vn_rdwr(UIO_WRITE, ITOV(ip), (caddr_t)&dirtemplate,
            sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE,
-           IO_NODELOCKED|IO_SYNC, ndp->ni_cred, (int *)0, (struct proc *)0);
+           IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (int *)0, (struct proc *)0);
        if (error) {
                dp->i_nlink--;
                dp->i_flag |= ICHG;
        if (error) {
                dp->i_nlink--;
                dp->i_flag |= ICHG;
@@ -1026,7 +1316,7 @@ ufs_mkdir(ndp, vap, p)
        }
 
        /* Directory set up, now install it's entry in the parent directory. */
        }
 
        /* Directory set up, now install it's entry in the parent directory. */
-       if (error = ufs_direnter(ip, ndp)) {
+       if (error = ufs_direnter(ip, dvp, cnp)) {
                dp->i_nlink--;
                dp->i_flag |= ICHG;
        }
                dp->i_nlink--;
                dp->i_flag |= ICHG;
        }
@@ -1040,8 +1330,8 @@ bad:
                ip->i_flag |= ICHG;
                ufs_iput(ip);
        } else
                ip->i_flag |= ICHG;
                ufs_iput(ip);
        } else
-               ndp->ni_vp = ITOV(ip);
-       FREE(ndp->ni_pnbuf, M_NAMEI);
+               *vpp = ITOV(ip);
+       FREE(cnp->cn_pnbuf, M_NAMEI);
        ufs_iput(dp);
        return (error);
 }
        ufs_iput(dp);
        return (error);
 }
@@ -1050,20 +1340,21 @@ bad:
  * Rmdir system call.
  */
 int
  * Rmdir system call.
  */
 int
-ufs_rmdir(ndp, p)
-       register struct nameidata *ndp;
-       struct proc *p;
+ufs_rmdir(dvp, vp, cnp)   /* converted to CN.   */
+/* old: ufs_rmdir(ndp, p) */
+       struct vnode *dvp, *vp;
+       struct componentname *cnp;
 {
        register struct inode *ip, *dp;
        int error;
 
 {
        register struct inode *ip, *dp;
        int error;
 
-       ip = VTOI(ndp->ni_vp);
-       dp = VTOI(ndp->ni_dvp);
+       ip = VTOI(vp);
+       dp = VTOI(dvp);
        /*
         * No rmdir "." please.
         */
        if (dp == ip) {
        /*
         * No rmdir "." please.
         */
        if (dp == ip) {
-               vrele(ndp->ni_dvp);
+               vrele(dvp);
                ufs_iput(ip);
                return (EINVAL);
        }
                ufs_iput(ip);
                return (EINVAL);
        }
@@ -1076,7 +1367,7 @@ ufs_rmdir(ndp, p)
         */
        error = 0;
        if (ip->i_nlink != 2 ||
         */
        error = 0;
        if (ip->i_nlink != 2 ||
-           !ufs_dirempty(ip, dp->i_number, ndp->ni_cred)) {
+           !ufs_dirempty(ip, dp->i_number, cnp->cn_cred)) {
                error = ENOTEMPTY;
                goto out;
        }
                error = ENOTEMPTY;
                goto out;
        }
@@ -1085,13 +1376,13 @@ ufs_rmdir(ndp, p)
         * inode.  If we crash in between, the directory
         * will be reattached to lost+found,
         */
         * inode.  If we crash in between, the directory
         * will be reattached to lost+found,
         */
-       if (error = ufs_dirremove(ndp))
+       if (error = ufs_dirremove(dvp, cnp))
                goto out;
        dp->i_nlink--;
        dp->i_flag |= ICHG;
                goto out;
        dp->i_nlink--;
        dp->i_flag |= ICHG;
-       cache_purge(ndp->ni_dvp);
+       cache_purge(dvp);
        ufs_iput(dp);
        ufs_iput(dp);
-       ndp->ni_dvp = NULL;
+       dvp = NULL;
        /*
         * Truncate inode.  The only stuff left
         * in the directory is "." and "..".  The
        /*
         * Truncate inode.  The only stuff left
         * in the directory is "." and "..".  The
@@ -1104,10 +1395,10 @@ ufs_rmdir(ndp, p)
         * worry about them later.
         */
        ip->i_nlink -= 2;
         * worry about them later.
         */
        ip->i_nlink -= 2;
-       error = VOP_TRUNCATE(ndp->ni_vp, (u_long)0, IO_SYNC);
+       error = VOP_TRUNCATE(vp, (u_long)0, IO_SYNC);
        cache_purge(ITOV(ip));
 out:
        cache_purge(ITOV(ip));
 out:
-       if (ndp->ni_dvp)
+       if (dvp)
                ufs_iput(dp);
        ufs_iput(ip);
        return (error);
                ufs_iput(dp);
        ufs_iput(ip);
        return (error);
@@ -1117,21 +1408,22 @@ out:
  * symlink -- make a symbolic link
  */
 int
  * symlink -- make a symbolic link
  */
 int
-ufs_symlink(ndp, vap, target, p)
-       struct nameidata *ndp;
+ufs_symlink(dvp, vpp, cnp, vap, target)   /* converted to CN.   */
+/* old: ufs_symlink(ndp, vap, target, p) */
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
        struct vattr *vap;
        char *target;
        struct vattr *vap;
        char *target;
-       struct proc *p;
 {
 {
-       struct vnode *vp;
        int error;
 
        int error;
 
-       if (error = ufs_makeinode(IFLNK | vap->va_mode, ndp, &vp))
+       if (error = ufs_makeinode(IFLNK | vap->va_mode, dvp, vpp, cnp))
                return (error);
                return (error);
-       error = vn_rdwr(UIO_WRITE, vp, target, strlen(target), (off_t)0,
-               UIO_SYSSPACE, IO_NODELOCKED, ndp->ni_cred, (int *)0,
+       error = vn_rdwr(UIO_WRITE, *vpp, target, strlen(target), (off_t)0,
+               UIO_SYSSPACE, IO_NODELOCKED, cnp->cn_cred, (int *)0,
                (struct proc *)0);
                (struct proc *)0);
-       vput(vp);
+       vput(*vpp);
        return (error);
 }
 
        return (error);
 }
 
@@ -1182,12 +1474,12 @@ ufs_readlink(vp, uiop, cred)
  */
 /* ARGSUSED */
 int
  */
 /* ARGSUSED */
 int
-ufs_abortop(ndp)
-       struct nameidata *ndp;
+ufs_abortop(dvp, cnp)    /* converted to CN.   */
+       struct vnode *dvp;
+       struct componentname *cnp;
 {
 {
-
-       if ((ndp->ni_nameiop & (HASBUF | SAVESTART)) == HASBUF)
-               FREE(ndp->ni_pnbuf, M_NAMEI);
+       if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
+               FREE(cnp->cn_pnbuf, M_NAMEI);
        return (0);
 }
 
        return (0);
 }
 
@@ -1557,36 +1849,38 @@ ufs_vinit(mntp, specops, fifoops, vpp)
  * Allocate a new inode.
  */
 int
  * Allocate a new inode.
  */
 int
-ufs_makeinode(mode, ndp, vpp)
+ufs_makeinode(mode, dvp, vpp, cnp)   /* converted to CN */
+/* OLD: ufs_makeinode(mode, ndp, vpp) */
        int mode;
        int mode;
-       register struct nameidata *ndp;
+       struct vnode *dvp;
        struct vnode **vpp;
        struct vnode **vpp;
+       struct componentname *cnp;
 {
        register struct inode *ip, *pdir;
        struct vnode *tvp;
        int error;
 
 {
        register struct inode *ip, *pdir;
        struct vnode *tvp;
        int error;
 
-       pdir = VTOI(ndp->ni_dvp);
+       pdir = VTOI(dvp);
 #ifdef DIANOSTIC
 #ifdef DIANOSTIC
-       if ((ndp->ni_nameiop & HASBUF) == 0)
+       if ((cnp->cn_flags & HASBUF) == 0)
                panic("ufs_makeinode: no name");
 #endif
        *vpp = NULL;
        if ((mode & IFMT) == 0)
                mode |= IFREG;
 
                panic("ufs_makeinode: no name");
 #endif
        *vpp = NULL;
        if ((mode & IFMT) == 0)
                mode |= IFREG;
 
-       if (error = VOP_VALLOC(ndp->ni_dvp, mode, ndp->ni_cred, &tvp)) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+       if (error = VOP_VALLOC(dvp, mode, cnp->cn_cred, &tvp)) {
+               free(cnp->cn_pnbuf, M_NAMEI);
                ufs_iput(pdir);
                return (error);
        }
        ip = VTOI(tvp);
                ufs_iput(pdir);
                return (error);
        }
        ip = VTOI(tvp);
-       ip->i_uid = ndp->ni_cred->cr_uid;
+       ip->i_uid = cnp->cn_cred->cr_uid;
        ip->i_gid = pdir->i_gid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
        ip->i_gid = pdir->i_gid;
 #ifdef QUOTA
        if ((error = getinoquota(ip)) ||
-           (error = chkiq(ip, 1, ndp->ni_cred, 0))) {
-               free(ndp->ni_pnbuf, M_NAMEI);
+           (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
+               free(cnp->cn_pnbuf, M_NAMEI);
                VOP_VFREE(tvp, ip->i_number, mode);
                ufs_iput(ip);
                ufs_iput(pdir);
                VOP_VFREE(tvp, ip->i_number, mode);
                ufs_iput(ip);
                ufs_iput(pdir);
@@ -1597,8 +1891,8 @@ ufs_makeinode(mode, ndp, vpp)
        ip->i_mode = mode;
        tvp->v_type = IFTOVT(mode);     /* Rest init'd in iget() */
        ip->i_nlink = 1;
        ip->i_mode = mode;
        tvp->v_type = IFTOVT(mode);     /* Rest init'd in iget() */
        ip->i_nlink = 1;
-       if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, ndp->ni_cred) &&
-           suser(ndp->ni_cred, NULL))
+       if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) &&
+           suser(cnp->cn_cred, NULL))
                ip->i_mode &= ~ISGID;
 
        /*
                ip->i_mode &= ~ISGID;
 
        /*
@@ -1606,10 +1900,10 @@ ufs_makeinode(mode, ndp, vpp)
         */
        if (error = VOP_UPDATE(tvp, &time, &time, 1))
                goto bad;
         */
        if (error = VOP_UPDATE(tvp, &time, &time, 1))
                goto bad;
-       if (error = ufs_direnter(ip, ndp))
+       if (error = ufs_direnter(ip, dvp, cnp))
                goto bad;
                goto bad;
-       if ((ndp->ni_nameiop & SAVESTART) == 0)
-               FREE(ndp->ni_pnbuf, M_NAMEI);
+       if ((cnp->cn_flags & SAVESTART) == 0)
+               FREE(cnp->cn_pnbuf, M_NAMEI);
        ufs_iput(pdir);
        *vpp = tvp;
        return (0);
        ufs_iput(pdir);
        *vpp = tvp;
        return (0);
@@ -1619,10 +1913,28 @@ bad:
         * Write error occurred trying to update the inode
         * or the directory so must deallocate the inode.
         */
         * Write error occurred trying to update the inode
         * or the directory so must deallocate the inode.
         */
-       free(ndp->ni_pnbuf, M_NAMEI);
+       free(cnp->cn_pnbuf, M_NAMEI);
        ufs_iput(pdir);
        ip->i_nlink = 0;
        ip->i_flag |= ICHG;
        ufs_iput(ip);
        return (error);
 }
        ufs_iput(pdir);
        ip->i_nlink = 0;
        ip->i_flag |= ICHG;
        ufs_iput(ip);
        return (error);
 }
+
+
+#if defined(JOHNH) && 0
+/*
+ * A hack to get the kernel to compile.
+ */
+int
+hang_addrlist()
+{
+    return 0;
+}
+int
+free_addrlist()
+{
+    return 0;
+}
+#endif
+