[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#22584: cp could be more precise than "Not a directory"
From: |
Bernhard Voelker |
Subject: |
bug#22584: cp could be more precise than "Not a directory" |
Date: |
Tue, 9 Feb 2016 08:29:12 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 02/08/2016 10:28 PM, 積丹尼 Dan Jacobson wrote:
> Ah ha, they just should have returned what the system calls said in the
> first place, and not tinker with the output!
>
> Them tinkering with the output only makes things worse.
Actually this _is_ an improvement:
After stat() has detected that the target does not exist, cp simply
tries to open() it - and while it has a trailing slash, the kernel
returns EISDIR:
stat("/tmp/My_DocVments/", 0x7ffdd335eee0) = -1 ENOENT (No such file or
directory)
...
open("/tmp/My_DocVments/", O_WRONLY|O_CREAT|O_EXCL, 0644) = -1 EISDIR (Is a
directory)
Taking this over as-is, the error diagnostic would be quite confusing and
plain wrong:
cp: cannot create regular file ‘/tmp/My_DocVments/’: Is a directory
Therefore, the current mapping to ENOTDIR - introduced in coreutils-v8.8 -
is the best we can do:
$ cp .profile /tmp/My_DocVments/
cp: cannot create regular file ‘/tmp/My_DocVments/’: Not a directory
Your suggestion to say "no such file or directory" (ENOENT) would be misleading,
because the target is treated by the system as a directory due to the trailing
slash.
Have a nice day,
Berny
- bug#22584: cp could be more precise than "Not a directory", 積丹尼 Dan Jacobson, 2016/02/07
- bug#22584: cp could be more precise than "Not a directory", Leslie S Satenstein, 2016/02/07
- bug#22584: cp could be more precise than "Not a directory", 積丹尼 Dan Jacobson, 2016/02/08
- bug#22584: cp could be more precise than "Not a directory", Assaf Gordon, 2016/02/08
- bug#22584: cp could be more precise than "Not a directory", 積丹尼 Dan Jacobson, 2016/02/08
- bug#22584: cp could be more precise than "Not a directory",
Bernhard Voelker <=
- bug#22584: cp could be more precise than "Not a directory", 積丹尼 Dan Jacobson, 2016/02/09