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 2048
27 #define NR_FILE 1024
28 #define NR_SUPER 32
29 #define NR_HASH 997
30 #define NR_IHASH 131
31 #define NR_FILE_LOCKS 32
32 #define BLOCK_SIZE 1024
33 #define BLOCK_SIZE_BITS 10
34 #define MAX_CHRDEV 32
35 #define MAX_BLKDEV 32
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 #define UNNAMED_MAJOR 0
59
60 #define MAY_EXEC 1
61 #define MAY_WRITE 2
62 #define MAY_READ 4
63
64 #define READ 0
65 #define WRITE 1
66 #define READA 2
67 #define WRITEA 3
68
69 extern void buffer_init(void);
70 extern unsigned long inode_init(unsigned long start, unsigned long end);
71 extern unsigned long file_table_init(unsigned long start, unsigned long end);
72
73 #define MAJOR(a) (((unsigned)(a))>>8)
74 #define MINOR(a) ((a)&0xff)
75
76 #ifndef NULL
77 #define NULL ((void *) 0)
78 #endif
79
80 #define NIL_FILP ((struct file *)0)
81 #define SEL_IN 1
82 #define SEL_OUT 2
83 #define SEL_EX 4
84
85
86
87
88 #define MS_RDONLY 1
89 #define MS_NOSUID 2
90 #define MS_NODEV 4
91 #define MS_NOEXEC 8
92 #define MS_SYNC 16
93 #define MS_REMOUNT 32
94
95
96
97
98 #define MS_RMT_MASK (MS_RDONLY)
99
100
101
102
103 #define MS_MGC_VAL 0xC0ED0000
104 #define MS_MGC_MSK 0xffff0000
105
106
107
108
109
110
111
112
113
114 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
115 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
116 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
117 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
118 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC)
119
120
121
122
123 #define BLKROSET 4701
124 #define BLKROGET 4702
125 #define BLKRRPART 4703
126 #define BLKGETSIZE 4704
127
128 #define BMAP_IOCTL 1
129 #define FIBMAP 1
130 #define FIGETBSZ 2
131
132
133
134 #define NOTIFY_SIZE 1
135 #define NOTIFY_MODE 2
136 #define NOTIFY_TIME 4
137 #define NOTIFY_UIDGID 8
138
139 typedef char buffer_block[BLOCK_SIZE];
140
141 struct buffer_head {
142 char * b_data;
143 unsigned long b_size;
144 unsigned long b_blocknr;
145 dev_t b_dev;
146 unsigned short b_count;
147 unsigned char b_uptodate;
148 unsigned char b_dirt;
149 unsigned char b_lock;
150 unsigned char b_req;
151 struct wait_queue * b_wait;
152 struct buffer_head * b_prev;
153 struct buffer_head * b_next;
154 struct buffer_head * b_prev_free;
155 struct buffer_head * b_next_free;
156 struct buffer_head * b_this_page;
157 struct buffer_head * b_reqnext;
158 };
159
160 #include <linux/pipe_fs_i.h>
161 #include <linux/minix_fs_i.h>
162 #include <linux/ext_fs_i.h>
163 #include <linux/ext2_fs_i.h>
164 #include <linux/msdos_fs_i.h>
165 #include <linux/iso_fs_i.h>
166 #include <linux/nfs_fs_i.h>
167 #include <linux/xia_fs_i.h>
168
169 struct inode {
170 dev_t i_dev;
171 unsigned long i_ino;
172 umode_t i_mode;
173 nlink_t i_nlink;
174 uid_t i_uid;
175 gid_t i_gid;
176 dev_t i_rdev;
177 off_t i_size;
178 time_t i_atime;
179 time_t i_mtime;
180 time_t i_ctime;
181 unsigned long i_blksize;
182 unsigned long i_blocks;
183 struct inode_operations * i_op;
184 struct super_block * i_sb;
185 struct wait_queue * i_wait;
186 struct file_lock * i_flock;
187 struct vm_area_struct * i_mmap;
188 struct inode * i_next, * i_prev;
189 struct inode * i_hash_next, * i_hash_prev;
190 struct inode * i_bound_to, * i_bound_by;
191 unsigned short i_count;
192 unsigned short i_flags;
193 unsigned char i_lock;
194 unsigned char i_dirt;
195 unsigned char i_pipe;
196 unsigned char i_mount;
197 unsigned char i_seek;
198 unsigned char i_update;
199 union {
200 struct pipe_inode_info pipe_i;
201 struct minix_inode_info minix_i;
202 struct ext_inode_info ext_i;
203 struct ext2_inode_info ext2_i;
204 struct msdos_inode_info msdos_i;
205 struct iso_inode_info isofs_i;
206 struct nfs_inode_info nfs_i;
207 struct xiafs_inode_info xiafs_i;
208 } u;
209 };
210
211 struct file {
212 mode_t f_mode;
213 dev_t f_rdev;
214 off_t f_pos;
215 unsigned short f_flags;
216 unsigned short f_count;
217 unsigned short f_reada;
218 struct file *f_next, *f_prev;
219 struct inode * f_inode;
220 struct file_operations * f_op;
221 };
222
223 struct file_lock {
224 struct file_lock *fl_next;
225 struct task_struct *fl_owner;
226 struct wait_queue *fl_wait;
227 char fl_type;
228 char fl_whence;
229 off_t fl_start;
230 off_t fl_end;
231 };
232
233 #include <linux/minix_fs_sb.h>
234 #include <linux/ext_fs_sb.h>
235 #include <linux/ext2_fs_sb.h>
236 #include <linux/msdos_fs_sb.h>
237 #include <linux/iso_fs_sb.h>
238 #include <linux/nfs_fs_sb.h>
239 #include <linux/xia_fs_sb.h>
240
241 struct super_block {
242 dev_t s_dev;
243 unsigned long s_blocksize;
244 unsigned char s_blocksize_bits;
245 unsigned char s_lock;
246 unsigned char s_rd_only;
247 unsigned char s_dirt;
248 struct super_operations *s_op;
249 unsigned long s_flags;
250 unsigned long s_magic;
251 unsigned long s_time;
252 struct inode * s_covered;
253 struct inode * s_mounted;
254 struct wait_queue * s_wait;
255 union {
256 struct minix_sb_info minix_sb;
257 struct ext_sb_info ext_sb;
258 struct ext2_sb_info ext2_sb;
259 struct msdos_sb_info msdos_sb;
260 struct isofs_sb_info isofs_sb;
261 struct nfs_sb_info nfs_sb;
262 struct xiafs_sb_info xiafs_sb;
263 } u;
264 };
265
266 struct file_operations {
267 int (*lseek) (struct inode *, struct file *, off_t, int);
268 int (*read) (struct inode *, struct file *, char *, int);
269 int (*write) (struct inode *, struct file *, char *, int);
270 int (*readdir) (struct inode *, struct file *, struct dirent *, int);
271 int (*select) (struct inode *, struct file *, int, select_table *);
272 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
273 int (*mmap) (struct inode *, struct file *, unsigned long, size_t, int, unsigned long);
274 int (*open) (struct inode *, struct file *);
275 void (*release) (struct inode *, struct file *);
276 int (*fsync) (struct inode *, struct file *);
277 };
278
279 struct inode_operations {
280 struct file_operations * default_file_ops;
281 int (*create) (struct inode *,const char *,int,int,struct inode **);
282 int (*lookup) (struct inode *,const char *,int,struct inode **);
283 int (*link) (struct inode *,struct inode *,const char *,int);
284 int (*unlink) (struct inode *,const char *,int);
285 int (*symlink) (struct inode *,const char *,int,const char *);
286 int (*mkdir) (struct inode *,const char *,int,int);
287 int (*rmdir) (struct inode *,const char *,int);
288 int (*mknod) (struct inode *,const char *,int,int,int);
289 int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
290 int (*readlink) (struct inode *,char *,int);
291 int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
292 int (*bmap) (struct inode *,int);
293 void (*truncate) (struct inode *);
294 int (*permission) (struct inode *, int);
295 };
296
297 struct super_operations {
298 void (*read_inode) (struct inode *);
299 int (*notify_change) (int flags, struct inode *);
300 void (*write_inode) (struct inode *);
301 void (*put_inode) (struct inode *);
302 void (*put_super) (struct super_block *);
303 void (*write_super) (struct super_block *);
304 void (*statfs) (struct super_block *, struct statfs *);
305 int (*remount_fs) (struct super_block *, int *);
306 };
307
308 struct file_system_type {
309 struct super_block *(*read_super) (struct super_block *, void *, int);
310 char *name;
311 int requires_dev;
312 };
313
314 #ifdef __KERNEL__
315
316 extern "C" int sys_open(const char *, int, int);
317 extern "C" int sys_close(unsigned int);
318
319 extern int getname(const char * filename, char **result);
320 extern void putname(char * name);
321
322 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
323 extern int blkdev_open(struct inode * inode, struct file * filp);
324 extern struct file_operations def_blk_fops;
325 extern struct inode_operations blkdev_inode_operations;
326
327 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
328 extern int chrdev_open(struct inode * inode, struct file * filp);
329 extern struct file_operations def_chr_fops;
330 extern struct inode_operations chrdev_inode_operations;
331
332 extern void init_fifo(struct inode * inode);
333
334 extern struct file_operations connecting_pipe_fops;
335 extern struct file_operations read_pipe_fops;
336 extern struct file_operations write_pipe_fops;
337 extern struct file_operations rdwr_pipe_fops;
338
339 extern struct file_system_type *get_fs_type(char *name);
340
341 extern int fs_may_mount(dev_t dev);
342 extern int fs_may_umount(dev_t dev, struct inode * mount_root);
343 extern int fs_may_remount_ro(dev_t dev);
344
345 extern struct file *first_file;
346 extern int nr_files;
347 extern struct super_block super_blocks[NR_SUPER];
348
349 extern void grow_buffers(int size);
350 extern int shrink_buffers(unsigned int priority);
351
352 extern int nr_buffers;
353 extern int buffermem;
354 extern int nr_buffer_heads;
355
356 extern void check_disk_change(dev_t dev);
357 extern void invalidate_inodes(dev_t dev);
358 extern void invalidate_buffers(dev_t dev);
359 extern int floppy_change(struct buffer_head * first_block);
360 extern void sync_inodes(dev_t dev);
361 extern void sync_dev(dev_t dev);
362 extern int fsync_dev(dev_t dev);
363 extern void sync_supers(dev_t dev);
364 extern int bmap(struct inode * inode,int block);
365 extern int notify_change(int flags, struct inode * inode);
366 extern int namei(const char * pathname, struct inode ** res_inode);
367 extern int lnamei(const char * pathname, struct inode ** res_inode);
368 extern int permission(struct inode * inode,int mask);
369 extern int open_namei(const char * pathname, int flag, int mode,
370 struct inode ** res_inode, struct inode * base);
371 extern int do_mknod(const char * filename, int mode, dev_t dev);
372 extern void iput(struct inode * inode);
373 extern struct inode * iget(struct super_block * sb,int nr);
374 extern struct inode * get_empty_inode(void);
375 extern void insert_inode_hash(struct inode *);
376 extern void clear_inode(struct inode *);
377 extern struct inode * get_pipe_inode(void);
378 extern struct file * get_empty_filp(void);
379 extern struct buffer_head * get_hash_table(dev_t dev, int block, int size);
380 extern struct buffer_head * getblk(dev_t dev, int block, int size);
381 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
382 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
383 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
384 extern void brelse(struct buffer_head * buf);
385 extern void set_blocksize(dev_t dev, int size);
386 extern struct buffer_head * bread(dev_t dev, int block, int size);
387 extern unsigned long bread_page(unsigned long addr,dev_t dev,int b[],int size,int prot);
388 extern struct buffer_head * breada(dev_t dev,int block,...);
389 extern void put_super(dev_t dev);
390 extern dev_t ROOT_DEV;
391
392 extern void mount_root(void);
393
394 extern int char_read(struct inode *, struct file *, char *, int);
395 extern int block_read(struct inode *, struct file *, char *, int);
396 extern int read_ahead[];
397
398 extern int char_write(struct inode *, struct file *, char *, int);
399 extern int block_write(struct inode *, struct file *, char *, int);
400
401 extern int generic_mmap(struct inode *, struct file *, unsigned long, size_t, int, unsigned long);
402
403 extern int block_fsync(struct inode *, struct file *);
404 extern int file_fsync(struct inode *, struct file *);
405
406 #endif
407
408 #endif