lkml.org 
[lkml]   [1996]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: POSIX feature or bug?
On 20 Sep 96 at 9:56, Linus Torvalds wrote:

>
>
> On Fri, 20 Sep 1996, Ulrich Windl wrote:
> >
> > In 2.0.20 I tried "cd /tmp; mkdir X; cd X; rmdir /tmp/X" with
> > success. A subsequent "pwd" complains about the working directory...
>
> "Don't do that then".
>
> Actually, it's neither a bug nor a POSIX feature: it's just how things
> work. Directories are just normal files, and you can think of having a
> directory as your current working directory as having a file open.
>
> What happens when you remove a file that you had open? The open file still
> works, but you can't get at it though the filesystem name-space any more.
> Similarly, when you remove a directory that you have as you cwd, the
> directory still exists, but you can't get at it through the filesystem
> name-space.
>
> There is a special restriction here, and that's the fact that a removed
> directory cannot have new files created in it. That's simply because the
> kernel doesn't really like the idea of having a file with a non-existent
> directory as the parent..
>
> Anyway, I think most other UNIX'es will act the same way.
>
> [ sounds of logging onto other systems.. ]
>
> Solaris, HP-UX and Digital UNIX work the same way as Linux, but Solaris and
> HP-UX try to be "clever" and notice that you're trying to remove the cwd. But
> under both the "clever" OS's you can just open another window and removing
> the cwd in _another_ process, no problem (so the check seems to be just some
> silly one-liner check added by some Sun/HP/xxx engineer who though the check
> would be a good idea for some strange reason, but it has no real meaning).
>

This is from HP-UX 10.01 (Patchlevel 7+)

rkdvmhp1:windl(32) % cd /tmp
rkdvmhp1:windl(33) % mkdir X
rkdvmhp1:windl(34) % cd X
rkdvmhp1:windl(35) % rmdir /tmp/X
rmdir: /tmp/X: Cannot remove mountable directory

> Linus

\
 
 \ /
  Last update: 2005-03-22 13:37    [from the cache]
©2003-2011 Jasper Spaans