Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!ptsfa!ihnp4!homxb!mtuxo!mtune!codas!killer!jfh From: jfh@killer.UUCP (The Beach Bum) Newsgroups: comp.unix.wizards Subject: Re: To . or not to . Message-ID: <1973@killer.UUCP> Date: Mon, 2-Nov-87 17:32:50 EST Article-I.D.: killer.1973 Posted: Mon Nov 2 17:32:50 1987 Date-Received: Sat, 7-Nov-87 04:21:49 EST References: <648@tut.cis.ohio-state.edu> <722@wacsvax.OZ> <9171@mimsy.UUCP> Organization: Big "D" Home for Wayward Hackers Lines: 64 Summary: Don't about about x/ using the zero length bug. Works just fine on 3B2 at killer. In article <9171@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > In article <722@wacsvax.OZ> frank@wacsvax.OZ (Frank O'Connor) writes: > >Please flame me if I am wrong but why wouldn't : > > for p in $x/*/ > > do > > stuff > > done > >be sufficient. ... > > Well, for one thing, this uses the zero-length-string file name > (right there after the second slash: it refers to the current > directory as of that slash). > > If System V's namei is consistent, this will fail in the same way > as open("", 0) (and it will not accept names like a//b or //x). > -- > In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) > Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris Sorry to do this to you Chris, but that works just fine here. I don't have sys/nami.c (or whatever the new name is) in front of me, but my understanding of what is going on is this: namei (func, mode) char (*func) (); int mode; { int c; c = (func) (); /* test for c == 0 to set u.u_error = ENOENT, or make current inode == root inode or current directory inode. */ do if room left insert character in u-page dirent structure. while ((c = (func) ()) != '/' && c != 0) while ((c = (func) ()) == '/' && c != 0) toss character out because it was just a /. /* at this point, c is '\0' or first char in next path name. */ /* go look in current directory for an entry that matches. */ /* if c == 0, return the current i-node, else go back. */ } Okay. Did anyone not know this already? Now, my understanding of the original bug was if the first `c' was '\0', the current I-node, which was the current directory, since c != '/'. That's why "" == . in the old world. Consider "/", where the first character returned is '/', and after that, the next is '\0'. The test, if I understand, and unless you have the sources, (which I don't, so I don't know ...), only happens that one time. A much better test is if u.u_dent.d_name[0] == 0, and return ENOENT. But '/' is still quite special ... - John. -- John F. Haugh II HECI Exploration Co. Inc. UUCP: ...!ihnp4!killer!jfh 11910 Greenville Ave, Suite 600 "Don't Have an Oil Well?" Dallas, TX. 75243 " ... Then Buy One!" (214) 231-0993