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

Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
12 Feb 1999 15:45:54 +0100


Alexander Viro <viro@math.psu.edu> writes:

|> On 12 Feb 1999, Andreas Schwab wrote:
|>
|> > Alexander Viro <viro@math.psu.edu> writes:
|> >
|> > |> --- fs/namei.c Tue Feb 9 10:17:15 1999
|> > |> +++ fs/namei.c.new Fri Feb 12 07:46:04 1999
|> > |> @@ -942,6 +942,9 @@
|> > |> if (error)
|> > |> return error;
|> > |>
|> > |> + 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.
|>
|> Erm??? SunOS 5.6 (both on tmpfs and NFS) doesn't allow "../foo"
|> just as it doesn't allow ".".

Just tested on SunOS 5.5.1:

$ mkdir xx
$ cd xx
$ rmdir .
rmdir: directory ".": Can't remove current directory or ..
$ rmdir ../xx
$ ls -a
$ ls ../xx
../xx: No such file or directory

Note that rmdir actually tries rmdir(".") first, and only then translates
the error (EINVAL) to the appropriate message.

-- 
Andreas Schwab                                      "And now for something
schwab@issan.cs.uni-dortmund.de                      completely different"
schwab@gnu.org

- 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/