- perror(string);
- return;
- }
- }
- if (special & CLOCK) {
- struct clockinfo *clkp = (struct clockinfo *)buf;
-
- if (!nflag)
- fprintf(stdout, "%s: ", string);
- fprintf(stdout,
- "hz = %d, tick = %d, profhz = %d, stathz = %d\n",
- clkp->hz, clkp->tick, clkp->profhz, clkp->stathz);
- return;
- }
- if (special & BOOTTIME) {
- struct timeval *btp = (struct timeval *)buf;
-
- if (!nflag)
- fprintf(stdout, "%s = %s\n", string,
- ctime((time_t *) &btp->tv_sec));
- else
- fprintf(stdout, "%d\n", btp->tv_sec);
- return;
- }
- if (special & CONSDEV) {
- dev_t dev = *(dev_t *)buf;
-
- if (!nflag)
- fprintf(stdout, "%s = %s\n", string,
- devname(dev, S_IFCHR));
- else
- fprintf(stdout, "0x%x\n", dev);
- return;
- }
- switch (type) {
- case CTLTYPE_INT:
- if (newsize == 0) {
- if (!nflag)
- fprintf(stdout, "%s = ", string);
- fprintf(stdout, useUnsignedInt ? "%u\n" : "%d\n", *(int *)buf);
- } else {
- if (!nflag)
- fprintf(stdout, useUnsignedInt ? "%s: %u -> " : "%s: %d -> ",
- string, *(int *)buf);
- fprintf(stdout, useUnsignedInt ? "%u\n" : "%d\n", *(int *)newval);
- }
- return;
-
- case CTLTYPE_STRING:
- if (newsize == 0) {
- if (!nflag)
- fprintf(stdout, "%s = ", string);
- fprintf(stdout, "%s\n", buf);
- } else {
- if (!nflag)
- fprintf(stdout, "%s: %s -> ", string, buf);
- fprintf(stdout, "%s\n", (char *) newval);
- }
- return;
-
- case CTLTYPE_QUAD:
- if (newsize == 0) {
- if (!nflag)
- fprintf(stdout, "%s = ", string);
- fprintf(stdout, "%qd\n", *(quad_t *)buf);
- } else {
- if (!nflag)
- fprintf(stdout, "%s: %qd -> ", string,
- *(quad_t *)buf);
- fprintf(stdout, "%qd\n", *(quad_t *)newval);
- }
- return;
-
- case CTLTYPE_STRUCT:
- return;
-
- default:
- case CTLTYPE_NODE:
- fprintf(stderr, "%s: unknown type returned\n",
- string);
- return;
- }
-}
-
-/*
- * Initialize the set of debugging names
- */
-void debuginit()
-{
- int mib[3], loc, i;
- size_t size;
-
- if (secondlevel[CTL_DEBUG].list != 0)
- return;
- secondlevel[CTL_DEBUG].list = debugname;
- mib[0] = CTL_DEBUG;
- mib[2] = CTL_DEBUG_NAME;
- for (loc = lastused, i = 0; i < CTL_DEBUG_MAXID; i++) {
- mib[1] = i;
- size = BUFSIZ - loc;
- if (sysctl(mib, 3, &names[loc], &size, NULL, 0) == -1)
- continue;
- debugname[i].ctl_name = &names[loc];
- debugname[i].ctl_type = CTLTYPE_INT;
- loc += size;
- }
- lastused = loc;
-}
-
-/*
- * Initialize the set of filesystem names
- */
-void vfsinit()
-{
- int mib[4], maxtypenum, cnt, loc, size;
- struct vfsconf vfc;
- size_t buflen;
-
- if (secondlevel[CTL_VFS].list != 0)
- return;
- mib[0] = CTL_VFS;
- mib[1] = VFS_GENERIC;
- mib[2] = VFS_MAXTYPENUM;
- buflen = 4;
- if (sysctl(mib, 3, &maxtypenum, &buflen, (void *)0, (size_t)0) < 0)
- return;
- if ((vfsname = malloc(maxtypenum * sizeof(*vfsname))) == 0)
- return;
- memset(vfsname, 0, maxtypenum * sizeof(*vfsname));
- mib[2] = VFS_CONF;
- buflen = sizeof vfc;
- for (loc = lastused, cnt = 0; cnt < maxtypenum; cnt++) {
- mib[3] = cnt;
- if (sysctl(mib, 4, &vfc, &buflen, (void *)0, (size_t)0) < 0) {
- if (errno == EOPNOTSUPP)
- continue;
- perror("vfsinit");
- free(vfsname);
- return;