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 #define KERN_REALROOTDEV 16     /* real root device to mount after initrd */
  60 #define KERN_NFSRNAME   17      /* NFS root name */
  61 #define KERN_NFSRADDRS  18      /* NFS root addresses */
  62 
  63 /* CTL_VM names: */
  64 #define VM_SWAPCTL      1       /* struct: Set vm swapping control */
  65 #define VM_KSWAPD       2       /* struct: control background pagout */
  66 #define VM_FREEPG       3       /* struct: Set free page thresholds */
  67 #define VM_BDFLUSH      4       /* struct: Control buffer cache flushing */
  68 #define VM_MAXID        5
  69 
  70 /* CTL_NET names: */
  71 
  72 /* CTL_PROC names: */
  73 
  74 /* CTL_FS names: */
  75 
  76 /* CTL_DEBUG names: */
  77 
  78 /* CTL_DEV names: */
  79 
  80 #ifdef __KERNEL__
  81 
  82 extern asmlinkage int sys_sysctl(struct __sysctl_args *);
  83 extern void init_sysctl(void);
  84 
  85 typedef struct ctl_table ctl_table;
  86 
  87 typedef int ctl_handler (ctl_table *table, int *name, int nlen,
  88                          void *oldval, size_t *oldlenp,
  89                          void *newval, size_t newlen, 
  90                          void **context);
  91 
  92 typedef int proc_handler (ctl_table *ctl, int write, struct file * filp,
  93                           void *buffer, size_t *lenp);
  94 
  95 extern int proc_dostring(ctl_table *, int, struct file *,
  96                          void *, size_t *);
  97 extern int proc_dointvec(ctl_table *, int, struct file *,
  98                          void *, size_t *);
  99 extern int proc_dointvec_minmax(ctl_table *, int, struct file *,
 100                                 void *, size_t *);
 101 
 102 extern int do_sysctl (int *name, int nlen,
 103                       void *oldval, size_t *oldlenp,
 104                       void *newval, size_t newlen);
 105 
 106 extern int do_sysctl_strategy (ctl_table *table, 
 107                                int *name, int nlen,
 108                                void *oldval, size_t *oldlenp,
 109                                void *newval, size_t newlen, void ** context);
 110 
 111 extern ctl_handler sysctl_string;
 112 extern ctl_handler sysctl_intvec;
 113 
 114 extern int do_string (
 115         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 116         int rdwr, char *data, size_t max);
 117 extern int do_int (
 118         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 119         int rdwr, int *data);
 120 extern int do_struct (
 121         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 122         int rdwr, void *data, size_t len);
 123 
 124 
 125 /*
 126  * Register a set of sysctl names by calling register_sysctl_table
 127  * with an initialised array of ctl_table's.  An entry with zero
 128  * ctl_name terminates the table.  table->de will be set up by the
 129  * registration and need not be initialised in advance.
 130  *
 131  * sysctl names can be mirrored automatically under /proc/sys.  The
 132  * procname supplied controls /proc naming.
 133  *
 134  * The table's mode will be honoured both for sys_sysctl(2) and
 135  * proc-fs access.
 136  *
 137  * Leaf nodes in the sysctl tree will be represented by a single file
 138  * under /proc; non-leaf nodes will be represented by directories.  A
 139  * null procname disables /proc mirroring at this node.
 140  * 
 141  * sysctl(2) can automatically manage read and write requests through
 142  * the sysctl table.  The data and maxlen fields of the ctl_table
 143  * struct enable minimal validation of the values being written to be
 144  * performed, and the mode field allows minimal authentication.
 145  * 
 146  * More sophisticated management can be enabled by the provision of a
 147  * strategy routine with the table entry.  This will be called before
 148  * any automatic read or write of the data is performed.
 149  * 
 150  * The strategy routine may return:
 151  * <0: Error occurred (error is passed to user process)
 152  * 0:  OK - proceed with automatic read or write.
 153  * >0: OK - read or write has been done by the strategy routine, so 
 154  *     return immediately.
 155  * 
 156  * There must be a proc_handler routine for any terminal nodes
 157  * mirrored under /proc/sys (non-terminals are handled by a built-in
 158  * directory handler).  Several default handlers are available to
 159  * cover common cases.
 160  */
 161 
 162 /* A sysctl table is an array of struct ctl_table: */
 163 struct ctl_table 
 164 {
 165         int ctl_name;                   /* Binary ID */
 166         const char *procname;           /* Text ID for /proc/sys, or zero */
 167         void *data;
 168         int maxlen;
 169         mode_t mode;
 170         ctl_table *child;
 171         proc_handler *proc_handler;     /* Callback for text formatting */
 172         ctl_handler *strategy;          /* Callback function for all r/w */
 173         struct proc_dir_entry *de;      /* /proc control block */
 174         void *extra1;
 175         void *extra2;
 176 };
 177 
 178 /* struct ctl_table_header is used to maintain dynamic lists of
 179    ctl_table trees. */
 180 struct ctl_table_header
 181 {
 182         ctl_table *ctl_table;
 183         DLNODE(struct ctl_table_header) ctl_entry;      
 184 };
 185 
 186 struct ctl_table_header * register_sysctl_table(ctl_table * table, 
 187                                                 int insert_at_head);
 188 void unregister_sysctl_table(struct ctl_table_header * table);
 189 
 190 #else /* __KERNEL__ */
 191 
 192 #endif /* __KERNEL__ */
 193 
 194 #endif /* _LINUX_SYSCTL_H */

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