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