1#ifndef _LINUX_FS_H
2#define _LINUX_FS_H
3
4
5
6
7
8
9#include <linux/config.h>
10#include <linux/linkage.h>
11#include <linux/limits.h>
12#include <linux/wait.h>
13#include <linux/types.h>
14#include <linux/vfs.h>
15#include <linux/net.h>
16#include <linux/kdev_t.h>
17#include <linux/ioctl.h>
18#include <linux/list.h>
19#include <linux/dcache.h>
20#include <linux/stat.h>
21#include <linux/cache.h>
22#include <linux/stddef.h>
23#include <linux/string.h>
24
25#include <asm/atomic.h>
26#include <asm/bitops.h>
27
28struct poll_table_struct;
29
30
31
32
33
34
35
36
37
38
39
40
41
42#undef NR_OPEN
43#define NR_OPEN (1024*1024)
44#define INR_OPEN 1024
45
46#define BLOCK_SIZE_BITS 10
47#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
48
49
50struct files_stat_struct {
51 int nr_files;
52 int nr_free_files;
53 int max_files;
54};
55extern struct files_stat_struct files_stat;
56
57struct inodes_stat_t {
58 int nr_inodes;
59 int nr_unused;
60 int dummy[5];
61};
62extern struct inodes_stat_t inodes_stat;
63
64extern int leases_enable, dir_notify_enable, lease_break_time;
65
66#define NR_FILE 8192
67#define NR_RESERVED_FILES 10
68#define NR_SUPER 256
69
70#define MAY_EXEC 1
71#define MAY_WRITE 2
72#define MAY_READ 4
73
74#define FMODE_READ 1
75#define FMODE_WRITE 2
76
77#define READ 0
78#define WRITE 1
79#define READA 2
80#define SPECIAL 4
81
82#define SEL_IN 1
83#define SEL_OUT 2
84#define SEL_EX 4
85
86
87#define FS_REQUIRES_DEV 1
88#define FS_NO_DCACHE 2
89#define FS_NO_PRELIM 4
90
91
92#define FS_SINGLE 8
93#define FS_NOMOUNT 16
94#define FS_LITTER 32
95#define FS_ODD_RENAME 32768
96
97
98
99
100
101#define MS_RDONLY 1
102#define MS_NOSUID 2
103#define MS_NODEV 4
104#define MS_NOEXEC 8
105#define MS_SYNCHRONOUS 16
106#define MS_REMOUNT 32
107#define MS_MANDLOCK 64
108#define MS_NOATIME 1024
109#define MS_NODIRATIME 2048
110#define MS_BIND 4096
111#define MS_MOVE 8192
112#define MS_REC 16384
113#define MS_VERBOSE 32768
114#define MS_ACTIVE (1<<30)
115#define MS_NOUSER (1<<31)
116
117
118
119
120#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
121 MS_NODIRATIME)
122
123
124
125
126#define MS_MGC_VAL 0xC0ED0000
127#define MS_MGC_MSK 0xffff0000
128
129
130
131#define S_SYNC 1
132#define S_NOATIME 2
133#define S_QUOTA 4
134#define S_APPEND 8
135#define S_IMMUTABLE 16
136#define S_DEAD 32
137#define S_NOQUOTA 64
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152#define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
153
154#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
155#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || ((inode)->i_flags & S_SYNC))
156#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
157
158#define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
159#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
160#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
161#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
162#define IS_NOATIME(inode) (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
163#define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
164
165#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
166
167
168
169
170#define BLKROSET _IO(0x12,93)
171#define BLKROGET _IO(0x12,94)
172#define BLKRRPART _IO(0x12,95)
173#define BLKGETSIZE _IO(0x12,96)
174#define BLKFLSBUF _IO(0x12,97)
175#define BLKRASET _IO(0x12,98)
176#define BLKRAGET _IO(0x12,99)
177#define BLKFRASET _IO(0x12,100)
178#define BLKFRAGET _IO(0x12,101)
179#define BLKSECTSET _IO(0x12,102)
180#define BLKSECTGET _IO(0x12,103)
181#define BLKSSZGET _IO(0x12,104)
182#if 0
183#define BLKPG _IO(0x12,105)
184#define BLKELVGET _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))
185#define BLKELVSET _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))
186
187
188#endif
189
190#define BLKBSZGET _IOR(0x12,112,sizeof(int))
191#define BLKBSZSET _IOW(0x12,113,sizeof(int))
192#define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64))
193
194#define BMAP_IOCTL 1
195#define FIBMAP _IO(0x00,1)
196#define FIGETBSZ _IO(0x00,2)
197
198#ifdef __KERNEL__
199
200#include <asm/semaphore.h>
201#include <asm/byteorder.h>
202
203extern void update_atime (struct inode *);
204extern void update_mctime (struct inode *);
205#define UPDATE_ATIME(inode) update_atime (inode)
206
207extern void buffer_init(unsigned long);
208extern void inode_init(unsigned long);
209extern void mnt_init(unsigned long);
210extern void files_init(unsigned long mempages);
211
212
213enum bh_state_bits {
214 BH_Uptodate,
215 BH_Dirty,
216 BH_Lock,
217 BH_Req,
218 BH_Mapped,
219 BH_New,
220 BH_Async,
221 BH_Wait_IO,
222 BH_Launder,
223 BH_Attached,
224 BH_JBD,
225 BH_Sync,
226 BH_Delay,
227
228 BH_PrivateStart,
229
230
231};
232
233#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
234
235
236
237
238
239
240
241
242
243
244
245
246struct buffer_head {
247
248 struct buffer_head *b_next;
249 unsigned long b_blocknr;
250 unsigned short b_size;
251 unsigned short b_list;
252 kdev_t b_dev;
253
254 atomic_t b_count;
255 kdev_t b_rdev;
256 unsigned long b_state;
257 unsigned long b_flushtime;
258
259 struct buffer_head *b_next_free;
260 struct buffer_head *b_prev_free;
261 struct buffer_head *b_this_page;
262 struct buffer_head *b_reqnext;
263
264 struct buffer_head **b_pprev;
265 char * b_data;
266 struct page *b_page;
267 void (*b_end_io)(struct buffer_head *bh, int uptodate);
268 void *b_private;
269
270 unsigned long b_rsector;
271 wait_queue_head_t b_wait;
272
273 struct list_head b_inode_buffers;
274};
275
276typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
277void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
278
279#define __buffer_state(bh, state) (((bh)->b_state & (1UL << BH_##state)) != 0)
280
281#define buffer_uptodate(bh) __buffer_state(bh,Uptodate)
282#define buffer_dirty(bh) __buffer_state(bh,Dirty)
283#define buffer_locked(bh) __buffer_state(bh,Lock)
284#define buffer_req(bh) __buffer_state(bh,Req)
285#define buffer_mapped(bh) __buffer_state(bh,Mapped)
286#define buffer_new(bh) __buffer_state(bh,New)
287#define buffer_async(bh) __buffer_state(bh,Async)
288#define buffer_launder(bh) __buffer_state(bh,Launder)
289#define buffer_delay(bh) __buffer_state(bh,Delay)
290
291#define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
292
293extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long offset);
294
295#define touch_buffer(bh) mark_page_accessed(bh->b_page)
296
297
298#include <linux/pipe_fs_i.h>
299#include <linux/minix_fs_i.h>
300#include <linux/ext2_fs_i.h>
301#include <linux/ext3_fs_i.h>
302#include <linux/hpfs_fs_i.h>
303#include <linux/ntfs_fs_i.h>
304#include <linux/msdos_fs_i.h>
305#include <linux/umsdos_fs_i.h>
306#include <linux/iso_fs_i.h>
307#include <linux/nfs_fs_i.h>
308#include <linux/sysv_fs_i.h>
309#include <linux/affs_fs_i.h>
310#include <linux/ufs_fs_i.h>
311#include <linux/efs_fs_i.h>
312#include <linux/coda_fs_i.h>
313#include <linux/romfs_fs_i.h>
314#include <linux/shmem_fs.h>
315#include <linux/smb_fs_i.h>
316#include <linux/hfs_fs_i.h>
317#include <linux/adfs_fs_i.h>
318#include <linux/qnx4_fs_i.h>
319#include <linux/reiserfs_fs_i.h>
320#include <linux/bfs_fs_i.h>
321#include <linux/udf_fs_i.h>
322#include <linux/ncp_fs_i.h>
323#include <linux/proc_fs_i.h>
324#include <linux/usbdev_fs_i.h>
325#include <linux/jffs2_fs_i.h>
326#include <linux/cramfs_fs_sb.h>
327
328
329
330
331
332#define ATTR_MODE 1
333#define ATTR_UID 2
334#define ATTR_GID 4
335#define ATTR_SIZE 8
336#define ATTR_ATIME 16
337#define ATTR_MTIME 32
338#define ATTR_CTIME 64
339#define ATTR_ATIME_SET 128
340#define ATTR_MTIME_SET 256
341#define ATTR_FORCE 512
342#define ATTR_ATTR_FLAG 1024
343
344
345
346
347
348
349
350
351
352
353struct iattr {
354 unsigned int ia_valid;
355 umode_t ia_mode;
356 uid_t ia_uid;
357 gid_t ia_gid;
358 loff_t ia_size;
359 time_t ia_atime;
360 time_t ia_mtime;
361 time_t ia_ctime;
362 unsigned int ia_attr_flags;
363};
364
365
366
367
368#define ATTR_FLAG_SYNCRONOUS 1
369#define ATTR_FLAG_NOATIME 2
370#define ATTR_FLAG_APPEND 4
371#define ATTR_FLAG_IMMUTABLE 8
372#define ATTR_FLAG_NODIRATIME 16
373
374
375
376
377#include <linux/quota.h>
378#include <linux/mount.h>
379
380
381
382
383struct page;
384struct address_space;
385struct kiobuf;
386
387struct address_space_operations {
388 int (*writepage)(struct page *);
389 int (*readpage)(struct file *, struct page *);
390 int (*sync_page)(struct page *);
391
392
393
394
395 int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
396 int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
397
398 int (*bmap)(struct address_space *, long);
399 int (*flushpage) (struct page *, unsigned long);
400 int (*releasepage) (struct page *, int);
401#define KERNEL_HAS_O_DIRECT
402 int (*direct_IO)(int, struct inode *, struct kiobuf *, unsigned long, int);
403#define KERNEL_HAS_DIRECT_FILEIO
404 int (*direct_fileIO)(int, struct file *, struct kiobuf *, unsigned long, int);
405 void (*removepage)(struct page *);
406};
407
408struct address_space {
409 struct list_head clean_pages;
410 struct list_head dirty_pages;
411 struct list_head locked_pages;
412 unsigned long nrpages;
413 struct address_space_operations *a_ops;
414 struct inode *host;
415 struct vm_area_struct *i_mmap;
416 struct vm_area_struct *i_mmap_shared;
417 spinlock_t i_shared_lock;
418 int gfp_mask;
419};
420
421struct char_device {
422 struct list_head hash;
423 atomic_t count;
424 dev_t dev;
425 atomic_t openers;
426 struct semaphore sem;
427};
428
429struct block_device {
430 struct list_head bd_hash;
431 atomic_t bd_count;
432 struct inode * bd_inode;
433 dev_t bd_dev;
434 int bd_openers;
435 const struct block_device_operations *bd_op;
436 struct semaphore bd_sem;
437 struct list_head bd_inodes;
438};
439
440struct inode {
441 struct list_head i_hash;
442 struct list_head i_list;
443 struct list_head i_dentry;
444
445 struct list_head i_dirty_buffers;
446 struct list_head i_dirty_data_buffers;
447
448 unsigned long i_ino;
449 atomic_t i_count;
450 kdev_t i_dev;
451 umode_t i_mode;
452 nlink_t i_nlink;
453 uid_t i_uid;
454 gid_t i_gid;
455 kdev_t i_rdev;
456 loff_t i_size;
457 time_t i_atime;
458 time_t i_mtime;
459 time_t i_ctime;
460 unsigned int i_blkbits;
461 unsigned long i_blksize;
462 unsigned long i_blocks;
463 unsigned long i_version;
464 unsigned short i_bytes;
465 struct semaphore i_sem;
466 struct rw_semaphore i_alloc_sem;
467 struct semaphore i_zombie;
468 struct inode_operations *i_op;
469 struct file_operations *i_fop;
470 struct super_block *i_sb;
471 wait_queue_head_t i_wait;
472 struct file_lock *i_flock;
473 struct address_space *i_mapping;
474 struct address_space i_data;
475 struct dquot *i_dquot[MAXQUOTAS];
476
477 struct list_head i_devices;
478 struct pipe_inode_info *i_pipe;
479 struct block_device *i_bdev;
480 struct char_device *i_cdev;
481
482 unsigned long i_dnotify_mask;
483 struct dnotify_struct *i_dnotify;
484
485 unsigned long i_state;
486
487 unsigned int i_flags;
488 unsigned char i_sock;
489
490 atomic_t i_writecount;
491 unsigned int i_attr_flags;
492 __u32 i_generation;
493 union {
494 struct minix_inode_info minix_i;
495 struct ext2_inode_info ext2_i;
496 struct ext3_inode_info ext3_i;
497 struct hpfs_inode_info hpfs_i;
498 struct ntfs_inode_info ntfs_i;
499 struct msdos_inode_info msdos_i;
500 struct umsdos_inode_info umsdos_i;
501 struct iso_inode_info isofs_i;
502 struct nfs_inode_info nfs_i;
503 struct sysv_inode_info sysv_i;
504 struct affs_inode_info affs_i;
505 struct ufs_inode_info ufs_i;
506 struct efs_inode_info efs_i;
507 struct romfs_inode_info romfs_i;
508 struct shmem_inode_info shmem_i;
509 struct coda_inode_info coda_i;
510 struct smb_inode_info smbfs_i;
511 struct hfs_inode_info hfs_i;
512 struct adfs_inode_info adfs_i;
513 struct qnx4_inode_info qnx4_i;
514 struct reiserfs_inode_info reiserfs_i;
515 struct bfs_inode_info bfs_i;
516 struct udf_inode_info udf_i;
517 struct ncp_inode_info ncpfs_i;
518 struct proc_inode_info proc_i;
519 struct socket socket_i;
520 struct usbdev_inode_info usbdev_i;
521 struct jffs2_inode_info jffs2_i;
522 void *generic_ip;
523 } u;
524};
525
526static inline void inode_add_bytes(struct inode *inode, loff_t bytes)
527{
528 inode->i_blocks += bytes >> 9;
529 bytes &= 511;
530 inode->i_bytes += bytes;
531 if (inode->i_bytes >= 512) {
532 inode->i_blocks++;
533 inode->i_bytes -= 512;
534 }
535}
536
537static inline void inode_sub_bytes(struct inode *inode, loff_t bytes)
538{
539 inode->i_blocks -= bytes >> 9;
540 bytes &= 511;
541 if (inode->i_bytes < bytes) {
542 inode->i_blocks--;
543 inode->i_bytes += 512;
544 }
545 inode->i_bytes -= bytes;
546}
547
548static inline loff_t inode_get_bytes(struct inode *inode)
549{
550 return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
551}
552
553static inline void inode_set_bytes(struct inode *inode, loff_t bytes)
554{
555 inode->i_blocks = bytes >> 9;
556 inode->i_bytes = bytes & 511;
557}
558
559struct fown_struct {
560 int pid;
561 uid_t uid, euid;
562 int signum;
563};
564
565struct file {
566 struct list_head f_list;
567 struct dentry *f_dentry;
568 struct vfsmount *f_vfsmnt;
569 struct file_operations *f_op;
570 atomic_t f_count;
571 unsigned int f_flags;
572 mode_t f_mode;
573 loff_t f_pos;
574 unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
575 struct fown_struct f_owner;
576 unsigned int f_uid, f_gid;
577 int f_error;
578
579 unsigned long f_version;
580
581
582 void *private_data;
583
584
585 struct kiobuf *f_iobuf;
586 long f_iobuf_lock;
587};
588extern spinlock_t files_lock;
589#define file_list_lock() spin_lock(&files_lock);
590#define file_list_unlock() spin_unlock(&files_lock);
591
592#define get_file(x) atomic_inc(&(x)->f_count)
593#define file_count(x) atomic_read(&(x)->f_count)
594
595extern int init_private_file(struct file *, struct dentry *, int);
596
597#define MAX_NON_LFS ((1UL<<31) - 1)
598
599
600
601#if BITS_PER_LONG==32
602#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
603#elif BITS_PER_LONG==64
604#define MAX_LFS_FILESIZE 0x7fffffffffffffff
605#endif
606
607#define FL_POSIX 1
608#define FL_FLOCK 2
609#define FL_BROKEN 4
610#define FL_ACCESS 8
611#define FL_LOCKD 16
612#define FL_LEASE 32
613
614
615
616
617
618
619
620
621typedef struct files_struct *fl_owner_t;
622
623struct file_lock {
624 struct file_lock *fl_next;
625 struct list_head fl_link;
626 struct list_head fl_block;
627 fl_owner_t fl_owner;
628 unsigned int fl_pid;
629 wait_queue_head_t fl_wait;
630 struct file *fl_file;
631 unsigned char fl_flags;
632 unsigned char fl_type;
633 loff_t fl_start;
634 loff_t fl_end;
635
636 void (*fl_notify)(struct file_lock *);
637 void (*fl_insert)(struct file_lock *);
638 void (*fl_remove)(struct file_lock *);
639
640 struct fasync_struct * fl_fasync;
641 unsigned long fl_break_time;
642
643 union {
644 struct nfs_lock_info nfs_fl;
645 } fl_u;
646};
647
648
649#ifndef OFFSET_MAX
650#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
651#define OFFSET_MAX INT_LIMIT(loff_t)
652#define OFFT_OFFSET_MAX INT_LIMIT(off_t)
653#endif
654
655extern struct list_head file_lock_list;
656
657#include <linux/fcntl.h>
658
659extern int fcntl_getlk(unsigned int, struct flock *);
660extern int fcntl_setlk(unsigned int, unsigned int, struct flock *);
661
662extern int fcntl_getlk64(unsigned int, struct flock64 *);
663extern int fcntl_setlk64(unsigned int, unsigned int, struct flock64 *);
664
665
666extern void locks_init_lock(struct file_lock *);
667extern void locks_copy_lock(struct file_lock *, struct file_lock *);
668extern void locks_remove_posix(struct file *, fl_owner_t);
669extern void locks_remove_flock(struct file *);
670extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
671extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
672extern void posix_block_lock(struct file_lock *, struct file_lock *);
673extern void posix_unblock_lock(struct file_lock *);
674extern int posix_locks_deadlock(struct file_lock *, struct file_lock *);
675extern int __get_lease(struct inode *inode, unsigned int flags);
676extern time_t lease_get_mtime(struct inode *);
677extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
678extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
679extern void steal_locks(fl_owner_t from);
680
681struct fasync_struct {
682 int magic;
683 int fa_fd;
684 struct fasync_struct *fa_next;
685 struct file *fa_file;
686};
687
688#define FASYNC_MAGIC 0x4601
689
690
691extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
692
693extern void kill_fasync(struct fasync_struct **, int, int);
694
695extern void __kill_fasync(struct fasync_struct *, int, int);
696
697struct nameidata {
698 struct dentry *dentry;
699 struct vfsmount *mnt;
700 struct qstr last;
701 unsigned int flags;
702 int last_type;
703};
704
705
706
707
708
709#define MNT_FORCE 0x00000001
710#define MNT_DETACH 0x00000002
711
712#include <linux/minix_fs_sb.h>
713#include <linux/ext2_fs_sb.h>
714#include <linux/ext3_fs_sb.h>
715#include <linux/hpfs_fs_sb.h>
716#include <linux/ntfs_fs_sb.h>
717#include <linux/msdos_fs_sb.h>
718#include <linux/iso_fs_sb.h>
719#include <linux/nfs_fs_sb.h>
720#include <linux/sysv_fs_sb.h>
721#include <linux/affs_fs_sb.h>
722#include <linux/ufs_fs_sb.h>
723#include <linux/efs_fs_sb.h>
724#include <linux/romfs_fs_sb.h>
725#include <linux/smb_fs_sb.h>
726#include <linux/hfs_fs_sb.h>
727#include <linux/adfs_fs_sb.h>
728#include <linux/qnx4_fs_sb.h>
729#include <linux/reiserfs_fs_sb.h>
730#include <linux/bfs_fs_sb.h>
731#include <linux/udf_fs_sb.h>
732#include <linux/ncp_fs_sb.h>
733#include <linux/usbdev_fs_sb.h>
734#include <linux/cramfs_fs_sb.h>
735#include <linux/jffs2_fs_sb.h>
736
737extern struct list_head super_blocks;
738extern spinlock_t sb_lock;
739
740#define sb_entry(list) list_entry((list), struct super_block, s_list)
741#define S_BIAS (1<<30)
742struct super_block {
743 struct list_head s_list;
744 kdev_t s_dev;
745 unsigned long s_blocksize;
746 unsigned char s_blocksize_bits;
747 unsigned char s_dirt;
748 unsigned long long s_maxbytes;
749 struct file_system_type *s_type;
750 struct super_operations *s_op;
751 struct dquot_operations *dq_op;
752 struct quotactl_ops *s_qcop;
753 unsigned long s_flags;
754 unsigned long s_magic;
755 struct dentry *s_root;
756 struct rw_semaphore s_umount;
757 struct semaphore s_lock;
758 int s_count;
759 atomic_t s_active;
760
761 struct list_head s_dirty;
762 struct list_head s_locked_inodes;
763 struct list_head s_files;
764
765 struct block_device *s_bdev;
766 struct list_head s_instances;
767 struct quota_info s_dquot;
768
769 union {
770 struct minix_sb_info minix_sb;
771 struct ext2_sb_info ext2_sb;
772 struct ext3_sb_info ext3_sb;
773 struct hpfs_sb_info hpfs_sb;
774 struct ntfs_sb_info ntfs_sb;
775 struct msdos_sb_info msdos_sb;
776 struct isofs_sb_info isofs_sb;
777 struct nfs_sb_info nfs_sb;
778 struct sysv_sb_info sysv_sb;
779 struct affs_sb_info affs_sb;
780 struct ufs_sb_info ufs_sb;
781 struct efs_sb_info efs_sb;
782 struct shmem_sb_info shmem_sb;
783 struct romfs_sb_info romfs_sb;
784 struct smb_sb_info smbfs_sb;
785 struct hfs_sb_info hfs_sb;
786 struct adfs_sb_info adfs_sb;
787 struct qnx4_sb_info qnx4_sb;
788 struct reiserfs_sb_info reiserfs_sb;
789 struct bfs_sb_info bfs_sb;
790 struct udf_sb_info udf_sb;
791 struct ncp_sb_info ncpfs_sb;
792 struct usbdev_sb_info usbdevfs_sb;
793 struct jffs2_sb_info jffs2_sb;
794 struct cramfs_sb_info cramfs_sb;
795 void *generic_sbp;
796 } u;
797
798
799
800
801 struct semaphore s_vfs_rename_sem;
802
803
804
805
806
807
808
809
810 struct semaphore s_nfsd_free_path_sem;
811};
812
813
814
815
816extern int vfs_create(struct inode *, struct dentry *, int);
817extern int vfs_mkdir(struct inode *, struct dentry *, int);
818extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
819extern int vfs_symlink(struct inode *, struct dentry *, const char *);
820extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
821extern int vfs_rmdir(struct inode *, struct dentry *);
822extern int vfs_unlink(struct inode *, struct dentry *);
823extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
824
825
826
827
828#define DT_UNKNOWN 0
829#define DT_FIFO 1
830#define DT_CHR 2
831#define DT_DIR 4
832#define DT_BLK 6
833#define DT_REG 8
834#define DT_LNK 10
835#define DT_SOCK 12
836#define DT_WHT 14
837
838
839
840
841
842
843
844typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
845
846struct block_device_operations {
847 int (*open) (struct inode *, struct file *);
848 int (*release) (struct inode *, struct file *);
849 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
850 int (*check_media_change) (kdev_t);
851 int (*revalidate) (kdev_t);
852 struct module *owner;
853};
854
855
856
857
858
859
860struct file_operations {
861 struct module *owner;
862 loff_t (*llseek) (struct file *, loff_t, int);
863 ssize_t (*read) (struct file *, char *, size_t, loff_t *);
864 ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
865 int (*readdir) (struct file *, void *, filldir_t);
866 unsigned int (*poll) (struct file *, struct poll_table_struct *);
867 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
868 int (*mmap) (struct file *, struct vm_area_struct *);
869 int (*open) (struct inode *, struct file *);
870 int (*flush) (struct file *);
871 int (*release) (struct inode *, struct file *);
872 int (*fsync) (struct file *, struct dentry *, int datasync);
873 int (*fasync) (int, struct file *, int);
874 int (*lock) (struct file *, int, struct file_lock *);
875 ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
876 ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
877 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
878 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
879};
880
881struct inode_operations {
882 int (*create) (struct inode *,struct dentry *,int);
883 struct dentry * (*lookup) (struct inode *,struct dentry *);
884 int (*link) (struct dentry *,struct inode *,struct dentry *);
885 int (*unlink) (struct inode *,struct dentry *);
886 int (*symlink) (struct inode *,struct dentry *,const char *);
887 int (*mkdir) (struct inode *,struct dentry *,int);
888 int (*rmdir) (struct inode *,struct dentry *);
889 int (*mknod) (struct inode *,struct dentry *,int,int);
890 int (*rename) (struct inode *, struct dentry *,
891 struct inode *, struct dentry *);
892 int (*readlink) (struct dentry *, char *,int);
893 int (*follow_link) (struct dentry *, struct nameidata *);
894 void (*truncate) (struct inode *);
895 int (*permission) (struct inode *, int);
896 int (*revalidate) (struct dentry *);
897 int (*setattr) (struct dentry *, struct iattr *);
898 int (*getattr) (struct dentry *, struct iattr *);
899 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
900 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
901 ssize_t (*listxattr) (struct dentry *, char *, size_t);
902 int (*removexattr) (struct dentry *, const char *);
903};
904
905struct seq_file;
906
907
908
909
910
911struct super_operations {
912 struct inode *(*alloc_inode)(struct super_block *sb);
913 void (*destroy_inode)(struct inode *);
914
915 void (*read_inode) (struct inode *);
916
917
918
919
920
921
922
923 void (*read_inode2) (struct inode *, void *) ;
924 void (*dirty_inode) (struct inode *);
925 void (*write_inode) (struct inode *, int);
926 void (*put_inode) (struct inode *);
927 void (*delete_inode) (struct inode *);
928 void (*put_super) (struct super_block *);
929 void (*write_super) (struct super_block *);
930 int (*sync_fs) (struct super_block *);
931 void (*write_super_lockfs) (struct super_block *);
932 void (*unlockfs) (struct super_block *);
933 int (*statfs) (struct super_block *, struct statfs *);
934 int (*remount_fs) (struct super_block *, int *, char *);
935 void (*clear_inode) (struct inode *);
936 void (*umount_begin) (struct super_block *);
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960 struct dentry * (*fh_to_dentry)(struct super_block *sb, __u32 *fh, int len, int fhtype, int parent);
961 int (*dentry_to_fh)(struct dentry *, __u32 *fh, int *lenp, int need_parent);
962 int (*show_options)(struct seq_file *, struct vfsmount *);
963};
964
965
966#define I_DIRTY_SYNC 1
967#define I_DIRTY_DATASYNC 2
968#define I_DIRTY_PAGES 4
969#define I_LOCK 8
970#define I_FREEING 16
971#define I_CLEAR 32
972#define I_NEW 64
973
974#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
975
976extern void __mark_inode_dirty(struct inode *, int);
977static inline void mark_inode_dirty(struct inode *inode)
978{
979 __mark_inode_dirty(inode, I_DIRTY);
980}
981
982static inline void mark_inode_dirty_sync(struct inode *inode)
983{
984 __mark_inode_dirty(inode, I_DIRTY_SYNC);
985}
986
987static inline void mark_inode_dirty_pages(struct inode *inode)
988{
989 __mark_inode_dirty(inode, I_DIRTY_PAGES);
990}
991
992struct file_system_type {
993 const char *name;
994 int fs_flags;
995 struct super_block *(*read_super) (struct super_block *, void *, int);
996 struct module *owner;
997 struct file_system_type * next;
998 struct list_head fs_supers;
999};
1000
1001#define DECLARE_FSTYPE(var,type,read,flags) \
1002struct file_system_type var = { \
1003 name: type, \
1004 read_super: read, \
1005 fs_flags: flags, \
1006 owner: THIS_MODULE, \
1007}
1008
1009#define DECLARE_FSTYPE_DEV(var,type,read) \
1010 DECLARE_FSTYPE(var,type,read,FS_REQUIRES_DEV)
1011
1012
1013#define fops_get(fops) \
1014 (((fops) && (fops)->owner) \
1015 ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
1016 : (fops))
1017
1018#define fops_put(fops) \
1019do { \
1020 if ((fops) && (fops)->owner) \
1021 __MOD_DEC_USE_COUNT((fops)->owner); \
1022} while(0)
1023
1024extern int register_filesystem(struct file_system_type *);
1025extern int unregister_filesystem(struct file_system_type *);
1026extern struct vfsmount *kern_mount(struct file_system_type *);
1027extern int may_umount(struct vfsmount *);
1028extern long do_mount(char *, char *, char *, unsigned long, void *);
1029
1030#define kern_umount mntput
1031
1032extern int vfs_statfs(struct super_block *, struct statfs *);
1033
1034
1035
1036
1037#define LOCK_USE_CLNT 1
1038
1039#define FLOCK_VERIFY_READ 1
1040#define FLOCK_VERIFY_WRITE 2
1041
1042extern int locks_mandatory_locked(struct inode *);
1043extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
1044
1045
1046
1047
1048
1049#define MANDATORY_LOCK(inode) \
1050 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
1051
1052static inline int locks_verify_locked(struct inode *inode)
1053{
1054 if (MANDATORY_LOCK(inode))
1055 return locks_mandatory_locked(inode);
1056 return 0;
1057}
1058
1059static inline int locks_verify_area(int read_write, struct inode *inode,
1060 struct file *filp, loff_t offset,
1061 size_t count)
1062{
1063 if (inode->i_flock && MANDATORY_LOCK(inode))
1064 return locks_mandatory_area(read_write, inode, filp, offset, count);
1065 return 0;
1066}
1067
1068static inline int locks_verify_truncate(struct inode *inode,
1069 struct file *filp,
1070 loff_t size)
1071{
1072 if (inode->i_flock && MANDATORY_LOCK(inode))
1073 return locks_mandatory_area(
1074 FLOCK_VERIFY_WRITE, inode, filp,
1075 size < inode->i_size ? size : inode->i_size,
1076 (size < inode->i_size ? inode->i_size - size
1077 : size - inode->i_size)
1078 );
1079 return 0;
1080}
1081
1082static inline int get_lease(struct inode *inode, unsigned int mode)
1083{
1084 if (inode->i_flock)
1085 return __get_lease(inode, mode);
1086 return 0;
1087}
1088
1089
1090
1091asmlinkage long sys_open(const char *, int, int);
1092asmlinkage long sys_close(unsigned int);
1093extern int do_truncate(struct dentry *, loff_t start);
1094
1095extern struct file *filp_open(const char *, int, int);
1096extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1097extern int filp_close(struct file *, fl_owner_t id);
1098extern char * getname(const char *);
1099
1100
1101extern void vfs_caches_init(unsigned long);
1102
1103#define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL)
1104#define putname(name) kmem_cache_free(names_cachep, (void *)(name))
1105
1106enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW};
1107extern int register_blkdev(unsigned int, const char *, struct block_device_operations *);
1108extern int unregister_blkdev(unsigned int, const char *);
1109extern struct block_device *bdget(dev_t);
1110extern int bd_acquire(struct inode *inode);
1111extern void bd_forget(struct inode *inode);
1112extern void bdput(struct block_device *);
1113extern struct char_device *cdget(dev_t);
1114extern void cdput(struct char_device *);
1115extern int blkdev_open(struct inode *, struct file *);
1116extern int blkdev_close(struct inode *, struct file *);
1117extern struct file_operations def_blk_fops;
1118extern struct address_space_operations def_blk_aops;
1119extern struct file_operations def_fifo_fops;
1120extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1121extern int blkdev_get(struct block_device *, mode_t, unsigned, int);
1122extern int blkdev_put(struct block_device *, int);
1123
1124
1125extern const struct block_device_operations *get_blkfops(unsigned int);
1126extern int register_chrdev(unsigned int, const char *, struct file_operations *);
1127extern int unregister_chrdev(unsigned int, const char *);
1128extern int chrdev_open(struct inode *, struct file *);
1129extern const char * bdevname(kdev_t);
1130extern const char * cdevname(kdev_t);
1131extern const char * kdevname(kdev_t);
1132extern void init_special_inode(struct inode *, umode_t, int);
1133
1134
1135extern void make_bad_inode(struct inode *);
1136extern int is_bad_inode(struct inode *);
1137
1138extern struct file_operations read_fifo_fops;
1139extern struct file_operations write_fifo_fops;
1140extern struct file_operations rdwr_fifo_fops;
1141extern struct file_operations read_pipe_fops;
1142extern struct file_operations write_pipe_fops;
1143extern struct file_operations rdwr_pipe_fops;
1144
1145extern int fs_may_remount_ro(struct super_block *);
1146
1147extern int FASTCALL(try_to_free_buffers(struct page *, unsigned int));
1148extern void refile_buffer(struct buffer_head * buf);
1149extern void create_empty_buffers(struct page *, kdev_t, unsigned long);
1150extern void end_buffer_io_sync(struct buffer_head *bh, int uptodate);
1151extern void end_buffer_io_async(struct buffer_head *bh, int uptodate);
1152
1153
1154extern void set_buffer_async_io(struct buffer_head *bh) ;
1155
1156#define BUF_CLEAN 0
1157#define BUF_LOCKED 1
1158#define BUF_DIRTY 2
1159#define NR_LIST 3
1160
1161static inline void get_bh(struct buffer_head * bh)
1162{
1163 atomic_inc(&(bh)->b_count);
1164}
1165
1166static inline void put_bh(struct buffer_head *bh)
1167{
1168 smp_mb__before_atomic_dec();
1169 atomic_dec(&bh->b_count);
1170}
1171
1172
1173
1174
1175static inline void mark_buffer_uptodate(struct buffer_head * bh, int on)
1176{
1177 if (on)
1178 set_bit(BH_Uptodate, &bh->b_state);
1179 else
1180 clear_bit(BH_Uptodate, &bh->b_state);
1181}
1182
1183#define atomic_set_buffer_clean(bh) test_and_clear_bit(BH_Dirty, &(bh)->b_state)
1184
1185static inline void __mark_buffer_clean(struct buffer_head *bh)
1186{
1187 refile_buffer(bh);
1188}
1189
1190static inline void mark_buffer_clean(struct buffer_head * bh)
1191{
1192 if (atomic_set_buffer_clean(bh))
1193 __mark_buffer_clean(bh);
1194}
1195
1196extern void FASTCALL(__mark_dirty(struct buffer_head *bh));
1197extern void FASTCALL(__mark_buffer_dirty(struct buffer_head *bh));
1198extern void FASTCALL(mark_buffer_dirty(struct buffer_head *bh));
1199
1200extern void FASTCALL(buffer_insert_list(struct buffer_head *, struct list_head *));
1201
1202static inline void buffer_insert_inode_queue(struct buffer_head *bh, struct inode *inode)
1203{
1204 buffer_insert_list(bh, &inode->i_dirty_buffers);
1205}
1206
1207static inline void buffer_insert_inode_data_queue(struct buffer_head *bh, struct inode *inode)
1208{
1209 buffer_insert_list(bh, &inode->i_dirty_data_buffers);
1210}
1211
1212static inline int atomic_set_buffer_dirty(struct buffer_head *bh)
1213{
1214 return test_and_set_bit(BH_Dirty, &bh->b_state);
1215}
1216
1217static inline void mark_buffer_async(struct buffer_head * bh, int on)
1218{
1219 if (on)
1220 set_bit(BH_Async, &bh->b_state);
1221 else
1222 clear_bit(BH_Async, &bh->b_state);
1223}
1224
1225static inline void set_buffer_attached(struct buffer_head *bh)
1226{
1227 set_bit(BH_Attached, &bh->b_state);
1228}
1229
1230static inline void clear_buffer_attached(struct buffer_head *bh)
1231{
1232 clear_bit(BH_Attached, &bh->b_state);
1233}
1234
1235static inline int buffer_attached(struct buffer_head *bh)
1236{
1237 return test_bit(BH_Attached, &bh->b_state);
1238}
1239
1240
1241
1242
1243
1244
1245
1246static inline void buffer_IO_error(struct buffer_head * bh)
1247{
1248 mark_buffer_clean(bh);
1249
1250
1251
1252 bh->b_end_io(bh, 0);
1253}
1254
1255static inline void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
1256{
1257 mark_buffer_dirty(bh);
1258 buffer_insert_inode_queue(bh, inode);
1259}
1260
1261extern void set_buffer_flushtime(struct buffer_head *);
1262extern inline int get_buffer_flushtime(void);
1263extern void balance_dirty(void);
1264extern int check_disk_change(kdev_t);
1265extern int invalidate_inodes(struct super_block *);
1266extern int invalidate_device(kdev_t, int);
1267extern void invalidate_inode_pages(struct inode *);
1268extern void invalidate_inode_pages2(struct address_space *);
1269extern void invalidate_inode_buffers(struct inode *);
1270#define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
1271#define destroy_buffers(dev) __invalidate_buffers((dev), 1)
1272extern void invalidate_bdev(struct block_device *, int);
1273extern void __invalidate_buffers(kdev_t dev, int);
1274extern void sync_inodes(kdev_t);
1275extern void sync_unlocked_inodes(void);
1276extern void write_inode_now(struct inode *, int);
1277extern int sync_buffers(kdev_t, int);
1278extern void sync_dev(kdev_t);
1279extern int fsync_dev(kdev_t);
1280extern int fsync_super(struct super_block *);
1281extern int fsync_no_super(kdev_t);
1282extern void sync_inodes_sb(struct super_block *);
1283extern int fsync_buffers_list(struct list_head *);
1284static inline int fsync_inode_buffers(struct inode *inode)
1285{
1286 return fsync_buffers_list(&inode->i_dirty_buffers);
1287}
1288static inline int fsync_inode_data_buffers(struct inode *inode)
1289{
1290 return fsync_buffers_list(&inode->i_dirty_data_buffers);
1291}
1292extern int inode_has_buffers(struct inode *);
1293extern int do_fdatasync(struct file *);
1294extern int filemap_fdatawrite(struct address_space *);
1295extern int filemap_fdatasync(struct address_space *);
1296extern int filemap_fdatawait(struct address_space *);
1297extern void sync_supers(kdev_t dev, int wait);
1298extern int bmap(struct inode *, int);
1299extern int notify_change(struct dentry *, struct iattr *);
1300extern int permission(struct inode *, int);
1301extern int vfs_permission(struct inode *, int);
1302extern int get_write_access(struct inode *);
1303extern int deny_write_access(struct file *);
1304static inline void put_write_access(struct inode * inode)
1305{
1306 atomic_dec(&inode->i_writecount);
1307}
1308static inline void allow_write_access(struct file *file)
1309{
1310 if (file)
1311 atomic_inc(&file->f_dentry->d_inode->i_writecount);
1312}
1313extern int do_pipe(int *);
1314
1315extern int open_namei(const char *, int, int, struct nameidata *);
1316
1317extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
1318extern struct file * open_exec(const char *);
1319
1320
1321extern int is_subdir(struct dentry *, struct dentry *);
1322extern ino_t find_inode_number(struct dentry *, struct qstr *);
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332static inline void *ERR_PTR(long error)
1333{
1334 return (void *) error;
1335}
1336
1337static inline long PTR_ERR(const void *ptr)
1338{
1339 return (long) ptr;
1340}
1341
1342static inline long IS_ERR(const void *ptr)
1343{
1344 return (unsigned long)ptr > (unsigned long)-1000L;
1345}
1346
1347
1348
1349
1350
1351
1352
1353
1354#define LOOKUP_FOLLOW (1)
1355#define LOOKUP_DIRECTORY (2)
1356#define LOOKUP_CONTINUE (4)
1357#define LOOKUP_POSITIVE (8)
1358#define LOOKUP_PARENT (16)
1359#define LOOKUP_NOALT (32)
1360
1361
1362
1363enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374typedef struct {
1375 size_t written;
1376 size_t count;
1377 char * buf;
1378 int error;
1379} read_descriptor_t;
1380
1381typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
1382
1383
1384extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1385
1386extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1387extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1388extern int FASTCALL(path_walk(const char *, struct nameidata *));
1389extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1390extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
1391extern void path_release(struct nameidata *);
1392extern int follow_down(struct vfsmount **, struct dentry **);
1393extern int follow_up(struct vfsmount **, struct dentry **);
1394extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
1395extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1396#define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1397#define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1398
1399extern void inode_init_once(struct inode *);
1400extern void __inode_init_once(struct inode *);
1401extern void iput(struct inode *);
1402extern void refile_inode(struct inode *inode);
1403extern void force_delete(struct inode *);
1404extern struct inode * igrab(struct inode *);
1405extern struct inode * ilookup(struct super_block *, unsigned long);
1406extern ino_t iunique(struct super_block *, ino_t);
1407extern void unlock_new_inode(struct inode *);
1408
1409typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
1410
1411extern struct inode * iget4_locked(struct super_block *, unsigned long,
1412 find_inode_t, void *);
1413
1414static inline struct inode *iget4(struct super_block *sb, unsigned long ino,
1415 find_inode_t find_actor, void *opaque)
1416{
1417 struct inode *inode = iget4_locked(sb, ino, find_actor, opaque);
1418
1419 if (inode && (inode->i_state & I_NEW)) {
1420
1421
1422
1423 if (sb->s_op->read_inode2)
1424 sb->s_op->read_inode2(inode, opaque);
1425 else
1426 sb->s_op->read_inode(inode);
1427 unlock_new_inode(inode);
1428 }
1429
1430 return inode;
1431}
1432
1433static inline struct inode *iget(struct super_block *sb, unsigned long ino)
1434{
1435 struct inode *inode = iget4_locked(sb, ino, NULL, NULL);
1436
1437 if (inode && (inode->i_state & I_NEW)) {
1438 sb->s_op->read_inode(inode);
1439 unlock_new_inode(inode);
1440 }
1441
1442 return inode;
1443}
1444
1445static inline struct inode *iget_locked(struct super_block *sb, unsigned long ino)
1446{
1447 return iget4_locked(sb, ino, NULL, NULL);
1448}
1449
1450extern void clear_inode(struct inode *);
1451extern struct inode *new_inode(struct super_block *sb);
1452extern void remove_suid(struct inode *inode);
1453
1454extern void insert_inode_hash(struct inode *);
1455extern void remove_inode_hash(struct inode *);
1456extern struct file * get_empty_filp(void);
1457extern void file_move(struct file *f, struct list_head *list);
1458extern struct buffer_head * get_hash_table(kdev_t, int, int);
1459extern struct buffer_head * getblk(kdev_t, int, int);
1460extern void ll_rw_block(int, int, struct buffer_head * bh[]);
1461extern void submit_bh(int, struct buffer_head *);
1462extern int is_read_only(kdev_t);
1463extern void __brelse(struct buffer_head *);
1464static inline void brelse(struct buffer_head *buf)
1465{
1466 if (buf)
1467 __brelse(buf);
1468}
1469extern void __bforget(struct buffer_head *);
1470static inline void bforget(struct buffer_head *buf)
1471{
1472 if (buf)
1473 __bforget(buf);
1474}
1475extern int set_blocksize(kdev_t, int);
1476extern int sb_set_blocksize(struct super_block *, int);
1477extern int sb_min_blocksize(struct super_block *, int);
1478extern struct buffer_head * bread(kdev_t, int, int);
1479static inline struct buffer_head * sb_bread(struct super_block *sb, int block)
1480{
1481 return bread(sb->s_dev, block, sb->s_blocksize);
1482}
1483static inline struct buffer_head * sb_getblk(struct super_block *sb, int block)
1484{
1485 return getblk(sb->s_dev, block, sb->s_blocksize);
1486}
1487static inline struct buffer_head * sb_get_hash_table(struct super_block *sb, int block)
1488{
1489 return get_hash_table(sb->s_dev, block, sb->s_blocksize);
1490}
1491extern void wakeup_bdflush(void);
1492extern void wakeup_kupdate(void);
1493extern void put_unused_buffer_head(struct buffer_head * bh);
1494extern struct buffer_head * get_unused_buffer_head(int async);
1495extern int block_dump;
1496
1497extern int brw_page(int, struct page *, kdev_t, int [], int);
1498
1499typedef int (get_block_t)(struct inode*,long,struct buffer_head*,int);
1500
1501
1502extern int try_to_release_page(struct page * page, int gfp_mask);
1503extern int discard_bh_page(struct page *, unsigned long, int);
1504#define block_flushpage(page, offset) discard_bh_page(page, offset, 1)
1505#define block_invalidate_page(page) discard_bh_page(page, 0, 0)
1506extern int block_symlink(struct inode *, const char *, int);
1507extern int block_write_full_page(struct page*, get_block_t*);
1508extern int block_read_full_page(struct page*, get_block_t*);
1509extern int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
1510extern int cont_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
1511 unsigned long *);
1512extern int generic_cont_expand(struct inode *inode, loff_t size) ;
1513extern int block_commit_write(struct page *page, unsigned from, unsigned to);
1514extern int block_sync_page(struct page *);
1515
1516int generic_block_bmap(struct address_space *, long, get_block_t *);
1517int generic_commit_write(struct file *, struct page *, unsigned, unsigned);
1518int block_truncate_page(struct address_space *, loff_t, get_block_t *);
1519extern int generic_direct_IO(int, struct inode *, struct kiobuf *, unsigned long, int, get_block_t *);
1520extern int waitfor_one_page(struct page *);
1521extern int writeout_one_page(struct page *);
1522
1523extern int generic_file_mmap(struct file *, struct vm_area_struct *);
1524extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
1525extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
1526extern inline ssize_t do_generic_direct_read(struct file *, char *, size_t, loff_t *);
1527extern int precheck_file_write(struct file *, struct inode *, size_t *, loff_t *);
1528extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *);
1529extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, read_actor_t);
1530extern ssize_t do_generic_file_write(struct file *, const char *, size_t, loff_t *);
1531extern ssize_t do_generic_direct_write(struct file *, const char *, size_t, loff_t *);
1532extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
1533extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
1534extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
1535extern int generic_file_open(struct inode * inode, struct file * filp);
1536
1537extern struct file_operations generic_ro_fops;
1538
1539extern int vfs_readlink(struct dentry *, char *, int, const char *);
1540extern int vfs_follow_link(struct nameidata *, const char *);
1541extern int page_readlink(struct dentry *, char *, int);
1542extern int page_follow_link(struct dentry *, struct nameidata *);
1543extern struct inode_operations page_symlink_inode_operations;
1544
1545extern int vfs_readdir(struct file *, filldir_t, void *);
1546extern int dcache_dir_open(struct inode *, struct file *);
1547extern int dcache_dir_close(struct inode *, struct file *);
1548extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
1549extern int dcache_dir_fsync(struct file *, struct dentry *, int);
1550extern int dcache_readdir(struct file *, void *, filldir_t);
1551extern struct file_operations dcache_dir_ops;
1552
1553extern struct file_system_type *get_fs_type(const char *name);
1554extern struct super_block *get_super(kdev_t);
1555extern void drop_super(struct super_block *sb);
1556static inline int is_mounted(kdev_t dev)
1557{
1558 struct super_block *sb = get_super(dev);
1559 if (sb) {
1560 drop_super(sb);
1561 return 1;
1562 }
1563 return 0;
1564}
1565unsigned long generate_cluster(kdev_t, int b[], int);
1566unsigned long generate_cluster_swab32(kdev_t, int b[], int);
1567extern kdev_t ROOT_DEV;
1568extern char root_device_name[];
1569
1570
1571extern void show_buffers(void);
1572
1573#ifdef CONFIG_BLK_DEV_INITRD
1574extern unsigned int real_root_dev;
1575#endif
1576
1577extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
1578extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
1579extern int read_ahead[];
1580
1581extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
1582extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
1583
1584extern int file_fsync(struct file *, struct dentry *, int);
1585extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start_idx, unsigned long end_idx);
1586extern int generic_osync_inode(struct inode *, int);
1587#define OSYNC_METADATA (1<<0)
1588#define OSYNC_DATA (1<<1)
1589#define OSYNC_INODE (1<<2)
1590
1591extern int inode_change_ok(struct inode *, struct iattr *);
1592extern int inode_setattr(struct inode *, struct iattr *);
1593
1594
1595extern int unshare_files(void);
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616static inline struct dentry *lock_parent(struct dentry *dentry)
1617{
1618 struct dentry *dir = dget(dentry->d_parent);
1619
1620 down(&dir->d_inode->i_sem);
1621 return dir;
1622}
1623
1624static inline struct dentry *get_parent(struct dentry *dentry)
1625{
1626 return dget(dentry->d_parent);
1627}
1628
1629static inline void unlock_dir(struct dentry *dir)
1630{
1631 up(&dir->d_inode->i_sem);
1632 dput(dir);
1633}
1634
1635
1636
1637
1638
1639static inline void double_down(struct semaphore *s1, struct semaphore *s2)
1640{
1641 if (s1 != s2) {
1642 if ((unsigned long) s1 < (unsigned long) s2) {
1643 struct semaphore *tmp = s2;
1644 s2 = s1; s1 = tmp;
1645 }
1646 down(s1);
1647 }
1648 down(s2);
1649}
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660static inline void triple_down(struct semaphore *s1,
1661 struct semaphore *s2,
1662 struct semaphore *s3)
1663{
1664 if (s1 != s2) {
1665 if ((unsigned long) s1 < (unsigned long) s2) {
1666 if ((unsigned long) s1 < (unsigned long) s3) {
1667 struct semaphore *tmp = s3;
1668 s3 = s1; s1 = tmp;
1669 }
1670 if ((unsigned long) s1 < (unsigned long) s2) {
1671 struct semaphore *tmp = s2;
1672 s2 = s1; s1 = tmp;
1673 }
1674 } else {
1675 if ((unsigned long) s1 < (unsigned long) s3) {
1676 struct semaphore *tmp = s3;
1677 s3 = s1; s1 = tmp;
1678 }
1679 if ((unsigned long) s2 < (unsigned long) s3) {
1680 struct semaphore *tmp = s3;
1681 s3 = s2; s2 = tmp;
1682 }
1683 }
1684 down(s1);
1685 } else if ((unsigned long) s2 < (unsigned long) s3) {
1686 struct semaphore *tmp = s3;
1687 s3 = s2; s2 = tmp;
1688 }
1689 down(s2);
1690 down(s3);
1691}
1692
1693static inline void double_up(struct semaphore *s1, struct semaphore *s2)
1694{
1695 up(s1);
1696 if (s1 != s2)
1697 up(s2);
1698}
1699
1700static inline void triple_up(struct semaphore *s1,
1701 struct semaphore *s2,
1702 struct semaphore *s3)
1703{
1704 up(s1);
1705 if (s1 != s2)
1706 up(s2);
1707 up(s3);
1708}
1709
1710static inline void double_lock(struct dentry *d1, struct dentry *d2)
1711{
1712 double_down(&d1->d_inode->i_sem, &d2->d_inode->i_sem);
1713}
1714
1715static inline void double_unlock(struct dentry *d1, struct dentry *d2)
1716{
1717 double_up(&d1->d_inode->i_sem,&d2->d_inode->i_sem);
1718 dput(d1);
1719 dput(d2);
1720}
1721
1722#endif
1723
1724#endif
1725