Bug 8726

Summary: -x option is broken on cp(1) fileutils-4.0
Product: [Retired] Red Hat Linux Reporter: Mark Lord <mlord>
Component: fileutilsAssignee: Bernhard Rosenkraenzer <bero>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-02-10 12:27:36 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
This patch fixes the -x option of the cp command. none

Description Mark Lord 2000-01-21 20:34:00 UTC
The -x (copy-one-filesystem) option does not work correctly
on the cp command.
For example:

        mkdir t
        cd t
        mkdir mntpoint
        mount some_file_system ./mntpoint
        mkdir ./mntpoint/mntpoint
        cp -auvfx . mntpoint

And watch it recurse, copying the contents of mntpoint to itself,
even though -x was supposed to prevent this from happening.

This appears due to a misplaced closing curly bracket in copy.c,
and is fixable by the following patch.  Bug report also sent to GNU.

--- fileutils-4.0/src/copy.c.orig       Mon Sep 28 12:09:18 1998
+++ fileutils-4.0/src/copy.c    Fri Jan 21 15:27:07 2000
@@ -668,11 +668,11 @@

          if (x->verbose)
            printf ("%s -> %s\n", src_path, dst_path);
-
-         /* Are we crossing a file system boundary?  */
-         if (x->one_file_system && device != 0 && device != src_sb.st_dev)
-           return 0;
        }
+
+       /* Are we crossing a file system boundary?  */
+       if (x->one_file_system && device != 0 && device != src_sb.st_dev)
+         return 0;

       /* Copy the contents of the directory.  */

Comment 1 Mark Lord 2000-01-21 20:34:59 UTC
Created attachment 73 [details]
This patch fixes the -x option of the cp command.

Comment 2 Bernhard Rosenkraenzer 2000-02-07 16:35:59 UTC
Thanks, fixed.

Comment 3 Nalin Dahyabhai 2000-02-09 17:52:59 UTC
The fix in the package breaks the -r flag.

Comment 4 Bernhard Rosenkraenzer 2000-02-10 12:27:59 UTC
I've taken out the patch for now - didn't have the time to fix it properly yet,
and -r is more important than -x...

Comment 5 Bernhard Rosenkraenzer 2000-10-05 12:21:17 UTC
It's fixed in 4.0z-1.