Module Name:    src
Committed By:   christos
Date:           Fri Apr 26 18:43:23 UTC 2013

Modified Files:
        src/bin/rm: rm.1 rm.c

Log Message:
PR/47770: Eitan Adler: add x flag to rm to avoid cross mount points


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/bin/rm/rm.1
cvs rdiff -u -r1.52 -r1.53 src/bin/rm/rm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/rm/rm.1
diff -u src/bin/rm/rm.1:1.25 src/bin/rm/rm.1:1.26
--- src/bin/rm/rm.1:1.25	Sat Oct 13 10:18:16 2012
+++ src/bin/rm/rm.1	Fri Apr 26 14:43:22 2013
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rm.1,v 1.25 2012/10/13 14:18:16 njoly Exp $
+.\"	$NetBSD: rm.1,v 1.26 2013/04/26 18:43:22 christos Exp $
 .\"
 .\" Copyright (c) 1990, 1993, 1994, 2003
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	@(#)rm.1	8.5 (Berkeley) 12/5/94
 .\"
-.Dd August 25, 2006
+.Dd April 26, 2013
 .Dt RM 1
 .Os
 .Sh NAME
@@ -41,7 +41,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl f | Fl i
-.Op Fl dPRrvW
+.Op Fl dPRrvWx
 .Ar
 .Sh DESCRIPTION
 The
@@ -110,6 +110,8 @@ to be verbose, showing files as they are
 Attempts to undelete the named files.
 Currently, this option can only be used to recover
 files covered by whiteouts.
+.It Fl x
+When removing a hierarchy, do not cross mount points.
 .El
 .Pp
 The
@@ -189,7 +191,9 @@ utility is expected to be
 compatible.
 The
 .Fl v
-option is an extension.
+and
+.Fl x
+options are extensions.
 .Pp
 The
 .Fl P

Index: src/bin/rm/rm.c
diff -u src/bin/rm/rm.c:1.52 src/bin/rm/rm.c:1.53
--- src/bin/rm/rm.c:1.52	Wed Jun 13 03:35:37 2012
+++ src/bin/rm/rm.c	Fri Apr 26 14:43:22 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rm.c,v 1.52 2012/06/13 07:35:37 dholland Exp $ */
+/* $NetBSD: rm.c,v 1.53 2013/04/26 18:43:22 christos Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993, 1994, 2003
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19
 #if 0
 static char sccsid[] = "@(#)rm.c	8.8 (Berkeley) 4/27/95";
 #else
-__RCSID("$NetBSD: rm.c,v 1.52 2012/06/13 07:35:37 dholland Exp $");
+__RCSID("$NetBSD: rm.c,v 1.53 2013/04/26 18:43:22 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -61,6 +61,7 @@ __RCSID("$NetBSD: rm.c,v 1.52 2012/06/13
 #include <unistd.h>
 
 static int dflag, eval, fflag, iflag, Pflag, stdin_ok, vflag, Wflag;
+static int xflag;
 static sig_atomic_t pinfo;
 
 static int	check(char *, char *, struct stat *);
@@ -94,8 +95,8 @@ main(int argc, char *argv[])
 	setprogname(argv[0]);
 	(void)setlocale(LC_ALL, "");
 
-	Pflag = rflag = 0;
-	while ((ch = getopt(argc, argv, "dfiPRrvW")) != -1)
+	Pflag = rflag = xflag = 0;
+	while ((ch = getopt(argc, argv, "dfiPRrvWx")) != -1)
 		switch (ch) {
 		case 'd':
 			dflag = 1;
@@ -118,6 +119,9 @@ main(int argc, char *argv[])
 		case 'v':
 			vflag = 1;
 			break;
+		case 'x':
+			xflag = 1;
+			break;
 		case 'W':
 			Wflag = 1;
 			break;
@@ -175,6 +179,8 @@ rm_tree(char **argv)
 		flags |= FTS_NOSTAT;
 	if (Wflag)
 		flags |= FTS_WHITEOUT;
+	if (xflag)
+		flags |= FTS_XDEV;
 	if ((fts = fts_open(argv, flags, NULL)) == NULL)
 		err(1, "fts_open failed");
 	while ((p = fts_read(fts)) != NULL) {
@@ -591,7 +597,7 @@ static void
 usage(void)
 {
 
-	(void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrvW] file ...\n",
+	(void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrvWx] file ...\n",
 	    getprogname());
 	exit(1);
 	/* NOTREACHED */

Reply via email to