From owner-freebsd-fs Mon Feb 18 21:47:15 2002 Delivered-To: freebsd-fs@freebsd.org Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by hub.freebsd.org (Postfix) with ESMTP id 28F4F37B404 for ; Mon, 18 Feb 2002 21:47:11 -0800 (PST) Received: by elvis.mu.org (Postfix, from userid 1192) id 03187AE03F; Mon, 18 Feb 2002 21:47:11 -0800 (PST) Date: Mon, 18 Feb 2002 21:47:10 -0800 From: Alfred Perlstein To: Bruce Evans Cc: fs@FreeBSD.ORG Subject: Re: mkdir / == odd Message-ID: <20020219054710.GD12136@elvis.mu.org> References: <20020218132751.GX12136@elvis.mu.org> <20020219162133.D858-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020219162133.D858-100000@gamplex.bde.org> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-fs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org * Bruce Evans [020218 21:33] wrote: > On Mon, 18 Feb 2002, Alfred Perlstein wrote: > > > # mkdir / > > mkdir: /: Is a directory > > > > shouldn't mkdir get a EEXIST error back? > > Looks like I didn't fix this special case when I fixed trailing slash > handling in rev.1.8 of vfs_lookup.c. > > > this patch to mkdir also fixes it. > > Um, kernel bugs can't be fixed in userland. I wasn't sure if this error was there for hysterical raisins or not, hence the userland work-around. > > Index: mkdir.c > > =================================================================== > > RCS file: /home/ncvs/src/bin/mkdir/mkdir.c,v > > retrieving revision 1.23 > > diff -u -r1.23 mkdir.c > > --- mkdir.c 5 Feb 2002 21:55:12 -0000 1.23 > > +++ mkdir.c 18 Feb 2002 13:28:06 -0000 > > @@ -143,7 +143,7 @@ > > p = path; > > oumask = 0; > > retval = 0; > > - if (p[0] == '/') /* Skip leading '/'. */ > > + while (p[0] == '/') /* Skip leading '/'. */ > > ++p; > > for (first = 1, last = 0; !last ; ++p) { > > if (p[0] == '\0') > > > > Skipping even one slash here probably breaks mkdir(1) on systems where a > leading "//" is special. *nod* I was looking at something like this: (untested) Index: vfs_lookup.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_lookup.c,v retrieving revision 1.49 diff -u -r1.49 vfs_lookup.c --- vfs_lookup.c 13 Jan 2002 21:37:48 -0000 1.49 +++ vfs_lookup.c 18 Feb 2002 20:59:59 -0000 @@ -386,7 +386,11 @@ goto bad; } if (cnp->cn_nameiop != LOOKUP) { - error = EISDIR; + if (cnp->cn_nameiop == CREATE && + (ndp->ni_cnd.cn_flags & WILLBEDIR) != 0) + error = EEXIST; + else + error = EISDIR; goto bad; } if (wantparent) { -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message