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 #define MKDEV(a,b) ((int)((((a) & 0xff) << 8) | ((b) & 0xff)))
53
54 #ifndef NULL
55 #define NULL ((void *) 0)
56 #endif
57
58 #define NIL_FILP ((struct file *)0)
59 #define SEL_IN 1
60 #define SEL_OUT 2
61 #define SEL_EX 4
62
63
64
65
66 #define MS_RDONLY 1
67 #define MS_NOSUID 2
68 #define MS_NODEV 4
69 #define MS_NOEXEC 8
70 #define MS_SYNC 16
71 #define MS_REMOUNT 32
72
73
74
75
76 #define MS_RMT_MASK (MS_RDONLY)
77
78
79
80
81 #define MS_MGC_VAL 0xC0ED0000
82 #define MS_MGC_MSK 0xffff0000
83
84
85
86
87
88
89
90
91
92 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
93 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
94 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
95 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
96 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC)
97
98
99
100
101 #define BLKROSET 4701
102 #define BLKROGET 4702
103 #define BLKRRPART 4703
104 #define BLKGETSIZE 4704
105 #define BLKFLSBUF 4705
106
107
108
109 #define SCSI_IOCTL_GET_IDLUN 0x5382
110
111
112
113 #define SCSI_IOCTL_TAGGED_ENABLE 0x5383
114 #define SCSI_IOCTL_TAGGED_DISABLE 0x5384
115
116
117 #define BMAP_IOCTL 1
118 #define FIBMAP 1
119 #define FIGETBSZ 2
120
121
122
123 #define NOTIFY_SIZE 1
124 #define NOTIFY_MODE 2
125 #define NOTIFY_TIME 4
126 #define NOTIFY_UIDGID 8
127
128 typedef char buffer_block[BLOCK_SIZE];
129
130 struct buffer_head {
131 char * b_data;
132 unsigned long b_size;
133 unsigned long b_blocknr;
134 dev_t b_dev;
135 unsigned short b_count;
136 unsigned char b_uptodate;
137 unsigned char b_dirt;
138 unsigned char b_lock;
139 unsigned char b_req;
140 struct wait_queue * b_wait;
141 struct buffer_head * b_prev;
142 struct buffer_head * b_next;
143 struct buffer_head * b_prev_free;
144 struct buffer_head * b_next_free;
145 struct buffer_head * b_this_page;
146 struct buffer_head * b_reqnext;
147 };
148
149 #include <linux/pipe_fs_i.h>
150 #include <linux/minix_fs_i.h>
151 #include <linux/ext_fs_i.h>
152 #include <linux/ext2_fs_i.h>
153 #include <linux/hpfs_fs_i.h>
154 #include <linux/msdos_fs_i.h>
155 #include <linux/iso_fs_i.h>
156 #include <linux/nfs_fs_i.h>
157 #include <linux/xia_fs_i.h>
158 #include <linux/sysv_fs_i.h>
159
160 struct inode {
161 dev_t i_dev;
162 unsigned long i_ino;
163 umode_t i_mode;
164 nlink_t i_nlink;
165 uid_t i_uid;
166 gid_t i_gid;
167 dev_t i_rdev;
168 off_t i_size;
169 time_t i_atime;
170 time_t i_mtime;
171 time_t i_ctime;
172 unsigned long i_blksize;
173 unsigned long i_blocks;
174 struct semaphore i_sem;
175 struct inode_operations * i_op;
176 struct super_block * i_sb;
177 struct wait_queue * i_wait;
178 struct file_lock * i_flock;
179 struct vm_area_struct * i_mmap;
180 struct inode * i_next, * i_prev;
181 struct inode * i_hash_next, * i_hash_prev;
182 struct inode * i_bound_to, * i_bound_by;
183 struct inode * i_mount;
184 struct socket * i_socket;
185 unsigned short i_count;
186 unsigned short i_flags;
187 unsigned char i_lock;
188 unsigned char i_dirt;
189 unsigned char i_pipe;
190 unsigned char i_seek;
191 unsigned char i_update;
192 union {
193 struct pipe_inode_info pipe_i;
194 struct minix_inode_info minix_i;
195 struct ext_inode_info ext_i;
196 struct ext2_inode_info ext2_i;
197 struct hpfs_inode_info hpfs_i;
198 struct msdos_inode_info msdos_i;
199 struct iso_inode_info isofs_i;
200 struct nfs_inode_info nfs_i;
201 struct xiafs_inode_info xiafs_i;
202 struct sysv_inode_info sysv_i;
203 } u;
204 };
205
206 struct file {
207 mode_t f_mode;
208 dev_t f_rdev;
209 off_t f_pos;
210 unsigned short f_flags;
211 unsigned short f_count;
212 unsigned short f_reada;
213 struct file *f_next, *f_prev;
214 struct inode * f_inode;
215 struct file_operations * f_op;
216 };
217
218 struct file_lock {
219 struct file_lock *fl_next;
220 struct task_struct *fl_owner;
221 unsigned int fl_fd;
222 struct wait_queue *fl_wait;
223 char fl_type;
224 char fl_whence;
225 off_t fl_start;
226 off_t fl_end;
227 };
228
229 #include <linux/minix_fs_sb.h>
230 #include <linux/ext_fs_sb.h>
231 #include <linux/ext2_fs_sb.h>
232 #include <linux/hpfs_fs_sb.h>
233 #include <linux/msdos_fs_sb.h>
234 #include <linux/iso_fs_sb.h>
235 #include <linux/nfs_fs_sb.h>
236 #include <linux/xia_fs_sb.h>
237 #include <linux/sysv_fs_sb.h>
238
239 struct super_block {
240 dev_t s_dev;
241 unsigned long s_blocksize;
242 unsigned char s_blocksize_bits;
243 unsigned char s_lock;
244 unsigned char s_rd_only;
245 unsigned char s_dirt;
246 struct super_operations *s_op;
247 unsigned long s_flags;
248 unsigned long s_magic;
249 unsigned long s_time;
250 struct inode * s_covered;
251 struct inode * s_mounted;
252 struct wait_queue * s_wait;
253 union {
254 struct minix_sb_info minix_sb;
255 struct ext_sb_info ext_sb;
256 struct ext2_sb_info ext2_sb;
257 struct hpfs_sb_info hpfs_sb;
258 struct msdos_sb_info msdos_sb;
259 struct isofs_sb_info isofs_sb;
260 struct nfs_sb_info nfs_sb;
261 struct xiafs_sb_info xiafs_sb;
262 struct sysv_sb_info sysv_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 *, char *);
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 asmlinkage int sys_open(const char *, int, int);
317 asmlinkage 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 unregister_blkdev(unsigned int major, const char * name);
324 extern int blkdev_open(struct inode * inode, struct file * filp);
325 extern struct file_operations def_blk_fops;
326 extern struct inode_operations blkdev_inode_operations;
327
328 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
329 extern int unregister_chrdev(unsigned int major, const char * name);
330 extern int chrdev_open(struct inode * inode, struct file * filp);
331 extern struct file_operations def_chr_fops;
332 extern struct inode_operations chrdev_inode_operations;
333
334 extern void init_fifo(struct inode * inode);
335
336 extern struct file_operations connecting_fifo_fops;
337 extern struct file_operations read_fifo_fops;
338 extern struct file_operations write_fifo_fops;
339 extern struct file_operations rdwr_fifo_fops;
340 extern struct file_operations read_pipe_fops;
341 extern struct file_operations write_pipe_fops;
342 extern struct file_operations rdwr_pipe_fops;
343
344 extern struct file_system_type *get_fs_type(char *name);
345
346 extern int fs_may_mount(dev_t dev);
347 extern int fs_may_umount(dev_t dev, struct inode * mount_root);
348 extern int fs_may_remount_ro(dev_t dev);
349
350 extern struct file *first_file;
351 extern int nr_files;
352 extern struct super_block super_blocks[NR_SUPER];
353
354 extern int shrink_buffers(unsigned int priority);
355
356 extern int nr_buffers;
357 extern int buffermem;
358 extern int nr_buffer_heads;
359
360 extern void check_disk_change(dev_t dev);
361 extern void invalidate_inodes(dev_t dev);
362 extern void invalidate_buffers(dev_t dev);
363 extern int floppy_change(struct buffer_head * first_block);
364 extern void sync_inodes(dev_t dev);
365 extern void sync_dev(dev_t dev);
366 extern int fsync_dev(dev_t dev);
367 extern void sync_supers(dev_t dev);
368 extern int bmap(struct inode * inode,int block);
369 extern int notify_change(int flags, struct inode * inode);
370 extern int namei(const char * pathname, struct inode ** res_inode);
371 extern int lnamei(const char * pathname, struct inode ** res_inode);
372 extern int permission(struct inode * inode,int mask);
373 extern int open_namei(const char * pathname, int flag, int mode,
374 struct inode ** res_inode, struct inode * base);
375 extern int do_mknod(const char * filename, int mode, dev_t dev);
376 extern void iput(struct inode * inode);
377 extern struct inode * __iget(struct super_block * sb,int nr,int crsmnt);
378 extern struct inode * iget(struct super_block * sb,int nr);
379 extern struct inode * get_empty_inode(void);
380 extern void insert_inode_hash(struct inode *);
381 extern void clear_inode(struct inode *);
382 extern struct inode * get_pipe_inode(void);
383 extern struct file * get_empty_filp(void);
384 extern struct buffer_head * get_hash_table(dev_t dev, int block, int size);
385 extern struct buffer_head * getblk(dev_t dev, int block, int size);
386 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
387 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
388 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
389 extern void brelse(struct buffer_head * buf);
390 extern void set_blocksize(dev_t dev, int size);
391 extern struct buffer_head * bread(dev_t dev, int block, int size);
392 extern unsigned long bread_page(unsigned long addr,dev_t dev,int b[],int size,int prot);
393 extern struct buffer_head * breada(dev_t dev,int block,...);
394 extern void put_super(dev_t dev);
395 extern dev_t ROOT_DEV;
396
397 extern void show_buffers(void);
398 extern void mount_root(void);
399
400 extern int char_read(struct inode *, struct file *, char *, int);
401 extern int block_read(struct inode *, struct file *, char *, int);
402 extern int read_ahead[];
403
404 extern int char_write(struct inode *, struct file *, char *, int);
405 extern int block_write(struct inode *, struct file *, char *, int);
406
407 extern int generic_mmap(struct inode *, struct file *, unsigned long, size_t, int, unsigned long);
408
409 extern int block_fsync(struct inode *, struct file *);
410 extern int file_fsync(struct inode *, struct file *);
411
412 #endif
413
414 #endif