1 #ifndef _LINUX_FS_H
2 #define _LINUX_FS_H
3
4
5
6
7
8
9 #include <linux/limits.h>
10 #include <linux/wait.h>
11 #include <linux/types.h>
12 #include <linux/dirent.h>
13 #include <linux/vfs.h>
14
15
16
17
18
19
20
21
22
23 #undef NR_OPEN
24 #define NR_OPEN 256
25
26 #define NR_INODE 256
27 #define NR_FILE 128
28 #define NR_SUPER 16
29 #define NR_HASH 997
30 #define NR_FILE_LOCKS 32
31 #define BLOCK_SIZE 1024
32 #define BLOCK_SIZE_BITS 10
33 #define MAX_CHRDEV 32
34 #define MAX_BLKDEV 32
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 #define UNNAMED_MAJOR 0
58
59 #define MAY_EXEC 1
60 #define MAY_WRITE 2
61 #define MAY_READ 4
62
63 #define READ 0
64 #define WRITE 1
65 #define READA 2
66 #define WRITEA 3
67
68 extern void buffer_init(void);
69 extern unsigned long inode_init(unsigned long start, unsigned long end);
70
71 #define MAJOR(a) (((unsigned)(a))>>8)
72 #define MINOR(a) ((a)&0xff)
73
74 #ifndef NULL
75 #define NULL ((void *) 0)
76 #endif
77
78 #define NIL_FILP ((struct file *)0)
79 #define SEL_IN 1
80 #define SEL_OUT 2
81 #define SEL_EX 4
82
83
84
85
86 #define MS_RDONLY 1
87 #define MS_NOSUID 2
88 #define MS_NODEV 4
89 #define MS_NOEXEC 8
90 #define MS_SYNC 16
91
92
93
94
95
96
97
98 #define IS_RDONLY(inode) ((inode)->i_flags & MS_RDONLY)
99 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
100 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
101 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
102 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC)
103
104
105
106
107 #define BLKROSET 4701
108 #define BLKROGET 4702
109 #define BLKRRPART 4703
110 #define BLKGETSIZE 4704
111
112 #define BMAP_IOCTL 1
113 #define FIBMAP 1
114 #define FIGETBSZ 2
115
116 typedef char buffer_block[BLOCK_SIZE];
117
118 struct buffer_head {
119 char * b_data;
120 unsigned long b_size;
121 unsigned long b_blocknr;
122 dev_t b_dev;
123 unsigned short b_count;
124 unsigned char b_uptodate;
125 unsigned char b_dirt;
126 unsigned char b_lock;
127 struct wait_queue * b_wait;
128 struct buffer_head * b_prev;
129 struct buffer_head * b_next;
130 struct buffer_head * b_prev_free;
131 struct buffer_head * b_next_free;
132 struct buffer_head * b_this_page;
133 struct buffer_head * b_reqnext;
134 };
135
136 #include <linux/pipe_fs_i.h>
137 #include <linux/minix_fs_i.h>
138 #include <linux/ext_fs_i.h>
139 #include <linux/msdos_fs_i.h>
140 #include <linux/iso_fs_i.h>
141 #include <linux/nfs_fs_i.h>
142
143 struct inode {
144 dev_t i_dev;
145 unsigned long i_ino;
146 umode_t i_mode;
147 nlink_t i_nlink;
148 uid_t i_uid;
149 gid_t i_gid;
150 dev_t i_rdev;
151 off_t i_size;
152 time_t i_atime;
153 time_t i_mtime;
154 time_t i_ctime;
155 unsigned long i_blksize;
156 unsigned long i_blocks;
157 struct inode_operations * i_op;
158 struct super_block * i_sb;
159 struct wait_queue * i_wait;
160 struct file_lock * i_flock;
161 struct vm_area_struct * i_mmap;
162 struct inode * i_next, * i_prev;
163 struct inode * i_hash_next, * i_hash_prev;
164 struct inode * i_bound_to, * i_bound_by;
165 unsigned short i_count;
166 unsigned short i_flags;
167 unsigned char i_lock;
168 unsigned char i_dirt;
169 unsigned char i_pipe;
170 unsigned char i_mount;
171 unsigned char i_seek;
172 unsigned char i_update;
173 union {
174 struct pipe_inode_info pipe_i;
175 struct minix_inode_info minix_i;
176 struct ext_inode_info ext_i;
177 struct msdos_inode_info msdos_i;
178 struct iso_inode_info isofs_i;
179 struct nfs_inode_info nfs_i;
180 } u;
181 };
182
183 struct file {
184 mode_t f_mode;
185 dev_t f_rdev;
186 off_t f_pos;
187 unsigned short f_flags;
188 unsigned short f_count;
189 unsigned short f_reada;
190 struct inode * f_inode;
191 struct file_operations * f_op;
192 };
193
194 struct file_lock {
195 struct file_lock *fl_next;
196 struct task_struct *fl_owner;
197 struct wait_queue *fl_wait;
198 char fl_type;
199 char fl_whence;
200 off_t fl_start;
201 off_t fl_end;
202 };
203
204 #include <linux/minix_fs_sb.h>
205 #include <linux/ext_fs_sb.h>
206 #include <linux/msdos_fs_sb.h>
207 #include <linux/iso_fs_sb.h>
208 #include <linux/nfs_fs_sb.h>
209
210 struct super_block {
211 dev_t s_dev;
212 unsigned long s_blocksize;
213 unsigned char s_lock;
214 unsigned char s_rd_only;
215 unsigned char s_dirt;
216 struct super_operations *s_op;
217 unsigned long s_flags;
218 unsigned long s_magic;
219 unsigned long s_time;
220 struct inode * s_covered;
221 struct inode * s_mounted;
222 struct wait_queue * s_wait;
223 union {
224 struct minix_sb_info minix_sb;
225 struct ext_sb_info ext_sb;
226 struct msdos_sb_info msdos_sb;
227 struct isofs_sb_info isofs_sb;
228 struct nfs_sb_info nfs_sb;
229 } u;
230 };
231
232 struct file_operations {
233 int (*lseek) (struct inode *, struct file *, off_t, int);
234 int (*read) (struct inode *, struct file *, char *, int);
235 int (*write) (struct inode *, struct file *, char *, int);
236 int (*readdir) (struct inode *, struct file *, struct dirent *, int);
237 int (*select) (struct inode *, struct file *, int, select_table *);
238 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned int);
239 int (*mmap) (void);
240 int (*open) (struct inode *, struct file *);
241 void (*release) (struct inode *, struct file *);
242 };
243
244 struct inode_operations {
245 struct file_operations * default_file_ops;
246 int (*create) (struct inode *,const char *,int,int,struct inode **);
247 int (*lookup) (struct inode *,const char *,int,struct inode **);
248 int (*link) (struct inode *,struct inode *,const char *,int);
249 int (*unlink) (struct inode *,const char *,int);
250 int (*symlink) (struct inode *,const char *,int,const char *);
251 int (*mkdir) (struct inode *,const char *,int,int);
252 int (*rmdir) (struct inode *,const char *,int);
253 int (*mknod) (struct inode *,const char *,int,int,int);
254 int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
255 int (*readlink) (struct inode *,char *,int);
256 int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
257 int (*bmap) (struct inode *,int);
258 void (*truncate) (struct inode *);
259 };
260
261 struct super_operations {
262 void (*read_inode) (struct inode *);
263 int (*notify_change) (struct inode *);
264 void (*write_inode) (struct inode *);
265 void (*put_inode) (struct inode *);
266 void (*put_super) (struct super_block *);
267 void (*write_super) (struct super_block *);
268 void (*statfs) (struct super_block *, struct statfs *);
269 };
270
271 struct file_system_type {
272 struct super_block *(*read_super) (struct super_block *, void *);
273 char *name;
274 int requires_dev;
275 };
276
277 extern struct file_operations * chrdev_fops[MAX_CHRDEV];
278 extern struct file_operations * blkdev_fops[MAX_BLKDEV];
279
280 extern struct file_system_type *get_fs_type(char *name);
281
282 extern int fs_may_mount(dev_t dev);
283 extern int fs_may_umount(dev_t dev, struct inode * mount_root);
284
285 extern struct file file_table[NR_FILE];
286 extern struct super_block super_block[NR_SUPER];
287
288 extern void grow_buffers(int size);
289 extern int shrink_buffers(unsigned int priority);
290
291 extern int nr_buffers;
292 extern int buffermem;
293 extern int nr_buffer_heads;
294
295 extern void check_disk_change(dev_t dev);
296 extern void invalidate_inodes(dev_t dev);
297 extern void invalidate_buffers(dev_t dev);
298 extern int floppy_change(struct buffer_head * first_block);
299 extern int ticks_to_floppy_on(unsigned int dev);
300 extern void floppy_on(unsigned int dev);
301 extern void floppy_off(unsigned int dev);
302 extern void sync_inodes(dev_t dev);
303 extern void sync_dev(dev_t dev);
304 extern void sync_supers(dev_t dev);
305 extern int bmap(struct inode * inode,int block);
306 extern int notify_change(struct inode * inode);
307 extern int namei(const char * pathname, struct inode ** res_inode);
308 extern int lnamei(const char * pathname, struct inode ** res_inode);
309 extern int permission(struct inode * inode,int mask);
310 extern int open_namei(const char * pathname, int flag, int mode,
311 struct inode ** res_inode, struct inode * base);
312 extern int do_mknod(const char * filename, int mode, dev_t dev);
313 extern void iput(struct inode * inode);
314 extern struct inode * iget(struct super_block * sb,int nr);
315 extern struct inode * get_empty_inode(void);
316 extern void clear_inode(struct inode *);
317 extern struct inode * get_pipe_inode(void);
318 extern struct file * get_empty_filp(void);
319 extern struct buffer_head * get_hash_table(dev_t dev, int block, int size);
320 extern struct buffer_head * getblk(dev_t dev, int block, int size);
321 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
322 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
323 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
324 extern void brelse(struct buffer_head * buf);
325 extern struct buffer_head * bread(dev_t dev, int block, int size);
326 extern void bread_page(unsigned long addr,dev_t dev,int b[4]);
327 extern struct buffer_head * breada(dev_t dev,int block,...);
328 extern void put_super(dev_t dev);
329 extern dev_t ROOT_DEV;
330
331 extern void mount_root(void);
332
333 extern int char_read(struct inode *, struct file *, char *, int);
334 extern int block_read(struct inode *, struct file *, char *, int);
335 extern int read_ahead[];
336
337 extern int char_write(struct inode *, struct file *, char *, int);
338 extern int block_write(struct inode *, struct file *, char *, int);
339
340 #endif