View | Details | Raw Unified | Return to bug 203918
Collapse All | Expand All

(-)sbin/sysctl/sysctl.8 (-2 / +4 lines)
Lines 36-48 Link Here
36
.Nd get or set kernel state
36
.Nd get or set kernel state
37
.Sh SYNOPSIS
37
.Sh SYNOPSIS
38
.Nm
38
.Nm
39
.Op Fl bdehiNnoRTqx
39
.Op Fl bdehiNnoRTtqx
40
.Op Fl B Ar bufsize
40
.Op Fl B Ar bufsize
41
.Op Fl f Ar filename
41
.Op Fl f Ar filename
42
.Ar name Ns Op = Ns Ar value
42
.Ar name Ns Op = Ns Ar value
43
.Ar ...
43
.Ar ...
44
.Nm
44
.Nm
45
.Op Fl bdehNnoRTqx
45
.Op Fl bdehNnoRTtqx
46
.Op Fl B Ar bufsize
46
.Op Fl B Ar bufsize
47
.Fl a
47
.Fl a
48
.Sh DESCRIPTION
48
.Sh DESCRIPTION
Lines 140-145 Link Here
140
to standard error.
140
to standard error.
141
.It Fl T
141
.It Fl T
142
Display only variables that are settable via loader (CTLFLAG_TUN).
142
Display only variables that are settable via loader (CTLFLAG_TUN).
143
.It Fl t
144
Print the type of the variable.
143
.It Fl W
145
.It Fl W
144
Display only writable variables that are not statistical.
146
Display only writable variables that are not statistical.
145
Useful for determining the set of runtime tunable sysctls.
147
Useful for determining the set of runtime tunable sysctls.
(-)sbin/sysctl/sysctl.c (-9 / +23 lines)
Lines 72-78 Link Here
72
static const char *conffile;
72
static const char *conffile;
73
73
74
static int	aflag, bflag, Bflag, dflag, eflag, hflag, iflag;
74
static int	aflag, bflag, Bflag, dflag, eflag, hflag, iflag;
75
static int	Nflag, nflag, oflag, qflag, Tflag, Wflag, xflag;
75
static int	Nflag, nflag, oflag, qflag, tflag, Tflag, Wflag, xflag;
76
76
77
static int	oidfmt(int *, int, char *, u_int *);
77
static int	oidfmt(int *, int, char *, u_int *);
78
static int	parsefile(const char *);
78
static int	parsefile(const char *);
Lines 105-110 Link Here
105
	[CTLTYPE_ULONG] = "unsigned long",
105
	[CTLTYPE_ULONG] = "unsigned long",
106
	[CTLTYPE_S64] = "int64_t",
106
	[CTLTYPE_S64] = "int64_t",
107
	[CTLTYPE_U64] = "uint64_t",
107
	[CTLTYPE_U64] = "uint64_t",
108
	[CTLTYPE_NODE] = "node",
109
	[CTLTYPE_STRING] = "string",
110
	[CTLTYPE_OPAQUE] = "opaque",
108
};
111
};
109
112
110
static void
113
static void
Lines 112-119 Link Here
112
{
115
{
113
116
114
	(void)fprintf(stderr, "%s\n%s\n",
117
	(void)fprintf(stderr, "%s\n%s\n",
115
	    "usage: sysctl [-bdehiNnoqTWx] [ -B <bufsize> ] [-f filename] name[=value] ...",
118
	    "usage: sysctl [-bdehiNnoqTtWx] [ -B <bufsize> ] [-f filename] name[=value] ...",
116
	    "       sysctl [-bdehNnoqTWx] [ -B <bufsize> ] -a");
119
	    "       sysctl [-bdehNnoqTtWx] [ -B <bufsize> ] -a");
117
	exit(1);
120
	exit(1);
118
}
121
}
119
122
Lines 127-133 Link Here
127
	setbuf(stdout,0);
130
	setbuf(stdout,0);
128
	setbuf(stderr,0);
131
	setbuf(stderr,0);
129
132
130
	while ((ch = getopt(argc, argv, "AabB:def:hiNnoqTwWxX")) != -1) {
133
	while ((ch = getopt(argc, argv, "AabB:def:hiNnoqtTwWxX")) != -1) {
131
		switch (ch) {
134
		switch (ch) {
132
		case 'A':
135
		case 'A':
133
			/* compatibility */
136
			/* compatibility */
Lines 169-174 Link Here
169
		case 'q':
172
		case 'q':
170
			qflag = 1;
173
			qflag = 1;
171
			break;
174
			break;
175
		case 't':
176
			tflag = 1;
177
			break;
172
		case 'T':
178
		case 'T':
173
			Tflag = 1;
179
			Tflag = 1;
174
			break;
180
			break;
Lines 795-801 Link Here
795
{
801
{
796
	u_char buf[BUFSIZ], *val, *oval, *p;
802
	u_char buf[BUFSIZ], *val, *oval, *p;
797
	char name[BUFSIZ], fmt[BUFSIZ];
803
	char name[BUFSIZ], fmt[BUFSIZ];
798
	const char *sep, *sep1;
804
	const char *sep, *sep1, *prntype;
799
	int qoid[CTL_MAXNAME+2];
805
	int qoid[CTL_MAXNAME+2];
800
	uintmax_t umv;
806
	uintmax_t umv;
801
	intmax_t mv;
807
	intmax_t mv;
Lines 841-852 Link Here
841
	else
847
	else
842
		sep = ": ";
848
		sep = ": ";
843
849
844
	if (dflag) {	/* just print description */
850
	ctltype = (kind & CTLTYPE);
851
	if (tflag || dflag) {	/* just print type and/or description */
852
		if (!nflag)
853
			printf("%s%s", name, sep);
854
		prntype = ctl_typename[ctltype] ?
855
			ctl_typename[ctltype] : "unknown";
856
		if (tflag && dflag) /* print type and description */
857
			printf("%s%s", prntype, sep);
858
		else if (tflag) {	/* print type only */
859
			printf("%s", prntype);
860
			return (0);
861
		}
845
		qoid[1] = 5;
862
		qoid[1] = 5;
846
		j = sizeof(buf);
863
		j = sizeof(buf);
847
		i = sysctl(qoid, nlen + 2, buf, &j, 0, 0);
864
		i = sysctl(qoid, nlen + 2, buf, &j, 0, 0);
848
		if (!nflag)
849
			printf("%s%s", name, sep);
850
		printf("%s", buf);
865
		printf("%s", buf);
851
		return (0);
866
		return (0);
852
	}
867
	}
Lines 864-870 Link Here
864
		warnx("malloc failed");
879
		warnx("malloc failed");
865
		return (1);
880
		return (1);
866
	}
881
	}
867
	ctltype = (kind & CTLTYPE);
868
	len = j;
882
	len = j;
869
	i = sysctl(oid, nlen, val, &len, 0, 0);
883
	i = sysctl(oid, nlen, val, &len, 0, 0);
870
	if (i != 0 || (len == 0 && ctltype != CTLTYPE_STRING)) {
884
	if (i != 0 || (len == 0 && ctltype != CTLTYPE_STRING)) {

Return to bug 203918