Package: coreutils
Version: 8.4-2
Severity: important

when files are created inside a directory during a `mv` of a the
directory, those files are deleted at the end of the move.

this typically happens when moving large (in terms of amount of data)
directories across file systems.

to reproduce, you need a current directory on a different partition than
your `/tmp`, then do

$ mkdir /tmp/movetest
$ mkdir movetest
$ dd if=/dev/zero of=movetest/bigfile bs=1024 count=300000
300000+0 records in
300000+0 records out
307200000 bytes (307 MB) copied, 11.4315 s, 26.9 MB/s

(it is important that the file is big enough to take some seconds to
create and read)

$ mv movetest /tmp/movetest/ &; sleep 3; echo foobar > movetest/latefile
[1]  + done       mv movetest /tmp/movetest/
$ ls -lamovetest
ls: cannot access movetest: No such file or directory
$ ls -la /tmp/movetest
total 300348
drwxr-xr-x   2 chrysn chrysn      4096 Apr 13 12:21 .
drwxrwxrwt 158 root   root       45056 Apr 13 12:21 ..
-rw-r--r--   1 chrysn chrysn 307200000 Apr 13 12:21 bigfile

you see that the `latestfile` has vanished.

no such behavior is documented in the man page.


i suggest that `mv` should only delete the files it has successfully
moved, and then should behave like `rmdir` for removing the directories.

i'm indifferent on whether it should just print a warning that some
folders could not be removed because they are not empty and return
successfully or set a non-zero exit status.

(there could be flags to modify the behavior, eg one to restore the old
behavior and one to make mv fail if the directories can't be removed.)


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.33-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages coreutils depends on:
ii  libacl1                       2.2.49-2   Access control list shared library
ii  libc6                         2.10.2-6   Embedded GNU C Library: Shared lib
ii  libselinux1                   2.0.94-1   SELinux runtime shared libraries

coreutils recommends no packages.

coreutils suggests no packages.

-- debconf-show failed

-- 
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom

Attachment: signature.asc
Description: Digital signature

Reply via email to