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