[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cp -x fails to preserve mount point permissions
From: |
Jim Meyering |
Subject: |
Re: cp -x fails to preserve mount point permissions |
Date: |
Sat, 03 Mar 2007 23:06:33 +0100 |
Paul Eggert <address@hidden> wrote:
> 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).
Thanks to both of you.
I've checked in a change that looks a little different still.
I prefer not to negate that expression, since doing that makes
it less readable.
Andrew, the "tiny change" is not a reflection on the value
of your patch :-), but merely on its size -- it's a note that
since it's small enough that we don't need copyright papers from you.
2007-03-03 Andrew Church <address@hidden> (tiny change)
Paul Eggert <address@hidden>
Fix a bug: cp -x would fail to set mount point permissions.
* NEWS: mention cp -x bug fix
* src/copy.c (copy_internal): Don't return immediately after
copying a mount point that we do not intend to recurse under.
Based on a patch by Andrew Church.
diff --git a/NEWS b/NEWS
index 65a7d52..57c51e1 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ GNU coreutils NEWS -*-
outline -*-
** Bug fixes
+ cp -x (--one-file-system) would fail to set mount point permissions
+
The default block size and output format for df -P are now unaffected by
the DF_BLOCK_SIZE, BLOCK_SIZE, and BLOCKSIZE environment variables. It
is still affected by POSIXLY_CORRECT, though.
diff --git a/src/copy.c b/src/copy.c
index 000c248..49bbb8c 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1604,19 +1604,20 @@ copy_internal (char const *src_name, char const
*dst_name,
emit_verbose (src_name, dst_name, NULL);
}
- /* Are we crossing a file system boundary? */
+ /* Decide whether to copy the contents of the directory. */
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))
{
- /* 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;
+ /* Here, we are crossing a file system boundary and cp's -x option
+ is in effect: so don't copy the contents of this directory. */
+ }
+ else
+ {
+ /* 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)