5 * This file has definitions for some important file table
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>
25 #include <asm/atomic.h>
26 #include <asm/bitops.h>
28 struct poll_table_struct;
32 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
33 * the file limit at runtime and only root can increase the per-process
34 * nr_file rlimit, so it's safe to set up a ridiculously high absolute
35 * upper limit on files-per-process.
37 * Some programs (notably those using select()) may have to be
38 * recompiled to take full advantage of the new limits..
41 /* Fixed constants first: */
43 #define NR_OPEN (1024*1024) /* Absolute upper limit on fd num */
44 #define INR_OPEN 1024 /* Initial setting for nfile rlimits */
46 #define BLOCK_SIZE_BITS 10
47 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
49 /* And dynamically-tunable limits and defaults: */
50 struct files_stat_struct {
51 int nr_files; /* read only */
52 int nr_free_files; /* read only */
53 int max_files; /* tunable */
55 extern struct files_stat_struct files_stat;
57 struct inodes_stat_t {
62 extern struct inodes_stat_t inodes_stat;
64 extern int leases_enable, dir_notify_enable, lease_break_time;
66 #define NR_FILE 8192 /* this can well be larger on a larger system */
67 #define NR_RESERVED_FILES 10 /* reserved for root */
79 #define READA 2 /* read-ahead - don't block if no resources */
80 #define SPECIAL 4 /* For non-blockdevice requests in request queue */
86 /* public flags for file_system_type */
87 #define FS_REQUIRES_DEV 1
88 #define FS_NO_DCACHE 2 /* Only dcache the necessary things. */
89 #define FS_NO_PRELIM 4 /* prevent preloading of dentries, even if
90 * FS_NO_DCACHE is not set.
92 #define FS_SINGLE 8 /* Filesystem that can have only one superblock */
93 #define FS_NOMOUNT 16 /* Never mount from userland */
94 #define FS_LITTER 32 /* Keeps the tree in dcache */
95 #define FS_ODD_RENAME 32768 /* Temporary stuff; will go away as soon
96 * as nfs_rename() will be cleaned up
99 * These are the fs-independent mount-flags: up to 32 flags are supported
101 #define MS_RDONLY 1 /* Mount read-only */
102 #define MS_NOSUID 2 /* Ignore suid and sgid bits */
103 #define MS_NODEV 4 /* Disallow access to device special files */
104 #define MS_NOEXEC 8 /* Disallow program execution */
105 #define MS_SYNCHRONOUS 16 /* Writes are synced at once */
106 #define MS_REMOUNT 32 /* Alter flags of a mounted FS */
107 #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
108 #define MS_NOATIME 1024 /* Do not update access times. */
109 #define MS_NODIRATIME 2048 /* Do not update directory access times */
112 #define MS_NOUSER (1<<31)
115 * Superblock flags that can be altered by MS_REMOUNT
117 #define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
121 * Old magic mount flag and mask
123 #define MS_MGC_VAL 0xC0ED0000
124 #define MS_MGC_MSK 0xffff0000
126 /* Inode flags - they have nothing to superblock flags now */
128 #define S_SYNC 1 /* Writes are synced at once */
129 #define S_NOATIME 2 /* Do not update access times */
130 #define S_QUOTA 4 /* Quota initialized for file */
131 #define S_APPEND 8 /* Append-only file */
132 #define S_IMMUTABLE 16 /* Immutable file */
133 #define S_DEAD 32 /* removed, but still open directory */
134 #define S_NOQUOTA 64 /* Inode is not counted to quota */
137 * Note that nosuid etc flags are inode-specific: setting some file-system
138 * flags just means all the inodes inherit those flags by default. It might be
139 * possible to override it selectively if you really wanted to with some
140 * ioctl() that is not currently implemented.
142 * Exception: MS_RDONLY is always applied to the entire file system.
144 * Unfortunately, it is possible to change a filesystems flags with it mounted
145 * with files in use. This means that all of the inodes will not have their
146 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
147 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
149 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
151 #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
152 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || ((inode)->i_flags & S_SYNC))
153 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
155 #define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
156 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
157 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
158 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
159 #define IS_NOATIME(inode) (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
160 #define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
162 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
164 /* the read-only stuff doesn't really belong here, but any other place is
165 probably as bad and I don't want to create yet another include file. */
167 #define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
168 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
169 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
170 #define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
171 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
172 #define BLKRASET _IO(0x12,98) /* Set read ahead for block device */
173 #define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
174 #define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
175 #define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
176 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
177 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
178 #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
180 #define BLKPG _IO(0x12,105)/* See blkpg.h */
181 #define BLKELVGET _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */
182 #define BLKELVSET _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))/* elevator set */
183 /* This was here just to show that the number is taken -
184 probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
186 /* A jump here: 108-111 have been used for various private purposes. */
187 #define BLKBSZGET _IOR(0x12,112,sizeof(int))
188 #define BLKBSZSET _IOW(0x12,113,sizeof(int))
189 #define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64)) /* return device size in bytes (u64 *arg) */
191 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
192 #define FIBMAP _IO(0x00,1) /* bmap access */
193 #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
197 #include <asm/semaphore.h>
198 #include <asm/byteorder.h>
200 extern void update_atime (struct inode *);
201 #define UPDATE_ATIME(inode) update_atime (inode)
203 extern void buffer_init(unsigned long);
204 extern void inode_init(unsigned long);
205 extern void mnt_init(unsigned long);
209 BH_Uptodate, /* 1 if the buffer contains valid data */
210 BH_Dirty, /* 1 if the buffer is dirty */
211 BH_Lock, /* 1 if the buffer is locked */
212 BH_Req, /* 0 if the buffer has been invalidated */
213 BH_Mapped, /* 1 if the buffer has a disk mapping */
214 BH_New, /* 1 if the buffer is new and not yet written out */
215 BH_Async, /* 1 if the buffer is under end_buffer_io_async I/O */
216 BH_Wait_IO, /* 1 if we should throttle on this buffer */
218 BH_PrivateStart,/* not a state bit, but the first bit available
219 * for private allocation by other entities
224 * Try to keep the most commonly used fields in single cache lines (16
225 * bytes) to improve performance. This ordering should be
226 * particularly beneficial on 32-bit processors.
228 * We use the first 16 bytes for the data which is used in searches
229 * over the block hash lists (ie. getblk() and friends).
231 * The second 16 bytes we use for lru buffer scans, as used by
232 * sync_buffers() and refill_freelist(). -- sct
235 /* First cache line: */
236 struct buffer_head *b_next; /* Hash queue list */
237 unsigned long b_blocknr; /* block number */
238 unsigned short b_size; /* block size */
239 unsigned short b_list; /* List that this buffer appears */
240 kdev_t b_dev; /* device (B_FREE = free) */
242 atomic_t b_count; /* users using this block */
243 kdev_t b_rdev; /* Real device */
244 unsigned long b_state; /* buffer state bitmap (see above) */
245 unsigned long b_flushtime; /* Time when (dirty) buffer should be written */
247 struct buffer_head *b_next_free;/* lru/free list linkage */
248 struct buffer_head *b_prev_free;/* doubly linked list of buffers */
249 struct buffer_head *b_this_page;/* circular list of buffers in one page */
250 struct buffer_head *b_reqnext; /* request queue */
252 struct buffer_head **b_pprev; /* doubly linked list of hash-queue */
253 char * b_data; /* pointer to data block */
254 struct page *b_page; /* the page this bh is mapped to */
255 void (*b_end_io)(struct buffer_head *bh, int uptodate); /* I/O completion */
256 void *b_private; /* reserved for b_end_io */
258 unsigned long b_rsector; /* Real buffer location on disk */
259 wait_queue_head_t b_wait;
261 struct inode * b_inode;
262 struct list_head b_inode_buffers; /* doubly linked list of inode dirty buffers */
265 typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
266 void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
268 #define __buffer_state(bh, state) (((bh)->b_state & (1UL << BH_##state)) != 0)
270 #define buffer_uptodate(bh) __buffer_state(bh,Uptodate)
271 #define buffer_dirty(bh) __buffer_state(bh,Dirty)
272 #define buffer_locked(bh) __buffer_state(bh,Lock)
273 #define buffer_req(bh) __buffer_state(bh,Req)
274 #define buffer_mapped(bh) __buffer_state(bh,Mapped)
275 #define buffer_new(bh) __buffer_state(bh,New)
276 #define buffer_async(bh) __buffer_state(bh,Async)
278 #define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
280 extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long offset);
282 #define touch_buffer(bh) mark_page_accessed(bh->b_page)
285 #include <linux/pipe_fs_i.h>
286 #include <linux/minix_fs_i.h>
287 #include <linux/ext2_fs_i.h>
288 #include <linux/hpfs_fs_i.h>
289 #include <linux/ntfs_fs_i.h>
290 #include <linux/msdos_fs_i.h>
291 #include <linux/umsdos_fs_i.h>
292 #include <linux/iso_fs_i.h>
293 #include <linux/nfs_fs_i.h>
294 #include <linux/sysv_fs_i.h>
295 #include <linux/affs_fs_i.h>
296 #include <linux/ufs_fs_i.h>
297 #include <linux/efs_fs_i.h>
298 #include <linux/coda_fs_i.h>
299 #include <linux/romfs_fs_i.h>
300 #include <linux/shmem_fs.h>
301 #include <linux/smb_fs_i.h>
302 #include <linux/hfs_fs_i.h>
303 #include <linux/adfs_fs_i.h>
304 #include <linux/qnx4_fs_i.h>
305 #include <linux/reiserfs_fs_i.h>
306 #include <linux/bfs_fs_i.h>
307 #include <linux/udf_fs_i.h>
308 #include <linux/ncp_fs_i.h>
309 #include <linux/proc_fs_i.h>
310 #include <linux/usbdev_fs_i.h>
311 #include <linux/jffs2_fs_i.h>
312 #include <linux/cramfs_fs_sb.h>
315 * Attribute flags. These should be or-ed together to figure out what
322 #define ATTR_ATIME 16
323 #define ATTR_MTIME 32
324 #define ATTR_CTIME 64
325 #define ATTR_ATIME_SET 128
326 #define ATTR_MTIME_SET 256
327 #define ATTR_FORCE 512 /* Not a change, but a change it */
328 #define ATTR_ATTR_FLAG 1024
331 * This is the Inode Attributes structure, used for notify_change(). It
332 * uses the above definitions as flags, to know which values have changed.
333 * Also, in this manner, a Filesystem can look at only the values it cares
334 * about. Basically, these are the attributes that the VFS layer can
335 * request to change from the FS layer.
337 * Derek Atkins <warlord@MIT.EDU> 94-10-20
340 unsigned int ia_valid;
348 unsigned int ia_attr_flags;
352 * This is the inode attributes flag definitions
354 #define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
355 #define ATTR_FLAG_NOATIME 2 /* Don't update atime */
356 #define ATTR_FLAG_APPEND 4 /* Append-only file */
357 #define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
358 #define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
361 * Includes for diskquotas and mount structures.
363 #include <linux/quota.h>
364 #include <linux/mount.h>
367 * oh the beauties of C type declarations.
370 struct address_space;
373 struct address_space_operations {
374 int (*writepage)(struct page *);
375 int (*readpage)(struct file *, struct page *);
376 int (*sync_page)(struct page *);
377 int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
378 int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
379 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
380 int (*bmap)(struct address_space *, long);
381 #define KERNEL_HAS_O_DIRECT /* this is for modules out of the kernel */
382 int (*direct_IO)(int, struct inode *, struct kiobuf *, unsigned long, int);
385 struct address_space {
386 struct list_head clean_pages; /* list of clean pages */
387 struct list_head dirty_pages; /* list of dirty pages */
388 struct list_head locked_pages; /* list of locked pages */
389 unsigned long nrpages; /* number of total pages */
390 struct address_space_operations *a_ops; /* methods */
391 struct inode *host; /* owner: inode, block_device */
392 struct vm_area_struct *i_mmap; /* list of private mappings */
393 struct vm_area_struct *i_mmap_shared; /* list of shared mappings */
394 spinlock_t i_shared_lock; /* and spinlock protecting it */
395 int gfp_mask; /* how to allocate the pages */
399 struct list_head hash;
403 struct semaphore sem;
406 struct block_device {
407 struct list_head bd_hash;
409 struct inode * bd_inode;
410 dev_t bd_dev; /* not a kdev_t - it's a search key */
412 const struct block_device_operations *bd_op;
413 struct semaphore bd_sem; /* open/close mutex */
414 struct list_head bd_inodes;
418 struct list_head i_hash;
419 struct list_head i_list;
420 struct list_head i_dentry;
422 struct list_head i_dirty_buffers;
423 struct list_head i_dirty_data_buffers;
437 unsigned int i_blkbits;
438 unsigned long i_blksize;
439 unsigned long i_blocks;
440 unsigned long i_version;
441 struct semaphore i_sem;
442 struct semaphore i_zombie;
443 struct inode_operations *i_op;
444 struct file_operations *i_fop; /* former ->i_op->default_file_ops */
445 struct super_block *i_sb;
446 wait_queue_head_t i_wait;
447 struct file_lock *i_flock;
448 struct address_space *i_mapping;
449 struct address_space i_data;
450 struct dquot *i_dquot[MAXQUOTAS];
451 /* These three should probably be a union */
452 struct list_head i_devices;
453 struct pipe_inode_info *i_pipe;
454 struct block_device *i_bdev;
455 struct char_device *i_cdev;
457 unsigned long i_dnotify_mask; /* Directory notify events */
458 struct dnotify_struct *i_dnotify; /* for directory notifications */
460 unsigned long i_state;
462 unsigned int i_flags;
463 unsigned char i_sock;
465 atomic_t i_writecount;
466 unsigned int i_attr_flags;
469 struct minix_inode_info minix_i;
470 struct ext2_inode_info ext2_i;
471 struct hpfs_inode_info hpfs_i;
472 struct ntfs_inode_info ntfs_i;
473 struct msdos_inode_info msdos_i;
474 struct umsdos_inode_info umsdos_i;
475 struct iso_inode_info isofs_i;
476 struct nfs_inode_info nfs_i;
477 struct sysv_inode_info sysv_i;
478 struct affs_inode_info affs_i;
479 struct ufs_inode_info ufs_i;
480 struct efs_inode_info efs_i;
481 struct romfs_inode_info romfs_i;
482 struct shmem_inode_info shmem_i;
483 struct coda_inode_info coda_i;
484 struct smb_inode_info smbfs_i;
485 struct hfs_inode_info hfs_i;
486 struct adfs_inode_info adfs_i;
487 struct qnx4_inode_info qnx4_i;
488 struct reiserfs_inode_info reiserfs_i;
489 struct bfs_inode_info bfs_i;
490 struct udf_inode_info udf_i;
491 struct ncp_inode_info ncpfs_i;
492 struct proc_inode_info proc_i;
493 struct socket socket_i;
494 struct usbdev_inode_info usbdev_i;
495 struct jffs2_inode_info jffs2_i;
501 int pid; /* pid or -pgrp where SIGIO should be sent */
502 uid_t uid, euid; /* uid/euid of process setting the owner */
503 int signum; /* posix.1b rt signal to be delivered on IO */
507 struct list_head f_list;
508 struct dentry *f_dentry;
509 struct vfsmount *f_vfsmnt;
510 struct file_operations *f_op;
512 unsigned int f_flags;
515 unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
516 struct fown_struct f_owner;
517 unsigned int f_uid, f_gid;
520 unsigned long f_version;
522 /* needed for tty driver, and maybe others */
525 /* preallocated helper kiobuf to speedup O_DIRECT */
526 struct kiobuf *f_iobuf;
529 extern spinlock_t files_lock;
530 #define file_list_lock() spin_lock(&files_lock);
531 #define file_list_unlock() spin_unlock(&files_lock);
533 #define get_file(x) atomic_inc(&(x)->f_count)
534 #define file_count(x) atomic_read(&(x)->f_count)
536 extern int init_private_file(struct file *, struct dentry *, int);
538 #define MAX_NON_LFS ((1UL<<31) - 1)
542 #define FL_BROKEN 4 /* broken flock() emulation */
543 #define FL_ACCESS 8 /* for processes suspended by mandatory locking */
544 #define FL_LOCKD 16 /* lock held by rpc.lockd */
545 #define FL_LEASE 32 /* lease held on this file */
548 * The POSIX file lock owner is determined by
549 * the "struct files_struct" in the thread group
550 * (or NULL for no owner - BSD locks).
552 * Lockd stuffs a "host" pointer into this.
554 typedef struct files_struct *fl_owner_t;
557 struct file_lock *fl_next; /* singly linked list for this inode */
558 struct list_head fl_link; /* doubly linked list of all locks */
559 struct list_head fl_block; /* circular list of blocked processes */
562 wait_queue_head_t fl_wait;
563 struct file *fl_file;
564 unsigned char fl_flags;
565 unsigned char fl_type;
569 void (*fl_notify)(struct file_lock *); /* unblock callback */
570 void (*fl_insert)(struct file_lock *); /* lock insertion callback */
571 void (*fl_remove)(struct file_lock *); /* lock removal callback */
573 struct fasync_struct * fl_fasync; /* for lease break notifications */
576 struct nfs_lock_info nfs_fl;
580 /* The following constant reflects the upper bound of the file/locking space */
582 #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
583 #define OFFSET_MAX INT_LIMIT(loff_t)
584 #define OFFT_OFFSET_MAX INT_LIMIT(off_t)
587 extern struct list_head file_lock_list;
589 #include <linux/fcntl.h>
591 extern int fcntl_getlk(unsigned int, struct flock *);
592 extern int fcntl_setlk(unsigned int, unsigned int, struct flock *);
594 extern int fcntl_getlk64(unsigned int, struct flock64 *);
595 extern int fcntl_setlk64(unsigned int, unsigned int, struct flock64 *);
598 extern void locks_init_lock(struct file_lock *);
599 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
600 extern void locks_remove_posix(struct file *, fl_owner_t);
601 extern void locks_remove_flock(struct file *);
602 extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
603 extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
604 extern void posix_block_lock(struct file_lock *, struct file_lock *);
605 extern void posix_unblock_lock(struct file_lock *);
606 extern int __get_lease(struct inode *inode, unsigned int flags);
607 extern time_t lease_get_mtime(struct inode *);
608 extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
609 extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
611 struct fasync_struct {
614 struct fasync_struct *fa_next; /* singly linked list */
615 struct file *fa_file;
618 #define FASYNC_MAGIC 0x4601
620 /* SMP safe fasync helpers: */
621 extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
622 /* can be called from interrupts */
623 extern void kill_fasync(struct fasync_struct **, int, int);
624 /* only for net: no internal synchronization */
625 extern void __kill_fasync(struct fasync_struct *, int, int);
628 struct dentry *dentry;
629 struct vfsmount *mnt;
635 #define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */
636 #define DQUOT_GRP_ENABLED 0x02 /* Group diskquotas enabled */
638 struct quota_mount_options
640 unsigned int flags; /* Flags for diskquotas on this device */
641 struct semaphore dqio_sem; /* lock device while I/O in progress */
642 struct semaphore dqoff_sem; /* serialize quota_off() and quota_on() on device */
643 struct file *files[MAXQUOTAS]; /* fp's to quotafiles */
644 time_t inode_expire[MAXQUOTAS]; /* expiretime for inode-quota */
645 time_t block_expire[MAXQUOTAS]; /* expiretime for block-quota */
646 char rsquash[MAXQUOTAS]; /* for quotas threat root as any other user */
653 #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
654 #define MNT_DETACH 0x00000002 /* Just detach from the tree */
656 #include <linux/minix_fs_sb.h>
657 #include <linux/ext2_fs_sb.h>
658 #include <linux/hpfs_fs_sb.h>
659 #include <linux/ntfs_fs_sb.h>
660 #include <linux/msdos_fs_sb.h>
661 #include <linux/iso_fs_sb.h>
662 #include <linux/nfs_fs_sb.h>
663 #include <linux/sysv_fs_sb.h>
664 #include <linux/affs_fs_sb.h>
665 #include <linux/ufs_fs_sb.h>
666 #include <linux/efs_fs_sb.h>
667 #include <linux/romfs_fs_sb.h>
668 #include <linux/smb_fs_sb.h>
669 #include <linux/hfs_fs_sb.h>
670 #include <linux/adfs_fs_sb.h>
671 #include <linux/qnx4_fs_sb.h>
672 #include <linux/reiserfs_fs_sb.h>
673 #include <linux/bfs_fs_sb.h>
674 #include <linux/udf_fs_sb.h>
675 #include <linux/ncp_fs_sb.h>
676 #include <linux/usbdev_fs_sb.h>
677 #include <linux/cramfs_fs_sb.h>
678 #include <linux/jffs2_fs_sb.h>
680 extern struct list_head super_blocks;
681 extern spinlock_t sb_lock;
683 #define sb_entry(list) list_entry((list), struct super_block, s_list)
684 #define S_BIAS (1<<30)
686 struct list_head s_list; /* Keep this first */
688 unsigned long s_blocksize;
689 unsigned char s_blocksize_bits;
690 unsigned char s_dirt;
691 unsigned long long s_maxbytes; /* Max file size */
692 struct file_system_type *s_type;
693 struct super_operations *s_op;
694 struct dquot_operations *dq_op;
695 unsigned long s_flags;
696 unsigned long s_magic;
697 struct dentry *s_root;
698 struct rw_semaphore s_umount;
699 struct semaphore s_lock;
703 struct list_head s_dirty; /* dirty inodes */
704 struct list_head s_locked_inodes;/* inodes being synced */
705 struct list_head s_files;
707 struct block_device *s_bdev;
708 struct list_head s_instances;
709 struct quota_mount_options s_dquot; /* Diskquota specific options */
712 struct minix_sb_info minix_sb;
713 struct ext2_sb_info ext2_sb;
714 struct hpfs_sb_info hpfs_sb;
715 struct ntfs_sb_info ntfs_sb;
716 struct msdos_sb_info msdos_sb;
717 struct isofs_sb_info isofs_sb;
718 struct nfs_sb_info nfs_sb;
719 struct sysv_sb_info sysv_sb;
720 struct affs_sb_info affs_sb;
721 struct ufs_sb_info ufs_sb;
722 struct efs_sb_info efs_sb;
723 struct shmem_sb_info shmem_sb;
724 struct romfs_sb_info romfs_sb;
725 struct smb_sb_info smbfs_sb;
726 struct hfs_sb_info hfs_sb;
727 struct adfs_sb_info adfs_sb;
728 struct qnx4_sb_info qnx4_sb;
729 struct reiserfs_sb_info reiserfs_sb;
730 struct bfs_sb_info bfs_sb;
731 struct udf_sb_info udf_sb;
732 struct ncp_sb_info ncpfs_sb;
733 struct usbdev_sb_info usbdevfs_sb;
734 struct jffs2_sb_info jffs2_sb;
735 struct cramfs_sb_info cramfs_sb;
739 * The next field is for VFS *only*. No filesystems have any business
740 * even looking at it. You had been warned.
742 struct semaphore s_vfs_rename_sem; /* Kludge */
744 /* The next field is used by knfsd when converting a (inode number based)
745 * file handle into a dentry. As it builds a path in the dcache tree from
746 * the bottom up, there may for a time be a subpath of dentrys which is not
747 * connected to the main tree. This semaphore ensure that there is only ever
748 * one such free path per filesystem. Note that unconnected files (or other
749 * non-directories) are allowed, but not unconnected diretories.
751 struct semaphore s_nfsd_free_path_sem;
755 * VFS helper functions..
757 extern int vfs_create(struct inode *, struct dentry *, int);
758 extern int vfs_mkdir(struct inode *, struct dentry *, int);
759 extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
760 extern int vfs_symlink(struct inode *, struct dentry *, const char *);
761 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
762 extern int vfs_rmdir(struct inode *, struct dentry *);
763 extern int vfs_unlink(struct inode *, struct dentry *);
764 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
780 * This is the "filldir" function type, used by readdir() to let
781 * the kernel specify what kind of dirent layout it wants to have.
782 * This allows the kernel to read directories into kernel space or
783 * to have different dirent layouts depending on the binary type.
785 typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
787 struct block_device_operations {
788 int (*open) (struct inode *, struct file *);
789 int (*release) (struct inode *, struct file *);
790 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
791 int (*check_media_change) (kdev_t);
792 int (*revalidate) (kdev_t);
797 * read, write, poll, fsync, readv, writev can be called
798 * without the big kernel lock held in all filesystems.
800 struct file_operations {
801 struct module *owner;
802 loff_t (*llseek) (struct file *, loff_t, int);
803 ssize_t (*read) (struct file *, char *, size_t, loff_t *);
804 ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
805 int (*readdir) (struct file *, void *, filldir_t);
806 unsigned int (*poll) (struct file *, struct poll_table_struct *);
807 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
808 int (*mmap) (struct file *, struct vm_area_struct *);
809 int (*open) (struct inode *, struct file *);
810 int (*flush) (struct file *);
811 int (*release) (struct inode *, struct file *);
812 int (*fsync) (struct file *, struct dentry *, int datasync);
813 int (*fasync) (int, struct file *, int);
814 int (*lock) (struct file *, int, struct file_lock *);
815 ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
816 ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
817 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
818 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
821 struct inode_operations {
822 int (*create) (struct inode *,struct dentry *,int);
823 struct dentry * (*lookup) (struct inode *,struct dentry *);
824 int (*link) (struct dentry *,struct inode *,struct dentry *);
825 int (*unlink) (struct inode *,struct dentry *);
826 int (*symlink) (struct inode *,struct dentry *,const char *);
827 int (*mkdir) (struct inode *,struct dentry *,int);
828 int (*rmdir) (struct inode *,struct dentry *);
829 int (*mknod) (struct inode *,struct dentry *,int,int);
830 int (*rename) (struct inode *, struct dentry *,
831 struct inode *, struct dentry *);
832 int (*readlink) (struct dentry *, char *,int);
833 int (*follow_link) (struct dentry *, struct nameidata *);
834 void (*truncate) (struct inode *);
835 int (*permission) (struct inode *, int);
836 int (*revalidate) (struct dentry *);
837 int (*setattr) (struct dentry *, struct iattr *);
838 int (*getattr) (struct dentry *, struct iattr *);
842 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
843 * without the big kernel lock held in all filesystems.
845 struct super_operations {
846 void (*read_inode) (struct inode *);
848 /* reiserfs kludge. reiserfs needs 64 bits of information to
849 ** find an inode. We are using the read_inode2 call to get
850 ** that information. We don't like this, and are waiting on some
851 ** VFS changes for the real solution.
852 ** iget4 calls read_inode2, iff it is defined
854 void (*read_inode2) (struct inode *, void *) ;
855 void (*dirty_inode) (struct inode *);
856 void (*write_inode) (struct inode *, int);
857 void (*put_inode) (struct inode *);
858 void (*delete_inode) (struct inode *);
859 void (*put_super) (struct super_block *);
860 void (*write_super) (struct super_block *);
861 void (*write_super_lockfs) (struct super_block *);
862 void (*unlockfs) (struct super_block *);
863 int (*statfs) (struct super_block *, struct statfs *);
864 int (*remount_fs) (struct super_block *, int *, char *);
865 void (*clear_inode) (struct inode *);
866 void (*umount_begin) (struct super_block *);
868 /* Following are for knfsd to interact with "interesting" filesystems
869 * Currently just reiserfs, but possibly FAT and others later
871 * fh_to_dentry is given a filehandle fragement with length, and a type flag
872 * and must return a dentry for the referenced object or, if "parent" is
873 * set, a dentry for the parent of the object.
874 * If a dentry cannot be found, a "root" dentry should be created and
875 * flaged as DCACHE_NFSD_DISCONNECTED. nfsd_iget is an example implementation.
877 * dentry_to_fh is given a dentry and must generate the filesys specific
878 * part of the file handle. Available length is passed in *lenp and used
879 * length should be returned therein.
880 * If need_parent is set, then dentry_to_fh should encode sufficient information
881 * to find the (current) parent.
882 * dentry_to_fh should return a 1byte "type" which will be passed back in
883 * the fhtype arguement to fh_to_dentry. Type of 0 is reserved.
884 * If filesystem was exportable before the introduction of fh_to_dentry,
885 * types 1 and 2 should be used is that same way as the generic code.
886 * Type 255 means error.
888 * Lengths are in units of 4bytes, not bytes.
890 struct dentry * (*fh_to_dentry)(struct super_block *sb, __u32 *fh, int len, int fhtype, int parent);
891 int (*dentry_to_fh)(struct dentry *, __u32 *fh, int *lenp, int need_parent);
894 /* Inode state bits.. */
895 #define I_DIRTY_SYNC 1 /* Not dirty enough for O_DATASYNC */
896 #define I_DIRTY_DATASYNC 2 /* Data-related inode changes pending */
897 #define I_DIRTY_PAGES 4 /* Data-related inode changes pending */
902 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
904 extern void __mark_inode_dirty(struct inode *, int);
905 static inline void mark_inode_dirty(struct inode *inode)
907 __mark_inode_dirty(inode, I_DIRTY);
910 static inline void mark_inode_dirty_sync(struct inode *inode)
912 __mark_inode_dirty(inode, I_DIRTY_SYNC);
915 static inline void mark_inode_dirty_pages(struct inode *inode)
917 __mark_inode_dirty(inode, I_DIRTY_PAGES);
920 struct dquot_operations {
921 void (*initialize) (struct inode *, short);
922 void (*drop) (struct inode *);
923 int (*alloc_block) (struct inode *, unsigned long, char);
924 int (*alloc_inode) (const struct inode *, unsigned long);
925 void (*free_block) (struct inode *, unsigned long);
926 void (*free_inode) (const struct inode *, unsigned long);
927 int (*transfer) (struct inode *, struct iattr *);
930 struct file_system_type {
933 struct super_block *(*read_super) (struct super_block *, void *, int);
934 struct module *owner;
935 struct file_system_type * next;
936 struct list_head fs_supers;
939 #define DECLARE_FSTYPE(var,type,read,flags) \
940 struct file_system_type var = { \
944 owner: THIS_MODULE, \
947 #define DECLARE_FSTYPE_DEV(var,type,read) \
948 DECLARE_FSTYPE(var,type,read,FS_REQUIRES_DEV)
950 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
951 #define fops_get(fops) \
952 (((fops) && (fops)->owner) \
953 ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
956 #define fops_put(fops) \
958 if ((fops) && (fops)->owner) \
959 __MOD_DEC_USE_COUNT((fops)->owner); \
962 extern int register_filesystem(struct file_system_type *);
963 extern int unregister_filesystem(struct file_system_type *);
964 extern struct vfsmount *kern_mount(struct file_system_type *);
965 extern int may_umount(struct vfsmount *);
966 extern long do_mount(char *, char *, char *, unsigned long, void *);
968 #define kern_umount mntput
970 extern int vfs_statfs(struct super_block *, struct statfs *);
972 /* Return value for VFS lock functions - tells locks.c to lock conventionally
973 * REALLY kosha for root NFS and nfs_lock
975 #define LOCK_USE_CLNT 1
977 #define FLOCK_VERIFY_READ 1
978 #define FLOCK_VERIFY_WRITE 2
980 extern int locks_mandatory_locked(struct inode *);
981 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
984 * Candidates for mandatory locking have the setgid bit set
985 * but no group execute bit - an otherwise meaningless combination.
987 #define MANDATORY_LOCK(inode) \
988 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
990 static inline int locks_verify_locked(struct inode *inode)
992 if (MANDATORY_LOCK(inode))
993 return locks_mandatory_locked(inode);
997 static inline int locks_verify_area(int read_write, struct inode *inode,
998 struct file *filp, loff_t offset,
1001 if (inode->i_flock && MANDATORY_LOCK(inode))
1002 return locks_mandatory_area(read_write, inode, filp, offset, count);
1006 static inline int locks_verify_truncate(struct inode *inode,
1010 if (inode->i_flock && MANDATORY_LOCK(inode))
1011 return locks_mandatory_area(
1012 FLOCK_VERIFY_WRITE, inode, filp,
1013 size < inode->i_size ? size : inode->i_size,
1014 (size < inode->i_size ? inode->i_size - size
1015 : size - inode->i_size)
1020 static inline int get_lease(struct inode *inode, unsigned int mode)
1022 if (inode->i_flock && (inode->i_flock->fl_flags & FL_LEASE))
1023 return __get_lease(inode, mode);
1029 asmlinkage long sys_open(const char *, int, int);
1030 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1031 extern int do_truncate(struct dentry *, loff_t start);
1033 extern struct file *filp_open(const char *, int, int);
1034 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1035 extern int filp_close(struct file *, fl_owner_t id);
1036 extern char * getname(const char *);
1039 extern void vfs_caches_init(unsigned long);
1041 #define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL)
1042 #define putname(name) kmem_cache_free(names_cachep, (void *)(name))
1044 enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW};
1045 extern int register_blkdev(unsigned int, const char *, struct block_device_operations *);
1046 extern int unregister_blkdev(unsigned int, const char *);
1047 extern struct block_device *bdget(dev_t);
1048 extern int bd_acquire(struct inode *inode);
1049 extern void bd_forget(struct inode *inode);
1050 extern void bdput(struct block_device *);
1051 extern struct char_device *cdget(dev_t);
1052 extern void cdput(struct char_device *);
1053 extern int blkdev_open(struct inode *, struct file *);
1054 extern int blkdev_close(struct inode *, struct file *);
1055 extern struct file_operations def_blk_fops;
1056 extern struct address_space_operations def_blk_aops;
1057 extern struct file_operations def_fifo_fops;
1058 extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1059 extern int blkdev_get(struct block_device *, mode_t, unsigned, int);
1060 extern int blkdev_put(struct block_device *, int);
1063 extern const struct block_device_operations *get_blkfops(unsigned int);
1064 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
1065 extern int unregister_chrdev(unsigned int, const char *);
1066 extern int chrdev_open(struct inode *, struct file *);
1067 extern const char * bdevname(kdev_t);
1068 extern const char * cdevname(kdev_t);
1069 extern const char * kdevname(kdev_t);
1070 extern void init_special_inode(struct inode *, umode_t, int);
1072 /* Invalid inode operations -- fs/bad_inode.c */
1073 extern void make_bad_inode(struct inode *);
1074 extern int is_bad_inode(struct inode *);
1076 extern struct file_operations read_fifo_fops;
1077 extern struct file_operations write_fifo_fops;
1078 extern struct file_operations rdwr_fifo_fops;
1079 extern struct file_operations read_pipe_fops;
1080 extern struct file_operations write_pipe_fops;
1081 extern struct file_operations rdwr_pipe_fops;
1083 extern int fs_may_remount_ro(struct super_block *);
1085 extern int try_to_free_buffers(struct page *, unsigned int);
1086 extern void refile_buffer(struct buffer_head * buf);
1087 extern void end_buffer_io_sync(struct buffer_head *bh, int uptodate);
1089 /* reiserfs_writepage needs this */
1090 extern void set_buffer_async_io(struct buffer_head *bh) ;
1093 #define BUF_LOCKED 1 /* Buffers scheduled for write */
1094 #define BUF_DIRTY 2 /* Dirty buffers, not yet scheduled for write */
1097 static inline void get_bh(struct buffer_head * bh)
1099 atomic_inc(&(bh)->b_count);
1102 static inline void put_bh(struct buffer_head *bh)
1104 smp_mb__before_atomic_dec();
1105 atomic_dec(&bh->b_count);
1109 * This is called by bh->b_end_io() handlers when I/O has completed.
1111 static inline void mark_buffer_uptodate(struct buffer_head * bh, int on)
1114 set_bit(BH_Uptodate, &bh->b_state);
1116 clear_bit(BH_Uptodate, &bh->b_state);
1119 #define atomic_set_buffer_clean(bh) test_and_clear_bit(BH_Dirty, &(bh)->b_state)
1121 static inline void __mark_buffer_clean(struct buffer_head *bh)
1126 static inline void mark_buffer_clean(struct buffer_head * bh)
1128 if (atomic_set_buffer_clean(bh))
1129 __mark_buffer_clean(bh);
1132 extern void FASTCALL(__mark_dirty(struct buffer_head *bh));
1133 extern void FASTCALL(__mark_buffer_dirty(struct buffer_head *bh));
1134 extern void FASTCALL(mark_buffer_dirty(struct buffer_head *bh));
1135 extern void FASTCALL(buffer_insert_inode_data_queue(struct buffer_head *, struct inode *));
1137 #define atomic_set_buffer_dirty(bh) test_and_set_bit(BH_Dirty, &(bh)->b_state)
1139 static inline void mark_buffer_async(struct buffer_head * bh, int on)
1142 set_bit(BH_Async, &bh->b_state);
1144 clear_bit(BH_Async, &bh->b_state);
1148 * If an error happens during the make_request, this function
1149 * has to be recalled. It marks the buffer as clean and not
1150 * uptodate, and it notifys the upper layer about the end
1153 static inline void buffer_IO_error(struct buffer_head * bh)
1155 mark_buffer_clean(bh);
1157 * b_end_io has to clear the BH_Uptodate bitflag in the error case!
1159 bh->b_end_io(bh, 0);
1162 extern void buffer_insert_inode_queue(struct buffer_head *, struct inode *);
1163 static inline void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
1165 mark_buffer_dirty(bh);
1166 buffer_insert_inode_queue(bh, inode);
1169 extern void balance_dirty(void);
1170 extern int check_disk_change(kdev_t);
1171 extern int invalidate_inodes(struct super_block *);
1172 extern int invalidate_device(kdev_t, int);
1173 extern void invalidate_inode_pages(struct inode *);
1174 extern void invalidate_inode_pages2(struct address_space *);
1175 extern void invalidate_inode_buffers(struct inode *);
1176 #define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
1177 #define destroy_buffers(dev) __invalidate_buffers((dev), 1)
1178 extern void invalidate_bdev(struct block_device *, int);
1179 extern void __invalidate_buffers(kdev_t dev, int);
1180 extern void sync_inodes(kdev_t);
1181 extern void sync_unlocked_inodes(void);
1182 extern void write_inode_now(struct inode *, int);
1183 extern int sync_buffers(kdev_t, int);
1184 extern void sync_dev(kdev_t);
1185 extern int fsync_dev(kdev_t);
1186 extern int fsync_super(struct super_block *);
1187 extern int fsync_no_super(kdev_t);
1188 extern void sync_inodes_sb(struct super_block *);
1189 extern int osync_inode_buffers(struct inode *);
1190 extern int osync_inode_data_buffers(struct inode *);
1191 extern int fsync_inode_buffers(struct inode *);
1192 extern int fsync_inode_data_buffers(struct inode *);
1193 extern int inode_has_buffers(struct inode *);
1194 extern void filemap_fdatasync(struct address_space *);
1195 extern void filemap_fdatawait(struct address_space *);
1196 extern void sync_supers(kdev_t);
1197 extern int bmap(struct inode *, int);
1198 extern int notify_change(struct dentry *, struct iattr *);
1199 extern int permission(struct inode *, int);
1200 extern int vfs_permission(struct inode *, int);
1201 extern int get_write_access(struct inode *);
1202 extern int deny_write_access(struct file *);
1203 static inline void put_write_access(struct inode * inode)
1205 atomic_dec(&inode->i_writecount);
1207 static inline void allow_write_access(struct file *file)
1210 atomic_inc(&file->f_dentry->d_inode->i_writecount);
1212 extern int do_pipe(int *);
1214 extern int open_namei(const char *, int, int, struct nameidata *);
1216 extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
1217 extern struct file * open_exec(const char *);
1219 /* fs/dcache.c -- generic fs support functions */
1220 extern int is_subdir(struct dentry *, struct dentry *);
1221 extern ino_t find_inode_number(struct dentry *, struct qstr *);
1224 * Kernel pointers have redundant information, so we can use a
1225 * scheme where we can return either an error code or a dentry
1226 * pointer with the same return value.
1228 * This should be a per-architecture thing, to allow different
1229 * error and pointer decisions.
1231 static inline void *ERR_PTR(long error)
1233 return (void *) error;
1236 static inline long PTR_ERR(const void *ptr)
1241 static inline long IS_ERR(const void *ptr)
1243 return (unsigned long)ptr > (unsigned long)-1000L;
1247 * The bitmask for a lookup event:
1248 * - follow links at the end
1249 * - require a directory
1250 * - ending slashes ok even for nonexistent files
1251 * - internal "there are more path compnents" flag
1253 #define LOOKUP_FOLLOW (1)
1254 #define LOOKUP_DIRECTORY (2)
1255 #define LOOKUP_CONTINUE (4)
1256 #define LOOKUP_POSITIVE (8)
1257 #define LOOKUP_PARENT (16)
1258 #define LOOKUP_NOALT (32)
1260 * Type of the last component on LOOKUP_PARENT
1262 enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
1265 * "descriptor" for what we're up to with a read for sendfile().
1266 * This allows us to use the same read code yet
1267 * have multiple different users of the data that
1268 * we read from a file.
1270 * The simplest case just copies the data to user
1278 } read_descriptor_t;
1280 typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
1282 /* needed for stackable file system support */
1283 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1285 extern int __user_walk(const char *, unsigned, struct nameidata *);
1286 extern int path_init(const char *, unsigned, struct nameidata *);
1287 extern int path_walk(const char *, struct nameidata *);
1288 extern void path_release(struct nameidata *);
1289 extern int follow_down(struct vfsmount **, struct dentry **);
1290 extern int follow_up(struct vfsmount **, struct dentry **);
1291 extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
1292 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1293 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1294 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1296 extern void iput(struct inode *);
1297 extern void force_delete(struct inode *);
1298 extern struct inode * igrab(struct inode *);
1299 extern ino_t iunique(struct super_block *, ino_t);
1301 typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
1302 extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
1303 static inline struct inode *iget(struct super_block *sb, unsigned long ino)
1305 return iget4(sb, ino, NULL, NULL);
1308 extern void clear_inode(struct inode *);
1309 extern struct inode * get_empty_inode(void);
1311 static inline struct inode * new_inode(struct super_block *sb)
1313 struct inode *inode = get_empty_inode();
1316 inode->i_dev = sb->s_dev;
1317 inode->i_blkbits = sb->s_blocksize_bits;
1321 extern void remove_suid(struct inode *inode);
1323 extern void insert_inode_hash(struct inode *);
1324 extern void remove_inode_hash(struct inode *);
1325 extern struct file * get_empty_filp(void);
1326 extern void file_move(struct file *f, struct list_head *list);
1327 extern struct buffer_head * get_hash_table(kdev_t, int, int);
1328 extern struct buffer_head * getblk(kdev_t, int, int);
1329 extern void ll_rw_block(int, int, struct buffer_head * bh[]);
1330 extern void submit_bh(int, struct buffer_head *);
1331 extern int is_read_only(kdev_t);
1332 extern void __brelse(struct buffer_head *);
1333 static inline void brelse(struct buffer_head *buf)
1338 extern void __bforget(struct buffer_head *);
1339 static inline void bforget(struct buffer_head *buf)
1344 extern int set_blocksize(kdev_t, int);
1345 extern struct buffer_head * bread(kdev_t, int, int);
1346 extern void wakeup_bdflush(void);
1348 extern int brw_page(int, struct page *, kdev_t, int [], int);
1350 typedef int (get_block_t)(struct inode*,long,struct buffer_head*,int);
1352 /* Generic buffer handling for block filesystems.. */
1353 extern int discard_bh_page(struct page *, unsigned long, int);
1354 #define block_flushpage(page, offset) discard_bh_page(page, offset, 1)
1355 #define block_invalidate_page(page) discard_bh_page(page, 0, 0)
1356 extern int block_symlink(struct inode *, const char *, int);
1357 extern int block_write_full_page(struct page*, get_block_t*);
1358 extern int block_read_full_page(struct page*, get_block_t*);
1359 extern int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
1360 extern int cont_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
1362 extern int block_commit_write(struct page *page, unsigned from, unsigned to);
1363 extern int block_sync_page(struct page *);
1365 int generic_block_bmap(struct address_space *, long, get_block_t *);
1366 int generic_commit_write(struct file *, struct page *, unsigned, unsigned);
1367 int block_truncate_page(struct address_space *, loff_t, get_block_t *);
1368 extern void create_empty_buffers(struct page *, kdev_t, unsigned long);
1370 extern int waitfor_one_page(struct page*);
1371 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
1372 extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
1373 extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
1374 extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *);
1375 extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, read_actor_t);
1376 extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
1377 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
1378 extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
1379 extern int generic_file_open(struct inode * inode, struct file * filp);
1381 extern struct file_operations generic_ro_fops;
1383 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1384 extern int vfs_follow_link(struct nameidata *, const char *);
1385 extern int page_readlink(struct dentry *, char *, int);
1386 extern int page_follow_link(struct dentry *, struct nameidata *);
1387 extern struct inode_operations page_symlink_inode_operations;
1389 extern int vfs_readdir(struct file *, filldir_t, void *);
1390 extern int dcache_readdir(struct file *, void *, filldir_t);
1392 extern struct file_system_type *get_fs_type(const char *name);
1393 extern struct super_block *get_super(kdev_t);
1394 extern void drop_super(struct super_block *sb);
1395 static inline int is_mounted(kdev_t dev)
1397 struct super_block *sb = get_super(dev);
1404 unsigned long generate_cluster(kdev_t, int b[], int);
1405 unsigned long generate_cluster_swab32(kdev_t, int b[], int);
1406 extern kdev_t ROOT_DEV;
1407 extern char root_device_name[];
1410 extern void show_buffers(void);
1411 extern void mount_root(void);
1413 #ifdef CONFIG_BLK_DEV_INITRD
1414 extern kdev_t real_root_dev;
1415 extern int change_root(kdev_t, const char *);
1418 extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
1419 extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
1420 extern int read_ahead[];
1422 extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
1423 extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
1425 extern int file_fsync(struct file *, struct dentry *, int);
1426 extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start_idx, unsigned long end_idx);
1427 extern int generic_osync_inode(struct inode *, int);
1428 #define OSYNC_METADATA (1<<0)
1429 #define OSYNC_DATA (1<<1)
1430 #define OSYNC_INODE (1<<2)
1432 extern int inode_change_ok(struct inode *, struct iattr *);
1433 extern int inode_setattr(struct inode *, struct iattr *);
1436 * Common dentry functions for inclusion in the VFS
1437 * or in other stackable file systems. Some of these
1438 * functions were in linux/fs/ C (VFS) files.
1443 * Locking the parent is needed to:
1444 * - serialize directory operations
1445 * - make sure the parent doesn't change from
1446 * under us in the middle of an operation.
1448 * NOTE! Right now we'd rather use a "struct inode"
1449 * for this, but as I expect things to move toward
1450 * using dentries instead for most things it is
1451 * probably better to start with the conceptually
1452 * better interface of relying on a path of dentries.
1454 static inline struct dentry *lock_parent(struct dentry *dentry)
1456 struct dentry *dir = dget(dentry->d_parent);
1458 down(&dir->d_inode->i_sem);
1462 static inline struct dentry *get_parent(struct dentry *dentry)
1464 return dget(dentry->d_parent);
1467 static inline void unlock_dir(struct dentry *dir)
1469 up(&dir->d_inode->i_sem);
1474 * Whee.. Deadlock country. Happily there are only two VFS
1475 * operations that does this..
1477 static inline void double_down(struct semaphore *s1, struct semaphore *s2)
1480 if ((unsigned long) s1 < (unsigned long) s2) {
1481 struct semaphore *tmp = s2;
1490 * Ewwwwwwww... _triple_ lock. We are guaranteed that the 3rd argument is
1491 * not equal to 1st and not equal to 2nd - the first case (target is parent of
1492 * source) would be already caught, the second is plain impossible (target is
1493 * its own parent and that case would be caught even earlier). Very messy.
1494 * I _think_ that it works, but no warranties - please, look it through.
1495 * Pox on bloody lusers who mandated overwriting rename() for directories...
1498 static inline void triple_down(struct semaphore *s1,
1499 struct semaphore *s2,
1500 struct semaphore *s3)
1503 if ((unsigned long) s1 < (unsigned long) s2) {
1504 if ((unsigned long) s1 < (unsigned long) s3) {
1505 struct semaphore *tmp = s3;
1508 if ((unsigned long) s1 < (unsigned long) s2) {
1509 struct semaphore *tmp = s2;
1513 if ((unsigned long) s1 < (unsigned long) s3) {
1514 struct semaphore *tmp = s3;
1517 if ((unsigned long) s2 < (unsigned long) s3) {
1518 struct semaphore *tmp = s3;
1523 } else if ((unsigned long) s2 < (unsigned long) s3) {
1524 struct semaphore *tmp = s3;
1531 static inline void double_up(struct semaphore *s1, struct semaphore *s2)
1538 static inline void triple_up(struct semaphore *s1,
1539 struct semaphore *s2,
1540 struct semaphore *s3)
1548 static inline void double_lock(struct dentry *d1, struct dentry *d2)
1550 double_down(&d1->d_inode->i_sem, &d2->d_inode->i_sem);
1553 static inline void double_unlock(struct dentry *d1, struct dentry *d2)
1555 double_up(&d1->d_inode->i_sem,&d2->d_inode->i_sem);
1560 #endif /* __KERNEL__ */
1562 #endif /* _LINUX_FS_H */