LJ Archive
#define KERN_BUSY 434 /* random number */
enum {BUSY_ON=1, BUSY_OFF};

int busy_ontime = 0;   /* loop 0 ticks */
int busy_offtime = HZ; /* every second */

/* two integer items (files) */
static ctl_table busy_table[] = {
   {BUSY_ON, "ontime", &busy_ontime,
   int), 0644, NULL, &proc_dointvec,
   _intvec, /* fill with 0's */},
   {BUSY_ON, "offtime", &busy_offtime,
   int), 0644, NULL, &proc_dointvec,
   _intvec, /* fill with 0's */},
   {0}
   };

/* a directory */
static ctl_table busy_kern_table[] = {
   {KERN_BUSY, "busy", NULL, 0, 0555,
      busy_table},
   {0}
   };

/* the parent directory */
static ctl_table busy_root_table[] = {
   {CTL_KERN, "kernel", NULL, 0, 0555,
      busy_kern_table},
   {0}
   };

static struct ctl_table_header *busy_table_header;

int init_module(void)
{
   busy_table_header =
      register_sysctl_table(busy_root_table,
      0);
   if (!busy_table_header)
      return -ENOMEM;
   busy_loop();
   return 0;
}

void cleanup_module(void)
{
        unregister_sysctl_table(busy_table_header);
}
LJ Archive