GNU bug report logs - #12339
Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so.

Previous Next

Package: coreutils;

Reported by: Linda Walsh <coreutils <at> tlinx.org>

Date: Mon, 3 Sep 2012 00:34:02 UTC

Severity: normal

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Jim Meyering <jim <at> meyering.net>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, Linda Walsh <coreutils <at> tlinx.org>, "12339 <at> debbugs.gnu.org" <12339 <at> debbugs.gnu.org>
Subject: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is	documented to do so.
Date: Tue, 04 Sep 2012 16:28:47 +0200

On 09/04/2012 02:55 PM, Jim Meyering wrote:
> With the following patch, I see new behavior.
> It's an improvement, but we're still not there:
> 
>     $ mkdir -p d/e/f; ln -s d s; rm -r s/
>     rm: cannot remove 's/': Not a directory
>     [Exit 1]
>     $ find
>     .
>     ./s
>     ./d
> 
> Notice how it did traverse s/ into d/, and removed d/e and d/e/f.
> The only problem is that when it attempted to remove the command-line
> specified "s/", unlinkat (AT_FDCWD, "s/", AT_REMOVEDIR) failed:
> 
>     unlinkat(4, "d", 0)                     = 0
>     unlinkat(5, "f", AT_REMOVEDIR)          = 0
>     unlinkat(4, "e", AT_REMOVEDIR)          = 0
>     unlinkat(AT_FDCWD, "s/", AT_REMOVEDIR)  = -1 ENOTDIR (Not a directory)
>     rm: cannot remove 's/': Not a directory
>     +++ exited with 1 +++
> 
> Now, this looks like a problem with unlinkat.

Hmm, what about dereferencing command line symlinks with trailing
slashes _before_ entering the FTS loop instead?

Have a nice day,
Berny




This bug report was last modified 6 years and 187 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.