static void setup_sysctl(void) { struct sysctlnode *pnode; sysctl_createv(NULL, 0, NULL, NULL, 0, CTLTYPE_NODE, "machdep", NULL, NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); sysctl_createv(NULL, 0, NULL, &pnode, 0, CTLTYPE_NODE, "domain0", NULL, NULL, 0, NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); if (pnode == NULL) return; sysctl_createv(NULL, 0, &pnode, &pnode, 0, CTLTYPE_NODE, "diskcookie", NULL, NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (pnode) diskcookies = pnode; }
static void fujitsu_hk_sysctl_setup(struct fujitsu_hk_softc *sc) { const struct sysctlnode *rnode; bool dummy_state; if (fujitsu_hk_get_backlight(sc, &dummy_state) == 0) { if ((sysctl_createv(&sc->sc_log, 0, NULL, &rnode, 0, CTLTYPE_NODE, "acpi", NULL, NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL)) != 0) goto fail; if ((sysctl_createv(&sc->sc_log, 0, &rnode, &rnode, 0, CTLTYPE_NODE, device_xname(sc->sc_dev), SYSCTL_DESCR("Fujitsu hotkeys controls"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0) goto fail; (void)sysctl_createv(&sc->sc_log, 0, &rnode, NULL, CTLFLAG_READWRITE, CTLTYPE_BOOL, "backlight", SYSCTL_DESCR("Internal DFP backlight switch state"), fujitsu_hk_sysctl_backlight, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL); } return; fail: aprint_error_dev(sc->sc_dev, "couldn't add sysctl nodes\n"); }
void tmx86_init_longrun(void) { const struct sysctlnode *mnode; /* create the sysctl machdep.tm_longrun_* nodes */ sysctl_createv(NULL, 0, NULL, &mnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL, NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); sysctl_createv(NULL, 0, NULL, NULL, CTLFLAG_READWRITE, CTLTYPE_INT, "tm_longrun_mode", NULL, sysctl_machdep_tm_longrun, 0, NULL, 0, CTL_MACHDEP, CPU_TMLR_MODE, CTL_EOL); sysctl_createv(NULL, 0, NULL, NULL, 0, CTLTYPE_INT, "tm_longrun_frequency", NULL, sysctl_machdep_tm_longrun, 0, NULL, 0, CTL_MACHDEP, CPU_TMLR_FREQUENCY, CTL_EOL); sysctl_createv(NULL, 0, NULL, NULL, 0, CTLTYPE_INT, "tm_longrun_voltage", NULL, sysctl_machdep_tm_longrun, 0, NULL, 0, CTL_MACHDEP, CPU_TMLR_VOLTAGE, CTL_EOL); sysctl_createv(NULL, 0, NULL, NULL, 0, CTLTYPE_INT, "tm_longrun_percentage", NULL, sysctl_machdep_tm_longrun, 0, NULL, 0, CTL_MACHDEP, CPU_TMLR_PERCENTAGE, CTL_EOL); }
static void obsled_attach(device_t parent, device_t self, void *aux) { struct obsled_softc *sc = device_private(self); struct gpio_attach_args *ga = aux; struct sysctlnode *node; int err, node_mib; char led_name[5]; /* int led = (1 << device_unit(sc->sc_dev)); */ snprintf(led_name, sizeof(led_name), "led%d", (1 << device_unit(sc->sc_dev)) & 0x7); aprint_naive(": OpenBlockS %s\n", led_name); aprint_normal(": OpenBlockS %s\n", led_name); sc->sc_dev = self; sc->sc_tag = ga->ga_tag; sc->sc_addr = ga->ga_addr; sc->sc_led_state = 0; obs266_led_set(OBS266_LED_OFF); /* add sysctl interface */ err = sysctl_createv(NULL, 0, NULL, NULL, 0, CTLTYPE_NODE, "hw", NULL, NULL, 0, NULL, 0, CTL_HW, CTL_EOL); if (err != 0) return; err = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&node, 0, CTLTYPE_NODE, "obsled", NULL, NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); if (err != 0) return; node_mib = node->sysctl_num; err = sysctl_createv(NULL, 0, NULL, (const struct sysctlnode **)&node, CTLFLAG_READWRITE, CTLTYPE_INT, led_name, SYSCTL_DESCR("OpenBlockS LED state (0=off, 1=on)"), obsled_sysctl_verify, 0, (void *)sc, 0, CTL_HW, node_mib, CTL_CREATE, CTL_EOL); if (err != 0) return; sc->sc_led_state_mib = node->sysctl_num; #if 0 { gpio_tag_t tag = sc->sc_tag; (*(tag)->io_or_write)((tag)->cookie, sc->sc_addr, 0); } #endif }
/* * sysctl management routines * You can set the address of an interface through: * net.link.tap.tap<number> * * Note the consistent use of tap_log in order to use * sysctl_teardown at unload time. * * In the kernel you will find a lot of SYSCTL_SETUP blocks. Those * blocks register a function in a special section of the kernel * (called a link set) which is used at init_sysctl() time to cycle * through all those functions to create the kernel's sysctl tree. * * It is not possible to use link sets in a module, so the * easiest is to simply call our own setup routine at load time. * * In the SYSCTL_SETUP blocks you find in the kernel, nodes have the * CTLFLAG_PERMANENT flag, meaning they cannot be removed. Once the * whole kernel sysctl tree is built, it is not possible to add any * permanent node. * * It should be noted that we're not saving the sysctlnode pointer * we are returned when creating the "tap" node. That structure * cannot be trusted once out of the calling function, as it might * get reused. So we just save the MIB number, and always give the * full path starting from the root for later calls to sysctl_createv * and sysctl_destroyv. */ static void sysctl_tap_setup(struct sysctllog **clog) { const struct sysctlnode *node; int error = 0; if ((error = sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "link", NULL, NULL, 0, NULL, 0, CTL_NET, AF_LINK, CTL_EOL)) != 0) return; /* * The first four parameters of sysctl_createv are for management. * * The four that follows, here starting with a '0' for the flags, * describe the node. * * The next series of four set its value, through various possible * means. * * Last but not least, the path to the node is described. That path * is relative to the given root (third argument). Here we're * starting from the root. */ if ((error = sysctl_createv(clog, 0, NULL, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "tap", NULL, NULL, 0, NULL, 0, CTL_NET, AF_LINK, CTL_CREATE, CTL_EOL)) != 0) return; tap_node = node->sysctl_num; }
static int vmt_sysctl_setup_root(device_t self) { const struct sysctlnode *machdep_node, *vmt_node; struct vmt_softc *sc = device_private(self); int rv; rv = sysctl_createv(&sc->sc_log, 0, NULL, &machdep_node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL, NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); if (rv != 0) goto fail; rv = sysctl_createv(&sc->sc_log, 0, &machdep_node, &vmt_node, 0, CTLTYPE_NODE, device_xname(self), NULL, NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (rv != 0) goto fail; rv = vmt_sysctl_setup_clock_sync(self, vmt_node); if (rv != 0) goto fail; return 0; fail: sysctl_teardown(&sc->sc_log); sc->sc_log = NULL; return rv; }
static void sysctl_wmi_hp_setup(struct wmi_hp_softc *sc) { const struct sysctlnode *rnode; int err; err = sysctl_createv(&wmihp_sysctllog, 0, NULL, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "acpi", NULL, NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); if (err != 0) return; err = sysctl_createv(&wmihp_sysctllog, 0, &rnode, &rnode, 0, CTLTYPE_NODE, "wmi", SYSCTL_DESCR("ACPI HP WMI"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (err != 0) return; if (wmi_hp_method_read(sc, WMI_HP_METHOD_CMD_ALS) == true) { (void)sysctl_createv(NULL, 0, &rnode, NULL, CTLFLAG_READWRITE, CTLTYPE_BOOL, "als", SYSCTL_DESCR("Ambient Light Sensor"), sysctl_wmi_hp_set_als, 0, NULL, 0, CTL_CREATE, CTL_EOL); } }
static ACPI_STATUS sony_walk_cb(ACPI_HANDLE hnd, UINT32 v, void *context, void **status) { struct sony_acpi_softc *sc = (void *)context; const struct sysctlnode *node, *snode; const char *name = acpi_name(hnd); ACPI_INTEGER acpi_val; char buf[SYSCTL_NAMELEN + 1], *ptr; int rv; if ((name = strrchr(name, '.')) == NULL) return AE_OK; name++; if ((*name != 'G') && (*name != 'S')) return AE_OK; (void)strlcpy(buf, name, sizeof(buf)); *buf = 'G'; /* * We assume that if the 'get' of the name as an integer is * successful it is ok. */ if (acpi_eval_integer(sc->sc_node->ad_handle, buf, &acpi_val)) return AE_OK; for (ptr = buf; *ptr; ptr++) *ptr = tolower(*ptr); if ((rv = sysctl_createv(&sc->sc_log, 0, NULL, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL, NULL, 0, NULL, 0, CTL_HW, CTL_EOL)) != 0) goto out; if ((rv = sysctl_createv(&sc->sc_log, 0, &node, &snode, 0, CTLTYPE_NODE, device_xname(sc->sc_dev), SYSCTL_DESCR("sony controls"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0) goto out; if ((rv = sysctl_createv(&sc->sc_log, 0, &snode, &node, CTLFLAG_READWRITE, CTLTYPE_INT, buf + 1, NULL, sony_sysctl_helper, 0, sc, 0, CTL_CREATE, CTL_EOL)) != 0) goto out; out: #ifdef DIAGNOSTIC if (rv) printf("%s: sysctl_createv failed (rv = %d)\n", device_xname(sc->sc_dev), rv); #endif return AE_OK; }
void gpiopwm_attach(device_t parent, device_t self, void *aux) { struct gpiopwm_softc *sc = device_private(self); struct gpio_attach_args *ga = aux; const struct sysctlnode *node; sc->sc_dev = self; /* Map pin */ sc->sc_gpio = ga->ga_gpio; sc->sc_map.pm_map = sc->_map; if (gpio_pin_map(sc->sc_gpio, ga->ga_offset, ga->ga_mask, &sc->sc_map)) { aprint_error(": can't map pin\n"); return; } aprint_normal(" [%d]", sc->sc_map.pm_map[0]); pmf_device_register(self, NULL, NULL); callout_init(&sc->sc_pulse, CALLOUT_MPSAFE); callout_setfunc(&sc->sc_pulse, gpiopwm_pulse, sc); sysctl_createv(&sc->sc_log, 0, NULL, &node, 0, CTLTYPE_NODE, device_xname(sc->sc_dev), SYSCTL_DESCR("GPIO software PWM"), NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); if (node == NULL) { printf(": can't create sysctl node\n"); return; } sysctl_createv(&sc->sc_log, 0, &node, NULL, CTLFLAG_READWRITE, CTLTYPE_INT, "on", SYSCTL_DESCR("PWM 'on' period in ticks"), gpiopwm_set_on, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL); sysctl_createv(&sc->sc_log, 0, &node, NULL, CTLFLAG_READWRITE, CTLTYPE_INT, "off", SYSCTL_DESCR("PWM 'off' period in ticks"), gpiopwm_set_off, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL); aprint_normal("\n"); return; }
static void acpicpu_sysctl(device_t self) { const struct sysctlnode *node; int err; KASSERT(acpicpu_log == NULL); err = sysctl_createv(&acpicpu_log, 0, NULL, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL, NULL, 0, NULL, 0, CTL_HW, CTL_EOL); if (err != 0) goto fail; err = sysctl_createv(&acpicpu_log, 0, &node, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "acpi", NULL, NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (err != 0) goto fail; err = sysctl_createv(&acpicpu_log, 0, &node, &node, 0, CTLTYPE_NODE, "cpu", SYSCTL_DESCR("ACPI CPU"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (err != 0) goto fail; err = sysctl_createv(&acpicpu_log, 0, &node, NULL, CTLFLAG_READWRITE, CTLTYPE_BOOL, "dynamic", SYSCTL_DESCR("Dynamic states"), NULL, 0, &acpicpu_dynamic, 0, CTL_CREATE, CTL_EOL); if (err != 0) goto fail; err = sysctl_createv(&acpicpu_log, 0, &node, NULL, CTLFLAG_READWRITE, CTLTYPE_BOOL, "passive", SYSCTL_DESCR("Passive cooling"), NULL, 0, &acpicpu_passive, 0, CTL_CREATE, CTL_EOL); if (err != 0) goto fail; return; fail: aprint_error_dev(self, "failed to initialize sysctl (err %d)\n", err); }
static int overlay_modcmd(modcmd_t cmd, void *arg) { int error; switch (cmd) { case MODULE_CMD_INIT: error = vfs_attach(&overlay_vfsops); if (error != 0) break; sysctl_createv(&overlay_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "overlay", SYSCTL_DESCR("Overlay file system"), NULL, 0, NULL, 0, CTL_VFS, CTL_CREATE, CTL_EOL); break; case MODULE_CMD_FINI: error = vfs_detach(&overlay_vfsops); if (error != 0) break; sysctl_teardown(&overlay_sysctl_log); break; default: error = ENOTTY; break; } return (error); }
static int union_modcmd(modcmd_t cmd, void *arg) { int error; switch (cmd) { case MODULE_CMD_INIT: error = vfs_attach(&union_vfsops); if (error != 0) break; sysctl_createv(&union_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "union", SYSCTL_DESCR("Union file system"), NULL, 0, NULL, 0, CTL_VFS, 15, CTL_EOL); /* * XXX the "15" above could be dynamic, thereby eliminating * one more instance of the "number to vfs" mapping problem, * but "15" is the order as taken from sys/mount.h */ break; case MODULE_CMD_FINI: error = vfs_detach(&union_vfsops); if (error != 0) break; sysctl_teardown(&union_sysctl_log); break; default: error = ENOTTY; break; } return (error); }
/* * Initialize clock frequencies and start both clocks running. */ void initclocks(void) { static struct sysctllog *clog; int i; /* * Set divisors to 1 (normal case) and let the machine-specific * code do its bit. */ psdiv = 1; /* * provide minimum default time counter * will only run at interrupt resolution */ intr_timecounter.tc_frequency = hz; tc_init(&intr_timecounter); cpu_initclocks(); /* * Compute profhz and stathz, fix profhz if needed. */ i = stathz ? stathz : hz; if (profhz == 0) profhz = i; psratio = profhz / i; if (schedhz == 0) { /* 16Hz is best */ hardscheddiv = hz / 16; if (hardscheddiv <= 0) panic("hardscheddiv"); } sysctl_createv(&clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRUCT, "clockrate", SYSCTL_DESCR("Kernel clock rates"), sysctl_kern_clockrate, 0, NULL, sizeof(struct clockinfo), CTL_KERN, KERN_CLOCKRATE, CTL_EOL); sysctl_createv(&clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_INT, "hardclock_ticks", SYSCTL_DESCR("Number of hardclock ticks"), NULL, 0, &hardclock_ticks, sizeof(hardclock_ticks), CTL_KERN, KERN_HARDCLOCK_TICKS, CTL_EOL); }
static int drm_sysctl_node(const char *name, const struct sysctlnode **node, struct sysctllog **log) { return sysctl_createv(log, 0, node, node, CTLFLAG_PERMANENT, CTLTYPE_NODE, name, NULL, NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); }
static int procfs_modcmd(modcmd_t cmd, void *arg) { int error; switch (cmd) { case MODULE_CMD_INIT: error = vfs_attach(&procfs_vfsops); if (error != 0) break; sysctl_createv(&procfs_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "vfs", NULL, NULL, 0, NULL, 0, CTL_VFS, CTL_EOL); sysctl_createv(&procfs_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "procfs", SYSCTL_DESCR("Process file system"), NULL, 0, NULL, 0, CTL_VFS, 12, CTL_EOL); /* * XXX the "12" above could be dynamic, thereby eliminating * one more instance of the "number to vfs" mapping problem, * but "12" is the order as taken from sys/mount.h */ procfs_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS, procfs_listener_cb, NULL); break; case MODULE_CMD_FINI: error = vfs_detach(&procfs_vfsops); if (error != 0) break; sysctl_teardown(&procfs_sysctl_log); kauth_unlisten_scope(procfs_listener); break; default: error = ENOTTY; break; } return (error); }
static int smbfs_modcmd(modcmd_t cmd, void *arg) { const struct sysctlnode *smb = NULL; int error; switch (cmd) { case MODULE_CMD_INIT: error = vfs_attach(&smbfs_vfsops); if (error != 0) break; sysctl_createv(&smbfs_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "vfs", NULL, NULL, 0, NULL, 0, CTL_VFS, CTL_EOL); sysctl_createv(&smbfs_sysctl_log, 0, NULL, &smb, CTLFLAG_PERMANENT, CTLTYPE_NODE, "samba", SYSCTL_DESCR("SMB/CIFS remote file system"), NULL, 0, NULL, 0, CTL_VFS, CTL_CREATE, CTL_EOL); if (smb != NULL) { sysctl_createv(&smbfs_sysctl_log, 0, &smb, NULL, CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE, CTLTYPE_INT, "version", SYSCTL_DESCR("smbfs version"), NULL, SMBFS_VERSION, NULL, 0, CTL_CREATE, CTL_EOL); } break; case MODULE_CMD_FINI: error = vfs_detach(&smbfs_vfsops); if (error != 0) break; sysctl_teardown(&smbfs_sysctl_log); break; default: error = ENOTTY; break; } return (error); }
/* * Setup sysctl(3) MIB, net.ieee80211.* * * TBD condition CTLFLAG_PERMANENT on being a module or not */ void ieee80211_rssadapt_sysctl_setup(struct sysctllog **clog) { int rc; const struct sysctlnode *node; if ((rc = sysctl_createv(clog, 0, NULL, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "link", NULL, NULL, 0, NULL, 0, CTL_NET, PF_LINK, CTL_EOL)) != 0) goto err; if ((rc = sysctl_createv(clog, 0, &node, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "ieee80211", NULL, NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0) goto err; if ((rc = sysctl_createv(clog, 0, &node, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "rssadapt", SYSCTL_DESCR("Received Signal Strength adaptation controls"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0) goto err; #ifdef IEEE80211_DEBUG /* control debugging printfs */ if ((rc = sysctl_createv(clog, 0, &node, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "debug", SYSCTL_DESCR("Enable RSS adaptation debugging output"), sysctl_ieee80211_rssadapt_debug, 0, &ieee80211_rssadapt_debug, 0, CTL_CREATE, CTL_EOL)) != 0) goto err; #endif /* IEEE80211_DEBUG */ /* control rate of decay for exponential averages */ if ((rc = sysctl_createv(clog, 0, &node, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_STRUCT, "expavgctl", SYSCTL_DESCR("RSS exponential averaging control"), sysctl_ieee80211_rssadapt_expavgctl, 0, &master_expavgctl, sizeof(master_expavgctl), CTL_CREATE, CTL_EOL)) != 0) goto err; return; err: printf("%s: sysctl_createv failed (rc = %d)\n", __func__, rc); }
static int cd9660_modcmd(modcmd_t cmd, void *arg) { int error; switch (cmd) { case MODULE_CMD_INIT: error = vfs_attach(&cd9660_vfsops); if (error != 0) break; sysctl_createv(&cd9660_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "vfs", NULL, NULL, 0, NULL, 0, CTL_VFS, CTL_EOL); sysctl_createv(&cd9660_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "cd9660", SYSCTL_DESCR("ISO-9660 file system"), NULL, 0, NULL, 0, CTL_VFS, 14, CTL_EOL); sysctl_createv(&cd9660_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "utf8_joliet", SYSCTL_DESCR("Encode Joliet filenames to UTF-8"), NULL, 0, &cd9660_utf8_joliet, 0, CTL_VFS, 14, CD9660_UTF8_JOLIET, CTL_EOL); /* * XXX the "14" above could be dynamic, thereby eliminating * one more instance of the "number to vfs" mapping problem, * but "14" is the order as taken from sys/mount.h */ break; case MODULE_CMD_FINI: error = vfs_detach(&cd9660_vfsops); if (error != 0) break; sysctl_teardown(&cd9660_sysctl_log); break; default: error = ENOTTY; break; } return (error); }
/* * Top level filesystem related information gathering. */ void compat_sysctl_vfs(struct sysctllog **clog) { extern int nmountcompatnames; sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE, CTLTYPE_INT, "maxtypenum", SYSCTL_DESCR("Highest valid filesystem type number"), NULL, nmountcompatnames, NULL, 0, CTL_VFS, VFS_GENERIC, VFS_MAXTYPENUM, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRUCT, "conf", SYSCTL_DESCR("Filesystem configuration information"), sysctl_vfs_generic_conf, 0, NULL, sizeof(struct vfsconf), CTL_VFS, VFS_GENERIC, VFS_CONF, CTL_EOL); }
void netbsd32_sysctl_init(void) { const struct sysctlnode *_root = &netbsd32_sysctl_root; extern const char machine_arch32[]; extern const char machine32[]; sysctl_createv(&netbsd32_clog, 0, &_root, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "kern", NULL, NULL, 0, NULL, 0, CTL_KERN, CTL_EOL); sysctl_createv(&netbsd32_clog, 0, &_root, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRUCT, "boottime", NULL, netbsd32_sysctl_kern_boottime, 0, NULL, sizeof(struct netbsd32_timeval), CTL_KERN, KERN_BOOTTIME, CTL_EOL); sysctl_createv(&netbsd32_clog, 0, &_root, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "vm", NULL, NULL, 0, NULL, 0, CTL_VM, CTL_EOL); sysctl_createv(&netbsd32_clog, 0, &_root, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRUCT, "loadavg", NULL, netbsd32_sysctl_vm_loadavg, 0, NULL, sizeof(struct netbsd32_loadavg), CTL_VM, VM_LOADAVG, CTL_EOL); sysctl_createv(&netbsd32_clog, 0, &_root, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL, NULL, 0, NULL, 0, CTL_HW, CTL_EOL); sysctl_createv(&netbsd32_clog, 0, &_root, NULL, CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE, CTLTYPE_INT, "alignbytes", NULL, NULL, ALIGNBYTES32, NULL, 0, CTL_HW, HW_ALIGNBYTES, CTL_EOL); sysctl_createv(&netbsd32_clog, 0, &_root, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRING, "machine", NULL, NULL, 0, __UNCONST(&machine32), 0, CTL_HW, HW_MACHINE, CTL_EOL); sysctl_createv(&netbsd32_clog, 0, &_root, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRING, "machine_arch", NULL, NULL, 0, __UNCONST(&machine_arch32), 0, CTL_HW, HW_MACHINE_ARCH, CTL_EOL); }
void cprng_init(void) { static struct sysctllog *random_sysctllog; nist_ctr_initialize(); sysctl_createv(&random_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_INT, "urandom", SYSCTL_DESCR("Random integer value"), sysctl_kern_urnd, 0, NULL, 0, CTL_KERN, KERN_URND, CTL_EOL); sysctl_createv(&random_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_INT, "arandom", SYSCTL_DESCR("n bytes of random data"), sysctl_kern_arnd, 0, NULL, 0, CTL_KERN, KERN_ARND, CTL_EOL); }
void drm_sysctl_init(struct drm_sysctl_def *def) { const void * const *b = def->bp, * const *e = def->ep; const struct sysctlnode *rnode = NULL, *cnode; const char *name = "drm2"; int error; if ((error = sysctl_createv(&def->log, 0, NULL, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, name, SYSCTL_DESCR("DRM driver parameters"), NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL)) != 0) { aprint_error("sysctl_createv returned %d, " "for %s ignoring\n", error, name); return; } for (; b < e; b++) { const struct linux_module_param_info *p = *b; char copy[256], *n, *nn; strlcpy(copy, p->name, sizeof(copy)); cnode = rnode; for (n = copy; (nn = strchr(n, '.')) != NULL; n = nn) { *nn++ = '\0'; if ((error = drm_sysctl_node(n, &cnode, &def->log)) != 0) { aprint_error("sysctl_createv returned %d, " "for %s ignoring\n", error, n); continue; } } if ((error = sysctl_createv(&def->log, 0, &cnode, &cnode, p->mode == 0600 ? CTLFLAG_READWRITE : 0, drm_sysctl_get_type(p), n, SYSCTL_DESCR(drm_sysctl_get_description(p, def)), NULL, 0, p->ptr, 0, CTL_CREATE, CTL_EOL)) != 0) aprint_error("sysctl_createv returned %d, " "for %s ignoring\n", error, n); } }
static int mfs_modcmd(modcmd_t cmd, void *arg) { int error; switch (cmd) { case MODULE_CMD_INIT: error = vfs_attach(&mfs_vfsops); if (error != 0) break; sysctl_createv(&mfs_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "vfs", NULL, NULL, 0, NULL, 0, CTL_VFS, CTL_EOL); sysctl_createv(&mfs_sysctl_log, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_ALIAS, CTLTYPE_NODE, "mfs", SYSCTL_DESCR("Memory based file system"), NULL, 1, NULL, 0, CTL_VFS, 3, CTL_EOL); /* * XXX the "1" and the "3" above could be dynamic, thereby * eliminating one more instance of the "number to vfs" * mapping problem, but they are in order as taken from * sys/mount.h */ break; case MODULE_CMD_FINI: error = vfs_detach(&mfs_vfsops); if (error != 0) break; sysctl_teardown(&mfs_sysctl_log); break; default: error = ENOTTY; break; } return (error); }
static int vmt_sysctl_setup_clock_sync(device_t self, const struct sysctlnode *root_node) { const struct sysctlnode *node, *period_node; struct vmt_softc *sc = device_private(self); int rv; rv = sysctl_createv(&sc->sc_log, 0, &root_node, &node, 0, CTLTYPE_NODE, "clock_sync", NULL, NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (rv != 0) return rv; rv = sysctl_createv(&sc->sc_log, 0, &node, &period_node, CTLFLAG_READWRITE, CTLTYPE_INT, "period", SYSCTL_DESCR("Period, in seconds, at which to update the " "guest's clock"), vmt_sysctl_update_clock_sync_period, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL); return rv; }
static void sysctl_swsensor_setup(void) { int ret; int node_sysctl_num; const struct sysctlnode *me = NULL; const struct sysctlnode *me2; KASSERT(swsensor_sysctllog == NULL); ret = sysctl_createv(&swsensor_sysctllog, 0, NULL, &me, CTLFLAG_READWRITE, CTLTYPE_NODE, "swsensor", NULL, NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); if (ret != 0) return; node_sysctl_num = me->sysctl_num; ret = sysctl_createv(&swsensor_sysctllog, 0, NULL, &me2, CTLFLAG_READWRITE, CTLTYPE_INT, "cur_value", NULL, NULL, 0, &sw_sensor_value, 0, CTL_HW, node_sysctl_num, CTL_CREATE, CTL_EOL); if (ret == 0) sensor_value_sysctl = me2->sysctl_num; node_sysctl_num = me->sysctl_num; ret = sysctl_createv(&swsensor_sysctllog, 0, NULL, &me2, CTLFLAG_READWRITE, CTLTYPE_INT, "state", NULL, NULL, 0, &sw_sensor_state, 0, CTL_HW, node_sysctl_num, CTL_CREATE, CTL_EOL); if (ret == 0) sensor_state_sysctl = me2->sysctl_num; }
static void ufsdirhash_sysctl_init(void) { const struct sysctlnode *rnode, *cnode; sysctl_createv(&ufsdirhash_sysctl_log, 0, NULL, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "vfs", NULL, NULL, 0, NULL, 0, CTL_VFS, CTL_EOL); sysctl_createv(&ufsdirhash_sysctl_log, 0, &rnode, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "ufs", SYSCTL_DESCR("ufs"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); sysctl_createv(&ufsdirhash_sysctl_log, 0, &rnode, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "dirhash", SYSCTL_DESCR("dirhash"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); sysctl_createv(&ufsdirhash_sysctl_log, 0, &rnode, &cnode, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "minblocks", SYSCTL_DESCR("minimum hashed directory size in blocks"), NULL, 0, &ufs_dirhashminblks, 0, CTL_CREATE, CTL_EOL); sysctl_createv(&ufsdirhash_sysctl_log, 0, &rnode, &cnode, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "maxmem", SYSCTL_DESCR("maximum dirhash memory usage"), NULL, 0, &ufs_dirhashmaxmem, 0, CTL_CREATE, CTL_EOL); sysctl_createv(&ufsdirhash_sysctl_log, 0, &rnode, &cnode, CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_INT, "memused", SYSCTL_DESCR("current dirhash memory usage"), NULL, 0, &ufs_dirhashmem, 0, CTL_CREATE, CTL_EOL); sysctl_createv(&ufsdirhash_sysctl_log, 0, &rnode, &cnode, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "docheck", SYSCTL_DESCR("enable extra sanity checks"), NULL, 0, &ufs_dirhashcheck, 0, CTL_CREATE, CTL_EOL); }
static void adbkbd_setup_sysctl(struct adbkbd_softc *sc) { const struct sysctlnode *me, *node; int ret; DPRINTF("%s: sysctl setup\n", device_xname(sc->sc_dev)); ret = sysctl_createv(NULL, 0, NULL, &me, CTLFLAG_READWRITE, CTLTYPE_NODE, device_xname(sc->sc_dev), NULL, NULL, 0, NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); ret = sysctl_createv(NULL, 0, NULL, (void *)&node, CTLFLAG_READWRITE | CTLFLAG_OWNDESC, CTLTYPE_BOOL, "emulate_usb", "USB keyboard emulation", adbkbd_sysctl_usb, 1, (void *)sc, 0, CTL_MACHDEP, me->sysctl_num, CTL_CREATE, CTL_EOL); #if NWSMOUSE > 0 if (sc->sc_wsmousedev != NULL) { ret = sysctl_createv(NULL, 0, NULL, (void *)&node, CTLFLAG_READWRITE | CTLFLAG_OWNDESC, CTLTYPE_INT, "middle", "middle mouse button", adbkbd_sysctl_mid, 1, (void *)sc, 0, CTL_MACHDEP, me->sysctl_num, CTL_CREATE, CTL_EOL); ret = sysctl_createv(NULL, 0, NULL, (void *)&node, CTLFLAG_READWRITE | CTLFLAG_OWNDESC, CTLTYPE_INT, "right", "right mouse button", adbkbd_sysctl_right, 2, (void *)sc, 0, CTL_MACHDEP, me->sysctl_num, CTL_CREATE, CTL_EOL); } #endif /* NWSMOUSE > 0 */ (void)ret; }
static void asus_sysctl_setup(struct asus_softc *sc) { const struct sysctlnode *node, *node_cfv, *node_ncfv; int err, node_mib; if (sc->sc_cfvnum == 0) return; err = sysctl_createv(&sc->sc_log, 0, NULL, &node, 0, CTLTYPE_NODE, device_xname(sc->sc_dev), NULL, NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); if (err) goto sysctl_err; node_mib = node->sysctl_num; err = sysctl_createv(&sc->sc_log, 0, NULL, &node_ncfv, CTLFLAG_READONLY, CTLTYPE_QUAD, "ncfv", SYSCTL_DESCR("Number of CPU frequency/voltage modes"), NULL, 0, &sc->sc_cfvnum, 0, CTL_HW, node_mib, CTL_CREATE, CTL_EOL); if (err) goto sysctl_err; sc->sc_cfvnum_mib = node_ncfv->sysctl_num; err = sysctl_createv(&sc->sc_log, 0, NULL, &node_cfv, CTLFLAG_READWRITE, CTLTYPE_INT, "cfv", SYSCTL_DESCR("Current CPU frequency/voltage mode"), asus_sysctl_verify, 0, (void *)sc, 0, CTL_HW, node_mib, CTL_CREATE, CTL_EOL); if (err) goto sysctl_err; sc->sc_cfv_mib = node_cfv->sysctl_num; return; sysctl_err: aprint_error_dev(sc->sc_dev, "failed to add sysctl nodes. (%d)\n", err); }
void exynos_sysctl_cpufreq_init(void) { const struct sysctlnode *node, *cpunode, *freqnode; char *cpos; int i, val; int error; memset(sysctl_cpu_freqs_txt, (int) ' ', sizeof(sysctl_cpu_freqs_txt)); cpos = sysctl_cpu_freqs_txt; for (i = 0; i < ncpu_freq_settings; i++) { val = cpu_freq_settings[i].freq; snprintf(cpos, 6, "%d ", val); cpos += (val < 1000) ? 4 : 5; } *cpos = 0; error = sysctl_createv(NULL, 0, NULL, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL, NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); if (error) printf("couldn't create `machdep' node\n"); error = sysctl_createv(NULL, 0, &node, &cpunode, 0, CTLTYPE_NODE, "cpu", NULL, NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (error) printf("couldn't create `cpu' node\n"); error = sysctl_createv(NULL, 0, &cpunode, &freqnode, 0, CTLTYPE_NODE, "frequency", NULL, NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (error) printf("couldn't create `frequency' node\n"); error = sysctl_createv(NULL, 0, &freqnode, &node, CTLFLAG_READWRITE, CTLTYPE_INT, "target", NULL, sysctl_cpufreq_target, 0, &cpu_freq_target, 0, CTL_CREATE, CTL_EOL); if (error) printf("couldn't create `target' node\n"); error = sysctl_createv(NULL, 0, &freqnode, &node, 0, CTLTYPE_INT, "current", NULL, sysctl_cpufreq_current, 0, NULL, 0, CTL_CREATE, CTL_EOL); if (error) printf("couldn't create `current' node\n"); error = sysctl_createv(NULL, 0, &freqnode, &node, CTLFLAG_READONLY, CTLTYPE_STRING, "available", NULL, NULL, 0, sysctl_cpu_freqs_txt, 0, CTL_CREATE, CTL_EOL); if (error) printf("couldn't create `available' node\b"); }
void sysctl_security_overlay_setup(struct sysctllog **clog) { const struct sysctlnode *rnode; sysctl_createv(clog, 0, NULL, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "models", NULL, NULL, 0, NULL, 0, CTL_SECURITY, CTL_CREATE, CTL_EOL); sysctl_createv(clog, 0, &rnode, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "overlay", SYSCTL_DESCR("Overlay security model on-top of bsd44"), NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL); sysctl_createv(clog, 0, &rnode, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRING, "name", NULL, NULL, 0, __UNCONST(SECMODEL_OVERLAY_NAME), 0, CTL_CREATE, CTL_EOL); }