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