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 #define MS_REMOUNT 32
92
93
94
95
96 #define MS_RMT_MASK (MS_RDONLY)
97
98
99
100
101 #define MS_MGC_VAL 0xC0ED0000
102 #define MS_MGC_MSK 0xffff0000
103
104
105
106
107
108
109
110
111
112 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
113 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
114 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
115 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
116 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC)
117
118
119
120
121 #define BLKROSET 4701
122 #define BLKROGET 4702
123 #define BLKRRPART 4703
124 #define BLKGETSIZE 4704
125
126 #define BMAP_IOCTL 1
127 #define FIBMAP 1
128 #define FIGETBSZ 2
129
130
131
132 #define NOTIFY_SIZE 1
133 #define NOTIFY_MODE 2
134 #define NOTIFY_TIME 4
135 #define NOTIFY_UIDGID 8
136
137 typedef char buffer_block[BLOCK_SIZE];
138
139 struct buffer_head {
140 char * b_data;
141 unsigned long b_size;
142 unsigned long b_blocknr;
143 dev_t b_dev;
144 unsigned short b_count;
145 unsigned char b_uptodate;
146 unsigned char b_dirt;
147 unsigned char b_lock;
148 struct wait_queue * b_wait;
149 struct buffer_head * b_prev;
150 struct buffer_head * b_next;
151 struct buffer_head * b_prev_free;
152 struct buffer_head * b_next_free;
153 struct buffer_head * b_this_page;
154 struct buffer_head * b_reqnext;
155 };
156
157 #include <linux/pipe_fs_i.h>
158 #include <linux/minix_fs_i.h>
159 #include <linux/ext_fs_i.h>
160 #include <linux/msdos_fs_i.h>
161 #include <linux/iso_fs_i.h>
162 #include <linux/nfs_fs_i.h>
163
164 struct inode {
165 dev_t i_dev;
166 unsigned long i_ino;
167 umode_t i_mode;
168 nlink_t i_nlink;
169 uid_t i_uid;
170 gid_t i_gid;
171 dev_t i_rdev;
172 off_t i_size;
173 time_t i_atime;
174 time_t i_mtime;
175 time_t i_ctime;
176 unsigned long i_blksize;
177 unsigned long i_blocks;
178 struct inode_operations * i_op;
179 struct super_block * i_sb;
180 struct wait_queue * i_wait;
181 struct file_lock * i_flock;
182 struct vm_area_struct * i_mmap;
183 struct inode * i_next, * i_prev;
184 struct inode * i_hash_next, * i_hash_prev;
185 struct inode * i_bound_to, * i_bound_by;
186 unsigned short i_count;
187 unsigned short i_flags;
188 unsigned char i_lock;
189 unsigned char i_dirt;
190 unsigned char i_pipe;
191 unsigned char i_mount;
192 unsigned char i_seek;
193 unsigned char i_update;
194 union {
195 struct pipe_inode_info pipe_i;
196 struct minix_inode_info minix_i;
197 struct ext_inode_info ext_i;
198 struct msdos_inode_info msdos_i;
199 struct iso_inode_info isofs_i;
200 struct nfs_inode_info nfs_i;
201 } u;
202 };
203
204 struct file {
205 mode_t f_mode;
206 dev_t f_rdev;
207 off_t f_pos;
208 unsigned short f_flags;
209 unsigned short f_count;
210 unsigned short f_reada;
211 struct inode * f_inode;
212 struct file_operations * f_op;
213 };
214
215 struct file_lock {
216 struct file_lock *fl_next;
217 struct task_struct *fl_owner;
218 struct wait_queue *fl_wait;
219 char fl_type;
220 char fl_whence;
221 off_t fl_start;
222 off_t fl_end;
223 };
224
225 #include <linux/minix_fs_sb.h>
226 #include <linux/ext_fs_sb.h>
227 #include <linux/msdos_fs_sb.h>
228 #include <linux/iso_fs_sb.h>
229 #include <linux/nfs_fs_sb.h>
230
231 struct super_block {
232 dev_t s_dev;
233 unsigned long s_blocksize;
234 unsigned char s_lock;
235 unsigned char s_rd_only;
236 unsigned char s_dirt;
237 struct super_operations *s_op;
238 unsigned long s_flags;
239 unsigned long s_magic;
240 unsigned long s_time;
241 struct inode * s_covered;
242 struct inode * s_mounted;
243 struct wait_queue * s_wait;
244 union {
245 struct minix_sb_info minix_sb;
246 struct ext_sb_info ext_sb;
247 struct msdos_sb_info msdos_sb;
248 struct isofs_sb_info isofs_sb;
249 struct nfs_sb_info nfs_sb;
250 } u;
251 };
252
253 struct file_operations {
254 int (*lseek) (struct inode *, struct file *, off_t, int);
255 int (*read) (struct inode *, struct file *, char *, int);
256 int (*write) (struct inode *, struct file *, char *, int);
257 int (*readdir) (struct inode *, struct file *, struct dirent *, int);
258 int (*select) (struct inode *, struct file *, int, select_table *);
259 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned int);
260 int (*mmap) (void);
261 int (*open) (struct inode *, struct file *);
262 void (*release) (struct inode *, struct file *);
263 int (*fsync) (struct inode *, struct file *);
264 };
265
266 struct inode_operations {
267 struct file_operations * default_file_ops;
268 int (*create) (struct inode *,const char *,int,int,struct inode **);
269 int (*lookup) (struct inode *,const char *,int,struct inode **);
270 int (*link) (struct inode *,struct inode *,const char *,int);
271 int (*unlink) (struct inode *,const char *,int);
272 int (*symlink) (struct inode *,const char *,int,const char *);
273 int (*mkdir) (struct inode *,const char *,int,int);
274 int (*rmdir) (struct inode *,const char *,int);
275 int (*mknod) (struct inode *,const char *,int,int,int);
276 int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
277 int (*readlink) (struct inode *,char *,int);
278 int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
279 int (*bmap) (struct inode *,int);
280 void (*truncate) (struct inode *);
281 int (*permission) (struct inode *, int);
282 };
283
284 struct super_operations {
285 void (*read_inode) (struct inode *);
286 int (*notify_change) (int flags, struct inode *);
287 void (*write_inode) (struct inode *);
288 void (*put_inode) (struct inode *);
289 void (*put_super) (struct super_block *);
290 void (*write_super) (struct super_block *);
291 void (*statfs) (struct super_block *, struct statfs *);
292 };
293
294 struct file_system_type {
295 struct super_block *(*read_super) (struct super_block *, void *);
296 char *name;
297 int requires_dev;
298 };
299
300 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
301 extern int blkdev_open(struct inode * inode, struct file * filp);
302 extern struct file_operations def_blk_fops;
303 extern struct inode_operations blkdev_inode_operations;
304
305 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
306 extern int chrdev_open(struct inode * inode, struct file * filp);
307 extern struct file_operations def_chr_fops;
308 extern struct inode_operations chrdev_inode_operations;
309
310 extern struct inode_operations fifo_inode_operations;
311
312 extern struct file_system_type *get_fs_type(char *name);
313
314 extern int fs_may_mount(dev_t dev);
315 extern int fs_may_umount(dev_t dev, struct inode * mount_root);
316
317 extern struct file file_table[NR_FILE];
318 extern struct super_block super_block[NR_SUPER];
319
320 extern void grow_buffers(int size);
321 extern int shrink_buffers(unsigned int priority);
322
323 extern int nr_buffers;
324 extern int buffermem;
325 extern int nr_buffer_heads;
326
327 extern void check_disk_change(dev_t dev);
328 extern void invalidate_inodes(dev_t dev);
329 extern void invalidate_buffers(dev_t dev);
330 extern int floppy_change(struct buffer_head * first_block);
331 extern int ticks_to_floppy_on(unsigned int dev);
332 extern void floppy_on(unsigned int dev);
333 extern void floppy_off(unsigned int dev);
334 extern void sync_inodes(dev_t dev);
335 extern void sync_dev(dev_t dev);
336 extern void sync_supers(dev_t dev);
337 extern int bmap(struct inode * inode,int block);
338 extern int notify_change(int flags, struct inode * inode);
339 extern int namei(const char * pathname, struct inode ** res_inode);
340 extern int lnamei(const char * pathname, struct inode ** res_inode);
341 extern int permission(struct inode * inode,int mask);
342 extern int open_namei(const char * pathname, int flag, int mode,
343 struct inode ** res_inode, struct inode * base);
344 extern int do_mknod(const char * filename, int mode, dev_t dev);
345 extern void iput(struct inode * inode);
346 extern struct inode * iget(struct super_block * sb,int nr);
347 extern struct inode * get_empty_inode(void);
348 extern void clear_inode(struct inode *);
349 extern struct inode * get_pipe_inode(void);
350 extern struct file * get_empty_filp(void);
351 extern struct buffer_head * get_hash_table(dev_t dev, int block, int size);
352 extern struct buffer_head * getblk(dev_t dev, int block, int size);
353 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
354 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
355 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
356 extern void brelse(struct buffer_head * buf);
357 extern struct buffer_head * bread(dev_t dev, int block, int size);
358 extern void bread_page(unsigned long addr,dev_t dev,int b[4]);
359 extern struct buffer_head * breada(dev_t dev,int block,...);
360 extern void put_super(dev_t dev);
361 extern dev_t ROOT_DEV;
362
363 extern void mount_root(void);
364
365 extern int char_read(struct inode *, struct file *, char *, int);
366 extern int block_read(struct inode *, struct file *, char *, int);
367 extern int read_ahead[];
368
369 extern int char_write(struct inode *, struct file *, char *, int);
370 extern int block_write(struct inode *, struct file *, char *, int);
371
372 #endif