next up previous
Next: Predefined proc callbacks Up: Proc API vor Kernel Previous: ctl_table hirarchy

basic proc_handlers

In many cases it is not necessary to write up a complex proc_handler callback function. The sysctl implementation provides a number of proc_handlers. They are fairly restrictive but on the other hand they are well tested. Before writing up proc callback handler, it should be checked if the task can't be done with one of these. In order to use one of the predefined handlers, a table entry has to be defined like:


proc_callback_type var[]=...;

ctl_table simple_table[] = {
   {ENUMERATION, "procname", &var, 
      sizeof(var), UNIX_MODE, NULL, 
      &proc_calback,...},
   {0}};

syctl can be used, or open/ read/ write/ close on the file "`procname"', and it will be bounded in type by the callback function, and in size by the initial variable size. For many of the sysctl needed, this will be sufficient.

The predefined proc callback handlers all have the same prototype:


extern int proc_xxxxxxxxx(
   ctl_table   *table, 
   int          direction, 
   struct file *filep,
   void        *data_buffer, 
   size_t      *lenth);

The integer direction is TRUE if this is a write to the sysctl table, FALSE other wise. The other values should be clear.



Der Herr Hofrat
2003-03-26