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