Re: `rmdir .` doesn't work in 2.4

Albert D. Cahalan
2001-01-09T13:54:14Z

Alexander Viro writes:

> [...] If you really need to destroy the directory
> that happens to be your pwd - sorry, no reliable way to do that without
> interesting locking. On _any_ UNIX out there. 2.2 included. It will
> happily give you -ENOENT and refuse to perform the action above in
> case if some other process renames your pwd. Yes, for rmdir(".");

Well, this bites.

Locking guess: use a global read-write lock, with the "write" case
being deletion of "." and the "read" case being everything else.
You could have one lock per CPU, with the writer needing to grab all
of them in order. So removal of "." pays the cost.

If the standards gripe, well, rmdot() is a nice name.