FreeBSD Bugzilla – Attachment 144693 Details for
Bug 191884
[PATCH] teach chown and chmod about SIGINFO
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to add siginfo support to chmod and chgrp.
chfoo-siginfo.patch (text/plain), 3.51 KB, created by
Dan McGregor
on 2014-07-15 18:45:57 UTC
(
hide
)
Description:
Patch to add siginfo support to chmod and chgrp.
Filename:
MIME Type:
Creator:
Dan McGregor
Created:
2014-07-15 18:45:57 UTC
Size:
3.51 KB
patch
obsolete
>Index: usr.sbin/chown/chown.c >=================================================================== >--- usr.sbin/chown/chown.c (révision 268671) >+++ usr.sbin/chown/chown.c (copie de travail) >@@ -62,12 +62,21 @@ > static void chownerr(const char *); > static uid_t id(const char *, const char *); > static void usage(void); >+static void verbose(const FTSENT *, int); > > static uid_t uid; > static gid_t gid; > static int ischown; > static const char *gname; >+static volatile sig_atomic_t siginfo; > >+static void >+siginfo_handler(int sig __unused) >+{ >+ >+ siginfo = 1; >+} >+ > int > main(int argc, char **argv) > { >@@ -118,6 +127,8 @@ > if (argc < 2) > usage(); > >+ (void)signal(SIGINFO, siginfo_handler); >+ > if (Rflag) { > fts_options = FTS_PHYSICAL; > if (hflag && (Hflag || Lflag)) >@@ -184,6 +195,10 @@ > default: > break; > } >+ if (siginfo) { >+ verbose(p, 2); >+ siginfo = 0; >+ } > if ((uid == (uid_t)-1 || uid == p->fts_statp->st_uid) && > (gid == (gid_t)-1 || gid == p->fts_statp->st_gid)) > continue; >@@ -194,33 +209,7 @@ > } > } else { > 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"); >+ verbose(p, vflag); > } > } > } >@@ -313,3 +302,36 @@ > "usage: chgrp [-fhvx] [-R [-H | -L | -P]] group file ..."); > exit(1); > } >+ >+static void >+verbose(const FTSENT *p, int 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"); >+} >Index: bin/chmod/chmod.c >=================================================================== >--- bin/chmod/chmod.c (révision 268671) >+++ bin/chmod/chmod.c (copie de travail) >@@ -53,9 +53,18 @@ > #include <string.h> > #include <unistd.h> > >+static volatile sig_atomic_t siginfo; >+ > static void usage(void); > static int may_have_nfs4acl(const FTSENT *ent, int hflag); > >+static void >+siginfo_handler(int sig __unused) >+{ >+ >+ siginfo = 1; >+} >+ > int > main(int argc, char *argv[]) > { >@@ -125,6 +134,8 @@ > if (argc < 2) > usage(); > >+ (void)signal(SIGINFO, siginfo_handler); >+ > if (Rflag) { > fts_options = FTS_PHYSICAL; > if (hflag) >@@ -192,10 +203,10 @@ > rval = 1; > } > } else { >- if (vflag) { >+ if (vflag || siginfo) { > (void)printf("%s", p->fts_path); > >- if (vflag > 1) { >+ if (vflag > 1 || siginfo) { > char m1[12], m2[12]; > > strmode(p->fts_statp->st_mode, m1); >@@ -207,6 +218,8 @@ > newmode, m2); > } > (void)printf("\n"); >+ >+ siginfo = 0; > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 191884
:
144693
|
144710
|
144711