summaryrefslogtreecommitdiffstats
path: root/usr.sbin/chown
diff options
context:
space:
mode:
authorgavin <gavin@FreeBSD.org>2010-02-21 10:14:06 +0000
committergavin <gavin@FreeBSD.org>2010-02-21 10:14:06 +0000
commit30a2ed98abdb690fb73d57e7d7fbfb034376d952 (patch)
tree029f225215057b4f66087fcfbd58a68432ec6e93 /usr.sbin/chown
parent002bfbf796a561ef0d5e9a0b8ec6f8542fdebb9a (diff)
downloadFreeBSD-src-30a2ed98abdb690fb73d57e7d7fbfb034376d952.zip
FreeBSD-src-30a2ed98abdb690fb73d57e7d7fbfb034376d952.tar.gz
Add a "-x" option to chown(8)/chgrp(1) similar to the same option in
du(1), cp(1) etc, to prevent the crossing of mountpoints whilst using the commands recursively. PR: bin/130855 Submitted by: keramida MFC after: 1 month
Diffstat (limited to 'usr.sbin/chown')
-rw-r--r--usr.sbin/chown/chgrp.110
-rw-r--r--usr.sbin/chown/chown.812
-rw-r--r--usr.sbin/chown/chown.c17
3 files changed, 26 insertions, 13 deletions
diff --git a/usr.sbin/chown/chgrp.1 b/usr.sbin/chown/chgrp.1
index 71b6806..8a4c271 100644
--- a/usr.sbin/chown/chgrp.1
+++ b/usr.sbin/chown/chgrp.1
@@ -31,7 +31,7 @@
.\" @(#)chgrp.1 8.3 (Berkeley) 3/31/94
.\" $FreeBSD$
.\"
-.Dd April 25, 2003
+.Dd February 21, 2010
.Dt CHGRP 1
.Os
.Sh NAME
@@ -39,7 +39,7 @@
.Nd change group
.Sh SYNOPSIS
.Nm
-.Op Fl fhv
+.Op Fl fhvx
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
@@ -89,6 +89,8 @@ If the
flag is specified more than once,
.Nm
will print the filename, followed by the old and new numeric group ID.
+.It Fl x
+File system mount points are not traversed.
.El
.Pp
The
@@ -125,7 +127,9 @@ In previous versions of this system, symbolic links did not have groups.
.Pp
The
.Fl v
-option is non-standard and its use in scripts is not recommended.
+and
+.Fl x
+options are non-standard and their use in scripts is not recommended.
.Sh SEE ALSO
.Xr chown 2 ,
.Xr fts 3 ,
diff --git a/usr.sbin/chown/chown.8 b/usr.sbin/chown/chown.8
index f617f73..b5882a3 100644
--- a/usr.sbin/chown/chown.8
+++ b/usr.sbin/chown/chown.8
@@ -28,7 +28,7 @@
.\" @(#)chown.8 8.3 (Berkeley) 3/31/94
.\" $FreeBSD$
.\"
-.Dd April 25, 2003
+.Dd February 21, 2010
.Dt CHOWN 8
.Os
.Sh NAME
@@ -36,7 +36,7 @@
.Nd change file owner and group
.Sh SYNOPSIS
.Nm
-.Op Fl fhv
+.Op Fl fhvx
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
@@ -44,7 +44,7 @@
.Ar owner Ns Op : Ns Ar group
.Ar
.Nm
-.Op Fl fhv
+.Op Fl fhvx
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
@@ -97,6 +97,8 @@ If the
flag is specified more than once,
.Nm
will print the filename, followed by the old and new numeric user/group ID.
+.It Fl x
+File system mount points are not traversed.
.El
.Pp
The
@@ -146,7 +148,9 @@ owners.
.Pp
The
.Fl v
-option is non-standard and its use in scripts is not recommended.
+and
+.Fl x
+options are non-standard and their use in scripts is not recommended.
.Sh SEE ALSO
.Xr chgrp 1 ,
.Xr find 1 ,
diff --git a/usr.sbin/chown/chown.c b/usr.sbin/chown/chown.c
index b79deca..7a22292 100644
--- a/usr.sbin/chown/chown.c
+++ b/usr.sbin/chown/chown.c
@@ -73,14 +73,14 @@ main(int argc, char **argv)
{
FTS *ftsp;
FTSENT *p;
- int Hflag, Lflag, Rflag, fflag, hflag, vflag;
+ int Hflag, Lflag, Rflag, fflag, hflag, vflag, xflag;
int ch, fts_options, rval;
char *cp;
ischown = (strcmp(basename(argv[0]), "chown") == 0);
- 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;
@@ -105,6 +105,9 @@ main(int argc, char **argv)
case 'v':
vflag++;
break;
+ case 'x':
+ xflag = 1;
+ break;
case '?':
default:
usage();
@@ -128,6 +131,8 @@ main(int argc, char **argv)
}
} else
fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
+ if (xflag)
+ fts_options |= FTS_XDEV;
uid = (uid_t)-1;
gid = (gid_t)-1;
@@ -301,11 +306,11 @@ usage(void)
if (ischown)
(void)fprintf(stderr, "%s\n%s\n",
- "usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group]"
+ "usage: chown [-fhvx] [-R [-H | -L | -P]] owner[:group]"
" file ...",
- " chown [-fhv] [-R [-H | -L | -P]] :group file ...");
+ " chown [-fhvx] [-R [-H | -L | -P]] :group file ...");
else
(void)fprintf(stderr, "%s\n",
- "usage: chgrp [-fhv] [-R [-H | -L | -P]] group file ...");
+ "usage: chgrp [-fhvx] [-R [-H | -L | -P]] group file ...");
exit(1);
}
OpenPOWER on IntegriCloud