root/include/linux/sysctl.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * sysctl.h: General linux system control interface
   3  *
   4  * Begun 24 March 1995, Stephen Tweedie
   5  */
   6 
   7 #include <linux/lists.h>
   8 
   9 #ifndef _LINUX_SYSCTL_H
  10 #define _LINUX_SYSCTL_H
  11 
  12 #define CTL_MAXNAME 10
  13 
  14 struct __sysctl_args {
  15         int *name;
  16         int nlen;
  17         void *oldval;
  18         size_t *oldlenp;
  19         void *newval;
  20         size_t newlen;
  21         unsigned long __unused[4];
  22 };
  23 
  24 /* Define sysctl names first */
  25 
  26 /* Top-level names: */
  27 
  28 /* For internal pattern-matching use only: */
  29 #ifdef __KERNEL__
  30 #define CTL_ANY         -1      /* Matches any name */
  31 #define CTL_NONE                0
  32 #endif
  33 
  34 #define CTL_KERN        1       /* General kernel info and control */
  35 #define CTL_VM          2       /* VM management */
  36 #define CTL_NET         3       /* Networking */
  37 #define CTL_PROC        4       /* Process info */
  38 #define CTL_FS          5       /* Filesystems */
  39 #define CTL_DEBUG       6       /* Debugging */
  40 #define CTL_DEV         7       /* Devices */
  41 #define CTL_MAXID       8
  42 
  43 /* CTL_KERN names: */
  44 #define KERN_OSTYPE     1       /* string: system version */
  45 #define KERN_OSRELEASE  2       /* string: system release */
  46 #define KERN_OSREV      3       /* int: system revision */
  47 #define KERN_VERSION    4       /* string: compile time info */
  48 #define KERN_SECUREMASK 5       /* struct: maximum rights mask */
  49 #define KERN_PROF       6       /* table: profiling information */
  50 #define KERN_NODENAME   7
  51 #define KERN_DOMAINNAME 8
  52 #define KERN_NRINODE    9
  53 #define KERN_MAXINODE   10
  54 #define KERN_NRFILE     11
  55 #define KERN_MAXFILE    12
  56 #define KERN_MAXID      13
  57 #define KERN_SECURELVL  14      /* int: system security level */
  58 #define KERN_PANIC      15      /* int: panic timeout */
  59 
  60 /* CTL_VM names: */
  61 #define VM_SWAPCTL      1       /* struct: Set vm swapping control */
  62 #define VM_KSWAPD       2       /* struct: control background pagout */
  63 #define VM_FREEPG       3       /* struct: Set free page thresholds */
  64 #define VM_BDFLUSH      4       /* struct: Control buffer cache flushing */
  65 #define VM_MAXID        5
  66 
  67 /* CTL_NET names: */
  68 
  69 /* CTL_PROC names: */
  70 
  71 /* CTL_FS names: */
  72 
  73 /* CTL_DEBUG names: */
  74 
  75 /* CTL_DEV names: */
  76 
  77 #ifdef __KERNEL__
  78 
  79 extern asmlinkage int sys_sysctl(struct __sysctl_args *);
  80 extern void init_sysctl(void);
  81 
  82 typedef struct ctl_table ctl_table;
  83 
  84 typedef int ctl_handler (ctl_table *table, int *name, int nlen,
  85                          void *oldval, size_t *oldlenp,
  86                          void *newval, size_t newlen, 
  87                          void **context);
  88 
  89 typedef int proc_handler (ctl_table *ctl, int write, struct file * filp,
  90                           void *buffer, size_t *lenp);
  91 
  92 extern int proc_dostring(ctl_table *, int, struct file *,
  93                          void *, size_t *);
  94 extern int proc_dointvec(ctl_table *, int, struct file *,
  95                          void *, size_t *);
  96 extern int proc_dointvec_minmax(ctl_table *, int, struct file *,
  97                                 void *, size_t *);
  98 
  99 extern int do_sysctl (int *name, int nlen,
 100                       void *oldval, size_t *oldlenp,
 101                       void *newval, size_t newlen);
 102 
 103 extern int do_sysctl_strategy (ctl_table *table, 
 104                                int *name, int nlen,
 105                                void *oldval, size_t *oldlenp,
 106                                void *newval, size_t newlen, void ** context);
 107 
 108 extern ctl_handler sysctl_string;
 109 extern ctl_handler sysctl_intvec;
 110 
 111 extern int do_string (
 112         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 113         int rdwr, char *data, size_t max);
 114 extern int do_int (
 115         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 116         int rdwr, int *data);
 117 extern int do_struct (
 118         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 119         int rdwr, void *data, size_t len);
 120 
 121 
 122 /*
 123  * Register a set of sysctl names by calling register_sysctl_table
 124  * with an initialised array of ctl_table's.  An entry with zero
 125  * ctl_name terminates the table.  table->de will be set up by the
 126  * registration and need not be initialised in advance.
 127  *
 128  * sysctl names can be mirrored automatically under /proc/sys.  The
 129  * procname supplied controls /proc naming.
 130  *
 131  * The table's mode will be honoured both for sys_sysctl(2) and
 132  * proc-fs access.
 133  *
 134  * Leaf nodes in the sysctl tree will be represented by a single file
 135  * under /proc; non-leaf nodes will be represented by directories.  A
 136  * null procname disables /proc mirroring at this node.
 137  * 
 138  * sysctl(2) can automatically manage read and write requests through
 139  * the sysctl table.  The data and maxlen fields of the ctl_table
 140  * struct enable minimal validation of the values being written to be
 141  * performed, and the mode field allows minimal authentication.
 142  * 
 143  * More sophisticated management can be enabled by the provision of a
 144  * strategy routine with the table entry.  This will be called before
 145  * any automatic read or write of the data is performed.
 146  * 
 147  * The strategy routine may return:
 148  * <0: Error occurred (error is passed to user process)
 149  * 0:  OK - proceed with automatic read or write.
 150  * >0: OK - read or write has been done by the strategy routine, so 
 151  *     return immediately.
 152  * 
 153  * There must be a proc_handler routine for any terminal nodes
 154  * mirrored under /proc/sys (non-terminals are handled by a built-in
 155  * directory handler).  Several default handlers are available to
 156  * cover common cases.
 157  */
 158 
 159 /* A sysctl table is an array of struct ctl_table: */
 160 struct ctl_table 
 161 {
 162         int ctl_name;                   /* Binary ID */
 163         const char *procname;           /* Text ID for /proc/sys, or zero */
 164         void *data;
 165         int maxlen;
 166         mode_t mode;
 167         ctl_table *child;
 168         proc_handler *proc_handler;     /* Callback for text formatting */
 169         ctl_handler *strategy;          /* Callback function for all r/w */
 170         struct proc_dir_entry *de;      /* /proc control block */
 171         void *extra1;
 172         void *extra2;
 173 };
 174 
 175 /* struct ctl_table_header is used to maintain dynamic lists of
 176    ctl_table trees. */
 177 struct ctl_table_header
 178 {
 179         ctl_table *ctl_table;
 180         DLNODE(struct ctl_table_header) ctl_entry;      
 181 };
 182 
 183 struct ctl_table_header * register_sysctl_table(ctl_table * table, 
 184                                                 int insert_at_head);
 185 void unregister_sysctl_table(struct ctl_table_header * table);
 186 
 187 #else /* __KERNEL__ */
 188 
 189 #endif /* __KERNEL__ */
 190 
 191 #endif /* _LINUX_SYSCTL_H */

/* [previous][next][first][last][top][bottom][index][help] */