FreeBSD Bugzilla – Attachment 162274 Details for
Bug 203918
[patch] sysctl -t to display field types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
sysctl -t patch
sysctl-t.diff (text/plain), 3.25 KB, created by
ota
on 2015-10-21 07:58:38 UTC
(
hide
)
Description:
sysctl -t patch
Filename:
MIME Type:
Creator:
ota
Created:
2015-10-21 07:58:38 UTC
Size:
3.25 KB
patch
obsolete
>Index: sbin/sysctl/sysctl.8 >=================================================================== >--- sbin/sysctl/sysctl.8 (revision 289605) >+++ sbin/sysctl/sysctl.8 (working copy) >@@ -36,13 +36,13 @@ > .Nd get or set kernel state > .Sh SYNOPSIS > .Nm >-.Op Fl bdehiNnoRTqx >+.Op Fl bdehiNnoRTtqx > .Op Fl B Ar bufsize > .Op Fl f Ar filename > .Ar name Ns Op = Ns Ar value > .Ar ... > .Nm >-.Op Fl bdehNnoRTqx >+.Op Fl bdehNnoRTtqx > .Op Fl B Ar bufsize > .Fl a > .Sh DESCRIPTION >@@ -140,6 +140,8 @@ > to standard error. > .It Fl T > Display only variables that are settable via loader (CTLFLAG_TUN). >+.It Fl t >+Print the type of the variable. > .It Fl W > Display only writable variables that are not statistical. > Useful for determining the set of runtime tunable sysctls. >Index: sbin/sysctl/sysctl.c >=================================================================== >--- sbin/sysctl/sysctl.c (revision 289605) >+++ sbin/sysctl/sysctl.c (working copy) >@@ -72,7 +72,7 @@ > static const char *conffile; > > static int aflag, bflag, Bflag, dflag, eflag, hflag, iflag; >-static int Nflag, nflag, oflag, qflag, Tflag, Wflag, xflag; >+static int Nflag, nflag, oflag, qflag, tflag, Tflag, Wflag, xflag; > > static int oidfmt(int *, int, char *, u_int *); > static int parsefile(const char *); >@@ -105,6 +105,9 @@ > [CTLTYPE_ULONG] = "unsigned long", > [CTLTYPE_S64] = "int64_t", > [CTLTYPE_U64] = "uint64_t", >+ [CTLTYPE_NODE] = "node", >+ [CTLTYPE_STRING] = "string", >+ [CTLTYPE_OPAQUE] = "opaque", > }; > > static void >@@ -112,8 +115,8 @@ > { > > (void)fprintf(stderr, "%s\n%s\n", >- "usage: sysctl [-bdehiNnoqTWx] [ -B <bufsize> ] [-f filename] name[=value] ...", >- " sysctl [-bdehNnoqTWx] [ -B <bufsize> ] -a"); >+ "usage: sysctl [-bdehiNnoqTtWx] [ -B <bufsize> ] [-f filename] name[=value] ...", >+ " sysctl [-bdehNnoqTtWx] [ -B <bufsize> ] -a"); > exit(1); > } > >@@ -127,7 +130,7 @@ > setbuf(stdout,0); > setbuf(stderr,0); > >- while ((ch = getopt(argc, argv, "AabB:def:hiNnoqTwWxX")) != -1) { >+ while ((ch = getopt(argc, argv, "AabB:def:hiNnoqtTwWxX")) != -1) { > switch (ch) { > case 'A': > /* compatibility */ >@@ -169,6 +172,9 @@ > case 'q': > qflag = 1; > break; >+ case 't': >+ tflag = 1; >+ break; > case 'T': > Tflag = 1; > break; >@@ -795,7 +801,7 @@ > { > u_char buf[BUFSIZ], *val, *oval, *p; > char name[BUFSIZ], fmt[BUFSIZ]; >- const char *sep, *sep1; >+ const char *sep, *sep1, *prntype; > int qoid[CTL_MAXNAME+2]; > uintmax_t umv; > intmax_t mv; >@@ -841,12 +847,21 @@ > else > sep = ": "; > >- if (dflag) { /* just print description */ >+ ctltype = (kind & CTLTYPE); >+ if (tflag || dflag) { /* just print type and/or description */ >+ if (!nflag) >+ printf("%s%s", name, sep); >+ prntype = ctl_typename[ctltype] ? >+ ctl_typename[ctltype] : "unknown"; >+ if (tflag && dflag) /* print type and description */ >+ printf("%s%s", prntype, sep); >+ else if (tflag) { /* print type only */ >+ printf("%s", prntype); >+ return (0); >+ } > 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); > } >@@ -864,7 +879,6 @@ > warnx("malloc failed"); > return (1); > } >- ctltype = (kind & CTLTYPE); > len = j; > i = sysctl(oid, nlen, val, &len, 0, 0); > if (i != 0 || (len == 0 && ctltype != CTLTYPE_STRING)) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 203918
: 162274