O'Reilly logo

FreeBSD Device Drivers by Joseph Kong

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required