Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
#ifndef _LINUX_PROC_FS_H
2
#define _LINUX_PROC_FS_H
3
 
4
#include <linux/config.h>
5
#include <linux/slab.h>
6
#include <linux/fs.h>
7
#include <asm/atomic.h>
8
 
9
/*
10
 * The proc filesystem constants/structures
11
 */
12
 
13
/*
14
 * Offset of the first process in the /proc root directory..
15
 */
16
#define FIRST_PROCESS_ENTRY 256
17
 
18
 
19
/*
20
 * We always define these enumerators
21
 */
22
 
23
enum {
24
        PROC_ROOT_INO = 1,
25
};
26
 
27
/* Finally, the dynamically allocatable proc entries are reserved: */
28
 
29
#define PROC_DYNAMIC_FIRST 4096
30
#define PROC_NDYNAMIC      16384
31
 
32
#define PROC_SUPER_MAGIC 0x9fa0
33
 
34
/*
35
 * This is not completely implemented yet. The idea is to
36
 * create an in-memory tree (like the actual /proc filesystem
37
 * tree) of these proc_dir_entries, so that we can dynamically
38
 * add new files to /proc.
39
 *
40
 * The "next" pointer creates a linked list of one /proc directory,
41
 * while parent/subdir create the directory structure (every
42
 * /proc file has a parent, but "subdir" is NULL for all
43
 * non-directory entries).
44
 *
45
 * "get_info" is called at "read", while "owner" is used to protect module
46
 * from unloading while proc_dir_entry is in use
47
 */
48
 
49
typedef int (read_proc_t)(char *page, char **start, off_t off,
50
                          int count, int *eof, void *data);
51
typedef int (write_proc_t)(struct file *file, const char __user *buffer,
52
                           unsigned long count, void *data);
53
typedef int (get_info_t)(char *, char **, off_t, int);
54
 
55
struct proc_dir_entry {
56
        unsigned short low_ino;
57
        unsigned short namelen;
58
        const char *name;
59
        mode_t mode;
60
        nlink_t nlink;
61
        uid_t uid;
62
        gid_t gid;
63
        unsigned long size;
64
        struct inode_operations * proc_iops;
65
        struct file_operations * proc_fops;
66
        get_info_t *get_info;
67
        struct module *owner;
68
        struct proc_dir_entry *next, *parent, *subdir;
69
        void *data;
70
        read_proc_t *read_proc;
71
        write_proc_t *write_proc;
72
        atomic_t count;         /* use count */
73
        int deleted;            /* delete flag */
74
};
75
 
76
struct kcore_list {
77
        struct kcore_list *next;
78
        unsigned long addr;
79
        size_t size;
80
};
81
 
82
#ifdef CONFIG_PROC_FS
83
 
84
extern struct proc_dir_entry proc_root;
85
extern struct proc_dir_entry *proc_root_fs;
86
extern struct proc_dir_entry *proc_net;
87
extern struct proc_dir_entry *proc_bus;
88
extern struct proc_dir_entry *proc_root_driver;
89
extern struct proc_dir_entry *proc_root_kcore;
90
 
91
extern void proc_root_init(void);
92
extern void proc_misc_init(void);
93
 
94
struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *);
95
struct dentry *proc_pid_unhash(struct task_struct *p);
96
void proc_pid_flush(struct dentry *proc_dentry);
97
int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
98
 
99
extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
100
                                                struct proc_dir_entry *parent);
101
extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
102
 
103
extern struct vfsmount *proc_mnt;
104
extern int proc_fill_super(struct super_block *,void *,int);
105
extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
106
 
107
extern int proc_match(int, const char *,struct proc_dir_entry *);
108
 
109
/*
110
 * These are generic /proc routines that use the internal
111
 * "struct proc_dir_entry" tree to traverse the filesystem.
112
 *
113
 * The /proc root directory has extended versions to take care
114
 * of the /proc/<pid> subdirectories.
115
 */
116
extern int proc_readdir(struct file *, void *, filldir_t);
117
extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *);
118
 
119
extern struct file_operations proc_kcore_operations;
120
extern struct file_operations proc_kmsg_operations;
121
extern struct file_operations ppc_htab_operations;
122
 
123
/*
124
 * proc_tty.c
125
 */
126
struct tty_driver;
127
extern void proc_tty_init(void);
128
extern void proc_tty_register_driver(struct tty_driver *driver);
129
extern void proc_tty_unregister_driver(struct tty_driver *driver);
130
 
131
/*
132
 * proc_devtree.c
133
 */
134
extern void proc_device_tree_init(void);
135
 
136
/*
137
 * proc_rtas.c
138
 */
139
extern void proc_rtas_init(void);
140
 
141
extern struct proc_dir_entry *proc_symlink(const char *,
142
                struct proc_dir_entry *, const char *);
143
extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
144
 
145
static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
146
        mode_t mode, struct proc_dir_entry *base,
147
        read_proc_t *read_proc, void * data)
148
{
149
        struct proc_dir_entry *res=create_proc_entry(name,mode,base);
150
        if (res) {
151
                res->read_proc=read_proc;
152
                res->data=data;
153
        }
154
        return res;
155
}
156
 
157
static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
158
        mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
159
{
160
        struct proc_dir_entry *res=create_proc_entry(name,mode,base);
161
        if (res) res->get_info=get_info;
162
        return res;
163
}
164
 
165
static inline struct proc_dir_entry *proc_net_create(const char *name,
166
        mode_t mode, get_info_t *get_info)
167
{
168
        return create_proc_info_entry(name,mode,proc_net,get_info);
169
}
170
 
171
static inline struct proc_dir_entry *proc_net_fops_create(const char *name,
172
        mode_t mode, struct file_operations *fops)
173
{
174
        struct proc_dir_entry *res = create_proc_entry(name, mode, proc_net);
175
        if (res)
176
                res->proc_fops = fops;
177
        return res;
178
}
179
 
180
static inline void proc_net_remove(const char *name)
181
{
182
        remove_proc_entry(name,proc_net);
183
}
184
 
185
#else
186
 
187
#define proc_root_driver NULL
188
#define proc_net NULL
189
 
190
#define proc_net_fops_create(name, mode, fops)  ({ (void)(mode), NULL; })
191
#define proc_net_create(name, mode, info)       ({ (void)(mode), NULL; })
192
static inline void proc_net_remove(const char *name) {}
193
 
194
static inline struct dentry *proc_pid_unhash(struct task_struct *p) { return NULL; }
195
static inline void proc_pid_flush(struct dentry *proc_dentry) { }
196
 
197
static inline struct proc_dir_entry *create_proc_entry(const char *name,
198
        mode_t mode, struct proc_dir_entry *parent) { return NULL; }
199
 
200
#define remove_proc_entry(name, parent) do {} while (0)
201
 
202
static inline struct proc_dir_entry *proc_symlink(const char *name,
203
                struct proc_dir_entry *parent,char *dest) {return NULL;}
204
static inline struct proc_dir_entry *proc_mkdir(const char *name,
205
        struct proc_dir_entry *parent) {return NULL;}
206
 
207
static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
208
        mode_t mode, struct proc_dir_entry *base,
209
        int (*read_proc)(char *, char **, off_t, int, int *, void *),
210
        void * data) { return NULL; }
211
static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
212
        mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
213
        { return NULL; }
214
 
215
struct tty_driver;
216
static inline void proc_tty_register_driver(struct tty_driver *driver) {};
217
static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
218
 
219
extern struct proc_dir_entry proc_root;
220
 
221
#endif /* CONFIG_PROC_FS */
222
 
223
#if !defined(CONFIG_PROC_FS)
224
static inline void kclist_add(struct kcore_list *new, void *addr, size_t size)
225
{
226
}
227
static inline struct kcore_list * kclist_del(void *addr)
228
{
229
        return NULL;
230
}
231
#else
232
extern void kclist_add(struct kcore_list *, void *, size_t);
233
extern struct kcore_list *kclist_del(void *);
234
#endif
235
 
236
struct proc_inode {
237
        struct task_struct *task;
238
        int type;
239
        union {
240
                int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
241
                int (*proc_read)(struct task_struct *task, char *page);
242
        } op;
243
        struct proc_dir_entry *pde;
244
        struct inode vfs_inode;
245
};
246
 
247
static inline struct proc_inode *PROC_I(const struct inode *inode)
248
{
249
        return container_of(inode, struct proc_inode, vfs_inode);
250
}
251
 
252
static inline struct proc_dir_entry *PDE(const struct inode *inode)
253
{
254
        return PROC_I(inode)->pde;
255
}
256
 
257
#endif /* _LINUX_PROC_FS_H */