source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/proc_fs.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

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