chflags(1): obey siginfo request on chflagsat(2) failure
Note that the error diagnostic can now be printed both to stderr due to the absence of the -f flag and to stdout due to SIGINFO simultaneously. Noted and reviewed by: jrtc27 Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
30c741c6e4
commit
2954af09f1
|
@ -61,7 +61,7 @@ main(int argc, char *argv[])
|
||||||
u_long clear, newflags, set;
|
u_long clear, newflags, set;
|
||||||
long val;
|
long val;
|
||||||
int Hflag, Lflag, Rflag, fflag, hflag, vflag, xflag;
|
int Hflag, Lflag, Rflag, fflag, hflag, vflag, xflag;
|
||||||
int ch, fts_options, oct, rval;
|
int ch, e, fts_options, oct, rval;
|
||||||
char *flags, *ep;
|
char *flags, *ep;
|
||||||
|
|
||||||
Hflag = Lflag = Rflag = fflag = hflag = vflag = xflag = 0;
|
Hflag = Lflag = Rflag = fflag = hflag = vflag = xflag = 0;
|
||||||
|
@ -183,10 +183,16 @@ main(int argc, char *argv[])
|
||||||
continue;
|
continue;
|
||||||
if (chflagsat(AT_FDCWD, p->fts_accpath, newflags,
|
if (chflagsat(AT_FDCWD, p->fts_accpath, newflags,
|
||||||
atflag) == -1) {
|
atflag) == -1) {
|
||||||
|
e = errno;
|
||||||
if (!fflag) {
|
if (!fflag) {
|
||||||
warn("%s", p->fts_path);
|
warnc(e, "%s", p->fts_path);
|
||||||
rval = 1;
|
rval = 1;
|
||||||
}
|
}
|
||||||
|
if (siginfo) {
|
||||||
|
(void)printf("%s: %s\n", p->fts_path,
|
||||||
|
strerror(e));
|
||||||
|
siginfo = 0;
|
||||||
|
}
|
||||||
} else if (vflag || siginfo) {
|
} else if (vflag || siginfo) {
|
||||||
(void)printf("%s", p->fts_path);
|
(void)printf("%s", p->fts_path);
|
||||||
if (vflag > 1 || siginfo)
|
if (vflag > 1 || siginfo)
|
||||||
|
|
Loading…
Reference in New Issue