Implementing sysctls, Part 1
Example 3-3 is a complete KLD (based on code written by Andrzej Bialecki) that creates multiple sysctls.
Example 3-3. pointless.c
#include <sys/param.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> #include <sys/sysctl.h> static long a = 100; static int b = 200; static char *c = "Are you suggesting coconuts migrate?"; static struct sysctl_ctx_list clist; static struct sysctl_oid *poid; static int sysctl_pointless_procedure(SYSCTL_HANDLER_ARGS) { char *buf = "Not at all. They could be carried."; return (sysctl_handle_string(oidp, buf, strlen(buf), req)); } static int pointless_modevent(module_t ...
Get FreeBSD Device Drivers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.