source: GPL/trunk/include/linux/proc_fs.h

Last change on this file was 679, checked in by David Azarewicz, 4 years ago

Merge changes from Paul's uniaud32next branch.

File size: 9.2 KB
Line 
1#ifndef _LINUX_PROC_FS_H
2#define _LINUX_PROC_FS_H
3
4#include <linux/config.h>
5#include <linux/malloc.h>
6
7/*
8 * The proc filesystem constants/structures
9 */
10
11struct proc_ops {
12 int (*proc_open)(struct inode *, struct file *);
13 ssize_t (*proc_read)(struct file *, char __user *, size_t, loff_t *);
14 ssize_t (*proc_write)(struct file *, const char __user *, size_t, loff_t *);
15 loff_t (*proc_lseek)(struct file *, loff_t, int);
16 int (*proc_release)(struct inode *, struct file *);
17 __poll_t (*proc_poll)(struct file *, struct poll_table_struct *);
18 long (*proc_ioctl)(struct file *, unsigned int, unsigned long);
19#ifdef CONFIG_COMPAT
20 long (*proc_compat_ioctl)(struct file *, unsigned int, unsigned long);
21#endif
22 int (*proc_mmap)(struct file *, struct vm_area_struct *);
23 unsigned long (*proc_get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
24};
25
26/*
27 * Offset of the first process in the /proc root directory..
28 */
29#define FIRST_PROCESS_ENTRY 256
30
31
32/*
33 * We always define these enumerators
34 */
35
36enum {
37 PROC_ROOT_INO = 1,
38};
39
40/* Finally, the dynamically allocatable proc entries are reserved: */
41
42#define PROC_DYNAMIC_FIRST 4096
43#define PROC_NDYNAMIC 4096
44#define PROC_OPENPROM_FIRST (PROC_DYNAMIC_FIRST+PROC_NDYNAMIC)
45#define PROC_OPENPROM PROC_OPENPROM_FIRST
46#define PROC_NOPENPROM 4096
47#define PROC_OPENPROMD_FIRST (PROC_OPENPROM_FIRST+PROC_NOPENPROM)
48#define PROC_NOPENPROMD 4096
49
50#define PROC_SUPER_MAGIC 0x9fa0
51
52/*
53 * This is not completely implemented yet. The idea is to
54 * create an in-memory tree (like the actual /proc filesystem
55 * tree) of these proc_dir_entries, so that we can dynamically
56 * add new files to /proc.
57 *
58 * The "next" pointer creates a linked list of one /proc directory,
59 * while parent/subdir create the directory structure (every
60 * /proc file has a parent, but "subdir" is NULL for all
61 * non-directory entries).
62 *
63 * "get_info" is called at "read", while "owner" is used to protect module
64 * from unloading while proc_dir_entry is in use
65 */
66
67typedef int (read_proc_t)(char *page, char **start, off_t off,
68 int count, int *eof, void *data);
69typedef int (write_proc_t)(struct file *file, const char *buffer,
70 unsigned long count, void *data);
71typedef int (get_info_t)(char *, char **, off_t, int, int);
72
73struct proc_dir_entry {
74 unsigned short low_ino;
75 unsigned short namelen;
76 const char *name;
77 mode_t mode;
78 nlink_t nlink;
79 uid_t uid;
80 gid_t gid;
81 unsigned long size;
82 struct inode_operations * ops;
83 get_info_t *get_info;
84 struct module *owner;
85 struct proc_dir_entry *next, *parent, *subdir;
86 void *data;
87 read_proc_t *read_proc;
88 write_proc_t *write_proc;
89 int (*readlink_proc)(struct proc_dir_entry *de, char *page);
90 void (*fill_inode)(struct inode *inode, int fill);
91 unsigned int count; /* use count */
92 int deleted; /* delete flag */
93};
94
95#define PROC_INODE_PROPER(inode) ((inode)->i_ino & ~0xffff)
96#define PROC_INODE_OPENPROM(inode) \
97 ((inode->i_ino >= PROC_OPENPROM_FIRST) \
98 && (inode->i_ino < PROC_OPENPROM_FIRST + PROC_NOPENPROM))
99
100#ifdef CONFIG_PROC_FS
101extern struct proc_dir_entry proc_root;
102extern struct proc_dir_entry *proc_root_fs;
103extern struct proc_dir_entry *proc_net;
104extern struct proc_dir_entry proc_sys;
105extern struct proc_dir_entry proc_openprom;
106extern struct proc_dir_entry *proc_mca;
107extern struct proc_dir_entry *proc_bus;
108extern struct proc_dir_entry *proc_root_driver;
109extern struct proc_dir_entry proc_root_kcore;
110
111extern void proc_root_init(void);
112extern void proc_misc_init(void);
113
114struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry);
115void proc_pid_delete_inode(struct inode *inode);
116int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
117
118extern int proc_register(struct proc_dir_entry *, struct proc_dir_entry *);
119extern int proc_unregister(struct proc_dir_entry *, int);
120
121extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
122 struct proc_dir_entry *parent);
123
124extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
125
126
127/*
128 * retrieve the proc_dir_entry associated with /proc/driver/$module_name
129 */
130struct proc_dir_entry *proc_driver_find (const char *module_name);
131
132
133/*
134 * remove /proc/driver/$module_name, and all its contents
135 */
136int proc_driver_unregister(const char *module_name);
137
138
139/*
140 * create driver-specific playground directory, /proc/driver/$module_name
141 */
142int proc_driver_register(const char *module_name);
143
144extern struct super_block *proc_super_blocks;
145extern struct dentry_operations proc_dentry_operations;
146extern struct super_block *proc_read_super(struct super_block *,void *,int);
147extern int init_proc_fs(void);
148extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
149extern int proc_statfs(struct super_block *, struct statfs *, int);
150extern void proc_read_inode(struct inode *);
151extern void proc_write_inode(struct inode *);
152
153extern int proc_match(int, const char *,struct proc_dir_entry *);
154
155/*
156 * These are generic /proc routines that use the internal
157 * "struct proc_dir_entry" tree to traverse the filesystem.
158 *
159 * The /proc root directory has extended versions to take care
160 * of the /proc/<pid> subdirectories.
161 */
162extern int proc_readdir(struct file *, void *, filldir_t);
163extern struct dentry *proc_lookup(struct inode *, struct dentry *);
164
165struct openpromfs_dev {
166 struct openpromfs_dev *next;
167 u32 node;
168 ino_t inode;
169 kdev_t rdev;
170 mode_t mode;
171 char name[32];
172};
173extern struct inode_operations *
174proc_openprom_register(int (*readdir)(struct file *, void *, filldir_t),
175 struct dentry * (*lookup)(struct inode *, struct dentry *),
176 void (*use)(struct inode *, int),
177 struct openpromfs_dev ***);
178extern void proc_openprom_deregister(void);
179extern void (*proc_openprom_use)(struct inode *,int);
180extern int proc_openprom_regdev(struct openpromfs_dev *);
181extern int proc_openprom_unregdev(struct openpromfs_dev *);
182
183extern struct inode_operations proc_dir_inode_operations;
184extern struct inode_operations proc_file_inode_operations;
185extern struct inode_operations proc_openprom_inode_operations;
186extern struct inode_operations proc_sys_inode_operations;
187extern struct inode_operations proc_kcore_inode_operations;
188extern struct inode_operations proc_profile_inode_operations;
189extern struct inode_operations proc_kmsg_inode_operations;
190#if CONFIG_AP1000
191extern struct inode_operations proc_ringbuf_inode_operations;
192#endif
193extern struct inode_operations proc_omirr_inode_operations;
194extern struct inode_operations proc_ppc_htab_inode_operations;
195
196/*
197 * proc_tty.c
198 */
199extern void proc_tty_init(void);
200extern void proc_tty_register_driver(struct tty_driver *driver);
201extern void proc_tty_unregister_driver(struct tty_driver *driver);
202
203/*
204 * proc_devtree.c
205 */
206extern void proc_device_tree_init(void);
207
208static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
209 mode_t mode, struct proc_dir_entry *base,
210 read_proc_t *read_proc, void * data)
211{
212 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
213 if (res) {
214 res->read_proc=read_proc;
215 res->data=data;
216 }
217 return res;
218}
219
220struct proc_dir_entry *create_proc_info_entry(const char *name,
221 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info);
222struct proc_dir_entry *proc_net_create(const char *name);
223void proc_net_remove(const char *name);
224static inline void proc_remove(struct proc_dir_entry *de) {}
225#else
226
227extern inline int proc_register(struct proc_dir_entry *a, struct proc_dir_entry *b) { return 0; }
228extern inline int proc_unregister(struct proc_dir_entry *a, int b) { return 0; }
229extern inline struct proc_dir_entry *proc_net_create(const char *name, mode_t mode,
230 get_info_t *get_info) {return NULL;}
231extern inline void proc_net_remove(const char *name) {}
232
233extern inline struct proc_dir_entry *create_proc_entry(const char *name,
234 mode_t mode, struct proc_dir_entry *parent) { return NULL; }
235
236extern inline void remove_proc_entry(const char *name, struct proc_dir_entry *parent) {};
237
238extern inline void proc_tty_register_driver(struct tty_driver *driver) {};
239extern inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
240
241static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
242 mode_t mode, struct proc_dir_entry *base,
243 read_proc_t *read_proc, void * data) { return NULL; }
244struct proc_dir_entry *create_proc_info_entry(const char *name,
245 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info);
246void proc_net_remove(const char *name);
247
248extern struct proc_dir_entry proc_root;
249static inline void proc_remove(struct proc_dir_entry *de) {}
250static inline void *PDE_DATA(const struct inode *inode) {return NULL;}
251#endif /* CONFIG_PROC_FS */
252
253static inline struct proc_dir_entry *PDE(const struct inode *inode)
254{
255 return (struct proc_dir_entry *) inode->u.generic_ip;
256}
257static inline void *PDE_DATA(const struct inode *inode) {return NULL;}
258
259extern struct proc_dir_entry *proc_symlink(const char *,
260 struct proc_dir_entry *, const char *);
261extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
262#endif /* _LINUX_PROC_FS_H */
Note: See TracBrowser for help on using the repository browser.