From ae29e30076cd8807e15927bd7f32724964c1b862 Mon Sep 17 00:00:00 2001 From: Johan Karlsson Date: Fri, 25 Apr 2003 08:57:55 +0000 Subject: [PATCH] Similar to chmod(1); make -v -v mean very verbose and show the old and new uid/gid. PR: 41341 Submitted by: Edward Brocklesby Reviewed by: bde@ (an older version) --- usr.sbin/chown/Makefile | 2 +- usr.sbin/chown/chgrp.1 | 7 ++++++- usr.sbin/chown/chown.8 | 7 ++++++- usr.sbin/chown/chown.c | 34 +++++++++++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/usr.sbin/chown/Makefile b/usr.sbin/chown/Makefile index 017ed610a937..63c5a22f05da 100644 --- a/usr.sbin/chown/Makefile +++ b/usr.sbin/chown/Makefile @@ -5,6 +5,6 @@ PROG= chown LINKS= ${BINDIR}/chown /usr/bin/chgrp MAN= chgrp.1 chown.8 -WARNS?= 2 +WARNS?= 5 .include diff --git a/usr.sbin/chown/chgrp.1 b/usr.sbin/chown/chgrp.1 index b52f7e557a43..c8d6d5ff7751 100644 --- a/usr.sbin/chown/chgrp.1 +++ b/usr.sbin/chown/chgrp.1 @@ -35,7 +35,7 @@ .\" @(#)chgrp.1 8.3 (Berkeley) 3/31/94 .\" $FreeBSD$ .\" -.Dd March 31, 1994 +.Dd April 25, 2003 .Dt CHGRP 1 .Os .Sh NAME @@ -88,6 +88,11 @@ rather than the file that is pointed to. Cause .Nm to be verbose, showing files as the group is modified. +If the +.Fl v +flag is specified more than once, +.Nm +will print the filename, followed by the old and new numeric group ID. .El .Pp The diff --git a/usr.sbin/chown/chown.8 b/usr.sbin/chown/chown.8 index 364ac883f050..c7718b6dcde6 100644 --- a/usr.sbin/chown/chown.8 +++ b/usr.sbin/chown/chown.8 @@ -32,7 +32,7 @@ .\" @(#)chown.8 8.3 (Berkeley) 3/31/94 .\" $FreeBSD$ .\" -.Dd March 31, 1994 +.Dd April 25, 2003 .Dt CHOWN 8 .Os .Sh NAME @@ -96,6 +96,11 @@ group ID of the link itself. Cause .Nm to be verbose, showing files as the owner is modified. +If the +.Fl v +flag is specified more than once, +.Nm +will print the filename, followed by the old and new numeric user/group ID. .El .Pp The diff --git a/usr.sbin/chown/chown.c b/usr.sbin/chown/chown.c index d737bdb226d9..cf7cb50ca4f5 100644 --- a/usr.sbin/chown/chown.c +++ b/usr.sbin/chown/chown.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -106,7 +107,7 @@ main(int argc, char **argv) hflag = 1; break; case 'v': - vflag = 1; + vflag++; break; case '?': default: @@ -191,8 +192,35 @@ main(int argc, char **argv) rval = 1; } } else { - if (vflag) - printf("%s\n", p->fts_path); + if (vflag) { + printf("%s", p->fts_path); + if (vflag > 1) { + if (ischown) { + printf(": %ju:%ju -> %ju:%ju", + (uintmax_t) + p->fts_statp->st_uid, + (uintmax_t) + p->fts_statp->st_gid, + (uid == (uid_t)-1) ? + (uintmax_t) + p->fts_statp->st_uid : + (uintmax_t)uid, + (gid == (gid_t)-1) ? + (uintmax_t) + p->fts_statp->st_gid : + (uintmax_t)gid); + } else { + printf(": %ju -> %ju", + (uintmax_t) + p->fts_statp->st_gid, + (gid == (gid_t)-1) ? + (uintmax_t) + p->fts_statp->st_gid : + (uintmax_t)gid); + } + } + printf("\n"); + } } } if (errno)