CVS commit: src/bin/chmod
Module Name:src Committed By: wiz Date: Tue Jul 4 06:47:27 UTC 2017 Modified Files: src/bin/chmod: chmod.1 Log Message: Use Ex. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/bin/chmod/chmod.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/chmod/chmod.1 diff -u src/bin/chmod/chmod.1:1.27 src/bin/chmod/chmod.1:1.28 --- src/bin/chmod/chmod.1:1.27 Mon Jul 3 21:33:22 2017 +++ src/bin/chmod/chmod.1 Tue Jul 4 06:47:27 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: chmod.1,v 1.27 2017/07/03 21:33:22 wiz Exp $ +.\" $NetBSD: chmod.1,v 1.28 2017/07/04 06:47:27 wiz Exp $ .\" .\" Copyright (c) 1989, 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -113,9 +113,7 @@ option had been specified. Only the owner of a file or the super-user is permitted to change the mode of a file. .Sh EXIT STATUS -The -.Nm -utility exits 0 on success, and >0 if an error occurs. +.Ex -std chmod .Sh MODES Modes may be absolute or symbolic. An absolute mode is an octal number constructed by
CVS commit: src/bin/chmod
Module Name:src Committed By: wiz Date: Tue Jul 4 06:47:27 UTC 2017 Modified Files: src/bin/chmod: chmod.1 Log Message: Use Ex. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/bin/chmod/chmod.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/chmod
Module Name:src Committed By: sevan Date: Thu Aug 11 00:10:42 UTC 2016 Modified Files: src/bin/chmod: chmod.1 Log Message: Document the version chmod first appeared. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/bin/chmod/chmod.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/chmod
Module Name:src Committed By: sevan Date: Thu Aug 11 00:10:42 UTC 2016 Modified Files: src/bin/chmod: chmod.1 Log Message: Document the version chmod first appeared. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/bin/chmod/chmod.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/chmod/chmod.1 diff -u src/bin/chmod/chmod.1:1.25 src/bin/chmod/chmod.1:1.26 --- src/bin/chmod/chmod.1:1.25 Tue Dec 17 09:54:08 2013 +++ src/bin/chmod/chmod.1 Thu Aug 11 00:10:42 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: chmod.1,v 1.25 2013/12/17 09:54:08 apb Exp $ +.\" $NetBSD: chmod.1,v 1.26 2016/08/11 00:10:42 sevan Exp $ .\" .\" Copyright (c) 1989, 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)chmod.1 8.4 (Berkeley) 3/31/94 .\" -.Dd October 22, 2012 +.Dd August 11, 2016 .Dt CHMOD 1 .Os .Sh NAME @@ -304,6 +304,11 @@ compatible with the exception of the symbol .Dq t which is not included in that standard. +.Sh HISTORY +A +.Nm +utility appeared in +.At v1 . .Sh BUGS There's no .Ar perm
CVS commit: src/bin/chmod
Module Name:src Committed By: christos Date: Mon Oct 22 17:47:06 UTC 2012 Modified Files: src/bin/chmod: chmod.1 chmod.c Log Message: add --reference=rfile To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/bin/chmod/chmod.1 cvs rdiff -u -r1.36 -r1.37 src/bin/chmod/chmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/chmod/chmod.1 diff -u src/bin/chmod/chmod.1:1.23 src/bin/chmod/chmod.1:1.24 --- src/bin/chmod/chmod.1:1.23 Fri Jan 22 00:41:36 2010 +++ src/bin/chmod/chmod.1 Mon Oct 22 13:47:06 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: chmod.1,v 1.23 2010/01/22 05:41:36 snj Exp $ +.\ $NetBSD: chmod.1,v 1.24 2012/10/22 17:47:06 christos Exp $ .\ .\ Copyright (c) 1989, 1990, 1993, 1994 .\ The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\ .\ @(#)chmod.1 8.4 (Berkeley) 3/31/94 .\ -.Dd January 22, 2010 +.Dd October 22, 2012 .Dt CHMOD 1 .Os .Sh NAME @@ -47,13 +47,26 @@ .Op Fl fh .Ar mode .Ar +.Nm +.Oo +.Fl R +.Op Fl H | Fl L | Fl P +.Oc +.Op Fl fh +.Fl Fl reference=rfile +.Ar .Sh DESCRIPTION The .Nm utility modifies the file mode bits of the listed files as specified by the .Ar mode -operand. +operand, or +copied from a reference +.Ar rfile , +as specified with the +.Fl Fl reference +argument. .Pp The options are as follows: .Bl -tag -width Ds Index: src/bin/chmod/chmod.c diff -u src/bin/chmod/chmod.c:1.36 src/bin/chmod/chmod.c:1.37 --- src/bin/chmod/chmod.c:1.36 Mon Aug 29 10:51:17 2011 +++ src/bin/chmod/chmod.c Mon Oct 22 13:47:06 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chmod.c,v 1.36 2011/08/29 14:51:17 joerg Exp $ */ +/* $NetBSD: chmod.c,v 1.37 2012/10/22 17:47:06 christos Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -40,7 +40,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = @(#)chmod.c 8.8 (Berkeley) 4/1/94; #else -__RCSID($NetBSD: chmod.c,v 1.36 2011/08/29 14:51:17 joerg Exp $); +__RCSID($NetBSD: chmod.c,v 1.37 2012/10/22 17:47:06 christos Exp $); #endif #endif /* not lint */ @@ -57,25 +57,39 @@ __RCSID($NetBSD: chmod.c,v 1.36 2011/08 #include stdlib.h #include string.h #include unistd.h +#include getopt.h __dead static void usage(void); +struct option chmod_longopts[] = { + { reference, required_argument, 0, + 1 }, + { NULL, 0, 0, + 0 }, +}; + int main(int argc, char *argv[]) { FTS *ftsp; FTSENT *p; - mode_t *set; + void *set; + mode_t mval; int Hflag, Lflag, Rflag, ch, fflag, fts_options, hflag, rval; - char *mode; + char *mode, *reference; int (*change_mode)(const char *, mode_t); setprogname(argv[0]); (void)setlocale(LC_ALL, ); Hflag = Lflag = Rflag = fflag = hflag = 0; - while ((ch = getopt(argc, argv, HLPRXfghorstuwx)) != -1) + reference = NULL; + while ((ch = getopt_long(argc, argv, HLPRXfghorstuwx, + chmod_longopts, NULL)) != -1) switch (ch) { + case 1: + reference = optarg; + break; case 'H': Hflag = 1; Lflag = 0; @@ -124,7 +138,7 @@ main(int argc, char *argv[]) done: argv += optind; argc -= optind; - if (argc 2) + if (argc 2 (argc 1 reference == NULL)) usage(); fts_options = FTS_PHYSICAL; @@ -147,13 +161,23 @@ done: argv += optind; else change_mode = chmod; - mode = *argv; - if ((set = setmode(mode)) == NULL) { - err(EXIT_FAILURE, Cannot set file mode `%s', mode); - /* NOTREACHED */ + if (reference == NULL) { + mode = *argv++; + if ((set = setmode(mode)) == NULL) { + err(EXIT_FAILURE, Cannot set file mode `%s', mode); + /* NOTREACHED */ + } + mval = 0; + } else { + struct stat st; + + if (stat(reference, st) == -1) + err(EXIT_FAILURE, Cannot stat `%s', reference); + mval = st.st_mode; + set = NULL; } - if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL) { + if ((ftsp = fts_open(argv, fts_options, 0)) == NULL) { err(EXIT_FAILURE, fts_open); /* NOTREACHED */ } @@ -189,7 +213,8 @@ done: argv += optind; break; } if ((*change_mode)(p-fts_accpath, - getmode(set, p-fts_statp-st_mode)) !fflag) { + set ? getmode(set, p-fts_statp-st_mode) : mval) + !fflag) { warn(%s, p-fts_path); rval = 1; } @@ -206,8 +231,9 @@ static void usage(void) { (void)fprintf(stderr, - usage: %s [-R [-H | -L | -P]] [-fh] mode file ...\n, - getprogname()); + Usage: %s [-R [-H | -L | -P]] [-fh] mode file ...\n + \t%s [-R [-H | -L | -P]] [-fh] --reference=rfile file ...\n, + getprogname(), getprogname()); exit(1); /* NOTREACHED */ }
CVS commit: src/bin/chmod
Module Name:src Committed By: christos Date: Mon Oct 22 18:00:46 UTC 2012 Modified Files: src/bin/chmod: chmod.c Log Message: fix argument parsing. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/bin/chmod/chmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/chmod/chmod.c diff -u src/bin/chmod/chmod.c:1.37 src/bin/chmod/chmod.c:1.38 --- src/bin/chmod/chmod.c:1.37 Mon Oct 22 13:47:06 2012 +++ src/bin/chmod/chmod.c Mon Oct 22 14:00:46 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chmod.c,v 1.37 2012/10/22 17:47:06 christos Exp $ */ +/* $NetBSD: chmod.c,v 1.38 2012/10/22 18:00:46 christos Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -40,7 +40,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = @(#)chmod.c 8.8 (Berkeley) 4/1/94; #else -__RCSID($NetBSD: chmod.c,v 1.37 2012/10/22 17:47:06 christos Exp $); +__RCSID($NetBSD: chmod.c,v 1.38 2012/10/22 18:00:46 christos Exp $); #endif #endif /* not lint */ @@ -138,7 +138,7 @@ main(int argc, char *argv[]) done: argv += optind; argc -= optind; - if (argc 2 (argc 1 reference == NULL)) + if (argc == 0 || (argc == 1 reference == NULL)) usage(); fts_options = FTS_PHYSICAL;
CVS commit: src/bin/chmod
Module Name:src Committed By: christos Date: Mon Oct 22 17:47:06 UTC 2012 Modified Files: src/bin/chmod: chmod.1 chmod.c Log Message: add --reference=rfile To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/bin/chmod/chmod.1 cvs rdiff -u -r1.36 -r1.37 src/bin/chmod/chmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/chmod
Module Name:src Committed By: christos Date: Mon Oct 22 18:00:46 UTC 2012 Modified Files: src/bin/chmod: chmod.c Log Message: fix argument parsing. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/bin/chmod/chmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/chmod
Module Name:src Committed By: snj Date: Fri Jan 22 05:41:36 UTC 2010 Modified Files: src/bin/chmod: chmod.1 chmod.c Log Message: Document -f. From Andreas Wiese in PR bin/35409, slightly modified. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/bin/chmod/chmod.1 cvs rdiff -u -r1.34 -r1.35 src/bin/chmod/chmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/chmod
Module Name:src Committed By: snj Date: Fri Jan 22 05:41:36 UTC 2010 Modified Files: src/bin/chmod: chmod.1 chmod.c Log Message: Document -f. From Andreas Wiese in PR bin/35409, slightly modified. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/bin/chmod/chmod.1 cvs rdiff -u -r1.34 -r1.35 src/bin/chmod/chmod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/chmod/chmod.1 diff -u src/bin/chmod/chmod.1:1.22 src/bin/chmod/chmod.1:1.23 --- src/bin/chmod/chmod.1:1.22 Tue Mar 24 00:10:58 2009 +++ src/bin/chmod/chmod.1 Fri Jan 22 05:41:36 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: chmod.1,v 1.22 2009/03/24 00:10:58 joerg Exp $ +.\ $NetBSD: chmod.1,v 1.23 2010/01/22 05:41:36 snj Exp $ .\ .\ Copyright (c) 1989, 1990, 1993, 1994 .\ The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\ .\ @(#)chmod.1 8.4 (Berkeley) 3/31/94 .\ -.Dd December 9, 2005 +.Dd January 22, 2010 .Dt CHMOD 1 .Os .Sh NAME @@ -44,7 +44,7 @@ .Fl R .Op Fl H | Fl L | Fl P .Oc -.Op Fl h +.Op Fl fh .Ar mode .Ar .Sh DESCRIPTION @@ -73,6 +73,10 @@ .It Fl R Change the modes of the file hierarchies rooted in the files instead of just the files themselves. +.It Fl f +Do not display a diagnostic message or modify the exit status if +.Nm +fails to change the mode of a file. .It Fl h If .Ar file Index: src/bin/chmod/chmod.c diff -u src/bin/chmod/chmod.c:1.34 src/bin/chmod/chmod.c:1.35 --- src/bin/chmod/chmod.c:1.34 Sun Jul 20 00:52:39 2008 +++ src/bin/chmod/chmod.c Fri Jan 22 05:41:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: chmod.c,v 1.34 2008/07/20 00:52:39 lukem Exp $ */ +/* $NetBSD: chmod.c,v 1.35 2010/01/22 05:41:36 snj Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = @(#)chmod.c 8.8 (Berkeley) 4/1/94; #else -__RCSID($NetBSD: chmod.c,v 1.34 2008/07/20 00:52:39 lukem Exp $); +__RCSID($NetBSD: chmod.c,v 1.35 2010/01/22 05:41:36 snj Exp $); #endif #endif /* not lint */ @@ -91,7 +91,7 @@ case 'R': Rflag = 1; break; - case 'f': /* XXX: undocumented. */ + case 'f': fflag = 1; break; case 'h': @@ -207,7 +207,7 @@ usage(void) { (void)fprintf(stderr, - usage: %s [-R [-H | -L | -P]] [-h] mode file ...\n, + usage: %s [-R [-H | -L | -P]] [-fh] mode file ...\n, getprogname()); exit(1); /* NOTREACHED */