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