Subject: bug#8636: cp -x flag does not work

From: Jim Meyering <[email-masked]>
Date: Sun, 08 May 2011 19:32:08 +0200

[email-masked] wrote:
> coreutils 8.12, i don't know if this problem existed in previous versions.
>
> copying the root directory ( / ) of a running linux system using cp -xdvpR
> cp followed a directory that was mounted via NFS under / . the copy was
> stopped before any other directories on other filesystems were copied so i
> can't speak about how cp would handle those mounts.

tags 8636 + moreinfo
thanks

Thanks for the report.

AFAIK, cp's -x (--one-file-system) option does work.
If it's not working for you, perhaps there is something
unusual about your situation.  What does "df" say about
the NFS-mounted directory that was mistakenly copied?

To test it without copying data unnecessarily, I ran this:

    mkdir junk && cp -srx / junk

That makes symlinks to the same files that a one-file-system "cp" would
have copied.  The only nonempty directories in junk/ correspond to ones
in "/" that reside on the same file system as "/".  So at least for me,
it works as advertised.  Note that copying each top-level mount point
directory is expected -- those are all empty in the destination (junk/
in my case).

Please provide more details, including
  - the precise command you ran
  - a sample of the output showing it copying a file that it shouldn't
  - what this prints: stat --format=%04D:%n / DIR
      where DIR is an NFS-mounted directory that was mistakenly copied