mv(1) may delete more than it should

Bug #48066 reported by Johan Kiviniemi
6
Affects Status Importance Assigned to Milestone
coreutils
New
Undecided
Unassigned
coreutils (Ubuntu)
Confirmed
Wishlist
Unassigned

Bug Description

1) mv huge_directory /nfs_mountpoint
2) During the transfer, mv other_directory huge_directory
3) After the first mv process has completed, it removes huge_directory, including huge_directory/other_directory. other_directory hasn't been moved to /nfs_mountpoint, naturally.

Expected result:

3) After the first mv process has completed, it should print "Cannot delete huge_directory: directory not empty". The remaining huge_directory should only contain other_directory.

The target doesn't need to be a NFS mountpoint. One was only used as an example.

Revision history for this message
Emmet Hikory (persia) wrote :

This has been the behaviour of mv since it supported migration between filesystems. Until this is addressed, a simple workaround is to always use `mkdir nfsmountpoint/huge_directory; mv huge_directory/* /nfs_mountpoint/huge_directory` to be sure of allowing additional files to be copied to the directory during the move operation.

Changed in coreutils:
status: Unconfirmed → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.