Subject: Re: Linux emulation and mkdir with trailing /
To: None <email@example.com>
From: Christos Zoulas <firstname.lastname@example.org>
Date: 09/24/2000 18:48:59
In article <20000924182408.94D046@proven.weird.com>,
Greg A. Woods <email@example.com> wrote:
> V6 & V7 & 32V & SysIII included this little loop twice in namei() [all
> these releases contain remarkably identical code]:
> while(c == '/')
> c = (*func)();
> (where `func' is "a function called to get the next char of name")
> John Lions gives the following explanation:
> Multiple slashes are acceptable! (i.e. "////a///b/" is the same
> as "/a/b");
> The second occurance would appear to be the one that eats up any
> trailing slashes. This does not appear to be done in 4.3BSD for reasons
> I cannot fathom, though I may be simply missing some subtlety in my
> quick and naive attempt at a code walkthrough. (if I'm right was it a
> simple omission in the rewrite?).
> I don't ever recall any difference in behaviour of any SysV -- I'm
> reasonably sure they all honoured the original Unix behaviour. In fact
> I remeber tripping over related "bugs" in BSD, but not the other way
> In NetBSD it would appear that there is code to do this, though it may
> not be happening at the right point to have the effect I think it does.
> In any case I think *BSD should definitely take on the behaviour of
> traditional Unix and do as Lions comment says. I cannot think of
> anything serious that would break, but I can thing of many things that
> would be fixed, not the least of which would be the elimination of any
> need for `special' handling of pathnames in programs that call mkdir(2).
> BTW, I think that doing this in a `POSIX' compatability routine would be
> absolutely wrong. If someone wants to wrap the kernel code in `#ifdef
> POSIX' then that might be OK, but in the case of NetBSD in particular I
> think `#define POSIX 1' is strongly in order!
Well, there is precedence to have a function behaving differently
in presense of a POSIX symbol: rename(2). Changing the particular namei()
behavior of ignoring the trailing slash affects too many system calls
and will break a lot of userland programs. A glaring example is doing
echo */ in a directory, which with this change will return all files.
[someone will need to visit all vestiges of globing code and take care
of this in userland].
Notice that Slowaris 2.7 is still broken with respect to that: try
echo */ in /bin using /bin/sh, /bin/csh, /bin/jsh, and /bin/ksh.
Lunix appears to ignore the trailing slash in directories, but not
in plain files.
Fixing this in userland is a PITA, specially when one considers
Having said that, it would be nice if:
- the emulations DTRT
- if posix really says that the trailing slashes are ignored:
- provide posix_ functions [but that is a pain because
there are too many of them, and it adds a lot of crud].
- provide a sysctl to turn this on [this is *really*