bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7450: cp does not check for errno=EISDIR when target is dangling lin


From: Eric Blake
Subject: bug#7450: cp does not check for errno=EISDIR when target is dangling link
Date: Mon, 22 Nov 2010 09:32:20 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6

On 11/20/2010 02:48 PM, Alan Curry wrote:
> strace shows this:
> 
> open("tgt/", O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE, 0600) = -1 EISDIR (Is a 
> directory)
> 
> which I think is just bad kernel behavior. There's no errno (among the
> classical errno values anyway) which completely expresses "you tried to creat
> something with a trailing slash", but I'd rather see ENOENT or ENOTDIR than
> EISDIR.

Actually, POSIX _does_ specify what should happen here, and the Linux
kernel is violating POSIX (on other systems, like Solaris 10, you get
the correct ENOTDIR).  It's just that its such a pervasive bug that we
haven't bothered to make gnulib work around this bug in the Linux
kernel.  I personally haven't reported this as a kernel bug, so I'm not
sure if the kernel folks are aware of this issue.

http://www.opengroup.org/onlinepubs/9699919799/functions/open.html

[ENOTDIR]
    A component of the path prefix is not a directory; or O_CREAT and
O_EXCL are not specified, the path argument contains at least one non-
<slash> character and ends with one or more trailing <slash> characters,
and the last pathname component names an existing file that is neither a
directory nor a symbolic link to a directory; or O_DIRECTORY was
specified and the path argument does not name a directory.

as further modified by:

http://austingroupbugs.net/view.php?id=146
http://austingroupbugs.net/view.php?id=324

At page 1382 line 45322 section open, change:

    [ENOENT] O_CREAT is not set and the named file does not exist; or
             O_CREAT is set and either the path prefix does not exist
             or the path argument points to an empty string.

to:

    [ENOENT] O_CREAT is not set and a component of path does not name
             an existing file, or O_CREAT is set and a component of
             the path prefix of path does not name an existing file,
             or path points to an empty string.

After page 1382 line 45324 section open, add:

    [ENOENT] or [ENOTDIR]
             O_CREAT is set, and the path argument contains at least
             one non-<slash> character and ends with one or more
             trailing <slash> characters.  If path names an existing
             file, an [ENOENT] error shall not occur.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]