Use err(3). Change err(-1,... to err(1,...

This commit is contained in:
Philippe Charnier 1997-10-20 12:53:54 +00:00
parent 0fc00685c3
commit d9b1bc7779
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30602
6 changed files with 172 additions and 164 deletions

View File

@ -32,23 +32,29 @@
*/
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)pathconf.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/unistd.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define PC_NAMES { \
{ 0, 0 }, \
@ -75,13 +81,16 @@ struct list pclist = { pcnames, PC_MAXID };
int Aflag, aflag, nflag, wflag, stdinflag;
int findname __P((char *, char *, char**, struct list *));
void listall __P((char *, struct list *));
void parse __P((char *, char *, int));
static void usage __P((void));
int
main(argc, argv)
int argc;
char *argv[];
{
extern char *optarg;
extern int optind;
char *path;
int ch;
@ -127,6 +136,7 @@ main(argc, argv)
/*
* List all variables known to the system.
*/
void
listall(path, lp)
char *path;
struct list *lp;
@ -146,6 +156,7 @@ listall(path, lp)
* Parse a name into an index.
* Lookup and print out the attribute if it exists.
*/
void
parse(pathname, string, flags)
char *pathname;
char *string;
@ -159,7 +170,7 @@ parse(pathname, string, flags)
if ((indx = findname(string, "top", &bufp, &pclist)) == -1)
return;
if (bufp) {
fprintf(stderr, "name %s in %s is unknown\n", *bufp, string);
warnx("name %s in %s is unknown", *bufp, string);
return;
}
if (stdinflag)
@ -171,18 +182,16 @@ parse(pathname, string, flags)
return;
switch (errno) {
case EOPNOTSUPP:
fprintf(stderr, "%s: value is not available\n", string);
warnx("%s: value is not available", string);
return;
case ENOTDIR:
fprintf(stderr, "%s: specification is incomplete\n",
string);
warnx("%s: specification is incomplete", string);
return;
case ENOMEM:
fprintf(stderr, "%s: type is unknown to this program\n",
string);
warnx("%s: type is unknown to this program", string);
return;
default:
perror(string);
warn("%s", string);
return;
}
}
@ -194,6 +203,7 @@ parse(pathname, string, flags)
/*
* Scan a list of names searching for a particular name.
*/
int
findname(string, level, bufp, namelist)
char *string;
char *level;
@ -204,7 +214,7 @@ findname(string, level, bufp, namelist)
int i;
if (namelist->list == 0 || (name = strsep(bufp, ".")) == NULL) {
fprintf(stderr, "%s: incomplete specification\n", string);
warnx("%s: incomplete specification", string);
return (-1);
}
for (i = 0; i < namelist->size; i++)
@ -212,18 +222,19 @@ findname(string, level, bufp, namelist)
strcmp(name, namelist->list[i].ctl_name) == 0)
break;
if (i == namelist->size) {
fprintf(stderr, "%s level name %s in %s is invalid\n",
level, name, string);
warnx("%s level name %s in %s is invalid", level, name, string);
return (-1);
}
return (i);
}
static void
usage()
{
(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n",
"pathname [-n] variable ...",
"pathname [-n] -a", "pathname [-n] -A");
(void)fprintf(stderr, "%s\n%s\n%s\n",
"usage: pathname [-n] variable ...",
" pathname [-n] -a",
" pathname [-n] -A");
exit(1);
}

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93
.\" $Id: sysctl.8,v 1.12 1997/02/22 16:13:58 peter Exp $
.\" $Id: sysctl.8,v 1.13 1997/08/30 02:28:00 kato Exp $
.\"
.Dd September 23, 1994
.Dt SYSCTL 8
@ -51,59 +51,55 @@
.Fl aAX
.Sh DESCRIPTION
The
.Nm sysctl
.Nm
utility retrieves kernel state and allows processes with
appropriate privilege to set kernel state.
The state to be retrieved or set is described using a
``Management Information Base'' (``MIB'') style name,
described as a dotted set of components.
.Pp
The
.Fl a
flag can be used to list all the currently available string or integer values.
.Pp
The
.Fl A
flag will list all the known MIB names including opaques.
The following options are available:
.Bl -tag -width indent
.It Fl a
List all the currently available string or integer values.
.It Fl A
List all the known MIB names including opaques.
Those with string or integer values will be printed as with the
.Fl a
flag; for the opaque values,
information about the format and the length is printed in addition the first
few bytes is dumped in hex.
.Pp
The
.Fl X
flag is the same as
.It Fl X
Same as
.Fl A
except the entire value of opaque variables is hexdumped.
.Pp
The
.Fl n
flag specifies that the printing of the field name should be
.It Fl n
Specify that the printing of the field name should be
suppressed and that only its value should be output.
This flag is useful for setting shell variables.
For example, to save the pagesize in variable psize, use:
.Bd -literal -offset indent -compact
set psize=`sysctl -n hw.pagesize`
.Ed
.Pp
The
.Fl b
flag forces the value of the variable(s) to be output in raw, binary
.It Fl b
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.
.Pp
If just a MIB style name is given,
.It Fl w Ar name=value ...
Set the MIB
.Ar name
to the new
.Ar value .
If just a MIB style
.Ar name
is given,
the corresponding value is retrieved.
If a value is to be set, the
.Fl w
flag must be specified and the MIB name followed
by an equal sign and the new value to be used.
.El
.Pp
The information available from
.Nm sysctl
.Nm
consists of integers, strings, and opaques.
.Nm sysctl
.Nm Sysctl
only knows about a couple of opaque types, and will resort to hexdumps
for the rest.
The opaque information is much more useful if retrieved by special
@ -179,7 +175,6 @@ privilege can change the value.
.It user.tzname_max integer no
.El
.Sh EXAMPLES
.Pp
For example, to retrieve the maximum number of processes allowed
in the system, one would use the follow request:
.Bd -literal -offset indent -compact
@ -197,7 +192,7 @@ Information about the system clock rate may be obtained with:
sysctl kern.clockrate
.Ed
.Pp
Information about the load average history may be obtained with
Information about the load average history may be obtained with:
.Bd -literal -offset indent -compact
sysctl vm.loadavg
.Ed
@ -227,17 +222,17 @@ definitions for fourth level UDP identifiers
.Sh SEE ALSO
.Xr sysctl 3
.Sh BUGS
.Nm sysctl
.Nm Sysctl
presently exploits an undocumented interface to the kernel
sysctl facility to traverse the sysctl tree and to retrieve format
and name information.
This correct interface is being thought about for the time being.
.Sh HISTORY
.Nm sysctl
.Nm Sysctl
first appeared in
.Bx 4.4 .
.Pp
In
.Fx 2.2
.Nm sysctl
.Fx 2.2 ,
.Nm
was significantly remodeled.

View File

@ -32,15 +32,17 @@
*/
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
/*static char sccsid[] = "From: @(#)sysctl.c 8.1 (Berkeley) 6/6/93"; */
#if 0
static char sccsid[] = "@(#)from: sysctl.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: sysctl.c,v 1.13 1997/03/31 05:11:25 imp Exp $";
"$Id$";
#endif /* not lint */
#include <sys/types.h>
@ -48,12 +50,13 @@ static const char rcsid[] =
#include <sys/sysctl.h>
#include <sys/resource.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <err.h>
#include <unistd.h>
static int Aflag, aflag, nflag, wflag, Xflag, bflag;
@ -67,20 +70,17 @@ static void
usage(void)
{
(void)fprintf(stderr, "usage:\n%s",
"\tsysctl [-bnX] variable ...\n"
"\tsysctl [-bnX] -w variable=value ...\n"
"\tsysctl [-bnX] -a\n"
"\tsysctl [-bnX] -A\n"
);
(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);
}
int
main(int argc, char **argv)
{
extern char *optarg;
extern int optind;
int ch;
setbuf(stdout,0);
setbuf(stderr,0);
@ -127,10 +127,8 @@ parse(char *string)
bufp = buf;
snprintf(buf, BUFSIZ, "%s", string);
if ((cp = strchr(string, '=')) != NULL) {
if (!wflag) {
fprintf(stderr, "Must specify -w to set variables\n");
exit(2);
}
if (!wflag)
errx(2, "must specify -w to set variables");
*strchr(buf, '=') = '\0';
*cp++ = '\0';
while (isspace(*cp))
@ -144,10 +142,10 @@ parse(char *string)
len = name2oid(bufp, mib);
if (len < 0)
errx(1, "Unknown oid '%s'", bufp);
errx(1, "unknown oid '%s'", bufp);
if (oidfmt(mib, len, 0, &kind))
err(1, "Couldn't find format of oid '%s'", bufp);
err(1, "couldn't find format of oid '%s'", bufp);
if (!wflag) {
if ((kind & CTLTYPE) == CTLTYPE_NODE) {
@ -190,16 +188,16 @@ parse(char *string)
putchar('\n');
switch (errno) {
case EOPNOTSUPP:
errx(1, "%s: value is not available\n",
errx(1, "%s: value is not available",
string);
case ENOTDIR:
errx(1, "%s: specification is incomplete\n",
errx(1, "%s: specification is incomplete",
string);
case ENOMEM:
errx(1, "%s: type is unknown to this program\n",
errx(1, "%s: type is unknown to this program",
string);
default:
perror(string);
warn("%s", string);
return;
}
}
@ -221,7 +219,7 @@ S_clockinfo(int l2, void *p)
{
struct clockinfo *ci = (struct clockinfo*)p;
if (l2 != sizeof *ci)
err(-1, "S_clockinfo %d != %d", l2, sizeof *ci);
err(1, "S_clockinfo %d != %d", l2, sizeof *ci);
printf("{ hz = %d, tick = %d, tickadj = %d, profhz = %d, stathz = %d }",
ci->hz, ci->tick, ci->tickadj, ci->profhz, ci->stathz);
return (0);
@ -233,7 +231,7 @@ S_loadavg(int l2, void *p)
struct loadavg *tv = (struct loadavg*)p;
if (l2 != sizeof *tv)
err(-1, "S_loadavg %d != %d", l2, sizeof *tv);
err(1, "S_loadavg %d != %d", l2, sizeof *tv);
printf("{ %.2f %.2f %.2f }",
(double)tv->ldavg[0]/(double)tv->fscale,
@ -249,7 +247,7 @@ S_timeval(int l2, void *p)
char *p1, *p2;
if (l2 != sizeof *tv)
err(-1, "S_timeval %d != %d", l2, sizeof *tv);
err(1, "S_timeval %d != %d", l2, sizeof *tv);
printf("{ sec = %ld, usec = %ld } ",
tv->tv_sec, tv->tv_usec);
p1 = strdup(ctime(&tv->tv_sec));
@ -265,7 +263,7 @@ T_dev_t(int l2, void *p)
{
dev_t *d = (dev_t *)p;
if (l2 != sizeof *d)
err(-1, "T_dev_T %d != %d", l2, sizeof *d);
err(1, "T_dev_T %d != %d", l2, sizeof *d);
printf("{ major = %d, minor = %d }",
major(*d), minor(*d));
return (0);
@ -311,7 +309,7 @@ oidfmt(int *oid, int len, char *fmt, u_int *kind)
j = sizeof buf;
i = sysctl(qoid, len + 2, buf, &j, 0, 0);
if (i)
err(-1, "sysctl fmt %d %d %d", i, j, errno);
err(1, "sysctl fmt %d %d %d", i, j, errno);
if (kind)
*kind = *(u_int *)buf;
@ -362,7 +360,7 @@ show_var(int *oid, int nlen)
j = sizeof buf;
i = sysctl(qoid, nlen + 2, buf, &j, 0, 0);
if (i || !j)
err(-1, "sysctl fmt %d %d %d", i, j, errno);
err(1, "sysctl fmt %d %d %d", i, j, errno);
kind = *(u_int *)buf;
@ -372,7 +370,7 @@ show_var(int *oid, int nlen)
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);
err(1, "sysctl name %d %d %d", i, j, errno);
p = val;
switch (*fmt) {
@ -442,7 +440,7 @@ sysctl_all (int *oid, int len)
if (errno == ENOENT)
return 0;
else
err(-1, "sysctl(getnext) %d %d", j, l2);
err(1, "sysctl(getnext) %d %d", j, l2);
l2 /= sizeof (int);

View File

@ -32,23 +32,29 @@
*/
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)pathconf.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/unistd.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define PC_NAMES { \
{ 0, 0 }, \
@ -75,13 +81,16 @@ struct list pclist = { pcnames, PC_MAXID };
int Aflag, aflag, nflag, wflag, stdinflag;
int findname __P((char *, char *, char**, struct list *));
void listall __P((char *, struct list *));
void parse __P((char *, char *, int));
static void usage __P((void));
int
main(argc, argv)
int argc;
char *argv[];
{
extern char *optarg;
extern int optind;
char *path;
int ch;
@ -127,6 +136,7 @@ main(argc, argv)
/*
* List all variables known to the system.
*/
void
listall(path, lp)
char *path;
struct list *lp;
@ -146,6 +156,7 @@ listall(path, lp)
* Parse a name into an index.
* Lookup and print out the attribute if it exists.
*/
void
parse(pathname, string, flags)
char *pathname;
char *string;
@ -159,7 +170,7 @@ parse(pathname, string, flags)
if ((indx = findname(string, "top", &bufp, &pclist)) == -1)
return;
if (bufp) {
fprintf(stderr, "name %s in %s is unknown\n", *bufp, string);
warnx("name %s in %s is unknown", *bufp, string);
return;
}
if (stdinflag)
@ -171,18 +182,16 @@ parse(pathname, string, flags)
return;
switch (errno) {
case EOPNOTSUPP:
fprintf(stderr, "%s: value is not available\n", string);
warnx("%s: value is not available", string);
return;
case ENOTDIR:
fprintf(stderr, "%s: specification is incomplete\n",
string);
warnx("%s: specification is incomplete", string);
return;
case ENOMEM:
fprintf(stderr, "%s: type is unknown to this program\n",
string);
warnx("%s: type is unknown to this program", string);
return;
default:
perror(string);
warn("%s", string);
return;
}
}
@ -194,6 +203,7 @@ parse(pathname, string, flags)
/*
* Scan a list of names searching for a particular name.
*/
int
findname(string, level, bufp, namelist)
char *string;
char *level;
@ -204,7 +214,7 @@ findname(string, level, bufp, namelist)
int i;
if (namelist->list == 0 || (name = strsep(bufp, ".")) == NULL) {
fprintf(stderr, "%s: incomplete specification\n", string);
warnx("%s: incomplete specification", string);
return (-1);
}
for (i = 0; i < namelist->size; i++)
@ -212,18 +222,19 @@ findname(string, level, bufp, namelist)
strcmp(name, namelist->list[i].ctl_name) == 0)
break;
if (i == namelist->size) {
fprintf(stderr, "%s level name %s in %s is invalid\n",
level, name, string);
warnx("%s level name %s in %s is invalid", level, name, string);
return (-1);
}
return (i);
}
static void
usage()
{
(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n",
"pathname [-n] variable ...",
"pathname [-n] -a", "pathname [-n] -A");
(void)fprintf(stderr, "%s\n%s\n%s\n",
"usage: pathname [-n] variable ...",
" pathname [-n] -a",
" pathname [-n] -A");
exit(1);
}

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93
.\" $Id: sysctl.8,v 1.12 1997/02/22 16:13:58 peter Exp $
.\" $Id: sysctl.8,v 1.13 1997/08/30 02:28:00 kato Exp $
.\"
.Dd September 23, 1994
.Dt SYSCTL 8
@ -51,59 +51,55 @@
.Fl aAX
.Sh DESCRIPTION
The
.Nm sysctl
.Nm
utility retrieves kernel state and allows processes with
appropriate privilege to set kernel state.
The state to be retrieved or set is described using a
``Management Information Base'' (``MIB'') style name,
described as a dotted set of components.
.Pp
The
.Fl a
flag can be used to list all the currently available string or integer values.
.Pp
The
.Fl A
flag will list all the known MIB names including opaques.
The following options are available:
.Bl -tag -width indent
.It Fl a
List all the currently available string or integer values.
.It Fl A
List all the known MIB names including opaques.
Those with string or integer values will be printed as with the
.Fl a
flag; for the opaque values,
information about the format and the length is printed in addition the first
few bytes is dumped in hex.
.Pp
The
.Fl X
flag is the same as
.It Fl X
Same as
.Fl A
except the entire value of opaque variables is hexdumped.
.Pp
The
.Fl n
flag specifies that the printing of the field name should be
.It Fl n
Specify that the printing of the field name should be
suppressed and that only its value should be output.
This flag is useful for setting shell variables.
For example, to save the pagesize in variable psize, use:
.Bd -literal -offset indent -compact
set psize=`sysctl -n hw.pagesize`
.Ed
.Pp
The
.Fl b
flag forces the value of the variable(s) to be output in raw, binary
.It Fl b
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.
.Pp
If just a MIB style name is given,
.It Fl w Ar name=value ...
Set the MIB
.Ar name
to the new
.Ar value .
If just a MIB style
.Ar name
is given,
the corresponding value is retrieved.
If a value is to be set, the
.Fl w
flag must be specified and the MIB name followed
by an equal sign and the new value to be used.
.El
.Pp
The information available from
.Nm sysctl
.Nm
consists of integers, strings, and opaques.
.Nm sysctl
.Nm Sysctl
only knows about a couple of opaque types, and will resort to hexdumps
for the rest.
The opaque information is much more useful if retrieved by special
@ -179,7 +175,6 @@ privilege can change the value.
.It user.tzname_max integer no
.El
.Sh EXAMPLES
.Pp
For example, to retrieve the maximum number of processes allowed
in the system, one would use the follow request:
.Bd -literal -offset indent -compact
@ -197,7 +192,7 @@ Information about the system clock rate may be obtained with:
sysctl kern.clockrate
.Ed
.Pp
Information about the load average history may be obtained with
Information about the load average history may be obtained with:
.Bd -literal -offset indent -compact
sysctl vm.loadavg
.Ed
@ -227,17 +222,17 @@ definitions for fourth level UDP identifiers
.Sh SEE ALSO
.Xr sysctl 3
.Sh BUGS
.Nm sysctl
.Nm Sysctl
presently exploits an undocumented interface to the kernel
sysctl facility to traverse the sysctl tree and to retrieve format
and name information.
This correct interface is being thought about for the time being.
.Sh HISTORY
.Nm sysctl
.Nm Sysctl
first appeared in
.Bx 4.4 .
.Pp
In
.Fx 2.2
.Nm sysctl
.Fx 2.2 ,
.Nm
was significantly remodeled.

View File

@ -32,15 +32,17 @@
*/
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
/*static char sccsid[] = "From: @(#)sysctl.c 8.1 (Berkeley) 6/6/93"; */
#if 0
static char sccsid[] = "@(#)from: sysctl.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: sysctl.c,v 1.13 1997/03/31 05:11:25 imp Exp $";
"$Id$";
#endif /* not lint */
#include <sys/types.h>
@ -48,12 +50,13 @@ static const char rcsid[] =
#include <sys/sysctl.h>
#include <sys/resource.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <err.h>
#include <unistd.h>
static int Aflag, aflag, nflag, wflag, Xflag, bflag;
@ -67,20 +70,17 @@ static void
usage(void)
{
(void)fprintf(stderr, "usage:\n%s",
"\tsysctl [-bnX] variable ...\n"
"\tsysctl [-bnX] -w variable=value ...\n"
"\tsysctl [-bnX] -a\n"
"\tsysctl [-bnX] -A\n"
);
(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);
}
int
main(int argc, char **argv)
{
extern char *optarg;
extern int optind;
int ch;
setbuf(stdout,0);
setbuf(stderr,0);
@ -127,10 +127,8 @@ parse(char *string)
bufp = buf;
snprintf(buf, BUFSIZ, "%s", string);
if ((cp = strchr(string, '=')) != NULL) {
if (!wflag) {
fprintf(stderr, "Must specify -w to set variables\n");
exit(2);
}
if (!wflag)
errx(2, "must specify -w to set variables");
*strchr(buf, '=') = '\0';
*cp++ = '\0';
while (isspace(*cp))
@ -144,10 +142,10 @@ parse(char *string)
len = name2oid(bufp, mib);
if (len < 0)
errx(1, "Unknown oid '%s'", bufp);
errx(1, "unknown oid '%s'", bufp);
if (oidfmt(mib, len, 0, &kind))
err(1, "Couldn't find format of oid '%s'", bufp);
err(1, "couldn't find format of oid '%s'", bufp);
if (!wflag) {
if ((kind & CTLTYPE) == CTLTYPE_NODE) {
@ -190,16 +188,16 @@ parse(char *string)
putchar('\n');
switch (errno) {
case EOPNOTSUPP:
errx(1, "%s: value is not available\n",
errx(1, "%s: value is not available",
string);
case ENOTDIR:
errx(1, "%s: specification is incomplete\n",
errx(1, "%s: specification is incomplete",
string);
case ENOMEM:
errx(1, "%s: type is unknown to this program\n",
errx(1, "%s: type is unknown to this program",
string);
default:
perror(string);
warn("%s", string);
return;
}
}
@ -221,7 +219,7 @@ S_clockinfo(int l2, void *p)
{
struct clockinfo *ci = (struct clockinfo*)p;
if (l2 != sizeof *ci)
err(-1, "S_clockinfo %d != %d", l2, sizeof *ci);
err(1, "S_clockinfo %d != %d", l2, sizeof *ci);
printf("{ hz = %d, tick = %d, tickadj = %d, profhz = %d, stathz = %d }",
ci->hz, ci->tick, ci->tickadj, ci->profhz, ci->stathz);
return (0);
@ -233,7 +231,7 @@ S_loadavg(int l2, void *p)
struct loadavg *tv = (struct loadavg*)p;
if (l2 != sizeof *tv)
err(-1, "S_loadavg %d != %d", l2, sizeof *tv);
err(1, "S_loadavg %d != %d", l2, sizeof *tv);
printf("{ %.2f %.2f %.2f }",
(double)tv->ldavg[0]/(double)tv->fscale,
@ -249,7 +247,7 @@ S_timeval(int l2, void *p)
char *p1, *p2;
if (l2 != sizeof *tv)
err(-1, "S_timeval %d != %d", l2, sizeof *tv);
err(1, "S_timeval %d != %d", l2, sizeof *tv);
printf("{ sec = %ld, usec = %ld } ",
tv->tv_sec, tv->tv_usec);
p1 = strdup(ctime(&tv->tv_sec));
@ -265,7 +263,7 @@ T_dev_t(int l2, void *p)
{
dev_t *d = (dev_t *)p;
if (l2 != sizeof *d)
err(-1, "T_dev_T %d != %d", l2, sizeof *d);
err(1, "T_dev_T %d != %d", l2, sizeof *d);
printf("{ major = %d, minor = %d }",
major(*d), minor(*d));
return (0);
@ -311,7 +309,7 @@ oidfmt(int *oid, int len, char *fmt, u_int *kind)
j = sizeof buf;
i = sysctl(qoid, len + 2, buf, &j, 0, 0);
if (i)
err(-1, "sysctl fmt %d %d %d", i, j, errno);
err(1, "sysctl fmt %d %d %d", i, j, errno);
if (kind)
*kind = *(u_int *)buf;
@ -362,7 +360,7 @@ show_var(int *oid, int nlen)
j = sizeof buf;
i = sysctl(qoid, nlen + 2, buf, &j, 0, 0);
if (i || !j)
err(-1, "sysctl fmt %d %d %d", i, j, errno);
err(1, "sysctl fmt %d %d %d", i, j, errno);
kind = *(u_int *)buf;
@ -372,7 +370,7 @@ show_var(int *oid, int nlen)
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);
err(1, "sysctl name %d %d %d", i, j, errno);
p = val;
switch (*fmt) {
@ -442,7 +440,7 @@ sysctl_all (int *oid, int len)
if (errno == ENOENT)
return 0;
else
err(-1, "sysctl(getnext) %d %d", j, l2);
err(1, "sysctl(getnext) %d %d", j, l2);
l2 /= sizeof (int);