diff options
| author | Luigi Rizzo <luigi@FreeBSD.org> | 2001-12-16 02:55:41 +0000 |
|---|---|---|
| committer | Luigi Rizzo <luigi@FreeBSD.org> | 2001-12-16 02:55:41 +0000 |
| commit | 6105f815658a08bdf488d8b4ff3a39b59b812660 (patch) | |
| tree | 1989073654ca57877e1de5559db56b11c61e4e7b /sbin/sysctl | |
| parent | 42e82026b79968782f39b2f05c23bc2df1a7173e (diff) | |
Notes
Diffstat (limited to 'sbin/sysctl')
| -rw-r--r-- | sbin/sysctl/sysctl.8 | 4 | ||||
| -rw-r--r-- | sbin/sysctl/sysctl.c | 20 |
2 files changed, 19 insertions, 5 deletions
diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8 index f6c1bb9e7307e..ec2e0540acb42 100644 --- a/sbin/sysctl/sysctl.8 +++ b/sbin/sysctl/sysctl.8 @@ -44,7 +44,7 @@ .Ar name Ns Op = Ns Ar value .Ar ... .Nm -.Op Fl beNnox +.Op Fl bdeNnox .Fl a .Sh DESCRIPTION The @@ -71,6 +71,8 @@ the command line. Force the value of the variable(s) to be output in raw, binary format. No names are printed and no terminating newlines are output. This is mostly useful with a single variable. +.It Fl d +Print the description of the variable instead of its value. .It Fl e Separate the name and the value of the variable(s) with .Ql = . diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 5ffb810a4b5bc..eb30b6e0303be 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -58,7 +58,7 @@ static const char rcsid[] = #include <string.h> #include <unistd.h> -static int aflag, bflag, eflag, Nflag, nflag, oflag, xflag; +static int aflag, bflag, dflag, eflag, Nflag, nflag, oflag, xflag; static int oidfmt(int *, int, char *, u_int *); static void parse(char *); @@ -71,8 +71,8 @@ usage(void) { (void)fprintf(stderr, "%s\n%s\n", - "usage: sysctl [-beNnox] variable[=value] ...", - " sysctl [-beNnox] -a"); + "usage: sysctl [-bdeNnox] variable[=value] ...", + " sysctl [-bdeNnox] -a"); exit(1); } @@ -83,7 +83,7 @@ main(int argc, char **argv) setbuf(stdout,0); setbuf(stderr,0); - while ((ch = getopt(argc, argv, "AabeNnowxX")) != -1) { + while ((ch = getopt(argc, argv, "AabdeNnowxX")) != -1) { switch (ch) { case 'A': /* compatibility */ @@ -95,6 +95,9 @@ main(int argc, char **argv) case 'b': bflag = 1; break; + case 'd': + dflag = 1; + break; case 'e': eflag = 1; break; @@ -409,6 +412,15 @@ show_var(int *oid, int nlen) else sep = ": "; + if (dflag) { /* just print description */ + qoid[1] = 5; + j = sizeof(buf); + i = sysctl(qoid, nlen + 2, buf, &j, 0, 0); + if (!nflag) + printf("%s%s", name, sep); + printf("%s", buf); + return (0); + } /* find an estimate of how much we need for this var */ j = 0; i = sysctl(oid, nlen, 0, &j, 0, 0); |
