Subject: Re: Linux emulation and mkdir with trailing /
To: Warner Losh <imp@village.org>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 09/18/2000 14:38:05
[ On Monday, September 18, 2000 at 11:08:19 (-0600), Warner Losh wrote: ]
> Subject: Re: Linux emulation and mkdir with trailing /
>
> In message <Pine.BSI.3.96.1000918120656.27676A-100000@doit.pgh.net> Matthew Orgass writes:
> : No, in SUSv2, multiple slashes are the same as one slash, not '.', and
> : trailing slashes refer to the directory. The exception is that the
> : presence of exactly two leading slashes is implementation dependent.
>
> And the trailing slash refers to the directory is identical with my
> statement that it is the same as dot.
No, I think that it's not *exactly* the same as the form with the
trailing dot ('.').
/foo/bar == /foo/bar/ == /foo/bar// == /foo/bar/// [[and so on]]
/foo/bar != /foo/bar/.
I.e. you're not referencing the same directory entry even though you do
eventually reference the same inode. With the trailing '.' you're
looking at the directory entry in the subdirectory whereas with the
other forms (any number of trailing slashes, including none), including
the you're looking at the directory entry in the parent directory.
There are major implications in terms of protection modes:
$ mkdir unreadable
$ chmod 0 unreadable
$ ls -ld unreadable
d--------- 2 woods sunstaff 512 Sep 18 14:35 unreadable
$ ls -ld unreadable/
d--------- 2 woods sunstaff 512 Sep 18 14:35 unreadable/
$ ls -ld unreadable///
d--------- 2 woods sunstaff 512 Sep 18 14:35 unreadable///
$ ls -ld unreadable/.
ls: unreadable/.: Permission denied
$
and also with rmdir (though the first would normally fail for other
reasons...)
$ rmdir unreadable/.
rmdir: unreadable/.: Permission denied
$ rmdir unreadable//
$
--
Greg A. Woods
+1 416 218-0098 VE3TCP <gwoods@acm.org> <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>