NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/47770: add x flag to rm to avoid cross mount points
>Number: 47770
>Category: bin
>Synopsis: add x flag to rm to avoid cross mount points
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Apr 26 18:30:00 +0000 2013
>Originator: Eitan Adler
>Release: HEAD
>Organization:
>Environment:
>Description:
Add an x option to avoid crossing filesystem boundaries when removing files.
>How-To-Repeat:
>Fix:
The diff, available as an attachment by request.
Index: rm.c
===================================================================
RCS file: /cvsroot/src/bin/rm/rm.c,v
retrieving revision 1.52
diff -u -r1.52 rm.c
--- rm.c 13 Jun 2012 07:35:37 -0000 1.52
+++ rm.c 26 Apr 2013 18:27:00 -0000
@@ -61,6 +61,7 @@
#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 @@
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 @@
case 'v':
vflag = 1;
break;
+ case 'x':
+ xflag = 1;
+ break;
case 'W':
Wflag = 1;
break;
@@ -175,6 +179,8 @@
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 @@
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 */
Index: rm.1
===================================================================
RCS file: /cvsroot/src/bin/rm/rm.1,v
retrieving revision 1.25
diff -u -r1.25 rm.1
--- rm.1 13 Oct 2012 14:18:16 -0000 1.25
+++ rm.1 26 Apr 2013 18:27:00 -0000
@@ -110,6 +110,8 @@
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
Home |
Main Index |
Thread Index |
Old Index