Move files by atomic rename instead of copy. # $Header: /CVSROOT/mvatom/DESCRIPTION,v 1.8 2011-08-25 12:27:14 tino Exp $ # # $Log: DESCRIPTION,v $ # Revision 1.8 2011-08-25 12:27:14 tino # dirlist removed # # Revision 1.7 2008-10-16 19:42:50 tino # Multiargs and options -a -d -l -m -u -o # # Revision 1.6 2008-05-28 14:47:56 tino # Option -c # # Revision 1.5 2008-05-07 15:12:17 tino # dirlist added # # Revision 1.4 2008-05-04 04:28:22 tino # Option -s added # # Revision 1.3 2006-11-07 12:41:20 tino # cmpanddel.sh added # # Revision 1.2 2006/08/12 02:07:38 tino # corrected for option -o # # Revision 1.1 2006/07/22 23:47:58 tino # First version for testing Post-modern mv implementations re-invented a wheel which is no more round. If they cannot move they do a copy/unlink() operation which is unsatisfying, as when the unlink() fails you stay with the copy which was insanely done. mv shall be an atomic operation. However you cannot switch mv into atomic mode. This version here does what mv is supposed to do: It renames the target and fails if it cannot do the rename (but beware the common NFS bug in such a situation). In unsafe mode it does this using the rename() operation (note that rename() has a possible race condition which may overwrite a destination unconditionally, if it is created after mvatom has checked the presence of the destination), in safe mode (will be introduced in 0.5.0) it will use hardlink/unlink. The move is "atomically" in respect to the destination either is there completely or missing, it is not "atomically" in the sense of "man 2 rename". If you need this, you need option -uf. Another thing is that it only guesses something for the last argument like mv does if it is instructed to do so. So it always works reliably. You know what it does from looking at the command line, and if no heuristics are given this does not depend from the last arg beeing a directory or not. If the destination is a directory this must be given as an option to mvatom. Also all options are simple and clear and there is no way to overwrite files, as mvatom never overwrites files (but beware the race condition in unsafe mode which was used before 0.5.0). Also you can "move away" files with mvatom, too. This is done with the "backup" feature, where an existing destination can be renamed. There now is a helper script:
dirlist -0p DIRa | mvatom -0dDIRb -