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#include <linux/radix-tree.h>
25#include <linux/bitops.h>
26
27#include <asm/atomic.h>
28
29struct poll_table_struct;
30struct nameidata;
31
32
33
34
35
36
37
38
39
40
41
42
43
44#undef NR_OPEN
45#define NR_OPEN (1024*1024)
46#define INR_OPEN 1024
47
48#define BLOCK_SIZE_BITS 10
49#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
50
51
52struct files_stat_struct {
53 int nr_files;
54 int nr_free_files;
55 int max_files;
56};
57extern struct files_stat_struct files_stat;
58
59struct inodes_stat_t {
60 int nr_inodes;
61 int nr_unused;
62 int dummy[5];
63};
64extern struct inodes_stat_t inodes_stat;
65
66extern int leases_enable, dir_notify_enable, lease_break_time;
67
68#define NR_FILE 8192
69#define NR_RESERVED_FILES 10
70#define NR_SUPER 256
71
72#define MAY_EXEC 1
73#define MAY_WRITE 2
74#define MAY_READ 4
75
76#define FMODE_READ 1
77#define FMODE_WRITE 2
78
79#define RW_MASK 1
80#define RWA_MASK 2
81#define READ 0
82#define WRITE 1
83#define READA 2
84#define SPECIAL 4
85
86#define SEL_IN 1
87#define SEL_OUT 2
88#define SEL_EX 4
89
90
91#define FS_REQUIRES_DEV 1
92#define FS_ODD_RENAME 32768
93
94
95
96
97
98#define MS_RDONLY 1
99#define MS_NOSUID 2
100#define MS_NODEV 4
101#define MS_NOEXEC 8
102#define MS_SYNCHRONOUS 16
103#define MS_REMOUNT 32
104#define MS_MANDLOCK 64
105#define MS_DIRSYNC 128
106#define MS_NOATIME 1024
107#define MS_NODIRATIME 2048
108#define MS_BIND 4096
109#define MS_MOVE 8192
110#define MS_REC 16384
111#define MS_VERBOSE 32768
112#define MS_ACTIVE (1<<30)
113#define MS_NOUSER (1<<31)
114
115
116
117
118#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
119 MS_NODIRATIME)
120
121
122
123
124#define MS_MGC_VAL 0xC0ED0000
125#define MS_MGC_MSK 0xffff0000
126
127
128
129#define S_SYNC 1
130#define S_NOATIME 2
131#define S_QUOTA 4
132#define S_APPEND 8
133#define S_IMMUTABLE 16
134#define S_DEAD 32
135#define S_NOQUOTA 64
136#define S_DIRSYNC 128
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151#define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
152
153#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
154#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
155 ((inode)->i_flags & S_SYNC))
156#define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
157 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
158#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
159
160#define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
161#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
162#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
163#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
164#define IS_NOATIME(inode) (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
165#define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
166
167#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
168
169
170
171
172#define BLKROSET _IO(0x12,93)
173#define BLKROGET _IO(0x12,94)
174#define BLKRRPART _IO(0x12,95)
175#define BLKGETSIZE _IO(0x12,96)
176#define BLKFLSBUF _IO(0x12,97)
177#define BLKRASET _IO(0x12,98)
178#define BLKRAGET _IO(0x12,99)
179#define BLKFRASET _IO(0x12,100)
180#define BLKFRAGET _IO(0x12,101)
181#define BLKSECTSET _IO(0x12,102)
182#define BLKSECTGET _IO(0x12,103)
183#define BLKSSZGET _IO(0x12,104)
184#if 0
185#define BLKPG _IO(0x12,105)
186#define BLKELVGET _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))
187#define BLKELVSET _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))
188
189
190#endif
191
192#define BLKBSZGET _IOR(0x12,112,sizeof(int))
193#define BLKBSZSET _IOW(0x12,113,sizeof(int))
194#define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64))
195
196#define BMAP_IOCTL 1
197#define FIBMAP _IO(0x00,1)
198#define FIGETBSZ _IO(0x00,2)
199
200#ifdef __KERNEL__
201
202#include <asm/semaphore.h>
203#include <asm/byteorder.h>
204
205extern void update_atime (struct inode *);
206#define UPDATE_ATIME(inode) update_atime (inode)
207
208extern void inode_init(unsigned long);
209extern void mnt_init(unsigned long);
210extern void files_init(unsigned long);
211
212struct buffer_head;
213typedef int (get_block_t)(struct inode*,sector_t,struct buffer_head*,int);
214
215#include <linux/pipe_fs_i.h>
216
217
218
219
220
221
222#define ATTR_MODE 1
223#define ATTR_UID 2
224#define ATTR_GID 4
225#define ATTR_SIZE 8
226#define ATTR_ATIME 16
227#define ATTR_MTIME 32
228#define ATTR_CTIME 64
229#define ATTR_ATIME_SET 128
230#define ATTR_MTIME_SET 256
231#define ATTR_FORCE 512
232#define ATTR_ATTR_FLAG 1024
233#define ATTR_KILL_SUID 2048
234#define ATTR_KILL_SGID 4096
235
236
237
238
239
240
241
242
243
244
245struct iattr {
246 unsigned int ia_valid;
247 umode_t ia_mode;
248 uid_t ia_uid;
249 gid_t ia_gid;
250 loff_t ia_size;
251 time_t ia_atime;
252 time_t ia_mtime;
253 time_t ia_ctime;
254 unsigned int ia_attr_flags;
255};
256
257
258
259
260#define ATTR_FLAG_SYNCRONOUS 1
261#define ATTR_FLAG_NOATIME 2
262#define ATTR_FLAG_APPEND 4
263#define ATTR_FLAG_IMMUTABLE 8
264#define ATTR_FLAG_NODIRATIME 16
265
266
267
268
269#include <linux/quota.h>
270#include <linux/mount.h>
271
272
273
274
275struct page;
276struct address_space;
277
278struct address_space_operations {
279 int (*writepage)(struct page *);
280 int (*readpage)(struct file *, struct page *);
281 int (*sync_page)(struct page *);
282
283
284 int (*writepages)(struct address_space *, int *nr_to_write);
285
286
287 int (*vm_writeback)(struct page *, int *nr_to_write);
288
289
290 int (*set_page_dirty)(struct page *page);
291
292 int (*readpages)(struct address_space *mapping,
293 struct list_head *pages, unsigned nr_pages);
294
295
296
297
298
299 int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
300 int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
301
302 int (*bmap)(struct address_space *, long);
303 int (*invalidatepage) (struct page *, unsigned long);
304 int (*releasepage) (struct page *, int);
305 int (*direct_IO)(int, struct inode *, char *buf,
306 loff_t offset, size_t count);
307};
308
309struct backing_dev_info;
310struct address_space {
311 struct inode *host;
312 struct radix_tree_root page_tree;
313 rwlock_t page_lock;
314 struct list_head clean_pages;
315 struct list_head dirty_pages;
316 struct list_head locked_pages;
317 struct list_head io_pages;
318 unsigned long nrpages;
319 struct address_space_operations *a_ops;
320 list_t i_mmap;
321 list_t i_mmap_shared;
322 spinlock_t i_shared_lock;
323 unsigned long dirtied_when;
324 int gfp_mask;
325 struct backing_dev_info *backing_dev_info;
326 spinlock_t private_lock;
327 struct list_head private_list;
328 struct address_space *assoc_mapping;
329};
330
331struct char_device {
332 struct list_head hash;
333 atomic_t count;
334 dev_t dev;
335 atomic_t openers;
336 struct semaphore sem;
337};
338
339struct block_device {
340 struct list_head bd_hash;
341 atomic_t bd_count;
342 struct inode * bd_inode;
343 dev_t bd_dev;
344 int bd_openers;
345 struct block_device_operations *bd_op;
346 struct request_queue *bd_queue;
347 struct semaphore bd_sem;
348 struct list_head bd_inodes;
349 void * bd_holder;
350 int bd_holders;
351 struct block_device * bd_contains;
352 unsigned bd_block_size;
353 unsigned long bd_offset;
354 struct semaphore bd_part_sem;
355 unsigned bd_part_count;
356};
357
358struct inode {
359 struct list_head i_hash;
360 struct list_head i_list;
361 struct list_head i_dentry;
362 unsigned long i_ino;
363 atomic_t i_count;
364 dev_t i_dev;
365 umode_t i_mode;
366 nlink_t i_nlink;
367 uid_t i_uid;
368 gid_t i_gid;
369 kdev_t i_rdev;
370 loff_t i_size;
371 time_t i_atime;
372 time_t i_mtime;
373 time_t i_ctime;
374 unsigned int i_blkbits;
375 unsigned long i_blksize;
376 unsigned long i_blocks;
377 unsigned long i_version;
378 unsigned short i_bytes;
379 struct semaphore i_sem;
380 struct inode_operations *i_op;
381 struct file_operations *i_fop;
382 struct super_block *i_sb;
383 struct file_lock *i_flock;
384 struct address_space *i_mapping;
385 struct address_space i_data;
386 struct dquot *i_dquot[MAXQUOTAS];
387
388 struct list_head i_devices;
389 struct pipe_inode_info *i_pipe;
390 struct block_device *i_bdev;
391 struct char_device *i_cdev;
392
393 unsigned long i_dnotify_mask;
394 struct dnotify_struct *i_dnotify;
395
396 unsigned long i_state;
397
398 unsigned int i_flags;
399 unsigned char i_sock;
400
401 atomic_t i_writecount;
402 __u32 i_generation;
403 union {
404 void *generic_ip;
405 } u;
406};
407
408struct socket_alloc {
409 struct socket socket;
410 struct inode vfs_inode;
411};
412
413static inline struct socket *SOCKET_I(struct inode *inode)
414{
415 return &container_of(inode, struct socket_alloc, vfs_inode)->socket;
416}
417
418static inline struct inode *SOCK_INODE(struct socket *socket)
419{
420 return &container_of(socket, struct socket_alloc, socket)->vfs_inode;
421}
422
423
424#include <linux/coda_fs_i.h>
425#include <linux/ext3_fs_i.h>
426#include <linux/efs_fs_i.h>
427
428struct fown_struct {
429 int pid;
430 uid_t uid, euid;
431 int signum;
432};
433
434static inline void inode_add_bytes(struct inode *inode, loff_t bytes)
435{
436 inode->i_blocks += bytes >> 9;
437 bytes &= 511;
438 inode->i_bytes += bytes;
439 if (inode->i_bytes >= 512) {
440 inode->i_blocks++;
441 inode->i_bytes -= 512;
442 }
443}
444
445static inline void inode_sub_bytes(struct inode *inode, loff_t bytes)
446{
447 inode->i_blocks -= bytes >> 9;
448 bytes &= 511;
449 if (inode->i_bytes < bytes) {
450 inode->i_blocks--;
451 inode->i_bytes += 512;
452 }
453 inode->i_bytes -= bytes;
454}
455
456static inline loff_t inode_get_bytes(struct inode *inode)
457{
458 return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
459}
460
461static inline void inode_set_bytes(struct inode *inode, loff_t bytes)
462{
463 inode->i_blocks = bytes >> 9;
464 inode->i_bytes = bytes & 511;
465}
466
467
468
469
470struct file_ra_state {
471 unsigned long start;
472 unsigned long size;
473 unsigned long next_size;
474 unsigned long prev_page;
475 unsigned long ahead_start;
476 unsigned long ahead_size;
477 unsigned long ra_pages;
478};
479
480struct file {
481 struct list_head f_list;
482 struct dentry *f_dentry;
483 struct vfsmount *f_vfsmnt;
484 struct file_operations *f_op;
485 atomic_t f_count;
486 unsigned int f_flags;
487 mode_t f_mode;
488 loff_t f_pos;
489 struct fown_struct f_owner;
490 unsigned int f_uid, f_gid;
491 int f_error;
492 struct file_ra_state f_ra;
493
494 unsigned long f_version;
495
496
497 void *private_data;
498};
499extern spinlock_t files_lock;
500#define file_list_lock() spin_lock(&files_lock);
501#define file_list_unlock() spin_unlock(&files_lock);
502
503#define get_file(x) atomic_inc(&(x)->f_count)
504#define file_count(x) atomic_read(&(x)->f_count)
505
506extern int init_private_file(struct file *, struct dentry *, int);
507
508#define MAX_NON_LFS ((1UL<<31) - 1)
509
510
511
512#if BITS_PER_LONG==32
513#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
514#elif BITS_PER_LONG==64
515#define MAX_LFS_FILESIZE 0x7fffffffffffffff
516#endif
517
518#define FL_POSIX 1
519#define FL_FLOCK 2
520#define FL_BROKEN 4
521#define FL_ACCESS 8
522#define FL_LOCKD 16
523#define FL_LEASE 32
524
525
526
527
528
529
530
531
532typedef struct files_struct *fl_owner_t;
533
534
535#include <linux/nfs_fs_i.h>
536
537struct file_lock {
538 struct file_lock *fl_next;
539 struct list_head fl_link;
540 struct list_head fl_block;
541 fl_owner_t fl_owner;
542 unsigned int fl_pid;
543 wait_queue_head_t fl_wait;
544 struct file *fl_file;
545 unsigned char fl_flags;
546 unsigned char fl_type;
547 loff_t fl_start;
548 loff_t fl_end;
549
550 void (*fl_notify)(struct file_lock *);
551 void (*fl_insert)(struct file_lock *);
552 void (*fl_remove)(struct file_lock *);
553
554 struct fasync_struct * fl_fasync;
555 unsigned long fl_break_time;
556
557 union {
558 struct nfs_lock_info nfs_fl;
559 } fl_u;
560};
561
562
563#ifndef OFFSET_MAX
564#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
565#define OFFSET_MAX INT_LIMIT(loff_t)
566#define OFFT_OFFSET_MAX INT_LIMIT(off_t)
567#endif
568
569extern struct list_head file_lock_list;
570
571#include <linux/fcntl.h>
572
573extern int fcntl_getlk(struct file *, struct flock *);
574extern int fcntl_setlk(struct file *, unsigned int, struct flock *);
575
576extern int fcntl_getlk64(struct file *, struct flock64 *);
577extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 *);
578
579
580extern void locks_init_lock(struct file_lock *);
581extern void locks_copy_lock(struct file_lock *, struct file_lock *);
582extern void locks_remove_posix(struct file *, fl_owner_t);
583extern void locks_remove_flock(struct file *);
584extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
585extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
586extern void posix_block_lock(struct file_lock *, struct file_lock *);
587extern void posix_unblock_lock(struct file_lock *);
588extern int posix_locks_deadlock(struct file_lock *, struct file_lock *);
589extern int __get_lease(struct inode *inode, unsigned int flags);
590extern time_t lease_get_mtime(struct inode *);
591extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
592extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
593
594struct fasync_struct {
595 int magic;
596 int fa_fd;
597 struct fasync_struct *fa_next;
598 struct file *fa_file;
599};
600
601#define FASYNC_MAGIC 0x4601
602
603
604extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
605
606extern void kill_fasync(struct fasync_struct **, int, int);
607
608extern void __kill_fasync(struct fasync_struct *, int, int);
609
610
611
612
613
614#define MNT_FORCE 0x00000001
615#define MNT_DETACH 0x00000002
616
617#include <linux/ext3_fs_sb.h>
618#include <linux/hpfs_fs_sb.h>
619#include <linux/ufs_fs_sb.h>
620#include <linux/romfs_fs_sb.h>
621
622extern struct list_head super_blocks;
623extern spinlock_t sb_lock;
624
625#define sb_entry(list) list_entry((list), struct super_block, s_list)
626#define S_BIAS (1<<30)
627struct super_block {
628 struct list_head s_list;
629 dev_t s_dev;
630 unsigned long s_blocksize;
631 unsigned long s_old_blocksize;
632 unsigned char s_blocksize_bits;
633 unsigned char s_dirt;
634 unsigned long long s_maxbytes;
635 struct file_system_type *s_type;
636 struct super_operations *s_op;
637 struct dquot_operations *dq_op;
638 struct quotactl_ops *s_qcop;
639 struct export_operations *s_export_op;
640 unsigned long s_flags;
641 unsigned long s_magic;
642 struct dentry *s_root;
643 struct rw_semaphore s_umount;
644 struct semaphore s_lock;
645 int s_count;
646 int s_syncing;
647 atomic_t s_active;
648
649 struct list_head s_dirty;
650 struct list_head s_io;
651 struct list_head s_locked_inodes;
652 struct list_head s_anon;
653 struct list_head s_files;
654
655 struct block_device *s_bdev;
656 struct list_head s_instances;
657 struct quota_info s_dquot;
658
659 char s_id[32];
660
661 union {
662 struct ext3_sb_info ext3_sb;
663 struct hpfs_sb_info hpfs_sb;
664 struct ufs_sb_info ufs_sb;
665 struct romfs_sb_info romfs_sb;
666 void *generic_sbp;
667 } u;
668
669
670
671
672 struct semaphore s_vfs_rename_sem;
673};
674
675
676
677
678static inline void lock_super(struct super_block * sb)
679{
680 down(&sb->s_lock);
681}
682
683static inline void unlock_super(struct super_block * sb)
684{
685 up(&sb->s_lock);
686}
687
688
689
690
691extern int vfs_create(struct inode *, struct dentry *, int);
692extern int vfs_mkdir(struct inode *, struct dentry *, int);
693extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
694extern int vfs_symlink(struct inode *, struct dentry *, const char *);
695extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
696extern int vfs_rmdir(struct inode *, struct dentry *);
697extern int vfs_unlink(struct inode *, struct dentry *);
698extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
699
700
701
702
703
704
705
706#define DT_UNKNOWN 0
707#define DT_FIFO 1
708#define DT_CHR 2
709#define DT_DIR 4
710#define DT_BLK 6
711#define DT_REG 8
712#define DT_LNK 10
713#define DT_SOCK 12
714#define DT_WHT 14
715
716
717
718
719
720
721
722typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
723
724struct block_device_operations {
725 int (*open) (struct inode *, struct file *);
726 int (*release) (struct inode *, struct file *);
727 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
728 int (*check_media_change) (kdev_t);
729 int (*revalidate) (kdev_t);
730 struct module *owner;
731};
732
733
734
735
736
737
738struct file_operations {
739 struct module *owner;
740 loff_t (*llseek) (struct file *, loff_t, int);
741 ssize_t (*read) (struct file *, char *, size_t, loff_t *);
742 ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
743 int (*readdir) (struct file *, void *, filldir_t);
744 unsigned int (*poll) (struct file *, struct poll_table_struct *);
745 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
746 int (*mmap) (struct file *, struct vm_area_struct *);
747 int (*open) (struct inode *, struct file *);
748 int (*flush) (struct file *);
749 int (*release) (struct inode *, struct file *);
750 int (*fsync) (struct file *, struct dentry *, int datasync);
751 int (*fasync) (int, struct file *, int);
752 int (*lock) (struct file *, int, struct file_lock *);
753 ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
754 ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
755 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
756 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
757};
758
759struct inode_operations {
760 int (*create) (struct inode *,struct dentry *,int);
761 struct dentry * (*lookup) (struct inode *,struct dentry *);
762 int (*link) (struct dentry *,struct inode *,struct dentry *);
763 int (*unlink) (struct inode *,struct dentry *);
764 int (*symlink) (struct inode *,struct dentry *,const char *);
765 int (*mkdir) (struct inode *,struct dentry *,int);
766 int (*rmdir) (struct inode *,struct dentry *);
767 int (*mknod) (struct inode *,struct dentry *,int,int);
768 int (*rename) (struct inode *, struct dentry *,
769 struct inode *, struct dentry *);
770 int (*readlink) (struct dentry *, char *,int);
771 int (*follow_link) (struct dentry *, struct nameidata *);
772 void (*truncate) (struct inode *);
773 int (*permission) (struct inode *, int);
774 int (*setattr) (struct dentry *, struct iattr *);
775 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
776 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
777 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
778 ssize_t (*listxattr) (struct dentry *, char *, size_t);
779 int (*removexattr) (struct dentry *, const char *);
780};
781
782struct seq_file;
783
784extern ssize_t vfs_read(struct file *, char *, size_t, loff_t *);
785extern ssize_t vfs_write(struct file *, const char *, size_t, loff_t *);
786
787
788
789
790
791struct super_operations {
792 struct inode *(*alloc_inode)(struct super_block *sb);
793 void (*destroy_inode)(struct inode *);
794
795 void (*read_inode) (struct inode *);
796
797 void (*dirty_inode) (struct inode *);
798 void (*write_inode) (struct inode *, int);
799 void (*put_inode) (struct inode *);
800 void (*drop_inode) (struct inode *);
801 void (*delete_inode) (struct inode *);
802 void (*put_super) (struct super_block *);
803 void (*write_super) (struct super_block *);
804 void (*write_super_lockfs) (struct super_block *);
805 void (*unlockfs) (struct super_block *);
806 int (*statfs) (struct super_block *, struct statfs *);
807 int (*remount_fs) (struct super_block *, int *, char *);
808 void (*clear_inode) (struct inode *);
809 void (*umount_begin) (struct super_block *);
810
811 int (*show_options)(struct seq_file *, struct vfsmount *);
812};
813
814
815#define I_DIRTY_SYNC 1
816#define I_DIRTY_DATASYNC 2
817#define I_DIRTY_PAGES 4
818#define I_LOCK 8
819#define I_FREEING 16
820#define I_CLEAR 32
821#define I_NEW 64
822
823#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
824
825extern void __mark_inode_dirty(struct inode *, int);
826static inline void mark_inode_dirty(struct inode *inode)
827{
828 __mark_inode_dirty(inode, I_DIRTY);
829}
830
831static inline void mark_inode_dirty_sync(struct inode *inode)
832{
833 __mark_inode_dirty(inode, I_DIRTY_SYNC);
834}
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917struct export_operations {
918 struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
919 int (*acceptable)(void *context, struct dentry *de),
920 void *context);
921 int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
922 int connectable);
923
924
925 int (*get_name)(struct dentry *parent, char *name,
926 struct dentry *child);
927 struct dentry * (*get_parent)(struct dentry *child);
928 struct dentry * (*get_dentry)(struct super_block *sb, void *inump);
929
930
931 struct dentry * (*find_exported_dentry)(
932 struct super_block *sb, void *obj, void *parent,
933 int (*acceptable)(void *context, struct dentry *de),
934 void *context);
935
936
937};
938
939
940struct file_system_type {
941 const char *name;
942 int fs_flags;
943 struct super_block *(*get_sb) (struct file_system_type *, int, char *, void *);
944 void (*kill_sb) (struct super_block *);
945 struct module *owner;
946 struct file_system_type * next;
947 struct list_head fs_supers;
948};
949
950struct super_block *get_sb_bdev(struct file_system_type *fs_type,
951 int flags, char *dev_name, void * data,
952 int (*fill_super)(struct super_block *, void *, int));
953struct super_block *get_sb_single(struct file_system_type *fs_type,
954 int flags, void *data,
955 int (*fill_super)(struct super_block *, void *, int));
956struct super_block *get_sb_nodev(struct file_system_type *fs_type,
957 int flags, void *data,
958 int (*fill_super)(struct super_block *, void *, int));
959void generic_shutdown_super(struct super_block *sb);
960void kill_block_super(struct super_block *sb);
961void kill_anon_super(struct super_block *sb);
962void kill_litter_super(struct super_block *sb);
963void deactivate_super(struct super_block *sb);
964int set_anon_super(struct super_block *s, void *data);
965struct super_block *sget(struct file_system_type *type,
966 int (*test)(struct super_block *,void *),
967 int (*set)(struct super_block *,void *),
968 void *data);
969struct super_block *get_sb_pseudo(struct file_system_type *, char *,
970 struct super_operations *ops, unsigned long);
971
972
973#define fops_get(fops) \
974 (((fops) && (fops)->owner) \
975 ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
976 : (fops))
977
978#define fops_put(fops) \
979do { \
980 if ((fops) && (fops)->owner) \
981 __MOD_DEC_USE_COUNT((fops)->owner); \
982} while(0)
983
984extern int register_filesystem(struct file_system_type *);
985extern int unregister_filesystem(struct file_system_type *);
986extern struct vfsmount *kern_mount(struct file_system_type *);
987extern int may_umount(struct vfsmount *);
988extern long do_mount(char *, char *, char *, unsigned long, void *);
989
990#define kern_umount mntput
991
992extern int vfs_statfs(struct super_block *, struct statfs *);
993
994
995
996
997#define LOCK_USE_CLNT 1
998
999#define FLOCK_VERIFY_READ 1
1000#define FLOCK_VERIFY_WRITE 2
1001
1002extern int locks_mandatory_locked(struct inode *);
1003extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
1004
1005
1006
1007
1008
1009#define MANDATORY_LOCK(inode) \
1010 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
1011
1012static inline int locks_verify_locked(struct inode *inode)
1013{
1014 if (MANDATORY_LOCK(inode))
1015 return locks_mandatory_locked(inode);
1016 return 0;
1017}
1018
1019static inline int locks_verify_area(int read_write, struct inode *inode,
1020 struct file *filp, loff_t offset,
1021 size_t count)
1022{
1023 if (inode->i_flock && MANDATORY_LOCK(inode))
1024 return locks_mandatory_area(read_write, inode, filp, offset, count);
1025 return 0;
1026}
1027
1028static inline int locks_verify_truncate(struct inode *inode,
1029 struct file *filp,
1030 loff_t size)
1031{
1032 if (inode->i_flock && MANDATORY_LOCK(inode))
1033 return locks_mandatory_area(
1034 FLOCK_VERIFY_WRITE, inode, filp,
1035 size < inode->i_size ? size : inode->i_size,
1036 (size < inode->i_size ? inode->i_size - size
1037 : size - inode->i_size)
1038 );
1039 return 0;
1040}
1041
1042static inline int get_lease(struct inode *inode, unsigned int mode)
1043{
1044 if (inode->i_flock && (inode->i_flock->fl_flags & FL_LEASE))
1045 return __get_lease(inode, mode);
1046 return 0;
1047}
1048
1049
1050
1051asmlinkage long sys_open(const char *, int, int);
1052asmlinkage long sys_close(unsigned int);
1053extern int do_truncate(struct dentry *, loff_t start);
1054
1055extern struct file *filp_open(const char *, int, int);
1056extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1057extern int filp_close(struct file *, fl_owner_t id);
1058extern char * getname(const char *);
1059
1060
1061extern void vfs_caches_init(unsigned long);
1062
1063#define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL)
1064#define putname(name) kmem_cache_free(names_cachep, (void *)(name))
1065
1066enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW};
1067extern int register_blkdev(unsigned int, const char *, struct block_device_operations *);
1068extern int unregister_blkdev(unsigned int, const char *);
1069extern struct block_device *bdget(dev_t);
1070extern int bd_acquire(struct inode *inode);
1071extern void bd_forget(struct inode *inode);
1072extern void bdput(struct block_device *);
1073extern struct char_device *cdget(dev_t);
1074extern void cdput(struct char_device *);
1075extern int blkdev_open(struct inode *, struct file *);
1076extern int blkdev_close(struct inode *, struct file *);
1077extern struct file_operations def_blk_fops;
1078extern struct address_space_operations def_blk_aops;
1079extern struct file_operations def_fifo_fops;
1080extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1081extern int blkdev_get(struct block_device *, mode_t, unsigned, int);
1082extern int blkdev_put(struct block_device *, int);
1083extern int bd_claim(struct block_device *, void *);
1084extern void bd_release(struct block_device *);
1085extern void blk_run_queues(void);
1086
1087
1088extern struct block_device_operations *get_blkfops(unsigned int);
1089extern int register_chrdev(unsigned int, const char *, struct file_operations *);
1090extern int unregister_chrdev(unsigned int, const char *);
1091extern int chrdev_open(struct inode *, struct file *);
1092extern const char *__bdevname(kdev_t);
1093extern inline const char *bdevname(struct block_device *bdev)
1094{
1095 return __bdevname(to_kdev_t(bdev->bd_dev));
1096}
1097extern const char * cdevname(kdev_t);
1098extern const char * kdevname(kdev_t);
1099extern void init_special_inode(struct inode *, umode_t, int);
1100
1101
1102extern void make_bad_inode(struct inode *);
1103extern int is_bad_inode(struct inode *);
1104
1105extern struct file_operations read_fifo_fops;
1106extern struct file_operations write_fifo_fops;
1107extern struct file_operations rdwr_fifo_fops;
1108extern struct file_operations read_pipe_fops;
1109extern struct file_operations write_pipe_fops;
1110extern struct file_operations rdwr_pipe_fops;
1111
1112extern int fs_may_remount_ro(struct super_block *);
1113
1114
1115
1116
1117#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK))
1118
1119
1120
1121
1122#define bio_data_dir(bio) ((bio)->bi_rw & 1)
1123
1124extern int check_disk_change(kdev_t);
1125extern int invalidate_inodes(struct super_block *);
1126extern int invalidate_device(kdev_t, int);
1127extern void invalidate_inode_pages(struct inode *);
1128extern void invalidate_inode_pages2(struct address_space *mapping);
1129extern void write_inode_now(struct inode *, int);
1130extern int filemap_fdatawrite(struct address_space *);
1131extern int filemap_fdatawait(struct address_space *);
1132extern void sync_supers(void);
1133extern int bmap(struct inode *, int);
1134extern int notify_change(struct dentry *, struct iattr *);
1135extern int permission(struct inode *, int);
1136extern int vfs_permission(struct inode *, int);
1137extern int get_write_access(struct inode *);
1138extern int deny_write_access(struct file *);
1139static inline void put_write_access(struct inode * inode)
1140{
1141 atomic_dec(&inode->i_writecount);
1142}
1143static inline void allow_write_access(struct file *file)
1144{
1145 if (file)
1146 atomic_inc(&file->f_dentry->d_inode->i_writecount);
1147}
1148extern int do_pipe(int *);
1149
1150extern int open_namei(const char *, int, int, struct nameidata *);
1151extern int may_open(struct nameidata *, int, int);
1152
1153extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
1154extern struct file * open_exec(const char *);
1155
1156
1157extern int is_subdir(struct dentry *, struct dentry *);
1158extern ino_t find_inode_number(struct dentry *, struct qstr *);
1159
1160#include <linux/err.h>
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171typedef struct {
1172 size_t written;
1173 size_t count;
1174 char * buf;
1175 int error;
1176} read_descriptor_t;
1177
1178typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
1179
1180
1181extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1182
1183extern void inode_init_once(struct inode *);
1184extern void iput(struct inode *);
1185extern struct inode * igrab(struct inode *);
1186extern ino_t iunique(struct super_block *, ino_t);
1187extern int inode_needs_sync(struct inode *inode);
1188extern void generic_delete_inode(struct inode *inode);
1189
1190extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
1191extern struct inode * iget_locked(struct super_block *, unsigned long);
1192extern void unlock_new_inode(struct inode *);
1193
1194static inline struct inode *iget(struct super_block *sb, unsigned long ino)
1195{
1196 struct inode *inode = iget_locked(sb, ino);
1197
1198 if (inode && (inode->i_state & I_NEW)) {
1199 sb->s_op->read_inode(inode);
1200 unlock_new_inode(inode);
1201 }
1202
1203 return inode;
1204}
1205
1206extern void __iget(struct inode * inode);
1207extern void clear_inode(struct inode *);
1208extern struct inode *new_inode(struct super_block *);
1209extern void remove_suid(struct dentry *);
1210
1211extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1212extern void remove_inode_hash(struct inode *);
1213static inline void insert_inode_hash(struct inode *inode) {
1214 __insert_inode_hash(inode, inode->i_ino);
1215}
1216
1217extern struct file * get_empty_filp(void);
1218extern void file_move(struct file *f, struct list_head *list);
1219extern void ll_rw_block(int, int, struct buffer_head * bh[]);
1220extern int submit_bh(int, struct buffer_head *);
1221struct bio;
1222extern int submit_bio(int, struct bio *);
1223extern int bdev_read_only(struct block_device *);
1224extern int set_blocksize(struct block_device *, int);
1225extern int sb_set_blocksize(struct super_block *, int);
1226extern int sb_min_blocksize(struct super_block *, int);
1227
1228extern int generic_file_mmap(struct file *, struct vm_area_struct *);
1229extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
1230extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
1231extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *);
1232extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, read_actor_t);
1233ssize_t generic_file_direct_IO(int rw, struct inode *inode, char *buf,
1234 loff_t offset, size_t count);
1235int generic_direct_IO(int rw, struct inode *inode, char *buf,
1236 loff_t offset, size_t count, get_block_t *get_block);
1237
1238extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
1239extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
1240extern loff_t remote_llseek(struct file *file, loff_t offset, int origin);
1241extern int generic_file_open(struct inode * inode, struct file * filp);
1242
1243extern int generic_vm_writeback(struct page *page, int *nr_to_write);
1244
1245extern struct file_operations generic_ro_fops;
1246
1247extern int vfs_readlink(struct dentry *, char *, int, const char *);
1248extern int vfs_follow_link(struct nameidata *, const char *);
1249extern int page_readlink(struct dentry *, char *, int);
1250extern int page_follow_link(struct dentry *, struct nameidata *);
1251extern int page_symlink(struct inode *inode, const char *symname, int len);
1252extern struct inode_operations page_symlink_inode_operations;
1253extern void generic_fillattr(struct inode *, struct kstat *);
1254extern int vfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
1255
1256extern int vfs_readdir(struct file *, filldir_t, void *);
1257
1258extern int vfs_stat(char *, struct kstat *);
1259extern int vfs_lstat(char *, struct kstat *);
1260extern int vfs_fstat(unsigned int, struct kstat *);
1261
1262extern struct file_system_type *get_fs_type(const char *name);
1263extern struct super_block *get_super(struct block_device *);
1264extern struct super_block *user_get_super(dev_t);
1265extern void drop_super(struct super_block *sb);
1266
1267extern int dcache_dir_open(struct inode *, struct file *);
1268extern int dcache_dir_close(struct inode *, struct file *);
1269extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
1270extern int dcache_readdir(struct file *, void *, filldir_t);
1271extern int simple_statfs(struct super_block *, struct statfs *);
1272extern struct dentry *simple_lookup(struct inode *, struct dentry *);
1273extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
1274extern struct file_operations simple_dir_operations;
1275extern struct inode_operations simple_dir_inode_operations;
1276
1277#ifdef CONFIG_BLK_DEV_INITRD
1278extern unsigned int real_root_dev;
1279#endif
1280
1281extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
1282extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
1283extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
1284extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
1285
1286extern int inode_change_ok(struct inode *, struct iattr *);
1287extern int inode_setattr(struct inode *, struct iattr *);
1288
1289static inline ino_t parent_ino(struct dentry *dentry)
1290{
1291 ino_t res;
1292 read_lock(&dparent_lock);
1293 res = dentry->d_parent->d_inode->i_ino;
1294 read_unlock(&dparent_lock);
1295 return res;
1296}
1297
1298
1299
1300static inline int dev_lock_part(kdev_t dev)
1301{
1302 struct block_device *bdev = bdget(kdev_t_to_nr(dev));
1303 if (!bdev)
1304 return -ENOMEM;
1305 if (!down_trylock(&bdev->bd_part_sem)) {
1306 if (!bdev->bd_part_count)
1307 return 0;
1308 up(&bdev->bd_part_sem);
1309 }
1310 bdput(bdev);
1311 return -EBUSY;
1312}
1313
1314static inline void dev_unlock_part(kdev_t dev)
1315{
1316 struct block_device *bdev = bdget(kdev_t_to_nr(dev));
1317 if (!bdev)
1318 BUG();
1319 up(&bdev->bd_part_sem);
1320 bdput(bdev);
1321 bdput(bdev);
1322}
1323
1324#endif
1325#endif
1326