- vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, p);
-
-dirloop:
- /*
- * Search a new directory.
- *
- * The cn_hash value is for use by vfs_cache.
- * Check pathconf for maximun length of name
- * 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.
- */
- cnp->cn_consume = 0;
- cnp->cn_hash = 0;
- for (cp = cnp->cn_nameptr, i=1; *cp != 0 && *cp != '/'; i++, cp++)
- cnp->cn_hash += (unsigned char)*cp * i;
- cnp->cn_namelen = cp - cnp->cn_nameptr;
- if (VOP_PATHCONF(dp, _PC_NAME_MAX, &namemax))
- namemax = NAME_MAX;
- if (cnp->cn_namelen > namemax) {
- error = ENAMETOOLONG;
- goto bad;
- }
-#ifdef NAMEI_DIAGNOSTIC
- { char c = *cp;
- *cp = '\0';
- printf("{%s}: ", cnp->cn_nameptr);
- *cp = c; }
-#endif
- ndp->ni_pathlen -= cnp->cn_namelen;
- ndp->ni_next = cp;
- cnp->cn_flags |= MAKEENTRY;
- if (*cp == '\0' && docache == 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;