]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
In move mode, always first try to rename. Before, upon failure to
authorJim Meyering <jim@meyering.net>
Sun, 29 Sep 2002 08:43:19 +0000 (08:43 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 29 Sep 2002 08:43:19 +0000 (08:43 +0000)
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.

src/copy.c

index 99f02868afb7bae09af55f3d7db67b0667ecb709..14f16c44c5af32e83b78397f7b4afa7620dd5c42 100644 (file)
@@ -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)
        {