From 25d90d5c97208edff7ad52d5db86d39e0d0a2b69 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 5 Mar 2018 01:56:07 +0000 Subject: [PATCH] chflags: Add -x option to not traverse mount points. MFC after: 2 weeks --- bin/chflags/chflags.1 | 6 ++++-- bin/chflags/chflags.c | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bin/chflags/chflags.1 b/bin/chflags/chflags.1 index bb6fe42d6e4c..6966f6c0fbc4 100644 --- a/bin/chflags/chflags.1 +++ b/bin/chflags/chflags.1 @@ -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 diff --git a/bin/chflags/chflags.c b/bin/chflags/chflags.c index 999df04338a4..3121f470e13a 100644 --- a/bin/chflags/chflags.c +++ b/bin/chflags/chflags.c @@ -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); }