Re: rmdir . - bug or feature

James Mastros (
Thu, 11 Sep 1997 19:17:07 -0400 (EDT)

On Wed, 10 Sep 1997, Pavel Machek wrote:
> Hi!
> This bug was found by mj & vojtech two days ago, but as it is still
> not fixed, I'm reporting it to the list...
> Well, I'm not really sure if it is bug or feature, but it definitely
> broke old tar (which may not be too bad, that tar really did not
> behave too well).
Feature, to hazard a guess. All of this behiour matches the unix '97 (only
spec I have access to) definition, and that spec allows (dosn't dissalow)

> pavel@Elf:/tmp$ mkdir delme
> pavel@Elf:/tmp$ cd delme/
> pavel@Elf:/tmp/delme$ ls -al
> total 17
> drwxr-xr-x 2 pavel users 1024 Sep 10 13:11 ./
> drwxrwxrwt 5 root root 15360 Sep 10 13:11 ../
> pavel@Elf:/tmp/delme$ rmdir .
> pavel@Elf:/tmp/delme$ ls -al
> total 17
> drwxr-xr-x 0 pavel users 1024 Sep 10 13:11 ./
> drwxrwxrwt 4 root root 15360 Sep 10 13:11 ../
All the links to '.' have been deleted (incl. '.' itself) (acatually, these
shouldn't be deleted), but these two files are still listed since '.' and
'..' don't have to go through lookup (they are "created" by dcache).

> pavel@Elf:/tmp/delme$ > testfile
> bash: testfile: Operation not permitted
By spec.

> pavel@Elf:/tmp/delme$ mkdir .
> mkdir: cannot make directory `.': No such file or directory
Looks up the absolute pathname by doing "<pwd>/.". (BTW - if the inode of
the current dir is linked into anway). But since the last element of pwd
dosn't exist, the lookup fails.

> pavel@Elf:/tmp/delme$
> Link count of 0 seems pretty nice to me. Well, you decide if this is
> correct behaviour.
It's not strictly to spec (by spec, the '.' and ".." entries aren't deleted
until the pwd is changed (until there are no fds refering to files in that
directory, or to the directory, and no processes have that as it's pwd).
But it's nice anyway.

> Pavel
-=- James Mastros

I can now be reached again at or
  "Shooting as [a] communications method is obsolete even here in Bosnia, so
I'll skip over it."
	-=- Dragisha Durich