From owner-svn-src-head@FreeBSD.ORG Sun Feb 21 10:14:06 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D5A451065670; Sun, 21 Feb 2010 10:14:06 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C36E28FC17; Sun, 21 Feb 2010 10:14:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1LAE67W092151; Sun, 21 Feb 2010 10:14:06 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1LAE6gw092147; Sun, 21 Feb 2010 10:14:06 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <201002211014.o1LAE6gw092147@svn.freebsd.org> From: Gavin Atkinson Date: Sun, 21 Feb 2010 10:14:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204165 - head/usr.sbin/chown X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Feb 2010 10:14:07 -0000 Author: gavin Date: Sun Feb 21 10:14:06 2010 New Revision: 204165 URL: http://svn.freebsd.org/changeset/base/204165 Log: 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 Modified: head/usr.sbin/chown/chgrp.1 head/usr.sbin/chown/chown.8 head/usr.sbin/chown/chown.c Modified: head/usr.sbin/chown/chgrp.1 ============================================================================== --- head/usr.sbin/chown/chgrp.1 Sun Feb 21 09:25:53 2010 (r204164) +++ head/usr.sbin/chown/chgrp.1 Sun Feb 21 10:14:06 2010 (r204165) @@ -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, sym .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 , Modified: head/usr.sbin/chown/chown.8 ============================================================================== --- head/usr.sbin/chown/chown.8 Sun Feb 21 09:25:53 2010 (r204164) +++ head/usr.sbin/chown/chown.8 Sun Feb 21 10:14:06 2010 (r204165) @@ -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 , Modified: head/usr.sbin/chown/chown.c ============================================================================== --- head/usr.sbin/chown/chown.c Sun Feb 21 09:25:53 2010 (r204164) +++ head/usr.sbin/chown/chown.c Sun Feb 21 10:14:06 2010 (r204165) @@ -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); }