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