GNU bug report logs - #8636
cp -x flag does not work

Previous Next

Package: coreutils;

Reported by: obb33 <at> verizon.net

Date: Sat, 7 May 2011 20:16:01 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 8636 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: obb33 <at> verizon.net
Cc: 8636 <at> debbugs.gnu.org
Subject: Re: bug#8636: cp -x flag does not work
Date: Mon, 09 May 2011 14:07:49 +0200
tags 8636 + notabug
thanks

obb33 <at> verizon.net wrote:
> context: copy a linux system to a directory where, after chrooting to that
> directory, i could safely  torture and mangle the duplicate system.
>
> the command used was cp -xvdpR /*   /newdirectory
>
> where / contains mounted other(not on the drive / is on) filesystems. these
> are nfs mounts(direct and via ssh), mounted hard drives, and mounted loop
> drives.
>
> the guilty party is apparently the wildcard
>
> the command as given above copies everything and descends all directories on
> all mounted file systems under / no matter what they are.
>
> the command:  cp -xvdp /<otherfs-dir>/*   /newdirectory

Thanks for explaining.
With -x, cp considers each specified source directory when applying this rule:

    `-x'
    `--one-file-system'
         Skip subdirectories that are on different file systems from the
         one that the copy started on.  However, mount point directories
         _are_ copied.

So this might have been what you intended, assuming that /newdirectory
is not on the same file system as "/":

    cp -xvdp / /newdirectory

Even if it is on the same file system, it should work,
but you should get a diagnostic about cp refusing to copy
/newdirectory into itself.

> descends into the top level of the  otherfs dir and copies the files
> therein, but does not descend into other directories.
>
> so the wildcard essentially negates -x and this was not anticipated
> behavior. checking the docs i did not find any mention of this.
>
> if this is WAD, then it should be documented, however, i don't think that
> someone using the -x wants a wildcard to undo that spec especially in a dir
> with several mounts on subdirectories.

I think it even works as _documented_ (in the "info" documentation) ;-)
Yes, the five-word description in --help (and hence in "man cp") is too
succinct, but at the end of that man page, you should see a note explaining
that "info cp" will give you the real documentation.

Would you like to suggest wording that would make it clearer?




This bug report was last modified 13 years and 248 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.