bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cp -x fails to preserve mount point permissions


From: Paul Eggert
Subject: Re: cp -x fails to preserve mount point permissions
Date: Sat, 03 Mar 2007 13:32:05 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

address@hidden (Andrew Church) writes:

>      The following patch may or may not be correct, but it seems to
> solve the problem for my case.

Thanks for catching this problem.  Too bad it's hard to write a portable
test case for it.

The patch looks correct to me, but how about this patch instead?  It
tries to make the code a bit clearer (and a tiny bit faster).

2007-03-03  Paul Eggert  <address@hidden>

        * src/copy.c (copy_internal): Don't return immediately after
        copying a mount point that we do not intend to recurse under.
        This fixes a bug where we didn't set the correct permissions
        for the mount point.  Problem reported by Andrew Church.

diff --git a/src/copy.c b/src/copy.c
index 000c248..8de4f80 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1604,19 +1604,16 @@ copy_internal (char const *src_name, char const 
*dst_name,
            emit_verbose (src_name, dst_name, NULL);
        }

-      /* Are we crossing a file system boundary?  */
-      if (x->one_file_system && device != 0 && device != src_sb.st_dev)
-       return true;
-
-      /* Copy the contents of the directory.  */
-
-      if (! copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x,
-                     copy_into_self))
+      /* Are we staying in the file system, or do we not care?  */
+      if (! x->one_file_system || device == 0 || device == src_sb.st_dev)
        {
-         /* Don't just return here -- otherwise, the failure to read a
-            single file in a source directory would cause the containing
-            destination directory not to have owner/perms set properly.  */
-         delayed_ok = false;
+         /* Copy the contents of the directory.  Don't just return if
+            this fails -- otherwise, the failure to read a single
+            file in a source directory would cause the containing
+            destination directory not to have owner/perms set
+            properly.  */
+         delayed_ok = copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x,
+                                copy_into_self);
        }
     }
   else if (x->symbolic_link)
M ChangeLog
M src/copy.c
Committed as 293658fb3621376f0b51c54f1258d67dbb40d090




reply via email to

[Prev in Thread] Current Thread [Next in Thread]