linux-old/include/linux/proc_fs.h
<<
>>
Prefs
   1#ifndef _LINUX_PROC_FS_H
   2#define _LINUX_PROC_FS_H
   3
   4#include <linux/config.h>
   5#include <linux/slab.h>
   6
   7/*
   8 * The proc filesystem constants/structures
   9 */
  10
  11/*
  12 * Offset of the first process in the /proc root directory..
  13 */
  14#define FIRST_PROCESS_ENTRY 256
  15
  16
  17/*
  18 * We always define these enumerators
  19 */
  20
  21enum {
  22        PROC_ROOT_INO = 1,
  23};
  24
  25/* Finally, the dynamically allocatable proc entries are reserved: */
  26
  27#define PROC_DYNAMIC_FIRST 4096
  28#define PROC_NDYNAMIC      4096
  29
  30#define PROC_SUPER_MAGIC 0x9fa0
  31
  32/*
  33 * This is not completely implemented yet. The idea is to
  34 * create an in-memory tree (like the actual /proc filesystem
  35 * tree) of these proc_dir_entries, so that we can dynamically
  36 * add new files to /proc.
  37 *
  38 * The "next" pointer creates a linked list of one /proc directory,
  39 * while parent/subdir create the directory structure (every
  40 * /proc file has a parent, but "subdir" is NULL for all
  41 * non-directory entries).
  42 *
  43 * "get_info" is called at "read", while "owner" is used to protect module
  44 * from unloading while proc_dir_entry is in use
  45 */
  46
  47typedef int (read_proc_t)(char *page, char **start, off_t off,
  48                          int count, int *eof, void *data);
  49typedef int (write_proc_t)(struct file *file, const char *buffer,
  50                           unsigned long count, void *data);
  51typedef int (get_info_t)(char *, char **, off_t, int);
  52
  53struct proc_dir_entry {
  54        unsigned short low_ino;
  55        unsigned short namelen;
  56        const char *name;
  57        mode_t mode;
  58        nlink_t nlink;
  59        uid_t uid;
  60        gid_t gid;
  61        unsigned long size;
  62        struct inode_operations * proc_iops;
  63        struct file_operations * proc_fops;
  64        get_info_t *get_info;
  65        struct module *owner;
  66        struct proc_dir_entry *next, *parent, *subdir;
  67        void *data;
  68        read_proc_t *read_proc;
  69        write_proc_t *write_proc;
  70        atomic_t count;         /* use count */
  71        int deleted;            /* delete flag */
  72        kdev_t  rdev;
  73};
  74
  75#define PROC_INODE_PROPER(inode) ((inode)->i_ino & ~0xffff)
  76
  77#ifdef CONFIG_PROC_FS
  78
  79extern struct proc_dir_entry proc_root;
  80extern struct proc_dir_entry *proc_root_fs;
  81extern struct proc_dir_entry *proc_net;
  82extern struct proc_dir_entry *proc_bus;
  83extern struct proc_dir_entry *proc_root_driver;
  84extern struct proc_dir_entry *proc_root_kcore;
  85
  86extern void proc_root_init(void);
  87extern void proc_misc_init(void);
  88
  89struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry);
  90void proc_pid_delete_inode(struct inode *inode);
  91int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
  92
  93extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
  94                                                struct proc_dir_entry *parent);
  95extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
  96
  97extern struct vfsmount *proc_mnt;
  98extern struct super_block *proc_read_super(struct super_block *,void *,int);
  99extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
 100
 101extern int proc_match(int, const char *,struct proc_dir_entry *);
 102
 103/*
 104 * These are generic /proc routines that use the internal
 105 * "struct proc_dir_entry" tree to traverse the filesystem.
 106 *
 107 * The /proc root directory has extended versions to take care
 108 * of the /proc/<pid> subdirectories.
 109 */
 110extern int proc_readdir(struct file *, void *, filldir_t);
 111extern struct dentry *proc_lookup(struct inode *, struct dentry *);
 112
 113extern struct file_operations proc_kcore_operations;
 114extern struct file_operations proc_kmsg_operations;
 115extern struct file_operations ppc_htab_operations;
 116
 117/*
 118 * proc_tty.c
 119 */
 120struct tty_driver;
 121extern void proc_tty_init(void);
 122extern void proc_tty_register_driver(struct tty_driver *driver);
 123extern void proc_tty_unregister_driver(struct tty_driver *driver);
 124
 125/*
 126 * proc_devtree.c
 127 */
 128extern void proc_device_tree_init(void);
 129
 130/*
 131 * proc_rtas.c
 132 */
 133extern void proc_rtas_init(void);
 134
 135/*
 136 * PPC64
 137 */ 
 138extern void proc_ppc64_init(void);
 139extern void iSeries_proc_create(void);
 140
 141extern struct proc_dir_entry *proc_symlink(const char *,
 142                struct proc_dir_entry *, const char *);
 143extern struct proc_dir_entry *proc_mknod(const char *,mode_t,
 144                struct proc_dir_entry *,kdev_t);
 145extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
 146
 147static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
 148        mode_t mode, struct proc_dir_entry *base, 
 149        read_proc_t *read_proc, void * data)
 150{
 151        struct proc_dir_entry *res=create_proc_entry(name,mode,base);
 152        if (res) {
 153                res->read_proc=read_proc;
 154                res->data=data;
 155        }
 156        return res;
 157}
 158 
 159static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
 160        mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
 161{
 162        struct proc_dir_entry *res=create_proc_entry(name,mode,base);
 163        if (res) res->get_info=get_info;
 164        return res;
 165}
 166 
 167static inline struct proc_dir_entry *proc_net_create(const char *name,
 168        mode_t mode, get_info_t *get_info)
 169{
 170        return create_proc_info_entry(name,mode,proc_net,get_info);
 171}
 172
 173static inline void proc_net_remove(const char *name)
 174{
 175        remove_proc_entry(name,proc_net);
 176}
 177
 178#else
 179
 180#define proc_root_driver NULL
 181
 182static inline struct proc_dir_entry *proc_net_create(const char *name, mode_t mode, 
 183        get_info_t *get_info) {return NULL;}
 184static inline void proc_net_remove(const char *name) {}
 185
 186static inline struct proc_dir_entry *create_proc_entry(const char *name,
 187        mode_t mode, struct proc_dir_entry *parent) { return NULL; }
 188
 189static inline void remove_proc_entry(const char *name, struct proc_dir_entry *parent) {};
 190static inline struct proc_dir_entry *proc_symlink(const char *name,
 191                struct proc_dir_entry *parent,char *dest) {return NULL;}
 192static inline struct proc_dir_entry *proc_mknod(const char *name,mode_t mode,
 193                struct proc_dir_entry *parent,kdev_t rdev) {return NULL;}
 194static inline struct proc_dir_entry *proc_mkdir(const char *name,
 195        struct proc_dir_entry *parent) {return NULL;}
 196
 197static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
 198        mode_t mode, struct proc_dir_entry *base, 
 199        int (*read_proc)(char *, char **, off_t, int, int *, void *),
 200        void * data) { return NULL; }
 201static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
 202        mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
 203        { return NULL; }
 204
 205static inline void proc_tty_register_driver(struct tty_driver *driver) {};
 206static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
 207
 208extern struct proc_dir_entry proc_root;
 209
 210#endif /* CONFIG_PROC_FS */
 211
 212#endif /* _LINUX_PROC_FS_H */
 213
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.