Creating Dynamic sysctls

The FreeBSD kernel provides the following 10 macros for creating sysctls during runtime:

#include <sys/types.h> #include <sys/sysctl.h> struct sysctl_oid * SYSCTL_ADD_OID(struct sysctl_ctx_list *ctx, struct sysctl_oid_list *parent, int number, const char *name, int kind, void *arg1, int arg2, int (*handler) (SYSCTL_HANDLER_ARGS), const char *format, const char *descr); struct sysctl_oid * SYSCTL_ADD_NODE(struct sysctl_ctx_list *ctx, struct sysctl_oid_list *parent, int number, const char *name, int access, int (*handler) (SYSCTL_HANDLER_ARGS), const char *descr); struct sysctl_oid * SYSCTL_ADD_STRING(struct sysctl_ctx_list *ctx, struct sysctl_oid_list *parent, int number, const char *name, int access, char *arg, int len, ...

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.