diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 1998-01-09 02:11:08 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 1998-01-09 02:11:08 +0000 |
commit | b6da6af6c1e7afd3f89b4051715a3551ce8900df (patch) | |
tree | b3ba2f923c0deb8d5a356055cf1eaa7532d5a4bd /sys | |
parent | c5fbd66c4bb7851c1c1c91b406bb39df6786c3d8 (diff) |
Fix for mkdir ("path/") problem
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_lookup.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 1795c833098..b283c76209a 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_lookup.c,v 1.11 1997/11/06 05:58:27 csapuntz Exp $ */ +/* $OpenBSD: vfs_lookup.c,v 1.12 1998/01/09 02:11:07 csapuntz Exp $ */ /* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */ /* @@ -147,6 +147,8 @@ namei(ndp) dp = fdp->fd_cdir; VREF(dp); } + + for (;;) { cnp->cn_nameptr = cnp->cn_pnbuf; ndp->ni_startdir = dp; @@ -288,9 +290,14 @@ lookup(ndp) ndp->ni_startdir = NULLVP; vn_lock(dp, LK_EXCLUSIVE | LK_RETRY, p); + /* Make sure the current node is a directory */ + if (dp->v_type != VDIR) { + error = ENOTDIR; + goto bad; + } + /* - * If we have a leading string of slashes, remove them, and just make - * sure the current node is a directory. + * If we have a leading string of slashes, remove them. */ cp = cnp->cn_nameptr; if (*cp == '/') { @@ -300,10 +307,6 @@ lookup(ndp) ndp->ni_pathlen -= cp - cnp->cn_nameptr; cnp->cn_nameptr = cp; - if (dp->v_type != VDIR) { - error = ENOTDIR; - goto bad; - } /* * If we've exhausted the path name, then just return the @@ -442,14 +445,13 @@ unionlookup: if (error != EJUSTRETURN) goto bad; - /* - * If this was not the last component, or there were trailing - * slashes, then the name must exist. - */ - if (cnp->cn_flags & REQUIREDIR) { - error = ENOENT; - goto bad; + +#ifdef DIAGNOSTIC + if (!(cnp->cn_flags & ISLASTCN)) { + printf ("Just got an EJUSTRETURN for something which wasn't the last component. Bad news\n"); } +#endif + /* * If creating and at end of pathname, then can consider * allowing file to be created. |