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 pageout */
  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 /* /proc/sys/net/core */
  73 #define NET_CORE                0x01000000
  74 
  75 /* /proc/sys/net/ethernet */
  76 #define NET_ETHER               0x02000000
  77 
  78 /* /proc/sys/net/802 */
  79 #define NET_802                 0x03000000
  80 
  81 /* /proc/sys/net/unix */
  82 #define NET_UNIX                0x04000000
  83 
  84 /* /proc/sys/net/ipv4 */
  85 #define NET_IPV4                0x05000000
  86 
  87 /* /proc/sys/net/ipx */
  88 #define NET_IPX                 0x06000000
  89 
  90 /* /proc/sys/net/appletalk */
  91 #define NET_ATALK               0x07000000
  92 
  93 /* /proc/sys/net/netrom */
  94 #define NET_NETROM              0x08000000
  95 
  96 /* /proc/sys/net/ax25 */
  97 #define NET_AX25                0x09000000
  98 
  99 /* CTL_PROC names: */
 100 
 101 /* CTL_FS names: */
 102 
 103 /* CTL_DEBUG names: */
 104 
 105 /* CTL_DEV names: */
 106 
 107 #ifdef __KERNEL__
 108 
 109 extern asmlinkage int sys_sysctl(struct __sysctl_args *);
 110 extern void init_sysctl(void);
 111 
 112 typedef struct ctl_table ctl_table;
 113 
 114 typedef int ctl_handler (ctl_table *table, int *name, int nlen,
 115                          void *oldval, size_t *oldlenp,
 116                          void *newval, size_t newlen, 
 117                          void **context);
 118 
 119 typedef int proc_handler (ctl_table *ctl, int write, struct file * filp,
 120                           void *buffer, size_t *lenp);
 121 
 122 extern int proc_dostring(ctl_table *, int, struct file *,
 123                          void *, size_t *);
 124 extern int proc_dointvec(ctl_table *, int, struct file *,
 125                          void *, size_t *);
 126 extern int proc_dointvec_minmax(ctl_table *, int, struct file *,
 127                                 void *, size_t *);
 128 
 129 extern int do_sysctl (int *name, int nlen,
 130                       void *oldval, size_t *oldlenp,
 131                       void *newval, size_t newlen);
 132 
 133 extern int do_sysctl_strategy (ctl_table *table, 
 134                                int *name, int nlen,
 135                                void *oldval, size_t *oldlenp,
 136                                void *newval, size_t newlen, void ** context);
 137 
 138 extern ctl_handler sysctl_string;
 139 extern ctl_handler sysctl_intvec;
 140 
 141 extern int do_string (
 142         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 143         int rdwr, char *data, size_t max);
 144 extern int do_int (
 145         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 146         int rdwr, int *data);
 147 extern int do_struct (
 148         void *oldval, size_t *oldlenp, void *newval, size_t newlen,
 149         int rdwr, void *data, size_t len);
 150 
 151 
 152 /*
 153  * Register a set of sysctl names by calling register_sysctl_table
 154  * with an initialised array of ctl_table's.  An entry with zero
 155  * ctl_name terminates the table.  table->de will be set up by the
 156  * registration and need not be initialised in advance.
 157  *
 158  * sysctl names can be mirrored automatically under /proc/sys.  The
 159  * procname supplied controls /proc naming.
 160  *
 161  * The table's mode will be honoured both for sys_sysctl(2) and
 162  * proc-fs access.
 163  *
 164  * Leaf nodes in the sysctl tree will be represented by a single file
 165  * under /proc; non-leaf nodes will be represented by directories.  A
 166  * null procname disables /proc mirroring at this node.
 167  * 
 168  * sysctl(2) can automatically manage read and write requests through
 169  * the sysctl table.  The data and maxlen fields of the ctl_table
 170  * struct enable minimal validation of the values being written to be
 171  * performed, and the mode field allows minimal authentication.
 172  * 
 173  * More sophisticated management can be enabled by the provision of a
 174  * strategy routine with the table entry.  This will be called before
 175  * any automatic read or write of the data is performed.
 176  * 
 177  * The strategy routine may return:
 178  * <0: Error occurred (error is passed to user process)
 179  * 0:  OK - proceed with automatic read or write.
 180  * >0: OK - read or write has been done by the strategy routine, so 
 181  *     return immediately.
 182  * 
 183  * There must be a proc_handler routine for any terminal nodes
 184  * mirrored under /proc/sys (non-terminals are handled by a built-in
 185  * directory handler).  Several default handlers are available to
 186  * cover common cases.
 187  */
 188 
 189 /* A sysctl table is an array of struct ctl_table: */
 190 struct ctl_table 
 191 {
 192         int ctl_name;                   /* Binary ID */
 193         const char *procname;           /* Text ID for /proc/sys, or zero */
 194         void *data;
 195         int maxlen;
 196         mode_t mode;
 197         ctl_table *child;
 198         proc_handler *proc_handler;     /* Callback for text formatting */
 199         ctl_handler *strategy;          /* Callback function for all r/w */
 200         struct proc_dir_entry *de;      /* /proc control block */
 201         void *extra1;
 202         void *extra2;
 203 };
 204 
 205 /* struct ctl_table_header is used to maintain dynamic lists of
 206    ctl_table trees. */
 207 struct ctl_table_header
 208 {
 209         ctl_table *ctl_table;
 210         DLNODE(struct ctl_table_header) ctl_entry;      
 211 };
 212 
 213 struct ctl_table_header * register_sysctl_table(ctl_table * table, 
 214                                                 int insert_at_head);
 215 void unregister_sysctl_table(struct ctl_table_header * table);
 216 
 217 #else /* __KERNEL__ */
 218 
 219 #endif /* __KERNEL__ */
 220 
 221 #endif /* _LINUX_SYSCTL_H */

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