[Top][All Lists]
[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: |
Alan Curry |
Subject: |
bug#7450: cp does not check for errno=EISDIR when target is dangling link |
Date: |
Sat, 20 Nov 2010 16:48:57 -0500 (GMT+5) |
=?UTF-8?Q?=D0=9C=D0=B0=D1=80=D0=BA_?= writes:
>
> How to reproduce:
>
> $ ln -s non-exist tgt
[...]
> $ cp /etc/passwd tgt/
> cp: cannot create regular file `tgt/': Is a directory
>
> Novices can not understand this message :)
The same confusing error message also occurs in the simpler case where the
target is simply any nonexistent name with a trailing slash.
$ ls -ld tgt
ls: cannot access tgt: No such file or directory
$ cp /etc/passwd tgt/
cp: cannot create regular file `tgt/': Is a directory
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.
When this open fails, nothing in sight "Is a directory". The problem is that
tgt/ _would_ be a directory, but since it doesn't exist and isn't about to be
created, "Is a directory" is an overstatement.
cp should dodge this issue by never calling creat with a trailing slash. It
could supply a meaningful error message instead of one that is derived from
an errno.
--
Alan Curry
- bug#7450: cp does not check for errno=EISDIR when target is dangling link, Марк Коренберг, 2010/11/20
- bug#7450: cp does not check for errno=EISDIR when target is dangling link,
Alan Curry <=
- bug#7450: cp does not check for errno=EISDIR when target is dangling link, Jim Meyering, 2010/11/21
- bug#7450: cp does not check for errno=EISDIR when target is, Alan Curry, 2010/11/21
- bug#7450: cp does not check for errno=EISDIR when target is dangling link, Paul Eggert, 2010/11/21
- bug#7450: cp does not check for errno=EISDIR when target is dangling link, Jim Meyering, 2010/11/22
- bug#7450: cp does not check for errno=EISDIR when target is dangling link, Pádraig Brady, 2010/11/22
- bug#7450: cp does not check for errno=EISDIR when target is dangling link, Eric Blake, 2010/11/22
- bug#7450: cp does not check for errno=EISDIR when target is dangling link, Paul Eggert, 2010/11/22
- bug#7450: cp does not check for errno=EISDIR when target is dangling link, Eric Blake, 2010/11/22
bug#7450: cp does not check for errno=EISDIR when target is dangling link, Eric Blake, 2010/11/22