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