Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Jan 2010 09:37:31 +0000 (UTC)
From:      Gavin Atkinson <gavin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r202461 - head/bin/cp
Message-ID:  <201001170937.o0H9bVM4078072@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gavin
Date: Sun Jan 17 09:37:31 2010
New Revision: 202461
URL: http://svn.freebsd.org/changeset/base/202461

Log:
  Implement an "-x" option to cp(1), for compatibility with Linux and
  feature parity with du(1) and similar:  When set, cp(1) will not traverse
  mount points.
  
  Initial patch by:       Graham J Lee   leeg teaching.physics.ox.ac.uk
  
  PR:		bin/88056
  Initial patch by: Graham J Lee   leeg teaching.physics.ox.ac.uk
  Approved by:	ed (mentor)
  MFC after:	1 month

Modified:
  head/bin/cp/cp.1
  head/bin/cp/cp.c
  head/bin/cp/utils.c

Modified: head/bin/cp/cp.1
==============================================================================
--- head/bin/cp/cp.1	Sun Jan 17 08:41:07 2010	(r202460)
+++ head/bin/cp/cp.1	Sun Jan 17 09:37:31 2010	(r202461)
@@ -32,7 +32,7 @@
 .\"	@(#)cp.1	8.3 (Berkeley) 4/18/94
 .\" $FreeBSD$
 .\"
-.Dd October 27, 2006
+.Dd January 17, 2010
 .Dt CP 1
 .Os
 .Sh NAME
@@ -45,7 +45,7 @@
 .Op Fl H | Fl L | Fl P
 .Oc
 .Op Fl f | i | n
-.Op Fl alpv
+.Op Fl alpvx
 .Ar source_file target_file
 .Nm
 .Oo
@@ -53,7 +53,7 @@
 .Op Fl H | Fl L | Fl P
 .Oc
 .Op Fl f | i | n
-.Op Fl alpv
+.Op Fl alpvx
 .Ar source_file ... target_directory
 .Sh DESCRIPTION
 In the first synopsis form, the
@@ -183,6 +183,8 @@ permissions.
 Cause
 .Nm
 to be verbose, showing files as they are copied.
+.It Fl x
+File system mount points are not traversed.
 .El
 .Pp
 For each destination file that already exists, its contents are

Modified: head/bin/cp/cp.c
==============================================================================
--- head/bin/cp/cp.c	Sun Jan 17 08:41:07 2010	(r202460)
+++ head/bin/cp/cp.c	Sun Jan 17 09:37:31 2010	(r202461)
@@ -101,8 +101,9 @@ main(int argc, char *argv[])
 	int Hflag, Lflag, Pflag, ch, fts_options, r, have_trailing_slash;
 	char *target;
 
+	fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
 	Hflag = Lflag = Pflag = 0;
-	while ((ch = getopt(argc, argv, "HLPRafilnprv")) != -1)
+	while ((ch = getopt(argc, argv, "HLPRafilnprvx")) != -1)
 		switch (ch) {
 		case 'H':
 			Hflag = 1;
@@ -150,6 +151,9 @@ main(int argc, char *argv[])
 		case 'v':
 			vflag = 1;
 			break;
+		case 'x':
+			fts_options |= FTS_XDEV;
+			break;
 		default:
 			usage();
 			break;
@@ -160,7 +164,6 @@ main(int argc, char *argv[])
 	if (argc < 2)
 		usage();
 
-	fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
 	if (Rflag && rflag)
 		errx(1, "the -R and -r options may not be specified together");
 	if (rflag)

Modified: head/bin/cp/utils.c
==============================================================================
--- head/bin/cp/utils.c	Sun Jan 17 08:41:07 2010	(r202460)
+++ head/bin/cp/utils.c	Sun Jan 17 09:37:31 2010	(r202461)
@@ -518,8 +518,8 @@ usage(void)
 {
 
 	(void)fprintf(stderr, "%s\n%s\n",
-"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpv] source_file target_file",
-"       cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpv] source_file ... "
+"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file",
+"       cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... "
 "target_directory");
 	exit(EX_USAGE);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001170937.o0H9bVM4078072>