Re: rmdir of one's pwd (was Re: rmdir of a busy directory)

Linus Torvalds (torvalds@transmeta.com)
Fri, 12 Feb 1999 09:49:14 -0800 (PST)


On 12 Feb 1999, Andreas Schwab wrote:

> |> + if (dentry == current->fs->pwd)
> |> + return -EINVAL;
> |> +
> |> if (!dir->i_op || !dir->i_op->rmdir)
> |> return -EPERM;
>
> This patch is wrong, it also forbids `rmdir ../foo'. Only a path ending
> in '.' is special. Think about it: to find out the real name of the entry
> to unlink you'll have find its link in the parent directory. With `.' you
> simply don't have enough information about what to unlink.

Actually, you do.

_I_ think "." just means "current working directory".

It's not my fault that other systems can't do this, Linux has the
information, and will happily remove the current working directory. I
don't think it's a bug, I think it's just very logical.

Show me POSIX or other standards that say that you can't do it, and I
guess I have to work around a standards problem, but right now I say that
if programs ask for 'rmdir(".")', then they had better get it. I don't
think the OS should second-guess anybody.

The reason '.' doesn't work on other UNIXes is that they don't have the
complete path information that Linux has.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/