diff options
Diffstat (limited to 'usr.sbin/sysctl')
| -rw-r--r-- | usr.sbin/sysctl/sysctl.8 | 9 | ||||
| -rw-r--r-- | usr.sbin/sysctl/sysctl.c | 60 |
2 files changed, 22 insertions, 47 deletions
diff --git a/usr.sbin/sysctl/sysctl.8 b/usr.sbin/sysctl/sysctl.8 index e959ecd77aff2..455dcaca85a42 100644 --- a/usr.sbin/sysctl/sysctl.8 +++ b/usr.sbin/sysctl/sysctl.8 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93 -.\" $Id: sysctl.8,v 1.17 1998/09/29 02:01:06 jkoshy Exp $ +.\" $Id: sysctl.8,v 1.16 1998/07/29 08:30:37 joerg Exp $ .\" .Dd September 23, 1994 .Dt SYSCTL 8 @@ -40,14 +40,14 @@ .Nd get or set kernel state .Sh SYNOPSIS .Nm sysctl -.Op Fl bdn +.Op Fl bn .Ar name ... .Nm sysctl .Op Fl bn .Fl w .Ar name=value ... .Nm sysctl -.Op Fl bdn +.Op Fl bn .Fl aAX .Sh DESCRIPTION The @@ -85,9 +85,6 @@ set psize=`sysctl -n hw.pagesize` 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 -Display the description rather than the value of the requested -variable(s). .It Fl w Ar name=value ... Set the MIB .Ar name diff --git a/usr.sbin/sysctl/sysctl.c b/usr.sbin/sysctl/sysctl.c index f264409d6b3d1..14247a08c225c 100644 --- a/usr.sbin/sysctl/sysctl.c +++ b/usr.sbin/sysctl/sysctl.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)from: sysctl.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: sysctl.c,v 1.19 1998/11/08 19:27:43 phk Exp $"; + "$Id: sysctl.c,v 1.17 1998/06/29 17:54:29 bde Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -58,7 +58,7 @@ static const char rcsid[] = #include <string.h> #include <unistd.h> -static int Aflag, aflag, bflag, dflag, nflag, wflag, Xflag; +static int Aflag, aflag, nflag, wflag, Xflag, bflag; static int oidfmt(int *, int, char *, u_int *); static void parse(char *); @@ -70,12 +70,11 @@ static void usage(void) { - (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", - "usage: sysctl [-bdn] variable ...", - " sysctl [-bn] -w variable=value ...", - " sysctl [-bdn] -a", - " sysctl [-bdn] -A", - " sysctl [-bdn] -X"); + (void)fprintf(stderr, "%s\n%s\n%s\n%s\n", + "usage: sysctl [-bnX] variable ...", + " sysctl [-bnX] -w variable=value ...", + " sysctl [-bnX] -a", + " sysctl [-bnX] -A"); exit(1); } @@ -86,12 +85,11 @@ main(int argc, char **argv) setbuf(stdout,0); setbuf(stderr,0); - while ((ch = getopt(argc, argv, "AabdnwX")) != -1) { + while ((ch = getopt(argc, argv, "AabnwX")) != -1) { switch (ch) { case 'A': Aflag = 1; break; case 'a': aflag = 1; break; case 'b': bflag = 1; break; - case 'd': dflag = 1; break; case 'n': nflag = 1; break; case 'w': wflag = 1; break; case 'X': Xflag = Aflag = 1; break; @@ -101,8 +99,6 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (wflag && (Aflag || aflag || dflag)) - usage(); if (Aflag || aflag) exit (sysctl_all(0, 0)); if (argc == 0) @@ -340,34 +336,13 @@ static int show_var(int *oid, int nlen) { u_char buf[BUFSIZ], *val, *p; - char name[BUFSIZ], descr[BUFSIZ], *fmt; + char name[BUFSIZ], *fmt; int qoid[CTL_MAXNAME+2]; int i; size_t j, len; u_int kind; int (*func)(int, void *) = 0; - qoid[0] = 0; - memcpy(qoid + 2, oid, nlen * sizeof(int)); - - qoid[1] = 1; - j = sizeof name; - i = sysctl(qoid, nlen + 2, name, &j, 0, 0); - if (i || !j) - err(1, "sysctl name %d %d %d", i, j, errno); - - if (dflag) { - qoid[1] = 5; - j = sizeof descr; - i = sysctl(qoid, nlen + 2, descr, &j, 0, 0); - if (i || !j) - err(1, "sysctl name %d %d %d", i, j, errno); - if (!nflag) - printf("%s: ", name); - printf("%s", descr[0] ? descr : "[no description]"); - return (0); - } - /* find an estimate of how much we need for this var */ j = 0; i = sysctl(oid, nlen, 0, &j, 0, 0); @@ -384,7 +359,10 @@ show_var(int *oid, int nlen) return (0); } + qoid[0] = 0; qoid[1] = 4; + memcpy(qoid + 2, oid, nlen * sizeof(int)); + j = sizeof buf; i = sysctl(qoid, nlen + 2, buf, &j, 0, 0); if (i || !j) @@ -394,6 +372,12 @@ show_var(int *oid, int nlen) fmt = (char *)(buf + sizeof(u_int)); + qoid[1] = 1; + j = sizeof name; + i = sysctl(qoid, nlen + 2, name, &j, 0, 0); + if (i || !j) + err(1, "sysctl name %d %d %d", i, j, errno); + p = val; switch (*fmt) { case 'A': @@ -405,13 +389,7 @@ show_var(int *oid, int nlen) case 'I': if (!nflag) printf("%s: ", name); - val = ""; - while (len >= sizeof(int)) { - printf("%s%d", val, *(int *)p); - val = " "; - len -= sizeof (int); - p += sizeof (int); - } + printf("%d", *(int *)p); return (0); case 'L': |
