This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / include / linux / fs.h
1 #ifndef _LINUX_FS_H
2 #define _LINUX_FS_H
3
4 /*
5  * This file has definitions for some important file table
6  * structures etc.
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/kdev_t.h>
15 #include <linux/ioctl.h>
16 #include <linux/dcache.h>
17 #include <linux/stat.h>
18 #include <linux/cache.h>
19 #include <linux/prio_tree.h>
20 #include <linux/kobject.h>
21 #include <linux/mount.h>
22 #include <asm/atomic.h>
23
24 struct iovec;
25 struct nameidata;
26 struct pipe_inode_info;
27 struct poll_table_struct;
28 struct kstatfs;
29 struct vm_area_struct;
30 struct vfsmount;
31
32 /*
33  * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
34  * the file limit at runtime and only root can increase the per-process
35  * nr_file rlimit, so it's safe to set up a ridiculously high absolute
36  * upper limit on files-per-process.
37  *
38  * Some programs (notably those using select()) may have to be 
39  * recompiled to take full advantage of the new limits..  
40  */
41
42 /* Fixed constants first: */
43 #undef NR_OPEN
44 #define NR_OPEN (1024*1024)     /* Absolute upper limit on fd num */
45 #define INR_OPEN 4096           /* Initial setting for nfile rlimits */
46
47 #define BLOCK_SIZE_BITS 10
48 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
49
50 /* And dynamically-tunable limits and defaults: */
51 struct files_stat_struct {
52         int nr_files;           /* read only */
53         int nr_free_files;      /* read only */
54         int max_files;          /* tunable */
55 };
56 extern struct files_stat_struct files_stat;
57
58 struct inodes_stat_t {
59         int nr_inodes;
60         int nr_unused;
61         int dummy[5];
62 };
63 extern struct inodes_stat_t inodes_stat;
64
65 extern int leases_enable, dir_notify_enable, lease_break_time;
66
67 #define NR_FILE  8192   /* this can well be larger on a larger system */
68 #define NR_RESERVED_FILES 10 /* reserved for root */
69 #define NR_SUPER 256
70
71 #define MAY_EXEC 1
72 #define MAY_WRITE 2
73 #define MAY_READ 4
74 #define MAY_APPEND 8
75
76 #define FMODE_READ 1
77 #define FMODE_WRITE 2
78
79 /* Internal kernel extensions */
80 #define FMODE_LSEEK     4
81 #define FMODE_PREAD     8
82 #define FMODE_PWRITE    FMODE_PREAD     /* These go hand in hand */
83
84 #define RW_MASK         1
85 #define RWA_MASK        2
86 #define READ 0
87 #define WRITE 1
88 #define READA 2         /* read-ahead  - don't block if no resources */
89 #define SPECIAL 4       /* For non-blockdevice requests in request queue */
90 #define READ_SYNC       (READ | (1 << BIO_RW_SYNC))
91 #define WRITE_SYNC      (WRITE | (1 << BIO_RW_SYNC))
92 #define WRITE_BARRIER   ((1 << BIO_RW) | (1 << BIO_RW_BARRIER))
93
94 #define SEL_IN          1
95 #define SEL_OUT         2
96 #define SEL_EX          4
97
98 /* public flags for file_system_type */
99 #define FS_REQUIRES_DEV 1 
100 #define FS_BINARY_MOUNTDATA 2
101 #define FS_REVAL_DOT    16384   /* Check the paths ".", ".." for staleness */
102 #define FS_ODD_RENAME   32768   /* Temporary stuff; will go away as soon
103                                   * as nfs_rename() will be cleaned up
104                                   */
105 /*
106  * These are the fs-independent mount-flags: up to 32 flags are supported
107  */
108 #define MS_RDONLY        1      /* Mount read-only */
109 #define MS_NOSUID        2      /* Ignore suid and sgid bits */
110 #define MS_NODEV         4      /* Disallow access to device special files */
111 #define MS_NOEXEC        8      /* Disallow program execution */
112 #define MS_SYNCHRONOUS  16      /* Writes are synced at once */
113 #define MS_REMOUNT      32      /* Alter flags of a mounted FS */
114 #define MS_MANDLOCK     64      /* Allow mandatory locks on an FS */
115 #define MS_DIRSYNC      128     /* Directory modifications are synchronous */
116 #define MS_NOATIME      1024    /* Do not update access times. */
117 #define MS_NODIRATIME   2048    /* Do not update directory access times */
118 #define MS_BIND         4096
119 #define MS_MOVE         8192
120 #define MS_REC          16384
121 #define MS_VERBOSE      32768
122 #define MS_POSIXACL     (1<<16) /* VFS does not apply the umask */
123 #define MS_ONE_SECOND   (1<<17) /* fs has 1 sec a/m/ctime resolution */
124 #define MS_TAGXID       (1<<24) /* tag inodes with context information */
125 #define MS_ACTIVE       (1<<30)
126 #define MS_NOUSER       (1<<31)
127
128 /*
129  * Superblock flags that can be altered by MS_REMOUNT
130  */
131 #define MS_RMT_MASK     (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
132                          MS_NODIRATIME)
133
134 /*
135  * Old magic mount flag and mask
136  */
137 #define MS_MGC_VAL 0xC0ED0000
138 #define MS_MGC_MSK 0xffff0000
139
140 /* Inode flags - they have nothing to superblock flags now */
141
142 #define S_SYNC          1       /* Writes are synced at once */
143 #define S_NOATIME       2       /* Do not update access times */
144 #define S_APPEND        4       /* Append-only file */
145 #define S_IMMUTABLE     8       /* Immutable file */
146 #define S_DEAD          16      /* removed, but still open directory */
147 #define S_NOQUOTA       32      /* Inode is not counted to quota */
148 #define S_DIRSYNC       64      /* Directory modifications are synchronous */
149 #define S_NOCMTIME      128     /* Do not update file c/mtime */
150 #define S_SWAPFILE      256     /* Do not truncate: swapon got its bmaps */
151 #define S_BARRIER       512     /* Barrier for chroot() */
152 #define S_IUNLINK       1024    /* Immutable unlink */
153
154 /*
155  * Note that nosuid etc flags are inode-specific: setting some file-system
156  * flags just means all the inodes inherit those flags by default. It might be
157  * possible to override it selectively if you really wanted to with some
158  * ioctl() that is not currently implemented.
159  *
160  * Exception: MS_RDONLY is always applied to the entire file system.
161  *
162  * Unfortunately, it is possible to change a filesystems flags with it mounted
163  * with files in use.  This means that all of the inodes will not have their
164  * i_flags updated.  Hence, i_flags no longer inherit the superblock mount
165  * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
166  */
167 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
168
169 #define IS_RDONLY(inode)        __IS_FLG(inode, MS_RDONLY)
170 #define IS_SYNC(inode)          (__IS_FLG(inode, MS_SYNCHRONOUS) || \
171                                         ((inode)->i_flags & S_SYNC))
172 #define IS_DIRSYNC(inode)       (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
173                                         ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
174 #define IS_MANDLOCK(inode)      __IS_FLG(inode, MS_MANDLOCK)
175
176 #define IS_NOQUOTA(inode)       ((inode)->i_flags & S_NOQUOTA)
177 #define IS_APPEND(inode)        ((inode)->i_flags & S_APPEND)
178 #define IS_IMMUTABLE(inode)     ((inode)->i_flags & S_IMMUTABLE)
179 #define IS_IUNLINK(inode)       ((inode)->i_flags & S_IUNLINK)
180 #define IS_IXORUNLINK(inode)    ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
181 #define IS_NOATIME(inode)       (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
182 #define IS_NODIRATIME(inode)    __IS_FLG(inode, MS_NODIRATIME)
183 #define IS_POSIXACL(inode)      __IS_FLG(inode, MS_POSIXACL)
184 #define IS_ONE_SECOND(inode)    __IS_FLG(inode, MS_ONE_SECOND)
185
186 #define IS_BARRIER(inode)       (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
187 #define IS_DEADDIR(inode)       ((inode)->i_flags & S_DEAD)
188 #define IS_NOCMTIME(inode)      ((inode)->i_flags & S_NOCMTIME)
189 #define IS_SWAPFILE(inode)      ((inode)->i_flags & S_SWAPFILE)
190
191 /* the read-only stuff doesn't really belong here, but any other place is
192    probably as bad and I don't want to create yet another include file. */
193
194 #define BLKROSET   _IO(0x12,93) /* set device read-only (0 = read-write) */
195 #define BLKROGET   _IO(0x12,94) /* get read-only status (0 = read_write) */
196 #define BLKRRPART  _IO(0x12,95) /* re-read partition table */
197 #define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
198 #define BLKFLSBUF  _IO(0x12,97) /* flush buffer cache */
199 #define BLKRASET   _IO(0x12,98) /* set read ahead for block device */
200 #define BLKRAGET   _IO(0x12,99) /* get current read ahead setting */
201 #define BLKFRASET  _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
202 #define BLKFRAGET  _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
203 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
204 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
205 #define BLKSSZGET  _IO(0x12,104)/* get block device sector size */
206 #if 0
207 #define BLKPG      _IO(0x12,105)/* See blkpg.h */
208
209 /* Some people are morons.  Do not use sizeof! */
210
211 #define BLKELVGET  _IOR(0x12,106,size_t)/* elevator get */
212 #define BLKELVSET  _IOW(0x12,107,size_t)/* elevator set */
213 /* This was here just to show that the number is taken -
214    probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
215 #endif
216 /* A jump here: 108-111 have been used for various private purposes. */
217 #define BLKBSZGET  _IOR(0x12,112,size_t)
218 #define BLKBSZSET  _IOW(0x12,113,size_t)
219 #define BLKGETSIZE64 _IOR(0x12,114,size_t)      /* return device size in bytes (u64 *arg) */
220
221 #define BMAP_IOCTL 1            /* obsolete - kept for compatibility */
222 #define FIBMAP     _IO(0x00,1)  /* bmap access */
223 #define FIGETBSZ   _IO(0x00,2)  /* get the block size used for bmap */
224
225 #ifdef __KERNEL__
226
227 #include <linux/list.h>
228 #include <linux/radix-tree.h>
229 #include <linux/audit.h>
230 #include <linux/init.h>
231 #include <asm/semaphore.h>
232 #include <asm/byteorder.h>
233
234 /* Used to be a macro which just called the function, now just a function */
235 extern void update_atime (struct inode *);
236
237 extern void __init inode_init(unsigned long);
238 extern void __init inode_init_early(void);
239 extern void __init mnt_init(unsigned long);
240 extern void __init files_init(unsigned long);
241
242 struct buffer_head;
243 typedef int (get_block_t)(struct inode *inode, sector_t iblock,
244                         struct buffer_head *bh_result, int create);
245 typedef int (get_blocks_t)(struct inode *inode, sector_t iblock,
246                         unsigned long max_blocks,
247                         struct buffer_head *bh_result, int create);
248 typedef void (dio_iodone_t)(struct inode *inode, loff_t offset,
249                         ssize_t bytes, void *private);
250
251 /*
252  * Attribute flags.  These should be or-ed together to figure out what
253  * has been changed!
254  */
255 #define ATTR_MODE       1
256 #define ATTR_UID        2
257 #define ATTR_GID        4
258 #define ATTR_SIZE       8
259 #define ATTR_ATIME      16
260 #define ATTR_MTIME      32
261 #define ATTR_CTIME      64
262 #define ATTR_ATIME_SET  128
263 #define ATTR_MTIME_SET  256
264 #define ATTR_FORCE      512     /* Not a change, but a change it */
265 #define ATTR_ATTR_FLAG  1024
266 #define ATTR_KILL_SUID  2048
267 #define ATTR_KILL_SGID  4096
268 #define ATTR_XID        8192
269
270 /*
271  * This is the Inode Attributes structure, used for notify_change().  It
272  * uses the above definitions as flags, to know which values have changed.
273  * Also, in this manner, a Filesystem can look at only the values it cares
274  * about.  Basically, these are the attributes that the VFS layer can
275  * request to change from the FS layer.
276  *
277  * Derek Atkins <warlord@MIT.EDU> 94-10-20
278  */
279 struct iattr {
280         unsigned int    ia_valid;
281         umode_t         ia_mode;
282         uid_t           ia_uid;
283         gid_t           ia_gid;
284         xid_t           ia_xid;
285         loff_t          ia_size;
286         struct timespec ia_atime;
287         struct timespec ia_mtime;
288         struct timespec ia_ctime;
289         unsigned int    ia_attr_flags;
290 };
291
292 /*
293  * This is the inode attributes flag definitions
294  */
295 #define ATTR_FLAG_SYNCRONOUS    1       /* Syncronous write */
296 #define ATTR_FLAG_NOATIME       2       /* Don't update atime */
297 #define ATTR_FLAG_APPEND        4       /* Append-only file */
298 #define ATTR_FLAG_IMMUTABLE     8       /* Immutable file */
299 #define ATTR_FLAG_NODIRATIME    16      /* Don't update atime for directory */
300
301 #define ATTR_FLAG_BARRIER       512     /* Barrier for chroot() */
302 #define ATTR_FLAG_IUNLINK       1024    /* Immutable unlink */
303
304 /*
305  * Includes for diskquotas.
306  */
307 #include <linux/quota.h>
308
309 /*
310  * oh the beauties of C type declarations.
311  */
312 struct page;
313 struct address_space;
314 struct writeback_control;
315 struct kiocb;
316
317 struct address_space_operations {
318         int (*writepage)(struct page *page, struct writeback_control *wbc);
319         int (*readpage)(struct file *, struct page *);
320         int (*sync_page)(struct page *);
321
322         /* Write back some dirty pages from this mapping. */
323         int (*writepages)(struct address_space *, struct writeback_control *);
324
325         /* Set a page dirty */
326         int (*set_page_dirty)(struct page *page);
327
328         int (*readpages)(struct file *filp, struct address_space *mapping,
329                         struct list_head *pages, unsigned nr_pages);
330
331         /*
332          * ext3 requires that a successful prepare_write() call be followed
333          * by a commit_write() call - they must be balanced
334          */
335         int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
336         int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
337         /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
338         sector_t (*bmap)(struct address_space *, sector_t);
339         int (*invalidatepage) (struct page *, unsigned long);
340         int (*releasepage) (struct page *, int);
341         ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
342                         loff_t offset, unsigned long nr_segs);
343 };
344
345 struct backing_dev_info;
346 struct address_space {
347         struct inode            *host;          /* owner: inode, block_device */
348         struct radix_tree_root  page_tree;      /* radix tree of all pages */
349         spinlock_t              tree_lock;      /* and spinlock protecting it */
350         unsigned int            i_mmap_writable;/* count VM_SHARED mappings */
351         struct prio_tree_root   i_mmap;         /* tree of private and shared mappings */
352         struct list_head        i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
353         spinlock_t              i_mmap_lock;    /* protect tree, count, list */
354         atomic_t                truncate_count; /* Cover race condition with truncate */
355         unsigned long           nrpages;        /* number of total pages */
356         pgoff_t                 writeback_index;/* writeback starts here */
357         struct address_space_operations *a_ops; /* methods */
358         unsigned long           flags;          /* error bits/gfp mask */
359         struct backing_dev_info *backing_dev_info; /* device readahead, etc */
360         spinlock_t              private_lock;   /* for use by the address_space */
361         struct list_head        private_list;   /* ditto */
362         struct address_space    *assoc_mapping; /* ditto */
363 };
364
365 struct block_device {
366         dev_t                   bd_dev;  /* not a kdev_t - it's a search key */
367         struct inode *          bd_inode;       /* will die */
368         int                     bd_openers;
369         struct semaphore        bd_sem; /* open/close mutex */
370         struct semaphore        bd_mount_sem;   /* mount mutex */
371         struct list_head        bd_inodes;
372         void *                  bd_holder;
373         int                     bd_holders;
374         struct block_device *   bd_contains;
375         unsigned                bd_block_size;
376         struct hd_struct *      bd_part;
377         /* number of times partitions within this device have been opened. */
378         unsigned                bd_part_count;
379         int                     bd_invalidated;
380         struct gendisk *        bd_disk;
381         struct list_head        bd_list;
382         struct backing_dev_info *bd_inode_backing_dev_info;
383         /*
384          * Private data.  You must have bd_claim'ed the block_device
385          * to use this.  NOTE:  bd_claim allows an owner to claim
386          * the same device multiple times, the owner must take special
387          * care to not mess up bd_private for that case.
388          */
389         unsigned long           bd_private;
390 };
391
392 /*
393  * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
394  * radix trees
395  */
396 #define PAGECACHE_TAG_DIRTY     0
397 #define PAGECACHE_TAG_WRITEBACK 1
398
399 int mapping_tagged(struct address_space *mapping, int tag);
400
401 /*
402  * Might pages of this file be mapped into userspace?
403  */
404 static inline int mapping_mapped(struct address_space *mapping)
405 {
406         return  !prio_tree_empty(&mapping->i_mmap) ||
407                 !list_empty(&mapping->i_mmap_nonlinear);
408 }
409
410 /*
411  * Might pages of this file have been modified in userspace?
412  * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff
413  * marks vma as VM_SHARED if it is shared, and the file was opened for
414  * writing i.e. vma may be mprotected writable even if now readonly.
415  */
416 static inline int mapping_writably_mapped(struct address_space *mapping)
417 {
418         return mapping->i_mmap_writable != 0;
419 }
420
421 /*
422  * Use sequence counter to get consistent i_size on 32-bit processors.
423  */
424 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
425 #include <linux/seqlock.h>
426 #define __NEED_I_SIZE_ORDERED
427 #define i_size_ordered_init(inode) seqcount_init(&inode->i_size_seqcount)
428 #else
429 #define i_size_ordered_init(inode) do { } while (0)
430 #endif
431
432 struct inode {
433         struct hlist_node       i_hash;
434         struct list_head        i_list;
435         struct list_head        i_dentry;
436         unsigned long           i_ino;
437         atomic_t                i_count;
438         umode_t                 i_mode;
439         unsigned int            i_nlink;
440         uid_t                   i_uid;
441         gid_t                   i_gid;
442         xid_t                   i_xid;
443         dev_t                   i_rdev;
444         loff_t                  i_size;
445         struct timespec         i_atime;
446         struct timespec         i_mtime;
447         struct timespec         i_ctime;
448         unsigned int            i_blkbits;
449         unsigned long           i_blksize;
450         unsigned long           i_version;
451         unsigned long           i_blocks;
452         unsigned short          i_bytes;
453         unsigned char           i_sock;
454         spinlock_t              i_lock; /* i_blocks, i_bytes, maybe i_size */
455         struct semaphore        i_sem;
456         struct rw_semaphore     i_alloc_sem;
457         struct inode_operations *i_op;
458         struct file_operations  *i_fop; /* former ->i_op->default_file_ops */
459         struct super_block      *i_sb;
460         struct file_lock        *i_flock;
461         struct address_space    *i_mapping;
462         struct address_space    i_data;
463 #ifdef CONFIG_QUOTA
464         struct dquot            *i_dquot[MAXQUOTAS];
465 #endif
466         /* These three should probably be a union */
467         struct list_head        i_devices;
468         struct pipe_inode_info  *i_pipe;
469         struct block_device     *i_bdev;
470         struct cdev             *i_cdev;
471         int                     i_cindex;
472
473         __u32                   i_generation;
474
475         unsigned long           i_dnotify_mask; /* Directory notify events */
476         struct dnotify_struct   *i_dnotify; /* for directory notifications */
477
478         unsigned long           i_state;
479         unsigned long           dirtied_when;   /* jiffies of first dirtying */
480
481         unsigned int            i_flags;
482
483         atomic_t                i_writecount;
484         void                    *i_security;
485         union {
486                 void            *generic_ip;
487         } u;
488 #ifdef __NEED_I_SIZE_ORDERED
489         seqcount_t              i_size_seqcount;
490 #endif
491 };
492
493 /*
494  * NOTE: in a 32bit arch with a preemptable kernel and
495  * an UP compile the i_size_read/write must be atomic
496  * with respect to the local cpu (unlike with preempt disabled),
497  * but they don't need to be atomic with respect to other cpus like in
498  * true SMP (so they need either to either locally disable irq around
499  * the read or for example on x86 they can be still implemented as a
500  * cmpxchg8b without the need of the lock prefix). For SMP compiles
501  * and 64bit archs it makes no difference if preempt is enabled or not.
502  */
503 static inline loff_t i_size_read(struct inode *inode)
504 {
505 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
506         loff_t i_size;
507         unsigned int seq;
508
509         do {
510                 seq = read_seqcount_begin(&inode->i_size_seqcount);
511                 i_size = inode->i_size;
512         } while (read_seqcount_retry(&inode->i_size_seqcount, seq));
513         return i_size;
514 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
515         loff_t i_size;
516
517         preempt_disable();
518         i_size = inode->i_size;
519         preempt_enable();
520         return i_size;
521 #else
522         return inode->i_size;
523 #endif
524 }
525
526
527 static inline void i_size_write(struct inode *inode, loff_t i_size)
528 {
529 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
530         write_seqcount_begin(&inode->i_size_seqcount);
531         inode->i_size = i_size;
532         write_seqcount_end(&inode->i_size_seqcount);
533 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
534         preempt_disable();
535         inode->i_size = i_size;
536         preempt_enable();
537 #else
538         inode->i_size = i_size;
539 #endif
540 }
541
542 static inline unsigned iminor(struct inode *inode)
543 {
544         return MINOR(inode->i_rdev);
545 }
546
547 static inline unsigned imajor(struct inode *inode)
548 {
549         return MAJOR(inode->i_rdev);
550 }
551
552 extern struct block_device *I_BDEV(struct inode *inode);
553
554 struct fown_struct {
555         rwlock_t lock;          /* protects pid, uid, euid fields */
556         int pid;                /* pid or -pgrp where SIGIO should be sent */
557         uid_t uid, euid;        /* uid/euid of process setting the owner */
558         void *security;
559         int signum;             /* posix.1b rt signal to be delivered on IO */
560 };
561
562 /*
563  * Track a single file's readahead state
564  */
565 struct file_ra_state {
566         unsigned long start;            /* Current window */
567         unsigned long size;
568         unsigned long next_size;        /* Next window size */
569         unsigned long prev_page;        /* Cache last read() position */
570         unsigned long ahead_start;      /* Ahead window */
571         unsigned long ahead_size;
572         unsigned long currnt_wnd_hit;   /* locality in the current window */
573         unsigned long average;          /* size of next current window */
574         unsigned long ra_pages;         /* Maximum readahead window */
575         unsigned long mmap_hit;         /* Cache hit stat for mmap accesses */
576         unsigned long mmap_miss;        /* Cache miss stat for mmap accesses */
577 };
578
579 struct file {
580         struct list_head        f_list;
581         struct dentry           *f_dentry;
582         struct vfsmount         *f_vfsmnt;
583         struct file_operations  *f_op;
584         atomic_t                f_count;
585         unsigned int            f_flags;
586         mode_t                  f_mode;
587         int                     f_error;
588         loff_t                  f_pos;
589         struct fown_struct      f_owner;
590         unsigned int            f_uid, f_gid;
591         struct file_ra_state    f_ra;
592
593         xid_t                   f_xid;
594
595         unsigned long           f_version;
596         void                    *f_security;
597
598         /* needed for tty driver, and maybe others */
599         void                    *private_data;
600
601 #ifdef CONFIG_EPOLL
602         /* Used by fs/eventpoll.c to link all the hooks to this file */
603         struct list_head        f_ep_links;
604         spinlock_t              f_ep_lock;
605 #endif /* #ifdef CONFIG_EPOLL */
606         struct address_space    *f_mapping;
607 };
608 extern spinlock_t files_lock;
609 #define file_list_lock() spin_lock(&files_lock);
610 #define file_list_unlock() spin_unlock(&files_lock);
611
612 #define get_file(x)     atomic_inc(&(x)->f_count)
613 #define file_count(x)   atomic_read(&(x)->f_count)
614
615 #define MAX_NON_LFS     ((1UL<<31) - 1)
616
617 /* Page cache limit. The filesystems should put that into their s_maxbytes 
618    limits, otherwise bad things can happen in VM. */ 
619 #if BITS_PER_LONG==32
620 #define MAX_LFS_FILESIZE        (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 
621 #elif BITS_PER_LONG==64
622 #define MAX_LFS_FILESIZE        0x7fffffffffffffffUL
623 #endif
624
625 #define FL_POSIX        1
626 #define FL_FLOCK        2
627 #define FL_ACCESS       8       /* not trying to lock, just looking */
628 #define FL_LOCKD        16      /* lock held by rpc.lockd */
629 #define FL_LEASE        32      /* lease held on this file */
630 #define FL_SLEEP        128     /* A blocking lock */
631
632 /*
633  * The POSIX file lock owner is determined by
634  * the "struct files_struct" in the thread group
635  * (or NULL for no owner - BSD locks).
636  *
637  * Lockd stuffs a "host" pointer into this.
638  */
639 typedef struct files_struct *fl_owner_t;
640
641 struct file_lock_operations {
642         void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
643         void (*fl_remove)(struct file_lock *);  /* lock removal callback */
644         void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
645         void (*fl_release_private)(struct file_lock *);
646 };
647
648 struct lock_manager_operations {
649         int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
650         void (*fl_notify)(struct file_lock *);  /* unblock callback */
651 };
652
653 /* that will die - we need it for nfs_lock_info */
654 #include <linux/nfs_fs_i.h>
655
656 struct file_lock {
657         struct file_lock *fl_next;      /* singly linked list for this inode  */
658         struct list_head fl_link;       /* doubly linked list of all locks */
659         struct list_head fl_block;      /* circular list of blocked processes */
660         fl_owner_t fl_owner;
661         unsigned int fl_pid;
662         wait_queue_head_t fl_wait;
663         struct file *fl_file;
664         unsigned char fl_flags;
665         unsigned char fl_type;
666         loff_t fl_start;
667         loff_t fl_end;
668
669         struct fasync_struct *  fl_fasync; /* for lease break notifications */
670         unsigned long fl_break_time;    /* for nonblocking lease breaks */
671
672         struct file_lock_operations *fl_ops;    /* Callbacks for filesystems */
673         struct lock_manager_operations *fl_lmops;       /* Callbacks for lockmanagers */
674         union {
675                 struct nfs_lock_info    nfs_fl;
676         } fl_u;
677 };
678
679 /* The following constant reflects the upper bound of the file/locking space */
680 #ifndef OFFSET_MAX
681 #define INT_LIMIT(x)    (~((x)1 << (sizeof(x)*8 - 1)))
682 #define OFFSET_MAX      INT_LIMIT(loff_t)
683 #define OFFT_OFFSET_MAX INT_LIMIT(off_t)
684 #endif
685
686 extern struct list_head file_lock_list;
687
688 #include <linux/fcntl.h>
689
690 extern int fcntl_getlk(struct file *, struct flock __user *);
691 extern int fcntl_setlk(struct file *, unsigned int, struct flock __user *);
692
693 #if BITS_PER_LONG == 32
694 extern int fcntl_getlk64(struct file *, struct flock64 __user *);
695 extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 __user *);
696 #endif
697
698 extern void send_sigio(struct fown_struct *fown, int fd, int band);
699 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
700 extern int fcntl_getlease(struct file *filp);
701
702 /* fs/locks.c */
703 extern void locks_init_lock(struct file_lock *);
704 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
705 extern void locks_remove_posix(struct file *, fl_owner_t);
706 extern void locks_remove_flock(struct file *);
707 extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
708 extern int posix_lock_file(struct file *, struct file_lock *);
709 extern int posix_lock_file_wait(struct file *, struct file_lock *);
710 extern void posix_block_lock(struct file_lock *, struct file_lock *);
711 extern void posix_unblock_lock(struct file *, struct file_lock *);
712 extern int posix_locks_deadlock(struct file_lock *, struct file_lock *);
713 extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
714 extern int __break_lease(struct inode *inode, unsigned int flags);
715 extern void lease_get_mtime(struct inode *, struct timespec *time);
716 extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
717 extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
718 extern void steal_locks(fl_owner_t from);
719
720 struct fasync_struct {
721         int     magic;
722         int     fa_fd;
723         struct  fasync_struct   *fa_next; /* singly linked list */
724         struct  file            *fa_file;
725 };
726
727 #define FASYNC_MAGIC 0x4601
728
729 /* SMP safe fasync helpers: */
730 extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
731 /* can be called from interrupts */
732 extern void kill_fasync(struct fasync_struct **, int, int);
733 /* only for net: no internal synchronization */
734 extern void __kill_fasync(struct fasync_struct *, int, int);
735
736 extern int f_setown(struct file *filp, unsigned long arg, int force);
737 extern void f_delown(struct file *filp);
738 extern int send_sigurg(struct fown_struct *fown);
739
740 /*
741  *      Umount options
742  */
743
744 #define MNT_FORCE       0x00000001      /* Attempt to forcibily umount */
745 #define MNT_DETACH      0x00000002      /* Just detach from the tree */
746 #define MNT_EXPIRE      0x00000004      /* Mark for expiry */
747
748 extern struct list_head super_blocks;
749 extern spinlock_t sb_lock;
750
751 #define sb_entry(list)  list_entry((list), struct super_block, s_list)
752 #define S_BIAS (1<<30)
753 struct super_block {
754         struct list_head        s_list;         /* Keep this first */
755         dev_t                   s_dev;          /* search index; _not_ kdev_t */
756         unsigned long           s_blocksize;
757         unsigned long           s_old_blocksize;
758         unsigned char           s_blocksize_bits;
759         unsigned char           s_dirt;
760         unsigned long long      s_maxbytes;     /* Max file size */
761         struct file_system_type *s_type;
762         struct super_operations *s_op;
763         struct dquot_operations *dq_op;
764         struct quotactl_ops     *s_qcop;
765         struct export_operations *s_export_op;
766         unsigned long           s_flags;
767         unsigned long           s_magic;
768         struct dentry           *s_root;
769         struct rw_semaphore     s_umount;
770         struct semaphore        s_lock;
771         int                     s_count;
772         int                     s_syncing;
773         int                     s_need_sync_fs;
774         atomic_t                s_active;
775         void                    *s_security;
776         struct xattr_handler    **s_xattr;
777
778         struct list_head        s_dirty;        /* dirty inodes */
779         struct list_head        s_io;           /* parked for writeback */
780         struct hlist_head       s_anon;         /* anonymous dentries for (nfs) exporting */
781         struct list_head        s_files;
782
783         struct block_device     *s_bdev;
784         struct list_head        s_instances;
785         struct quota_info       s_dquot;        /* Diskquota specific options */
786
787         int                     s_frozen;
788         wait_queue_head_t       s_wait_unfrozen;
789
790         char s_id[32];                          /* Informational name */
791
792         void                    *s_fs_info;     /* Filesystem private info */
793
794         /*
795          * The next field is for VFS *only*. No filesystems have any business
796          * even looking at it. You had been warned.
797          */
798         struct semaphore s_vfs_rename_sem;      /* Kludge */
799 };
800
801 /*
802  * Snapshotting support.
803  */
804 enum {
805         SB_UNFROZEN = 0,
806         SB_FREEZE_WRITE = 1,
807         SB_FREEZE_TRANS = 2,
808 };
809
810 #define vfs_check_frozen(sb, level) \
811         wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level)))
812
813 /*
814  * Superblock locking.
815  */
816 static inline void lock_super(struct super_block * sb)
817 {
818         down(&sb->s_lock);
819 }
820
821 static inline void unlock_super(struct super_block * sb)
822 {
823         up(&sb->s_lock);
824 }
825
826 /*
827  * VFS helper functions..
828  */
829 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
830 extern int vfs_mkdir(struct inode *, struct dentry *, int);
831 extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
832 extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
833 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
834 extern int vfs_rmdir(struct inode *, struct dentry *);
835 extern int vfs_unlink(struct inode *, struct dentry *);
836 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
837
838 /*
839  * VFS dentry helper functions.
840  */
841 extern void dentry_unhash(struct dentry *dentry);
842
843 /*
844  * File types
845  *
846  * NOTE! These match bits 12..15 of stat.st_mode
847  * (ie "(i_mode >> 12) & 15").
848  */
849 #define DT_UNKNOWN      0
850 #define DT_FIFO         1
851 #define DT_CHR          2
852 #define DT_DIR          4
853 #define DT_BLK          6
854 #define DT_REG          8
855 #define DT_LNK          10
856 #define DT_SOCK         12
857 #define DT_WHT          14
858
859 #define OSYNC_METADATA  (1<<0)
860 #define OSYNC_DATA      (1<<1)
861 #define OSYNC_INODE     (1<<2)
862 int generic_osync_inode(struct inode *, struct address_space *, int);
863
864 /*
865  * This is the "filldir" function type, used by readdir() to let
866  * the kernel specify what kind of dirent layout it wants to have.
867  * This allows the kernel to read directories into kernel space or
868  * to have different dirent layouts depending on the binary type.
869  */
870 typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
871
872 struct block_device_operations {
873         int (*open) (struct inode *, struct file *);
874         int (*release) (struct inode *, struct file *);
875         int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
876         int (*media_changed) (struct gendisk *);
877         int (*revalidate_disk) (struct gendisk *);
878         struct module *owner;
879 };
880
881 /*
882  * "descriptor" for what we're up to with a read for sendfile().
883  * This allows us to use the same read code yet
884  * have multiple different users of the data that
885  * we read from a file.
886  *
887  * The simplest case just copies the data to user
888  * mode.
889  */
890 typedef struct {
891         size_t written;
892         size_t count;
893         union {
894                 char __user * buf;
895                 void *data;
896         } arg;
897         int error;
898 } read_descriptor_t;
899
900 typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
901
902 /*
903  * NOTE:
904  * read, write, poll, fsync, readv, writev can be called
905  *   without the big kernel lock held in all filesystems.
906  */
907 struct file_operations {
908         struct module *owner;
909         loff_t (*llseek) (struct file *, loff_t, int);
910         ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
911         ssize_t (*aio_read) (struct kiocb *, char __user *, size_t, loff_t);
912         ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
913         ssize_t (*aio_write) (struct kiocb *, const char __user *, size_t, loff_t);
914         int (*readdir) (struct file *, void *, filldir_t);
915         unsigned int (*poll) (struct file *, struct poll_table_struct *);
916         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
917         int (*mmap) (struct file *, struct vm_area_struct *);
918         int (*open) (struct inode *, struct file *);
919         int (*flush) (struct file *);
920         int (*release) (struct inode *, struct file *);
921         int (*fsync) (struct file *, struct dentry *, int datasync);
922         int (*aio_fsync) (struct kiocb *, int datasync);
923         int (*fasync) (int, struct file *, int);
924         int (*lock) (struct file *, int, struct file_lock *);
925         ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
926         ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
927         ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);
928         ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
929         unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
930         int (*check_flags)(int);
931         int (*dir_notify)(struct file *filp, unsigned long arg);
932         int (*flock) (struct file *, int, struct file_lock *);
933 };
934
935 struct inode_operations {
936         int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
937         struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
938         int (*link) (struct dentry *,struct inode *,struct dentry *);
939         int (*unlink) (struct inode *,struct dentry *);
940         int (*symlink) (struct inode *,struct dentry *,const char *);
941         int (*mkdir) (struct inode *,struct dentry *,int);
942         int (*rmdir) (struct inode *,struct dentry *);
943         int (*mknod) (struct inode *,struct dentry *,int,dev_t);
944         int (*rename) (struct inode *, struct dentry *,
945                         struct inode *, struct dentry *);
946         int (*readlink) (struct dentry *, char __user *,int);
947         int (*follow_link) (struct dentry *, struct nameidata *);
948         void (*put_link) (struct dentry *, struct nameidata *);
949         void (*truncate) (struct inode *);
950         int (*permission) (struct inode *, int, struct nameidata *);
951         int (*setattr) (struct dentry *, struct iattr *);
952         int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
953         int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
954         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
955         ssize_t (*listxattr) (struct dentry *, char *, size_t);
956         int (*removexattr) (struct dentry *, const char *);
957 };
958
959 struct seq_file;
960
961 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
962 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
963 extern ssize_t vfs_readv(struct file *, const struct iovec __user *,
964                 unsigned long, loff_t *);
965 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
966                 unsigned long, loff_t *);
967
968 /*
969  * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
970  * without the big kernel lock held in all filesystems.
971  */
972 struct super_operations {
973         struct inode *(*alloc_inode)(struct super_block *sb);
974         void (*destroy_inode)(struct inode *);
975
976         void (*read_inode) (struct inode *);
977   
978         void (*dirty_inode) (struct inode *);
979         int (*write_inode) (struct inode *, int);
980         void (*put_inode) (struct inode *);
981         void (*drop_inode) (struct inode *);
982         void (*delete_inode) (struct inode *);
983         void (*put_super) (struct super_block *);
984         void (*write_super) (struct super_block *);
985         int (*sync_fs)(struct super_block *sb, int wait);
986         void (*write_super_lockfs) (struct super_block *);
987         void (*unlockfs) (struct super_block *);
988         int (*statfs) (struct super_block *, struct kstatfs *);
989         int (*remount_fs) (struct super_block *, int *, char *);
990         void (*clear_inode) (struct inode *);
991         void (*umount_begin) (struct super_block *);
992
993         int (*show_options)(struct seq_file *, struct vfsmount *);
994 };
995
996 /* Inode state bits.  Protected by inode_lock. */
997 #define I_DIRTY_SYNC            1 /* Not dirty enough for O_DATASYNC */
998 #define I_DIRTY_DATASYNC        2 /* Data-related inode changes pending */
999 #define I_DIRTY_PAGES           4 /* Data-related inode changes pending */
1000 #define I_LOCK                  8
1001 #define I_FREEING               16
1002 #define I_CLEAR                 32
1003 #define I_NEW                   64
1004
1005 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
1006
1007 extern void __mark_inode_dirty(struct inode *, int);
1008 static inline void mark_inode_dirty(struct inode *inode)
1009 {
1010         __mark_inode_dirty(inode, I_DIRTY);
1011 }
1012
1013 static inline void mark_inode_dirty_sync(struct inode *inode)
1014 {
1015         __mark_inode_dirty(inode, I_DIRTY_SYNC);
1016 }
1017
1018 static inline void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
1019 {
1020         struct inode *inode = dentry->d_inode;
1021
1022         if (MNT_IS_NOATIME(mnt))
1023                 return;
1024         if (S_ISDIR(inode->i_mode) && MNT_IS_NODIRATIME(mnt))
1025                 return;
1026         if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
1027                 return;
1028
1029         update_atime(inode);
1030 }
1031
1032 static inline void file_accessed(struct file *file)
1033 {
1034         if (!(file->f_flags & O_NOATIME))
1035                 touch_atime(file->f_vfsmnt, file->f_dentry);
1036 }
1037
1038 int sync_inode(struct inode *inode, struct writeback_control *wbc);
1039
1040 /**
1041  * &export_operations - for nfsd to communicate with file systems
1042  * decode_fh:      decode a file handle fragment and return a &struct dentry
1043  * encode_fh:      encode a file handle fragment from a dentry
1044  * get_name:       find the name for a given inode in a given directory
1045  * get_parent:     find the parent of a given directory
1046  * get_dentry:     find a dentry for the inode given a file handle sub-fragment
1047  *
1048  * Description:
1049  *    The export_operations structure provides a means for nfsd to communicate
1050  *    with a particular exported file system  - particularly enabling nfsd and
1051  *    the filesystem to co-operate when dealing with file handles.
1052  *
1053  *    export_operations contains two basic operation for dealing with file handles,
1054  *    decode_fh() and encode_fh(), and allows for some other operations to be defined
1055  *    which standard helper routines use to get specific information from the
1056  *    filesystem.
1057  *
1058  *    nfsd encodes information use to determine which filesystem a filehandle
1059  *    applies to in the initial part of the file handle.  The remainder, termed a
1060  *    file handle fragment, is controlled completely by the filesystem.
1061  *    The standard helper routines assume that this fragment will contain one or two
1062  *    sub-fragments, one which identifies the file, and one which may be used to
1063  *    identify the (a) directory containing the file.
1064  *
1065  *    In some situations, nfsd needs to get a dentry which is connected into a
1066  *    specific part of the file tree.  To allow for this, it passes the function
1067  *    acceptable() together with a @context which can be used to see if the dentry
1068  *    is acceptable.  As there can be multiple dentrys for a given file, the filesystem
1069  *    should check each one for acceptability before looking for the next.  As soon
1070  *    as an acceptable one is found, it should be returned.
1071  *
1072  * decode_fh:
1073  *    @decode_fh is given a &struct super_block (@sb), a file handle fragment (@fh, @fh_len)
1074  *    and an acceptability testing function (@acceptable, @context).  It should return
1075  *    a &struct dentry which refers to the same file that the file handle fragment refers
1076  *    to,  and which passes the acceptability test.  If it cannot, it should return
1077  *    a %NULL pointer if the file was found but no acceptable &dentries were available, or
1078  *    a %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or %ENOMEM).
1079  *
1080  * encode_fh:
1081  *    @encode_fh should store in the file handle fragment @fh (using at most @max_len bytes)
1082  *    information that can be used by @decode_fh to recover the file refered to by the
1083  *    &struct dentry @de.  If the @connectable flag is set, the encode_fh() should store
1084  *    sufficient information so that a good attempt can be made to find not only
1085  *    the file but also it's place in the filesystem.   This typically means storing
1086  *    a reference to de->d_parent in the filehandle fragment.
1087  *    encode_fh() should return the number of bytes stored or a negative error code
1088  *    such as %-ENOSPC
1089  *
1090  * get_name:
1091  *    @get_name should find a name for the given @child in the given @parent directory.
1092  *    The name should be stored in the @name (with the understanding that it is already
1093  *    pointing to a a %NAME_MAX+1 sized buffer.   get_name() should return %0 on success,
1094  *    a negative error code or error.
1095  *    @get_name will be called without @parent->i_sem held.
1096  *
1097  * get_parent:
1098  *    @get_parent should find the parent directory for the given @child which is also
1099  *    a directory.  In the event that it cannot be found, or storage space cannot be
1100  *    allocated, a %ERR_PTR should be returned.
1101  *
1102  * get_dentry:
1103  *    Given a &super_block (@sb) and a pointer to a file-system specific inode identifier,
1104  *    possibly an inode number, (@inump) get_dentry() should find the identified inode and
1105  *    return a dentry for that inode.
1106  *    Any suitable dentry can be returned including, if necessary, a new dentry created
1107  *    with d_alloc_root.  The caller can then find any other extant dentrys by following the
1108  *    d_alias links.  If a new dentry was created using d_alloc_root, DCACHE_NFSD_DISCONNECTED
1109  *    should be set, and the dentry should be d_rehash()ed.
1110  *
1111  *    If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code can be returned.
1112  *    The @inump will be whatever was passed to nfsd_find_fh_dentry() in either the
1113  *    @obj or @parent parameters.
1114  *
1115  * Locking rules:
1116  *  get_parent is called with child->d_inode->i_sem down
1117  *  get_name is not (which is possibly inconsistent)
1118  */
1119
1120 struct export_operations {
1121         struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
1122                          int (*acceptable)(void *context, struct dentry *de),
1123                          void *context);
1124         int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
1125                          int connectable);
1126
1127         /* the following are only called from the filesystem itself */
1128         int (*get_name)(struct dentry *parent, char *name,
1129                         struct dentry *child);
1130         struct dentry * (*get_parent)(struct dentry *child);
1131         struct dentry * (*get_dentry)(struct super_block *sb, void *inump);
1132
1133         /* This is set by the exporting module to a standard helper */
1134         struct dentry * (*find_exported_dentry)(
1135                 struct super_block *sb, void *obj, void *parent,
1136                 int (*acceptable)(void *context, struct dentry *de),
1137                 void *context);
1138
1139
1140 };
1141
1142
1143 struct file_system_type {
1144         const char *name;
1145         int fs_flags;
1146         struct super_block *(*get_sb) (struct file_system_type *, int,
1147                                        const char *, void *);
1148         void (*kill_sb) (struct super_block *);
1149         struct module *owner;
1150         struct file_system_type * next;
1151         struct list_head fs_supers;
1152 };
1153
1154 struct super_block *get_sb_bdev(struct file_system_type *fs_type,
1155         int flags, const char *dev_name, void *data,
1156         int (*fill_super)(struct super_block *, void *, int));
1157 struct super_block *get_sb_single(struct file_system_type *fs_type,
1158         int flags, void *data,
1159         int (*fill_super)(struct super_block *, void *, int));
1160 struct super_block *get_sb_nodev(struct file_system_type *fs_type,
1161         int flags, void *data,
1162         int (*fill_super)(struct super_block *, void *, int));
1163 void generic_shutdown_super(struct super_block *sb);
1164 void kill_block_super(struct super_block *sb);
1165 void kill_anon_super(struct super_block *sb);
1166 void kill_litter_super(struct super_block *sb);
1167 void deactivate_super(struct super_block *sb);
1168 int set_anon_super(struct super_block *s, void *data);
1169 struct super_block *sget(struct file_system_type *type,
1170                         int (*test)(struct super_block *,void *),
1171                         int (*set)(struct super_block *,void *),
1172                         void *data);
1173 struct super_block *get_sb_pseudo(struct file_system_type *, char *,
1174                         struct super_operations *ops, unsigned long);
1175 int __put_super(struct super_block *sb);
1176 int __put_super_and_need_restart(struct super_block *sb);
1177 void unnamed_dev_init(void);
1178
1179 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
1180 #define fops_get(fops) \
1181         (((fops) && try_module_get((fops)->owner) ? (fops) : NULL))
1182 #define fops_put(fops) \
1183         do { if (fops) module_put((fops)->owner); } while(0)
1184
1185 extern int register_filesystem(struct file_system_type *);
1186 extern int unregister_filesystem(struct file_system_type *);
1187 extern struct vfsmount *kern_mount(struct file_system_type *);
1188 extern int may_umount_tree(struct vfsmount *);
1189 extern int may_umount(struct vfsmount *);
1190 extern long do_mount(char *, char *, char *, unsigned long, void *);
1191
1192 extern int vfs_statfs(struct super_block *, struct kstatfs *);
1193
1194 /* Return value for VFS lock functions - tells locks.c to lock conventionally
1195  * REALLY kosha for root NFS and nfs_lock
1196  */ 
1197 #define LOCK_USE_CLNT 1
1198
1199 #define FLOCK_VERIFY_READ  1
1200 #define FLOCK_VERIFY_WRITE 2
1201
1202 extern int locks_mandatory_locked(struct inode *);
1203 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
1204
1205 /*
1206  * Candidates for mandatory locking have the setgid bit set
1207  * but no group execute bit -  an otherwise meaningless combination.
1208  */
1209 #define MANDATORY_LOCK(inode) \
1210         (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
1211
1212 static inline int locks_verify_locked(struct inode *inode)
1213 {
1214         if (MANDATORY_LOCK(inode))
1215                 return locks_mandatory_locked(inode);
1216         return 0;
1217 }
1218
1219 static inline int locks_verify_area(int read_write, struct inode *inode,
1220                                     struct file *filp, loff_t offset,
1221                                     size_t count)
1222 {
1223         if (inode->i_flock && MANDATORY_LOCK(inode))
1224                 return locks_mandatory_area(read_write, inode, filp, offset, count);
1225         return 0;
1226 }
1227
1228 static inline int locks_verify_truncate(struct inode *inode,
1229                                     struct file *filp,
1230                                     loff_t size)
1231 {
1232         if (inode->i_flock && MANDATORY_LOCK(inode))
1233                 return locks_mandatory_area(
1234                         FLOCK_VERIFY_WRITE, inode, filp,
1235                         size < inode->i_size ? size : inode->i_size,
1236                         (size < inode->i_size ? inode->i_size - size
1237                          : size - inode->i_size)
1238                 );
1239         return 0;
1240 }
1241
1242 static inline int break_lease(struct inode *inode, unsigned int mode)
1243 {
1244         if (inode->i_flock)
1245                 return __break_lease(inode, mode);
1246         return 0;
1247 }
1248
1249 /* fs/open.c */
1250
1251 extern int do_truncate(struct dentry *, loff_t start);
1252 extern struct file *filp_open(const char *, int, int);
1253 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1254 extern int filp_close(struct file *, fl_owner_t id);
1255 extern char * getname(const char __user *);
1256
1257 /* fs/dcache.c */
1258 extern void __init vfs_caches_init_early(void);
1259 extern void __init vfs_caches_init(unsigned long);
1260
1261 #define __getname()     kmem_cache_alloc(names_cachep, SLAB_KERNEL)
1262 #define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
1263 #ifndef CONFIG_AUDITSYSCALL
1264 #define putname(name)   __putname(name)
1265 #else
1266 #define putname(name)                                                   \
1267         do {                                                            \
1268                 if (unlikely(current->audit_context))                   \
1269                         audit_putname(name);                            \
1270                 else                                                    \
1271                         __putname(name);                                \
1272         } while (0)
1273 #endif
1274
1275 extern int register_blkdev(unsigned int, const char *);
1276 extern int unregister_blkdev(unsigned int, const char *);
1277 extern struct block_device *bdget(dev_t);
1278 extern void bd_set_size(struct block_device *, loff_t size);
1279 extern void bd_forget(struct inode *inode);
1280 extern void bdput(struct block_device *);
1281 extern struct block_device *open_by_devnum(dev_t, unsigned);
1282 extern struct file_operations def_blk_fops;
1283 extern struct address_space_operations def_blk_aops;
1284 extern struct file_operations def_chr_fops;
1285 extern struct file_operations bad_sock_fops;
1286 extern struct file_operations def_fifo_fops;
1287 extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1288 extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long);
1289 extern int blkdev_get(struct block_device *, mode_t, unsigned);
1290 extern int blkdev_put(struct block_device *);
1291 extern int bd_claim(struct block_device *, void *);
1292 extern void bd_release(struct block_device *);
1293
1294 /* fs/char_dev.c */
1295 extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, char *);
1296 extern int register_chrdev_region(dev_t, unsigned, char *);
1297 extern int register_chrdev(unsigned int, const char *,
1298                            struct file_operations *);
1299 extern int unregister_chrdev(unsigned int, const char *);
1300 extern void unregister_chrdev_region(dev_t, unsigned);
1301 extern int chrdev_open(struct inode *, struct file *);
1302
1303 /* fs/block_dev.c */
1304 #define BDEVNAME_SIZE   32      /* Largest string for a blockdev identifier */
1305 extern const char *__bdevname(dev_t, char *buffer);
1306 extern const char *bdevname(struct block_device *bdev, char *buffer);
1307 extern struct block_device *lookup_bdev(const char *);
1308 extern struct block_device *open_bdev_excl(const char *, int, void *);
1309 extern void close_bdev_excl(struct block_device *);
1310
1311 extern void init_special_inode(struct inode *, umode_t, dev_t);
1312
1313 /* Invalid inode operations -- fs/bad_inode.c */
1314 extern void make_bad_inode(struct inode *);
1315 extern int is_bad_inode(struct inode *);
1316
1317 extern struct file_operations read_fifo_fops;
1318 extern struct file_operations write_fifo_fops;
1319 extern struct file_operations rdwr_fifo_fops;
1320 extern struct file_operations read_pipe_fops;
1321 extern struct file_operations write_pipe_fops;
1322 extern struct file_operations rdwr_pipe_fops;
1323
1324 extern int fs_may_remount_ro(struct super_block *);
1325
1326 /*
1327  * return READ, READA, or WRITE
1328  */
1329 #define bio_rw(bio)             ((bio)->bi_rw & (RW_MASK | RWA_MASK))
1330
1331 /*
1332  * return data direction, READ or WRITE
1333  */
1334 #define bio_data_dir(bio)       ((bio)->bi_rw & 1)
1335
1336 extern int check_disk_change(struct block_device *);
1337 extern int invalidate_inodes(struct super_block *);
1338 extern int __invalidate_device(struct block_device *, int);
1339 extern int invalidate_partition(struct gendisk *, int);
1340 unsigned long invalidate_mapping_pages(struct address_space *mapping,
1341                                         pgoff_t start, pgoff_t end);
1342 unsigned long invalidate_inode_pages(struct address_space *mapping);
1343 static inline void invalidate_remote_inode(struct inode *inode)
1344 {
1345         if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
1346             S_ISLNK(inode->i_mode))
1347                 invalidate_inode_pages(inode->i_mapping);
1348 }
1349 extern void invalidate_inode_pages2(struct address_space *mapping);
1350 extern void write_inode_now(struct inode *, int);
1351 extern int filemap_fdatawrite(struct address_space *);
1352 extern int filemap_flush(struct address_space *);
1353 extern int filemap_fdatawait(struct address_space *);
1354 extern int filemap_write_and_wait(struct address_space *mapping);
1355 extern void sync_supers(void);
1356 extern void sync_filesystems(int wait);
1357 extern void emergency_sync(void);
1358 extern void emergency_remount(void);
1359 extern int do_remount_sb(struct super_block *sb, int flags,
1360                          void *data, int force);
1361 extern sector_t bmap(struct inode *, sector_t);
1362 extern int setattr_mask(unsigned int);
1363 extern int notify_change(struct dentry *, struct iattr *);
1364 extern int permission(struct inode *, int, struct nameidata *);
1365 extern int vfs_permission(struct inode *, int);
1366 extern int get_write_access(struct inode *);
1367 extern int deny_write_access(struct file *);
1368 static inline void put_write_access(struct inode * inode)
1369 {
1370         atomic_dec(&inode->i_writecount);
1371 }
1372 static inline void allow_write_access(struct file *file)
1373 {
1374         if (file)
1375                 atomic_inc(&file->f_dentry->d_inode->i_writecount);
1376 }
1377 extern int do_pipe(int *);
1378
1379 extern int open_namei(const char *, int, int, struct nameidata *);
1380 extern int may_open(struct nameidata *, int, int);
1381
1382 extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
1383 extern struct file * open_exec(const char *);
1384  
1385 /* fs/dcache.c -- generic fs support functions */
1386 extern int is_subdir(struct dentry *, struct dentry *);
1387 extern ino_t find_inode_number(struct dentry *, struct qstr *);
1388
1389 #include <linux/err.h>
1390
1391 /* needed for stackable file system support */
1392 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1393
1394 extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin);
1395
1396 extern void inode_init_once(struct inode *);
1397 extern void iput(struct inode *);
1398 extern struct inode * igrab(struct inode *);
1399 extern ino_t iunique(struct super_block *, ino_t);
1400 extern int inode_needs_sync(struct inode *inode);
1401 extern void generic_delete_inode(struct inode *inode);
1402
1403 extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
1404                 int (*test)(struct inode *, void *), void *data);
1405 extern struct inode *ilookup(struct super_block *sb, unsigned long ino);
1406
1407 extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
1408 extern struct inode * iget_locked(struct super_block *, unsigned long);
1409 extern void unlock_new_inode(struct inode *);
1410
1411 static inline struct inode *iget(struct super_block *sb, unsigned long ino)
1412 {
1413         struct inode *inode = iget_locked(sb, ino);
1414         
1415         if (inode && (inode->i_state & I_NEW)) {
1416                 sb->s_op->read_inode(inode);
1417                 unlock_new_inode(inode);
1418         }
1419
1420         return inode;
1421 }
1422
1423 extern void __iget(struct inode * inode);
1424 extern void clear_inode(struct inode *);
1425 extern void destroy_inode(struct inode *);
1426 extern struct inode *new_inode(struct super_block *);
1427 extern int remove_suid(struct dentry *);
1428 extern void remove_dquot_ref(struct super_block *, int, struct list_head *);
1429 extern struct semaphore iprune_sem;
1430
1431 extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1432 extern void remove_inode_hash(struct inode *);
1433 static inline void insert_inode_hash(struct inode *inode) {
1434         __insert_inode_hash(inode, inode->i_ino);
1435 }
1436
1437 extern struct file * get_empty_filp(void);
1438 extern void file_move(struct file *f, struct list_head *list);
1439 extern void file_kill(struct file *f);
1440 struct bio;
1441 extern void submit_bio(int, struct bio *);
1442 extern int bdev_read_only(struct block_device *);
1443 extern int set_blocksize(struct block_device *, int);
1444 extern int sb_set_blocksize(struct super_block *, int);
1445 extern int sb_min_blocksize(struct super_block *, int);
1446
1447 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
1448 extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
1449 extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
1450 extern int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
1451 extern ssize_t generic_file_read(struct file *, char __user *, size_t, loff_t *);
1452 int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
1453 extern ssize_t generic_file_write(struct file *, const char __user *, size_t, loff_t *);
1454 extern ssize_t generic_file_aio_read(struct kiocb *, char __user *, size_t, loff_t);
1455 extern ssize_t __generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t *);
1456 extern ssize_t generic_file_aio_write(struct kiocb *, const char __user *, size_t, loff_t);
1457 extern ssize_t generic_file_aio_write_nolock(struct kiocb *, const struct iovec *,
1458                 unsigned long, loff_t *);
1459 extern ssize_t generic_file_direct_write(struct kiocb *, const struct iovec *,
1460                 unsigned long *, loff_t, loff_t *, size_t, size_t);
1461 extern ssize_t generic_file_buffered_write(struct kiocb *, const struct iovec *,
1462                 unsigned long, loff_t, loff_t *, size_t, ssize_t);
1463 extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos);
1464 extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
1465 ssize_t generic_file_write_nolock(struct file *file, const struct iovec *iov,
1466                                 unsigned long nr_segs, loff_t *ppos);
1467 extern ssize_t generic_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
1468 extern void do_generic_mapping_read(struct address_space *mapping,
1469                                     struct file_ra_state *, struct file *,
1470                                     loff_t *, read_descriptor_t *, read_actor_t, int);
1471 extern void
1472 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
1473 extern ssize_t generic_file_direct_IO(int rw, struct kiocb *iocb,
1474         const struct iovec *iov, loff_t offset, unsigned long nr_segs);
1475 extern ssize_t generic_file_readv(struct file *filp, const struct iovec *iov, 
1476         unsigned long nr_segs, loff_t *ppos);
1477 ssize_t generic_file_writev(struct file *filp, const struct iovec *iov, 
1478                         unsigned long nr_segs, loff_t *ppos);
1479 extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
1480 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
1481 extern loff_t remote_llseek(struct file *file, loff_t offset, int origin);
1482 extern int generic_file_open(struct inode * inode, struct file * filp);
1483 extern int nonseekable_open(struct inode * inode, struct file * filp);
1484
1485 static inline void do_generic_file_read(struct file * filp, loff_t *ppos,
1486                                         read_descriptor_t * desc,
1487                                         read_actor_t actor, int nonblock)
1488 {
1489         do_generic_mapping_read(filp->f_mapping,
1490                                 &filp->f_ra,
1491                                 filp,
1492                                 ppos,
1493                                 desc,
1494                                 actor,
1495                                 nonblock);
1496 }
1497
1498 ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1499         struct block_device *bdev, const struct iovec *iov, loff_t offset,
1500         unsigned long nr_segs, get_blocks_t get_blocks, dio_iodone_t end_io,
1501         int lock_type);
1502
1503 enum {
1504         DIO_LOCKING = 1, /* need locking between buffered and direct access */
1505         DIO_NO_LOCKING,  /* bdev; no locking at all between buffered/direct */
1506         DIO_OWN_LOCKING, /* filesystem locks buffered and direct internally */
1507 };
1508
1509 static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
1510         struct inode *inode, struct block_device *bdev, const struct iovec *iov,
1511         loff_t offset, unsigned long nr_segs, get_blocks_t get_blocks,
1512         dio_iodone_t end_io)
1513 {
1514         return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
1515                                 nr_segs, get_blocks, end_io, DIO_LOCKING);
1516 }
1517
1518 static inline ssize_t blockdev_direct_IO_no_locking(int rw, struct kiocb *iocb,
1519         struct inode *inode, struct block_device *bdev, const struct iovec *iov,
1520         loff_t offset, unsigned long nr_segs, get_blocks_t get_blocks,
1521         dio_iodone_t end_io)
1522 {
1523         return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
1524                                 nr_segs, get_blocks, end_io, DIO_NO_LOCKING);
1525 }
1526
1527 static inline ssize_t blockdev_direct_IO_own_locking(int rw, struct kiocb *iocb,
1528         struct inode *inode, struct block_device *bdev, const struct iovec *iov,
1529         loff_t offset, unsigned long nr_segs, get_blocks_t get_blocks,
1530         dio_iodone_t end_io)
1531 {
1532         return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
1533                                 nr_segs, get_blocks, end_io, DIO_OWN_LOCKING);
1534 }
1535
1536 extern struct file_operations generic_ro_fops;
1537
1538 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1539
1540 extern int vfs_readlink(struct dentry *, char __user *, int, const char *);
1541 extern int vfs_follow_link(struct nameidata *, const char *);
1542 extern int page_readlink(struct dentry *, char __user *, int);
1543 extern int page_follow_link_light(struct dentry *, struct nameidata *);
1544 extern void page_put_link(struct dentry *, struct nameidata *);
1545 extern int page_symlink(struct inode *inode, const char *symname, int len);
1546 extern struct inode_operations page_symlink_inode_operations;
1547 extern int generic_readlink(struct dentry *, char __user *, int);
1548 extern void generic_fillattr(struct inode *, struct kstat *);
1549 extern int vfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
1550 void inode_add_bytes(struct inode *inode, loff_t bytes);
1551 void inode_sub_bytes(struct inode *inode, loff_t bytes);
1552 loff_t inode_get_bytes(struct inode *inode);
1553 void inode_set_bytes(struct inode *inode, loff_t bytes);
1554
1555 extern int vfs_readdir(struct file *, filldir_t, void *);
1556
1557 extern int vfs_stat(char __user *, struct kstat *);
1558 extern int vfs_lstat(char __user *, struct kstat *);
1559 extern int vfs_fstat(unsigned int, struct kstat *);
1560
1561 extern struct file_system_type *get_fs_type(const char *name);
1562 extern struct super_block *get_super(struct block_device *);
1563 extern struct super_block *user_get_super(dev_t);
1564 extern void drop_super(struct super_block *sb);
1565
1566 extern int dcache_dir_open(struct inode *, struct file *);
1567 extern int dcache_dir_close(struct inode *, struct file *);
1568 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
1569 extern int dcache_readdir(struct file *, void *, filldir_t);
1570 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
1571 extern int simple_statfs(struct super_block *, struct kstatfs *);
1572 extern int simple_link(struct dentry *, struct inode *, struct dentry *);
1573 extern int simple_unlink(struct inode *, struct dentry *);
1574 extern int simple_rmdir(struct inode *, struct dentry *);
1575 extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1576 extern int simple_sync_file(struct file *, struct dentry *, int);
1577 extern int simple_empty(struct dentry *);
1578 extern int simple_readpage(struct file *file, struct page *page);
1579 extern int simple_prepare_write(struct file *file, struct page *page,
1580                         unsigned offset, unsigned to);
1581 extern int simple_commit_write(struct file *file, struct page *page,
1582                                 unsigned offset, unsigned to);
1583
1584 extern struct dentry *simple_lookup(struct inode *, struct dentry *, struct nameidata *);
1585 extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);
1586 extern struct file_operations simple_dir_operations;
1587 extern struct inode_operations simple_dir_inode_operations;
1588 struct tree_descr { char *name; struct file_operations *ops; int mode; };
1589 extern int simple_fill_super(struct super_block *, int, struct tree_descr *);
1590 extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count);
1591 extern void simple_release_fs(struct vfsmount **mount, int *count);
1592
1593 extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t);
1594
1595 extern int inode_change_ok(struct inode *, struct iattr *);
1596 extern int __must_check inode_setattr(struct inode *, struct iattr *);
1597
1598 extern void inode_update_time(struct inode *inode, struct vfsmount *mnt, int ctime_too);
1599
1600 static inline ino_t parent_ino(struct dentry *dentry)
1601 {
1602         ino_t res;
1603
1604         spin_lock(&dentry->d_lock);
1605         res = dentry->d_parent->d_inode->i_ino;
1606         spin_unlock(&dentry->d_lock);
1607         return res;
1608 }
1609
1610 /* kernel/fork.c */
1611 extern int unshare_files(void);
1612
1613 /* Transaction based IO helpers */
1614
1615 /*
1616  * An argresp is stored in an allocated page and holds the
1617  * size of the argument or response, along with its content
1618  */
1619 struct simple_transaction_argresp {
1620         ssize_t size;
1621         char data[0];
1622 };
1623
1624 #define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp))
1625
1626 char *simple_transaction_get(struct file *file, const char __user *buf,
1627                                 size_t size);
1628 ssize_t simple_transaction_read(struct file *file, char __user *buf,
1629                                 size_t size, loff_t *pos);
1630 int simple_transaction_release(struct inode *inode, struct file *file);
1631
1632 static inline void simple_transaction_set(struct file *file, size_t n)
1633 {
1634         struct simple_transaction_argresp *ar = file->private_data;
1635
1636         BUG_ON(n > SIMPLE_TRANSACTION_LIMIT);
1637
1638         /*
1639          * The barrier ensures that ar->size will really remain zero until
1640          * ar->data is ready for reading.
1641          */
1642         smp_mb();
1643         ar->size = n;
1644 }
1645
1646 #ifdef CONFIG_SECURITY
1647 static inline char *alloc_secdata(void)
1648 {
1649         return (char *)get_zeroed_page(GFP_KERNEL);
1650 }
1651
1652 static inline void free_secdata(void *secdata)
1653 {
1654         free_page((unsigned long)secdata);
1655 }
1656 #else
1657 static inline char *alloc_secdata(void)
1658 {
1659         return (char *)1;
1660 }
1661
1662 static inline void free_secdata(void *secdata)
1663 { }
1664 #endif  /* CONFIG_SECURITY */
1665
1666 /* io priorities */
1667
1668 #define IOPRIO_NR      21
1669
1670 #define IOPRIO_IDLE     0
1671 #define IOPRIO_NORM     10
1672 #define IOPRIO_RT       20
1673
1674 asmlinkage int sys_ioprio_set(int ioprio);
1675 asmlinkage int sys_ioprio_get(void);
1676
1677 /* common structure for cfq & ckrm I/O controller */
1678 typedef struct cfqlim {
1679         int nskip;
1680         unsigned long navsec;
1681         int timedout;
1682         atomic_t sectorate;
1683         u64 sec[2];
1684 } cfqlim_t ;
1685
1686
1687 #endif /* __KERNEL__ */
1688 #endif /* _LINUX_FS_H */