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