This source file includes following definitions.
- buffer_uptodate
- buffer_dirty
- buffer_locked
- buffer_req
- buffer_touched
- buffer_has_aged
- buffer_protected
- mark_buffer_uptodate
- mark_buffer_clean
- mark_buffer_dirty
- brelse
- bforget
- iget
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/vfs.h>
14 #include <linux/net.h>
15 #include <linux/kdev_t.h>
16 #include <linux/ioctl.h>
17
18
19
20
21
22
23
24
25
26 #undef NR_OPEN
27 #define NR_OPEN 256
28
29 #define NR_INODE 2048
30 #define NR_FILE 1024
31 #define NR_SUPER 32
32 #define NR_IHASH 131
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 FMODE_READ 1
41 #define FMODE_WRITE 2
42
43 #define READ 0
44 #define WRITE 1
45 #define READA 2
46 #define WRITEA 3
47
48 #ifndef NULL
49 #define NULL ((void *) 0)
50 #endif
51
52 #define NIL_FILP ((struct file *)0)
53 #define SEL_IN 1
54 #define SEL_OUT 2
55 #define SEL_EX 4
56
57
58
59
60 #define MS_RDONLY 1
61 #define MS_NOSUID 2
62 #define MS_NODEV 4
63 #define MS_NOEXEC 8
64 #define MS_SYNCHRONOUS 16
65 #define MS_REMOUNT 32
66 #define S_WRITE 128
67 #define S_APPEND 256
68 #define S_IMMUTABLE 512
69
70
71
72
73 #define MS_RMT_MASK (MS_RDONLY)
74
75
76
77
78 #define MS_MGC_VAL 0xC0ED0000
79 #define MS_MGC_MSK 0xffff0000
80
81
82
83
84
85
86
87
88
89 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
90 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
91 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
92 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
93 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNCHRONOUS)
94
95 #define IS_WRITABLE(inode) ((inode)->i_flags & S_WRITE)
96 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
97 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
98
99
100
101
102 #define BLKROSET _IO(0x12,93)
103 #define BLKROGET _IO(0x12,94)
104 #define BLKRRPART _IO(0x12,95)
105 #define BLKGETSIZE _IO(0x12,96)
106 #define BLKFLSBUF _IO(0x12,97)
107 #define BLKRASET _IO(0x12,98)
108 #define BLKRAGET _IO(0x12,99)
109
110 #define BMAP_IOCTL 1
111 #define FIBMAP _IO(0x00,1)
112 #define FIGETBSZ _IO(0x00,2)
113
114 #ifdef __KERNEL__
115
116 #include <asm/bitops.h>
117
118 extern void buffer_init(void);
119 extern unsigned long inode_init(unsigned long start, unsigned long end);
120 extern unsigned long file_table_init(unsigned long start, unsigned long end);
121 extern unsigned long name_cache_init(unsigned long start, unsigned long end);
122
123 typedef char buffer_block[BLOCK_SIZE];
124
125
126 #define BH_Uptodate 0
127 #define BH_Dirty 1
128 #define BH_Lock 2
129 #define BH_Req 3
130 #define BH_Touched 4
131 #define BH_Has_aged 5
132 #define BH_Protected 6
133
134 struct buffer_head {
135 char * b_data;
136 unsigned long b_size;
137 unsigned long b_blocknr;
138 kdev_t b_dev;
139 unsigned long b_state;
140 unsigned int b_count;
141 unsigned int b_list;
142 unsigned long b_flushtime;
143
144 unsigned long b_lru_time;
145
146 struct wait_queue * b_wait;
147 struct buffer_head * b_prev;
148 struct buffer_head * b_next;
149 struct buffer_head * b_prev_free;
150 struct buffer_head * b_next_free;
151 struct buffer_head * b_this_page;
152 struct buffer_head * b_reqnext;
153 };
154
155 static inline int buffer_uptodate(struct buffer_head * bh)
156 {
157 return test_bit(BH_Uptodate, &bh->b_state);
158 }
159
160 static inline int buffer_dirty(struct buffer_head * bh)
161 {
162 return test_bit(BH_Dirty, &bh->b_state);
163 }
164
165 static inline int buffer_locked(struct buffer_head * bh)
166 {
167 return test_bit(BH_Lock, &bh->b_state);
168 }
169
170 static inline int buffer_req(struct buffer_head * bh)
171 {
172 return test_bit(BH_Req, &bh->b_state);
173 }
174
175 static inline int buffer_touched(struct buffer_head * bh)
176 {
177 return test_bit(BH_Touched, &bh->b_state);
178 }
179
180 static inline int buffer_has_aged(struct buffer_head * bh)
181 {
182 return test_bit(BH_Has_aged, &bh->b_state);
183 }
184
185 static inline int buffer_protected(struct buffer_head * bh)
186 {
187 return test_bit(BH_Protected, &bh->b_state);
188 }
189
190 #include <linux/pipe_fs_i.h>
191 #include <linux/minix_fs_i.h>
192 #include <linux/ext_fs_i.h>
193 #include <linux/ext2_fs_i.h>
194 #include <linux/hpfs_fs_i.h>
195 #include <linux/msdos_fs_i.h>
196 #include <linux/umsdos_fs_i.h>
197 #include <linux/iso_fs_i.h>
198 #include <linux/nfs_fs_i.h>
199 #include <linux/xia_fs_i.h>
200 #include <linux/sysv_fs_i.h>
201
202
203
204
205
206 #define ATTR_MODE 1
207 #define ATTR_UID 2
208 #define ATTR_GID 4
209 #define ATTR_SIZE 8
210 #define ATTR_ATIME 16
211 #define ATTR_MTIME 32
212 #define ATTR_CTIME 64
213 #define ATTR_ATIME_SET 128
214 #define ATTR_MTIME_SET 256
215
216
217
218
219
220
221
222
223
224
225 struct iattr {
226 unsigned int ia_valid;
227 umode_t ia_mode;
228 uid_t ia_uid;
229 gid_t ia_gid;
230 off_t ia_size;
231 time_t ia_atime;
232 time_t ia_mtime;
233 time_t ia_ctime;
234 };
235
236 #include <linux/quota.h>
237
238 struct inode {
239 kdev_t i_dev;
240 unsigned long i_ino;
241 umode_t i_mode;
242 nlink_t i_nlink;
243 uid_t i_uid;
244 gid_t i_gid;
245 kdev_t i_rdev;
246 off_t i_size;
247 time_t i_atime;
248 time_t i_mtime;
249 time_t i_ctime;
250 unsigned long i_blksize;
251 unsigned long i_blocks;
252 unsigned long i_version;
253 unsigned long i_nrpages;
254 struct semaphore i_sem;
255 struct inode_operations *i_op;
256 struct super_block *i_sb;
257 struct wait_queue *i_wait;
258 struct file_lock *i_flock;
259 struct vm_area_struct *i_mmap;
260 struct page *i_pages;
261 struct dquot *i_dquot[MAXQUOTAS];
262 struct inode *i_next, *i_prev;
263 struct inode *i_hash_next, *i_hash_prev;
264 struct inode *i_bound_to, *i_bound_by;
265 struct inode *i_mount;
266 unsigned short i_count;
267 unsigned short i_flags;
268 unsigned char i_lock;
269 unsigned char i_dirt;
270 unsigned char i_pipe;
271 unsigned char i_sock;
272 unsigned char i_seek;
273 unsigned char i_update;
274 unsigned short i_writecount;
275 union {
276 struct pipe_inode_info pipe_i;
277 struct minix_inode_info minix_i;
278 struct ext_inode_info ext_i;
279 struct ext2_inode_info ext2_i;
280 struct hpfs_inode_info hpfs_i;
281 struct msdos_inode_info msdos_i;
282 struct umsdos_inode_info umsdos_i;
283 struct iso_inode_info isofs_i;
284 struct nfs_inode_info nfs_i;
285 struct xiafs_inode_info xiafs_i;
286 struct sysv_inode_info sysv_i;
287 struct socket socket_i;
288 void * generic_ip;
289 } u;
290 };
291
292 struct file {
293 mode_t f_mode;
294 loff_t f_pos;
295 unsigned short f_flags;
296 unsigned short f_count;
297 off_t f_reada;
298 struct file *f_next, *f_prev;
299 int f_owner;
300 struct inode * f_inode;
301 struct file_operations * f_op;
302 unsigned long f_version;
303 void *private_data;
304 };
305
306 struct file_lock {
307 struct file_lock *fl_next;
308 struct file_lock *fl_nextlink;
309 struct file_lock *fl_prevlink;
310 struct file_lock *fl_block;
311 struct task_struct *fl_owner;
312 struct wait_queue *fl_wait;
313 struct file *fl_file;
314 char fl_flags;
315 char fl_type;
316 off_t fl_start;
317 off_t fl_end;
318 };
319
320 struct fasync_struct {
321 int magic;
322 struct fasync_struct *fa_next;
323 struct file *fa_file;
324 };
325
326 #define FASYNC_MAGIC 0x4601
327
328 extern int fasync_helper(struct inode *, struct file *, int, struct fasync_struct **);
329
330 #include <linux/minix_fs_sb.h>
331 #include <linux/ext_fs_sb.h>
332 #include <linux/ext2_fs_sb.h>
333 #include <linux/hpfs_fs_sb.h>
334 #include <linux/msdos_fs_sb.h>
335 #include <linux/iso_fs_sb.h>
336 #include <linux/nfs_fs_sb.h>
337 #include <linux/xia_fs_sb.h>
338 #include <linux/sysv_fs_sb.h>
339
340 struct super_block {
341 kdev_t s_dev;
342 unsigned long s_blocksize;
343 unsigned char s_blocksize_bits;
344 unsigned char s_lock;
345 unsigned char s_rd_only;
346 unsigned char s_dirt;
347 struct file_system_type *s_type;
348 struct super_operations *s_op;
349 struct dquot_operations *dq_op;
350 unsigned long s_flags;
351 unsigned long s_magic;
352 unsigned long s_time;
353 struct inode * s_covered;
354 struct inode * s_mounted;
355 struct wait_queue * s_wait;
356 union {
357 struct minix_sb_info minix_sb;
358 struct ext_sb_info ext_sb;
359 struct ext2_sb_info ext2_sb;
360 struct hpfs_sb_info hpfs_sb;
361 struct msdos_sb_info msdos_sb;
362 struct isofs_sb_info isofs_sb;
363 struct nfs_sb_info nfs_sb;
364 struct xiafs_sb_info xiafs_sb;
365 struct sysv_sb_info sysv_sb;
366 void *generic_sbp;
367 } u;
368 };
369
370
371
372
373
374
375
376 typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
377
378 struct file_operations {
379 int (*lseek) (struct inode *, struct file *, off_t, int);
380 int (*read) (struct inode *, struct file *, char *, int);
381 int (*write) (struct inode *, struct file *, const char *, int);
382 int (*readdir) (struct inode *, struct file *, void *, filldir_t);
383 int (*select) (struct inode *, struct file *, int, select_table *);
384 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
385 int (*mmap) (struct inode *, struct file *, struct vm_area_struct *);
386 int (*open) (struct inode *, struct file *);
387 void (*release) (struct inode *, struct file *);
388 int (*fsync) (struct inode *, struct file *);
389 int (*fasync) (struct inode *, struct file *, int);
390 int (*check_media_change) (kdev_t dev);
391 int (*revalidate) (kdev_t dev);
392 };
393
394 struct inode_operations {
395 struct file_operations * default_file_ops;
396 int (*create) (struct inode *,const char *,int,int,struct inode **);
397 int (*lookup) (struct inode *,const char *,int,struct inode **);
398 int (*link) (struct inode *,struct inode *,const char *,int);
399 int (*unlink) (struct inode *,const char *,int);
400 int (*symlink) (struct inode *,const char *,int,const char *);
401 int (*mkdir) (struct inode *,const char *,int,int);
402 int (*rmdir) (struct inode *,const char *,int);
403 int (*mknod) (struct inode *,const char *,int,int,int);
404 int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
405 int (*readlink) (struct inode *,char *,int);
406 int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
407 int (*readpage) (struct inode *, unsigned long, char *);
408 int (*writepage) (struct inode *, struct page *);
409 int (*bmap) (struct inode *,int);
410 void (*truncate) (struct inode *);
411 int (*permission) (struct inode *, int);
412 int (*smap) (struct inode *,int);
413 };
414
415 struct super_operations {
416 void (*read_inode) (struct inode *);
417 int (*notify_change) (struct inode *, struct iattr *);
418 void (*write_inode) (struct inode *);
419 void (*put_inode) (struct inode *);
420 void (*put_super) (struct super_block *);
421 void (*write_super) (struct super_block *);
422 void (*statfs) (struct super_block *, struct statfs *, int);
423 int (*remount_fs) (struct super_block *, int *, char *);
424 };
425
426 struct dquot_operations {
427 void (*initialize) (struct inode *, short);
428 void (*drop) (struct inode *);
429 int (*alloc_block) (const struct inode *, unsigned long);
430 int (*alloc_inode) (const struct inode *, unsigned long);
431 void (*free_block) (const struct inode *, unsigned long);
432 void (*free_inode) (const struct inode *, unsigned long);
433 int (*transfer) (struct inode *, struct iattr *, char);
434 };
435
436 struct file_system_type {
437 struct super_block *(*read_super) (struct super_block *, void *, int);
438 const char *name;
439 int requires_dev;
440 struct file_system_type * next;
441 };
442
443 extern int register_filesystem(struct file_system_type *);
444 extern int unregister_filesystem(struct file_system_type *);
445
446 asmlinkage int sys_open(const char *, int, int);
447 asmlinkage int sys_close(unsigned int);
448
449 extern void kill_fasync(struct fasync_struct *fa, int sig);
450
451 extern int getname(const char * filename, char **result);
452 extern void putname(char * name);
453 extern int do_truncate(struct inode *, unsigned long);
454 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
455 extern int unregister_blkdev(unsigned int major, const char * name);
456 extern int blkdev_open(struct inode * inode, struct file * filp);
457 extern struct file_operations def_blk_fops;
458 extern struct inode_operations blkdev_inode_operations;
459
460 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
461 extern int unregister_chrdev(unsigned int major, const char * name);
462 extern int chrdev_open(struct inode * inode, struct file * filp);
463 extern struct file_operations def_chr_fops;
464 extern struct inode_operations chrdev_inode_operations;
465
466 extern void init_fifo(struct inode * inode);
467
468 extern struct file_operations connecting_fifo_fops;
469 extern struct file_operations read_fifo_fops;
470 extern struct file_operations write_fifo_fops;
471 extern struct file_operations rdwr_fifo_fops;
472 extern struct file_operations read_pipe_fops;
473 extern struct file_operations write_pipe_fops;
474 extern struct file_operations rdwr_pipe_fops;
475
476 extern struct file_system_type *get_fs_type(const char *name);
477
478 extern int fs_may_mount(kdev_t dev);
479 extern int fs_may_umount(kdev_t dev, struct inode * mount_root);
480 extern int fs_may_remount_ro(kdev_t dev);
481
482 extern struct file *first_file;
483 extern int nr_files;
484 extern struct super_block super_blocks[NR_SUPER];
485
486 extern int shrink_buffers(unsigned int priority, unsigned long limit);
487 extern void refile_buffer(struct buffer_head * buf);
488 extern void set_writetime(struct buffer_head * buf, int flag);
489 extern void refill_freelist(int size);
490
491 extern struct buffer_head ** buffer_pages;
492 extern int nr_buffers;
493 extern int buffermem;
494 extern int nr_buffer_heads;
495
496 #define BUF_CLEAN 0
497 #define BUF_UNSHARED 1
498 #define BUF_LOCKED 2
499 #define BUF_LOCKED1 3
500 #define BUF_DIRTY 4
501 #define BUF_SHARED 5
502 #define NR_LIST 6
503
504 extern inline void mark_buffer_uptodate(struct buffer_head * bh, int on)
505 {
506 if (on)
507 set_bit(BH_Uptodate, &bh->b_state);
508 else
509 clear_bit(BH_Uptodate, &bh->b_state);
510 }
511
512 extern inline void mark_buffer_clean(struct buffer_head * bh)
513 {
514 if (clear_bit(BH_Dirty, &bh->b_state)) {
515 if (bh->b_list == BUF_DIRTY)
516 refile_buffer(bh);
517 }
518 }
519
520 extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag)
521 {
522 if (!set_bit(BH_Dirty, &bh->b_state)) {
523 set_writetime(bh, flag);
524 if (bh->b_list != BUF_DIRTY)
525 refile_buffer(bh);
526 }
527 }
528
529 extern int check_disk_change(kdev_t dev);
530 extern void invalidate_inodes(kdev_t dev);
531 extern void invalidate_inode_pages(struct inode *, unsigned long);
532 extern void invalidate_buffers(kdev_t dev);
533 extern int floppy_is_wp(int minor);
534 extern void sync_inodes(kdev_t dev);
535 extern void sync_dev(kdev_t dev);
536 extern int fsync_dev(kdev_t dev);
537 extern void sync_supers(kdev_t dev);
538 extern int bmap(struct inode * inode,int block);
539 extern int notify_change(struct inode *, struct iattr *);
540 extern int namei(const char * pathname, struct inode ** res_inode);
541 extern int lnamei(const char * pathname, struct inode ** res_inode);
542 extern int permission(struct inode * inode,int mask);
543 extern int get_write_access(struct inode *inode);
544 extern void put_write_access(struct inode *inode);
545 extern int open_namei(const char * pathname, int flag, int mode,
546 struct inode ** res_inode, struct inode * base);
547 extern int do_mknod(const char * filename, int mode, dev_t dev);
548 extern int do_pipe(int *);
549 extern void iput(struct inode * inode);
550 extern struct inode * __iget(struct super_block * sb,int nr,int crsmnt);
551 extern struct inode * get_empty_inode(void);
552 extern void insert_inode_hash(struct inode *);
553 extern void clear_inode(struct inode *);
554 extern struct inode * get_pipe_inode(void);
555 extern struct file * get_empty_filp(void);
556 extern int close_fp(struct file *filp);
557 extern struct buffer_head * get_hash_table(kdev_t dev, int block, int size);
558 extern struct buffer_head * getblk(kdev_t dev, int block, int size);
559 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
560 extern void ll_rw_page(int rw, kdev_t dev, unsigned long nr, char * buffer);
561 extern void ll_rw_swap_file(int rw, kdev_t dev, unsigned int *b, int nb, char *buffer);
562 extern int is_read_only(kdev_t dev);
563 extern void __brelse(struct buffer_head *buf);
564 extern inline void brelse(struct buffer_head *buf)
565 {
566 if (buf)
567 __brelse(buf);
568 }
569 extern void __bforget(struct buffer_head *buf);
570 extern inline void bforget(struct buffer_head *buf)
571 {
572 if (buf)
573 __bforget(buf);
574 }
575 extern void set_blocksize(kdev_t dev, int size);
576 extern struct buffer_head * bread(kdev_t dev, int block, int size);
577 extern int bread_page(unsigned long addr,kdev_t dev,int b[],int size);
578 extern void bwrite_page(unsigned long addr,kdev_t dev,int b[],int size);
579 extern struct buffer_head * breada(kdev_t dev,int block, int size,
580 unsigned int pos, unsigned int filesize);
581 extern void put_super(kdev_t dev);
582 unsigned long generate_cluster(kdev_t dev, int b[], int size);
583 extern kdev_t ROOT_DEV;
584
585 extern void show_buffers(void);
586 extern void mount_root(void);
587
588 extern int char_read(struct inode *, struct file *, char *, int);
589 extern int block_read(struct inode *, struct file *, char *, int);
590 extern int read_ahead[];
591
592 extern int char_write(struct inode *, struct file *, const char *, int);
593 extern int block_write(struct inode *, struct file *, const char *, int);
594
595 extern int generic_mmap(struct inode *, struct file *, struct vm_area_struct *);
596
597 extern int block_fsync(struct inode *, struct file *);
598 extern int file_fsync(struct inode *, struct file *);
599
600 extern void dcache_add(struct inode *, const char *, int, unsigned long);
601 extern int dcache_lookup(struct inode *, const char *, int, unsigned long *);
602
603 extern int inode_change_ok(struct inode *, struct iattr *);
604 extern void inode_setattr(struct inode *, struct iattr *);
605
606 extern inline struct inode * iget(struct super_block * sb,int nr)
607 {
608 return __iget(sb, nr, 1);
609 }
610
611 #endif
612
613 #endif