chflags: Add -x option to not traverse mount points.

MFC after:	2 weeks
This commit is contained in:
bdrewery 2018-03-05 01:56:07 +00:00
parent cf698c1283
commit bd5a73afa4
2 changed files with 13 additions and 6 deletions

View File

@ -32,7 +32,7 @@
.\" @(#)chflags.1 8.4 (Berkeley) 5/2/95
.\" $FreeBSD$
.\"
.Dd April 20, 2015
.Dd March 4, 2018
.Dt CHFLAGS 1
.Os
.Sh NAME
@ -40,7 +40,7 @@
.Nd change file flags
.Sh SYNOPSIS
.Nm
.Op Fl fhv
.Op Fl fhvx
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
@ -98,6 +98,8 @@ If the
.Fl v
option is specified more than once, the old and new flags of the file
will also be printed, in octal notation.
.It Fl x
Do not cross mount points.
.El
.Pp
The flags are specified as an octal number or a comma separated list

View File

@ -65,12 +65,12 @@ main(int argc, char *argv[])
FTSENT *p;
u_long clear, newflags, set;
long val;
int Hflag, Lflag, Rflag, fflag, hflag, vflag;
int Hflag, Lflag, Rflag, fflag, hflag, vflag, xflag;
int ch, fts_options, oct, rval;
char *flags, *ep;
Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
while ((ch = getopt(argc, argv, "HLPRfhv")) != -1)
Hflag = Lflag = Rflag = fflag = hflag = vflag = xflag = 0;
while ((ch = getopt(argc, argv, "HLPRfhvx")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@ -95,6 +95,9 @@ main(int argc, char *argv[])
case 'v':
vflag++;
break;
case 'x':
xflag = 1;
break;
case '?':
default:
usage();
@ -123,6 +126,8 @@ main(int argc, char *argv[])
} else {
fts_options = FTS_LOGICAL;
}
if (xflag)
fts_options |= FTS_XDEV;
flags = *argv;
if (*flags >= '0' && *flags <= '7') {
@ -201,6 +206,6 @@ static void
usage(void)
{
(void)fprintf(stderr,
"usage: chflags [-fhv] [-R [-H | -L | -P]] flags file ...\n");
"usage: chflags [-fhvx] [-R [-H | -L | -P]] flags file ...\n");
exit(1);
}