chmod: Add SIGINFO handler
PR: 191884 Submitted by: Dan McGregor <dan.mcgregor at usask.ca> Reviewed by: mjg@ (earlier version)
This commit is contained in:
parent
8436bcc87d
commit
a758566cb8
@ -32,7 +32,7 @@
|
|||||||
.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
|
.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd April 20, 2015
|
.Dd January 7, 2017
|
||||||
.Dt CHMOD 1
|
.Dt CHMOD 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -106,6 +106,16 @@ option is specified.
|
|||||||
In addition, these options override each other and the
|
In addition, these options override each other and the
|
||||||
command's actions are determined by the last one specified.
|
command's actions are determined by the last one specified.
|
||||||
.Pp
|
.Pp
|
||||||
|
If
|
||||||
|
.Nm
|
||||||
|
receives a
|
||||||
|
.Dv SIGINFO
|
||||||
|
signal (see the
|
||||||
|
.Cm status
|
||||||
|
argument for
|
||||||
|
.Xr stty 1 ) ,
|
||||||
|
then the current filename as well as the old and new modes are displayed.
|
||||||
|
.Pp
|
||||||
Only the owner of a file or the super-user is permitted to change
|
Only the owner of a file or the super-user is permitted to change
|
||||||
the mode of a file.
|
the mode of a file.
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
|
@ -49,14 +49,24 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fts.h>
|
#include <fts.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
static volatile sig_atomic_t siginfo;
|
||||||
|
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
static int may_have_nfs4acl(const FTSENT *ent, int hflag);
|
static int may_have_nfs4acl(const FTSENT *ent, int hflag);
|
||||||
|
|
||||||
|
static void
|
||||||
|
siginfo_handler(int sig __unused)
|
||||||
|
{
|
||||||
|
|
||||||
|
siginfo = 1;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -125,6 +135,8 @@ done: argv += optind;
|
|||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
(void)signal(SIGINFO, siginfo_handler);
|
||||||
|
|
||||||
if (Rflag) {
|
if (Rflag) {
|
||||||
if (hflag)
|
if (hflag)
|
||||||
errx(1, "the -R and -h options may not be "
|
errx(1, "the -R and -h options may not be "
|
||||||
@ -192,10 +204,10 @@ done: argv += optind;
|
|||||||
&& !fflag) {
|
&& !fflag) {
|
||||||
warn("%s", p->fts_path);
|
warn("%s", p->fts_path);
|
||||||
rval = 1;
|
rval = 1;
|
||||||
} else if (vflag) {
|
} else if (vflag || siginfo) {
|
||||||
(void)printf("%s", p->fts_path);
|
(void)printf("%s", p->fts_path);
|
||||||
|
|
||||||
if (vflag > 1) {
|
if (vflag > 1 || siginfo) {
|
||||||
char m1[12], m2[12];
|
char m1[12], m2[12];
|
||||||
|
|
||||||
strmode(p->fts_statp->st_mode, m1);
|
strmode(p->fts_statp->st_mode, m1);
|
||||||
@ -207,6 +219,7 @@ done: argv += optind;
|
|||||||
newmode, m2);
|
newmode, m2);
|
||||||
}
|
}
|
||||||
(void)printf("\n");
|
(void)printf("\n");
|
||||||
|
siginfo = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errno)
|
if (errno)
|
||||||
|
Loading…
Reference in New Issue
Block a user