GNU bug report logs - #19051
rm symboliclink/ # "Is a directory"

Previous Next

Package: coreutils;

Reported by: aaron brick <abrick <at> ccsf.edu>

Date: Fri, 14 Nov 2014 07:20:01 UTC

Severity: normal

Tags: notabug

Full log


Message #14 received at 19051 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Pádraig Brady <P <at> draigBrady.com>,
 aaron brick <abrick <at> ccsf.edu>, 19051 <at> debbugs.gnu.org
Subject: Re: bug#19051: rm symboliclink/ # "Is a directory"
Date: Fri, 14 Nov 2014 07:47:44 -0700
[Message part 1 (text/plain, inline)]
On 11/14/2014 06:15 AM, Eric Blake wrote:

>> Confused me too when I encountered it first, but tt's required by POSIX:
>> http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11
> 
> No, actually, POSIX requires that it (attempt to) remove the DIRECTORY,
> not the symlink.  Linux is intentionally in violation of POSIX on this
> front.
> 
> Try this on Solaris:
> 
> $ mkdir a
> $ ln -s a b
> $ rm b/
> $ ls -d ?
> b

Uggh, serves me right for typing without testing.  I'm mixing up
rename(), unlink(), and rmdir() semantics.  Basically,
unlink("anything/") is required by POSIX to fail because the trailing /
means that the only thing to be removed is a directory, but directories
can only be removed by rmdir(), not unlink().

Still, my point remains when you use 'rm -r b/': on Linux, it fails
(cannot remove 'b/': Not a directory), on Solaris it succeeds at
removing 'a' and leaving 'b' dangling.

The fact that Linux intentionally violates POSIX on some of the corner
cases related to symlinks to directories makes it harder to definitively
state what coreutils should do.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

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

Previous Next


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