bug-coreutils
[Top][All Lists]
Advanced

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

bug#9823: request for more correct error reporting of mv


From: Eric Blake
Subject: bug#9823: request for more correct error reporting of mv
Date: Fri, 21 Oct 2011 06:59:22 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.4 Thunderbird/3.1.15

tag 9823 moreinfo
thanks

On 10/21/2011 06:46 AM, address@hidden wrote:


Hello,



if one uses mv to move a directory, and the target dir already

exists, mv reports "Directory not empty".

Can you please show a shell session that sets up the necessary paths and the actual command you typed that resulted in this message? A shell transcript will make it possible for us to repeat your actions and analyze them, much more so than a vague paraphrased English description.

For example, I tried this, and it didn't give an error:

$ rm -rf ?
$ mkdir a b
$ touch b/c
$ mv a b

but it did move a to become b/a. Meanwhile, I can use a GNU extension to reproduce your error message:

$ rm -rf ?
$ mkdir a b
$ touch b/c
$ mv -T a b
mv: cannot move `a' to `b': Directory not empty

But to me, this gives me an expected error - directory b is not empty, therefore the syscall rename("a","b") is required to fail by POSIX, and POSIX states that the failure will be either EEXIST or ENOTEMPTY (Linux chose ENOTEMPTY) - so mv is faithfully reporting the strerror() value of the actual error encountered. It's not possible to change the strerror() database, and printing a message not in the strerror() database can be confusing to developers that have come to expect specific output for specific errno values.

I find this misleading. The message should also contain the

message "target dir already exists" or something similar.

So it sounds like you'd prefer it if the message were for EEXIST instead of ENOTEMPTY? Have you tried to take it up with the Linux kernel folks? Or maybe coreutils could add a special case that if rename() fails with ENOTEMPTY and the conditions are right, then convert the errno to EEXIST before calling strerror(). But is it worth the minor pessimization (we do have precedence for some errno massaging, but it tends to need good justification)? mv -T is seldom called in the first place, since it is not POSIX.

Or did you encounter a scenario with this error message without using GNU extensions?

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





reply via email to

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