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