Add "-q" argument to sysctl(8), which suppresses a limited set of warnings/
errors generated. In particular, it suppresses "unknown oid" when attempting to get or set a sysctl not present in the kernel. MFC after: 1 week
This commit is contained in:
parent
ca17bccaa1
commit
f93d36fd92
@ -40,7 +40,7 @@
|
|||||||
.Ar name Ns Op = Ns Ar value
|
.Ar name Ns Op = Ns Ar value
|
||||||
.Ar ...
|
.Ar ...
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl bdehNnox
|
.Op Fl bdehNnoqx
|
||||||
.Fl a
|
.Fl a
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
@ -111,6 +111,10 @@ use:
|
|||||||
Show opaque variables (which are normally suppressed).
|
Show opaque variables (which are normally suppressed).
|
||||||
The format and length are printed, as well as a hex dump of the first
|
The format and length are printed, as well as a hex dump of the first
|
||||||
sixteen bytes of the value.
|
sixteen bytes of the value.
|
||||||
|
.It Fl q
|
||||||
|
Suppress some warnings generated by
|
||||||
|
.Nm
|
||||||
|
to standard error.
|
||||||
.It Fl X
|
.It Fl X
|
||||||
Equivalent to
|
Equivalent to
|
||||||
.Fl x a
|
.Fl x a
|
||||||
|
@ -60,7 +60,8 @@ static const char rcsid[] =
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag, xflag;
|
static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag;
|
||||||
|
static int qflag, xflag;
|
||||||
|
|
||||||
static int oidfmt(int *, int, char *, u_int *);
|
static int oidfmt(int *, int, char *, u_int *);
|
||||||
static void parse(char *);
|
static void parse(char *);
|
||||||
@ -89,7 +90,7 @@ main(int argc, char **argv)
|
|||||||
setbuf(stdout,0);
|
setbuf(stdout,0);
|
||||||
setbuf(stderr,0);
|
setbuf(stderr,0);
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "AabdehNnowxX")) != -1) {
|
while ((ch = getopt(argc, argv, "AabdehNnoqwxX")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'A':
|
case 'A':
|
||||||
/* compatibility */
|
/* compatibility */
|
||||||
@ -119,6 +120,9 @@ main(int argc, char **argv)
|
|||||||
case 'o':
|
case 'o':
|
||||||
oflag = 1;
|
oflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
qflag = 1;
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
/* compatibility */
|
/* compatibility */
|
||||||
/* ignored */
|
/* ignored */
|
||||||
@ -181,8 +185,12 @@ parse(char *string)
|
|||||||
}
|
}
|
||||||
len = name2oid(bufp, mib);
|
len = name2oid(bufp, mib);
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0) {
|
||||||
errx(1, "unknown oid '%s'", bufp);
|
if (qflag)
|
||||||
|
exit(1);
|
||||||
|
else
|
||||||
|
errx(1, "unknown oid '%s'", bufp);
|
||||||
|
}
|
||||||
|
|
||||||
if (oidfmt(mib, len, fmt, &kind))
|
if (oidfmt(mib, len, fmt, &kind))
|
||||||
err(1, "couldn't find format of oid '%s'", bufp);
|
err(1, "couldn't find format of oid '%s'", bufp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user