Add -x option to avoid crossing mount points when removing a hierarchy.
Discussed on: -hackers Inspired by: DragonflyBSD MFC After: 1 week
This commit is contained in:
parent
a618ef521c
commit
d4319e7433
@ -32,7 +32,7 @@
|
|||||||
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
|
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd March 15, 2013
|
.Dd April 25, 2013
|
||||||
.Dt RM 1
|
.Dt RM 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -42,7 +42,7 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl f | i
|
.Op Fl f | i
|
||||||
.Op Fl dIPRrvW
|
.Op Fl dIPRrvWx
|
||||||
.Ar
|
.Ar
|
||||||
.Nm unlink
|
.Nm unlink
|
||||||
.Ar file
|
.Ar file
|
||||||
@ -132,6 +132,8 @@ Attempt to undelete the named files.
|
|||||||
Currently, this option can only be used to recover
|
Currently, this option can only be used to recover
|
||||||
files covered by whiteouts in a union file system (see
|
files covered by whiteouts in a union file system (see
|
||||||
.Xr undelete 2 ) .
|
.Xr undelete 2 ) .
|
||||||
|
.It Fl x
|
||||||
|
When removing a hierarchy, do not cross mount points.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
|
13
bin/rm/rm.c
13
bin/rm/rm.c
@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
|
static int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
|
||||||
static int rflag, Iflag;
|
static int rflag, Iflag, xflag;
|
||||||
static uid_t uid;
|
static uid_t uid;
|
||||||
static volatile sig_atomic_t info;
|
static volatile sig_atomic_t info;
|
||||||
|
|
||||||
@ -106,8 +106,8 @@ main(int argc, char *argv[])
|
|||||||
exit(eval);
|
exit(eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pflag = rflag = 0;
|
Pflag = rflag = xflag = 0;
|
||||||
while ((ch = getopt(argc, argv, "dfiIPRrvW")) != -1)
|
while ((ch = getopt(argc, argv, "dfiIPRrvWx")) != -1)
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'd':
|
case 'd':
|
||||||
dflag = 1;
|
dflag = 1;
|
||||||
@ -136,6 +136,9 @@ main(int argc, char *argv[])
|
|||||||
case 'W':
|
case 'W':
|
||||||
Wflag = 1;
|
Wflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'x':
|
||||||
|
xflag = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@ -196,6 +199,8 @@ rm_tree(char **argv)
|
|||||||
flags |= FTS_NOSTAT;
|
flags |= FTS_NOSTAT;
|
||||||
if (Wflag)
|
if (Wflag)
|
||||||
flags |= FTS_WHITEOUT;
|
flags |= FTS_WHITEOUT;
|
||||||
|
if (xflag)
|
||||||
|
flags |= FTS_XDEV;
|
||||||
if (!(fts = fts_open(argv, flags, NULL))) {
|
if (!(fts = fts_open(argv, flags, NULL))) {
|
||||||
if (fflag && errno == ENOENT)
|
if (fflag && errno == ENOENT)
|
||||||
return;
|
return;
|
||||||
@ -624,7 +629,7 @@ usage(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
(void)fprintf(stderr, "%s\n%s\n",
|
(void)fprintf(stderr, "%s\n%s\n",
|
||||||
"usage: rm [-f | -i] [-dIPRrvW] file ...",
|
"usage: rm [-f | -i] [-dIPRrvWx] file ...",
|
||||||
" unlink file");
|
" unlink file");
|
||||||
exit(EX_USAGE);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user