diff options
author | Jim Meyering <jim@meyering.net> | 2002-09-29 08:43:19 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2002-09-29 08:43:19 +0000 |
commit | 6daabb757807b8730502043e4dabeb191bc2bad6 (patch) | |
tree | 6477703e72ceee2e6b37a7f76b9fa77834a91f3b | |
parent | d7e2b7fa84b0c6d7ca201666ea2285d8db556b4d (diff) | |
download | coreutils-6daabb757807b8730502043e4dabeb191bc2bad6.tar.xz |
In move mode, always first try to rename. Before, upon failure to
rename a directory, this code would never attempt to rename any
other file in that directory, but would thenceforth always copy.
On some systems (NetApp version ??), renaming a directory may fail
with EXDEV, yet renaming files within that directory to a newly-
created destination directory succeeds.
(copy_internal): Remove local, move_mode;
use x->move_mode instead. Based on a patch from Tom Haynes.
-rw-r--r-- | src/copy.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/copy.c b/src/copy.c index 99f02868a..14f16c44c 100644 --- a/src/copy.c +++ b/src/copy.c @@ -87,7 +87,7 @@ static int copy_internal PARAMS ((const char *src_path, const char *dst_path, int new_dst, dev_t device, struct dir_list *ancestors, const struct cp_options *x, - int move_mode, + int command_line_arg, int *copy_into_self, int *rename_succeeded)); @@ -801,14 +801,7 @@ copy_internal (const char *src_path, const char *dst_path, int ran_chown = 0; int preserve_metadata; - /* move_mode is set to the value from the `options' parameter for the - first copy_internal call. For any subsequent recursive call, it must - be zero. This is because if we're moving (via mv) a hierarchy and - end up having to recurse, it means the initial rename failed and so we - are in the process of *copy*ing all of the parts, not renaming them. */ - int move_mode = (command_line_arg ? x->move_mode : 0); - - if (move_mode && rename_succeeded) + if (x->move_mode && rename_succeeded) *rename_succeeded = 0; *copy_into_self = 0; @@ -964,7 +957,7 @@ copy_internal (const char *src_path, const char *dst_path, } } - if (move_mode) + if (x->move_mode) { /* In move_mode, DEST may not be an existing directory. */ if (S_ISDIR (dst_sb.st_mode)) @@ -1127,9 +1120,7 @@ copy_internal (const char *src_path, const char *dst_path, return 0; } - /* Note that this is testing the local variable move_mode, not - the x->move_mode member. */ - if (move_mode) + if (x->move_mode) { if (rename (src_path, dst_path) == 0) { |