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