summaryrefslogtreecommitdiffstats
path: root/sbin/sysctl/sysctl.c
diff options
context:
space:
mode:
authorgavin <gavin@FreeBSD.org>2010-01-31 19:33:25 +0000
committergavin <gavin@FreeBSD.org>2010-01-31 19:33:25 +0000
commite367b167d9a57c4707785dd85b02efa0349da230 (patch)
treefb8c7e96537813b77e031ce5301413723c90b0ca /sbin/sysctl/sysctl.c
parentf54e0fab4c381ffac266474cd866b849f62dce62 (diff)
downloadFreeBSD-src-e367b167d9a57c4707785dd85b02efa0349da230.zip
FreeBSD-src-e367b167d9a57c4707785dd85b02efa0349da230.tar.gz
Implement the "-i" option to sysctl(8), to ignore failures while
retrieving individual OIDs. This allows the same list of OIDs to be passed to sysctl(8) across different systems where particular OIDs may not exist, and still get as much information as possible from them. PR: bin/123644 Submitted by: dhw Approved by: ed (mentor) MFC after: 2 weeks
Diffstat (limited to 'sbin/sysctl/sysctl.c')
-rw-r--r--sbin/sysctl/sysctl.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 38c5038..616b4cd 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -58,8 +58,8 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
-static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag;
-static int qflag, xflag, warncount;
+static int aflag, bflag, dflag, eflag, hflag, iflag;
+static int Nflag, nflag, oflag, qflag, xflag, warncount;
static int oidfmt(int *, int, char *, u_int *);
static void parse(char *);
@@ -89,7 +89,7 @@ main(int argc, char **argv)
setbuf(stdout,0);
setbuf(stderr,0);
- while ((ch = getopt(argc, argv, "AabdehNnoqwxX")) != -1) {
+ while ((ch = getopt(argc, argv, "AabdehiNnoqwxX")) != -1) {
switch (ch) {
case 'A':
/* compatibility */
@@ -110,6 +110,9 @@ main(int argc, char **argv)
case 'h':
hflag = 1;
break;
+ case 'i':
+ iflag = 1;
+ break;
case 'N':
Nflag = 1;
break;
@@ -187,6 +190,8 @@ parse(char *string)
len = name2oid(bufp, mib);
if (len < 0) {
+ if (iflag)
+ return;
if (qflag)
exit(1);
else
OpenPOWER on IntegriCloud