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 64
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 #define BLKFLSBUF 4705
128
129
130
131 #define SCSI_IOCTL_GET_IDLUN 0x5382
132
133
134 #define BMAP_IOCTL 1
135 #define FIBMAP 1
136 #define FIGETBSZ 2
137
138
139
140 #define NOTIFY_SIZE 1
141 #define NOTIFY_MODE 2
142 #define NOTIFY_TIME 4
143 #define NOTIFY_UIDGID 8
144
145 typedef char buffer_block[BLOCK_SIZE];
146
147 struct buffer_head {
148 char * b_data;
149 unsigned long b_size;
150 unsigned long b_blocknr;
151 dev_t b_dev;
152 unsigned short b_count;
153 unsigned char b_uptodate;
154 unsigned char b_dirt;
155 unsigned char b_lock;
156 unsigned char b_req;
157 struct wait_queue * b_wait;
158 struct buffer_head * b_prev;
159 struct buffer_head * b_next;
160 struct buffer_head * b_prev_free;
161 struct buffer_head * b_next_free;
162 struct buffer_head * b_this_page;
163 struct buffer_head * b_reqnext;
164 };
165
166 #include <linux/pipe_fs_i.h>
167 #include <linux/minix_fs_i.h>
168 #include <linux/ext_fs_i.h>
169 #include <linux/ext2_fs_i.h>
170 #include <linux/msdos_fs_i.h>
171 #include <linux/iso_fs_i.h>
172 #include <linux/nfs_fs_i.h>
173 #include <linux/xia_fs_i.h>
174
175 struct inode {
176 dev_t i_dev;
177 unsigned long i_ino;
178 umode_t i_mode;
179 nlink_t i_nlink;
180 uid_t i_uid;
181 gid_t i_gid;
182 dev_t i_rdev;
183 off_t i_size;
184 time_t i_atime;
185 time_t i_mtime;
186 time_t i_ctime;
187 unsigned long i_blksize;
188 unsigned long i_blocks;
189 struct inode_operations * i_op;
190 struct super_block * i_sb;
191 struct wait_queue * i_wait;
192 struct file_lock * i_flock;
193 struct vm_area_struct * i_mmap;
194 struct inode * i_next, * i_prev;
195 struct inode * i_hash_next, * i_hash_prev;
196 struct inode * i_bound_to, * i_bound_by;
197 unsigned short i_count;
198 unsigned short i_flags;
199 unsigned char i_lock;
200 unsigned char i_dirt;
201 unsigned char i_pipe;
202 unsigned char i_mount;
203 unsigned char i_seek;
204 unsigned char i_update;
205 union {
206 struct pipe_inode_info pipe_i;
207 struct minix_inode_info minix_i;
208 struct ext_inode_info ext_i;
209 struct ext2_inode_info ext2_i;
210 struct msdos_inode_info msdos_i;
211 struct iso_inode_info isofs_i;
212 struct nfs_inode_info nfs_i;
213 struct xiafs_inode_info xiafs_i;
214 } u;
215 };
216
217 struct file {
218 mode_t f_mode;
219 dev_t f_rdev;
220 off_t f_pos;
221 unsigned short f_flags;
222 unsigned short f_count;
223 unsigned short f_reada;
224 struct file *f_next, *f_prev;
225 struct inode * f_inode;
226 struct file_operations * f_op;
227 };
228
229 struct file_lock {
230 struct file_lock *fl_next;
231 struct task_struct *fl_owner;
232 struct wait_queue *fl_wait;
233 char fl_type;
234 char fl_whence;
235 off_t fl_start;
236 off_t fl_end;
237 };
238
239 #include <linux/minix_fs_sb.h>
240 #include <linux/ext_fs_sb.h>
241 #include <linux/ext2_fs_sb.h>
242 #include <linux/msdos_fs_sb.h>
243 #include <linux/iso_fs_sb.h>
244 #include <linux/nfs_fs_sb.h>
245 #include <linux/xia_fs_sb.h>
246
247 struct super_block {
248 dev_t s_dev;
249 unsigned long s_blocksize;
250 unsigned char s_blocksize_bits;
251 unsigned char s_lock;
252 unsigned char s_rd_only;
253 unsigned char s_dirt;
254 struct super_operations *s_op;
255 unsigned long s_flags;
256 unsigned long s_magic;
257 unsigned long s_time;
258 struct inode * s_covered;
259 struct inode * s_mounted;
260 struct wait_queue * s_wait;
261 union {
262 struct minix_sb_info minix_sb;
263 struct ext_sb_info ext_sb;
264 struct ext2_sb_info ext2_sb;
265 struct msdos_sb_info msdos_sb;
266 struct isofs_sb_info isofs_sb;
267 struct nfs_sb_info nfs_sb;
268 struct xiafs_sb_info xiafs_sb;
269 } u;
270 };
271
272 struct file_operations {
273 int (*lseek) (struct inode *, struct file *, off_t, int);
274 int (*read) (struct inode *, struct file *, char *, int);
275 int (*write) (struct inode *, struct file *, char *, int);
276 int (*readdir) (struct inode *, struct file *, struct dirent *, int);
277 int (*select) (struct inode *, struct file *, int, select_table *);
278 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
279 int (*mmap) (struct inode *, struct file *, unsigned long, size_t, int, unsigned long);
280 int (*open) (struct inode *, struct file *);
281 void (*release) (struct inode *, struct file *);
282 int (*fsync) (struct inode *, struct file *);
283 };
284
285 struct inode_operations {
286 struct file_operations * default_file_ops;
287 int (*create) (struct inode *,const char *,int,int,struct inode **);
288 int (*lookup) (struct inode *,const char *,int,struct inode **);
289 int (*link) (struct inode *,struct inode *,const char *,int);
290 int (*unlink) (struct inode *,const char *,int);
291 int (*symlink) (struct inode *,const char *,int,const char *);
292 int (*mkdir) (struct inode *,const char *,int,int);
293 int (*rmdir) (struct inode *,const char *,int);
294 int (*mknod) (struct inode *,const char *,int,int,int);
295 int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
296 int (*readlink) (struct inode *,char *,int);
297 int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
298 int (*bmap) (struct inode *,int);
299 void (*truncate) (struct inode *);
300 int (*permission) (struct inode *, int);
301 };
302
303 struct super_operations {
304 void (*read_inode) (struct inode *);
305 int (*notify_change) (int flags, struct inode *);
306 void (*write_inode) (struct inode *);
307 void (*put_inode) (struct inode *);
308 void (*put_super) (struct super_block *);
309 void (*write_super) (struct super_block *);
310 void (*statfs) (struct super_block *, struct statfs *);
311 int (*remount_fs) (struct super_block *, int *);
312 };
313
314 struct file_system_type {
315 struct super_block *(*read_super) (struct super_block *, void *, int);
316 char *name;
317 int requires_dev;
318 };
319
320 #ifdef __KERNEL__
321
322 extern "C" int sys_open(const char *, int, int);
323 extern "C" int sys_close(unsigned int);
324
325 extern int getname(const char * filename, char **result);
326 extern void putname(char * name);
327
328 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
329 extern int blkdev_open(struct inode * inode, struct file * filp);
330 extern struct file_operations def_blk_fops;
331 extern struct inode_operations blkdev_inode_operations;
332
333 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
334 extern int chrdev_open(struct inode * inode, struct file * filp);
335 extern struct file_operations def_chr_fops;
336 extern struct inode_operations chrdev_inode_operations;
337
338 extern void init_fifo(struct inode * inode);
339
340 extern struct file_operations connecting_pipe_fops;
341 extern struct file_operations read_pipe_fops;
342 extern struct file_operations write_pipe_fops;
343 extern struct file_operations rdwr_pipe_fops;
344
345 extern struct file_system_type *get_fs_type(char *name);
346
347 extern int fs_may_mount(dev_t dev);
348 extern int fs_may_umount(dev_t dev, struct inode * mount_root);
349 extern int fs_may_remount_ro(dev_t dev);
350
351 extern struct file *first_file;
352 extern int nr_files;
353 extern struct super_block super_blocks[NR_SUPER];
354
355 extern void grow_buffers(int size);
356 extern int shrink_buffers(unsigned int priority);
357
358 extern int nr_buffers;
359 extern int buffermem;
360 extern int nr_buffer_heads;
361
362 extern void check_disk_change(dev_t dev);
363 extern void invalidate_inodes(dev_t dev);
364 extern void invalidate_buffers(dev_t dev);
365 extern int floppy_change(struct buffer_head * first_block);
366 extern void sync_inodes(dev_t dev);
367 extern void sync_dev(dev_t dev);
368 extern int fsync_dev(dev_t dev);
369 extern void sync_supers(dev_t dev);
370 extern int bmap(struct inode * inode,int block);
371 extern int notify_change(int flags, struct inode * inode);
372 extern int namei(const char * pathname, struct inode ** res_inode);
373 extern int lnamei(const char * pathname, struct inode ** res_inode);
374 extern int permission(struct inode * inode,int mask);
375 extern int open_namei(const char * pathname, int flag, int mode,
376 struct inode ** res_inode, struct inode * base);
377 extern int do_mknod(const char * filename, int mode, dev_t dev);
378 extern void iput(struct inode * inode);
379 extern struct inode * iget(struct super_block * sb,int nr);
380 extern struct inode * get_empty_inode(void);
381 extern void insert_inode_hash(struct inode *);
382 extern void clear_inode(struct inode *);
383 extern struct inode * get_pipe_inode(void);
384 extern struct file * get_empty_filp(void);
385 extern struct buffer_head * get_hash_table(dev_t dev, int block, int size);
386 extern struct buffer_head * getblk(dev_t dev, int block, int size);
387 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
388 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
389 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
390 extern void brelse(struct buffer_head * buf);
391 extern void set_blocksize(dev_t dev, int size);
392 extern struct buffer_head * bread(dev_t dev, int block, int size);
393 extern unsigned long bread_page(unsigned long addr,dev_t dev,int b[],int size,int prot);
394 extern struct buffer_head * breada(dev_t dev,int block,...);
395 extern void put_super(dev_t dev);
396 extern dev_t ROOT_DEV;
397
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