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
;
56 extern int max_super_blocks
, nr_super_blocks
;
57 extern int leases_enable
, dir_notify_enable
, lease_break_time
;
59 #define NR_FILE 8192 /* this can well be larger on a larger system */
60 #define NR_RESERVED_FILES 10 /* reserved for root */
72 #define READA 2 /* read-ahead - don't block if no resources */
73 #define SPECIAL 4 /* For non-blockdevice requests in request queue */
79 /* public flags for file_system_type */
80 #define FS_REQUIRES_DEV 1
81 #define FS_NO_DCACHE 2 /* Only dcache the necessary things. */
82 #define FS_NO_PRELIM 4 /* prevent preloading of dentries, even if
83 * FS_NO_DCACHE is not set.
85 #define FS_SINGLE 8 /*
86 * Filesystem that can have only one superblock;
87 * kernel-wide vfsmnt is placed in ->kern_mnt by
88 * kern_mount() which must be called _after_
89 * register_filesystem().
91 #define FS_NOMOUNT 16 /* Never mount from userland */
92 #define FS_LITTER 32 /* Keeps the tree in dcache */
93 #define FS_ODD_RENAME 32768 /* Temporary stuff; will go away as soon
94 * as nfs_rename() will be cleaned up
97 * These are the fs-independent mount-flags: up to 32 flags are supported
99 #define MS_RDONLY 1 /* Mount read-only */
100 #define MS_NOSUID 2 /* Ignore suid and sgid bits */
101 #define MS_NODEV 4 /* Disallow access to device special files */
102 #define MS_NOEXEC 8 /* Disallow program execution */
103 #define MS_SYNCHRONOUS 16 /* Writes are synced at once */
104 #define MS_REMOUNT 32 /* Alter flags of a mounted FS */
105 #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
106 #define MS_NOATIME 1024 /* Do not update access times. */
107 #define MS_NODIRATIME 2048 /* Do not update directory access times */
111 * Flags that can be altered by MS_REMOUNT
113 #define MS_RMT_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|\
114 MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
117 * Magic mount flag number. Has to be or-ed to the flag values.
119 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
120 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
122 /* Inode flags - they have nothing to superblock flags now */
124 #define S_SYNC 1 /* Writes are synced at once */
125 #define S_NOATIME 2 /* Do not update access times */
126 #define S_QUOTA 4 /* Quota initialized for file */
127 #define S_APPEND 8 /* Append-only file */
128 #define S_IMMUTABLE 16 /* Immutable file */
129 #define S_DEAD 32 /* removed, but still open directory */
132 * Note that nosuid etc flags are inode-specific: setting some file-system
133 * flags just means all the inodes inherit those flags by default. It might be
134 * possible to override it selectively if you really wanted to with some
135 * ioctl() that is not currently implemented.
137 * Exception: MS_RDONLY is always applied to the entire file system.
139 * Unfortunately, it is possible to change a filesystems flags with it mounted
140 * with files in use. This means that all of the inodes will not have their
141 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
142 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
144 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
146 #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
147 #define IS_NOSUID(inode) __IS_FLG(inode, MS_NOSUID)
148 #define IS_NODEV(inode) __IS_FLG(inode, MS_NODEV)
149 #define IS_NOEXEC(inode) __IS_FLG(inode, MS_NOEXEC)
150 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || ((inode)->i_flags & S_SYNC))
151 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
153 #define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
154 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
155 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
156 #define IS_NOATIME(inode) (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
157 #define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
159 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
161 /* the read-only stuff doesn't really belong here, but any other place is
162 probably as bad and I don't want to create yet another include file. */
164 #define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
165 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
166 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
167 #define BLKGETSIZE _IO(0x12,96) /* return device size */
168 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
169 #define BLKRASET _IO(0x12,98) /* Set read ahead for block device */
170 #define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
171 #define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
172 #define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
173 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
174 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
175 #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
177 #define BLKPG _IO(0x12,105)/* See blkpg.h */
178 #define BLKELVGET _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */
179 #define BLKELVSET _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))/* elevator set */
180 /* This was here just to show that the number is taken -
181 probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
185 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
186 #define FIBMAP _IO(0x00,1) /* bmap access */
187 #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
191 #include <asm/semaphore.h>
192 #include <asm/byteorder.h>
194 extern void update_atime (struct inode
*);
195 #define UPDATE_ATIME(inode) update_atime (inode)
197 extern void buffer_init(unsigned long);
198 extern void inode_init(unsigned long);
201 #define BH_Uptodate 0 /* 1 if the buffer contains valid data */
202 #define BH_Dirty 1 /* 1 if the buffer is dirty */
203 #define BH_Lock 2 /* 1 if the buffer is locked */
204 #define BH_Req 3 /* 0 if the buffer has been invalidated */
205 #define BH_Mapped 4 /* 1 if the buffer has a disk mapping */
206 #define BH_New 5 /* 1 if the buffer is new and not yet written out */
207 #define BH_Protected 6 /* 1 if the buffer is protected */
210 * Try to keep the most commonly used fields in single cache lines (16
211 * bytes) to improve performance. This ordering should be
212 * particularly beneficial on 32-bit processors.
214 * We use the first 16 bytes for the data which is used in searches
215 * over the block hash lists (ie. getblk() and friends).
217 * The second 16 bytes we use for lru buffer scans, as used by
218 * sync_buffers() and refill_freelist(). -- sct
221 /* First cache line: */
222 struct buffer_head
*b_next
; /* Hash queue list */
223 unsigned long b_blocknr
; /* block number */
224 unsigned short b_size
; /* block size */
225 unsigned short b_list
; /* List that this buffer appears */
226 kdev_t b_dev
; /* device (B_FREE = free) */
228 atomic_t b_count
; /* users using this block */
229 kdev_t b_rdev
; /* Real device */
230 unsigned long b_state
; /* buffer state bitmap (see above) */
231 unsigned long b_flushtime
; /* Time when (dirty) buffer should be written */
233 struct buffer_head
*b_next_free
;/* lru/free list linkage */
234 struct buffer_head
*b_prev_free
;/* doubly linked list of buffers */
235 struct buffer_head
*b_this_page
;/* circular list of buffers in one page */
236 struct buffer_head
*b_reqnext
; /* request queue */
238 struct buffer_head
**b_pprev
; /* doubly linked list of hash-queue */
239 char * b_data
; /* pointer to data block (512 byte) */
240 struct page
*b_page
; /* the page this bh is mapped to */
241 void (*b_end_io
)(struct buffer_head
*bh
, int uptodate
); /* I/O completion */
242 void *b_private
; /* reserved for b_end_io */
244 unsigned long b_rsector
; /* Real buffer location on disk */
245 wait_queue_head_t b_wait
;
247 struct inode
* b_inode
;
248 struct list_head b_inode_buffers
; /* doubly linked list of inode dirty buffers */
251 typedef void (bh_end_io_t
)(struct buffer_head
*bh
, int uptodate
);
252 void init_buffer(struct buffer_head
*, bh_end_io_t
*, void *);
254 #define __buffer_state(bh, state) (((bh)->b_state & (1UL << BH_##state)) != 0)
256 #define buffer_uptodate(bh) __buffer_state(bh,Uptodate)
257 #define buffer_dirty(bh) __buffer_state(bh,Dirty)
258 #define buffer_locked(bh) __buffer_state(bh,Lock)
259 #define buffer_req(bh) __buffer_state(bh,Req)
260 #define buffer_mapped(bh) __buffer_state(bh,Mapped)
261 #define buffer_new(bh) __buffer_state(bh,New)
262 #define buffer_protected(bh) __buffer_state(bh,Protected)
264 #define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
266 extern void set_bh_page(struct buffer_head
*bh
, struct page
*page
, unsigned long offset
);
268 #define touch_buffer(bh) SetPageReferenced(bh->b_page)
271 #include <linux/pipe_fs_i.h>
272 #include <linux/minix_fs_i.h>
273 #include <linux/ext2_fs_i.h>
274 #include <linux/hpfs_fs_i.h>
275 #include <linux/ntfs_fs_i.h>
276 #include <linux/msdos_fs_i.h>
277 #include <linux/umsdos_fs_i.h>
278 #include <linux/iso_fs_i.h>
279 #include <linux/nfs_fs_i.h>
280 #include <linux/sysv_fs_i.h>
281 #include <linux/affs_fs_i.h>
282 #include <linux/ufs_fs_i.h>
283 #include <linux/efs_fs_i.h>
284 #include <linux/coda_fs_i.h>
285 #include <linux/romfs_fs_i.h>
286 #include <linux/smb_fs_i.h>
287 #include <linux/hfs_fs_i.h>
288 #include <linux/adfs_fs_i.h>
289 #include <linux/qnx4_fs_i.h>
290 #include <linux/bfs_fs_i.h>
291 #include <linux/udf_fs_i.h>
292 #include <linux/ncp_fs_i.h>
293 #include <linux/proc_fs_i.h>
294 #include <linux/usbdev_fs_i.h>
297 * Attribute flags. These should be or-ed together to figure out what
304 #define ATTR_ATIME 16
305 #define ATTR_MTIME 32
306 #define ATTR_CTIME 64
307 #define ATTR_ATIME_SET 128
308 #define ATTR_MTIME_SET 256
309 #define ATTR_FORCE 512 /* Not a change, but a change it */
310 #define ATTR_ATTR_FLAG 1024
313 * This is the Inode Attributes structure, used for notify_change(). It
314 * uses the above definitions as flags, to know which values have changed.
315 * Also, in this manner, a Filesystem can look at only the values it cares
316 * about. Basically, these are the attributes that the VFS layer can
317 * request to change from the FS layer.
319 * Derek Atkins <warlord@MIT.EDU> 94-10-20
322 unsigned int ia_valid
;
330 unsigned int ia_attr_flags
;
334 * This is the inode attributes flag definitions
336 #define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
337 #define ATTR_FLAG_NOATIME 2 /* Don't update atime */
338 #define ATTR_FLAG_APPEND 4 /* Append-only file */
339 #define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
340 #define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
343 * Includes for diskquotas and mount structures.
345 #include <linux/quota.h>
346 #include <linux/mount.h>
349 * oh the beauties of C type declarations.
352 struct address_space
;
354 struct address_space_operations
{
355 int (*writepage
)(struct page
*);
356 int (*readpage
)(struct file
*, struct page
*);
357 int (*sync_page
)(struct page
*);
358 int (*prepare_write
)(struct file
*, struct page
*, unsigned, unsigned);
359 int (*commit_write
)(struct file
*, struct page
*, unsigned, unsigned);
360 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
361 int (*bmap
)(struct address_space
*, long);
364 struct address_space
{
365 struct list_head pages
; /* list of pages */
366 unsigned long nrpages
; /* number of pages */
367 struct address_space_operations
*a_ops
; /* methods */
368 void *host
; /* owner: inode, block_device */
369 struct vm_area_struct
*i_mmap
; /* list of private mappings */
370 struct vm_area_struct
*i_mmap_shared
; /* list of shared mappings */
371 spinlock_t i_shared_lock
; /* and spinlock protecting it */
374 struct block_device
{
375 struct list_head bd_hash
;
377 /* struct address_space bd_data; */
378 dev_t bd_dev
; /* not a kdev_t - it's a search key */
380 const struct block_device_operations
*bd_op
;
381 struct semaphore bd_sem
; /* open/close mutex */
385 struct list_head i_hash
;
386 struct list_head i_list
;
387 struct list_head i_dentry
;
389 struct list_head i_dirty_buffers
;
403 unsigned long i_blksize
;
404 unsigned long i_blocks
;
405 unsigned long i_version
;
406 struct semaphore i_sem
;
407 struct semaphore i_zombie
;
408 struct inode_operations
*i_op
;
409 struct file_operations
*i_fop
; /* former ->i_op->default_file_ops */
410 struct super_block
*i_sb
;
411 wait_queue_head_t i_wait
;
412 struct file_lock
*i_flock
;
413 struct address_space
*i_mapping
;
414 struct address_space i_data
;
415 struct dquot
*i_dquot
[MAXQUOTAS
];
416 struct pipe_inode_info
*i_pipe
;
417 struct block_device
*i_bdev
;
419 unsigned long i_dnotify_mask
; /* Directory notify events */
420 struct dnotify_struct
*i_dnotify
; /* for directory notifications */
422 unsigned long i_state
;
424 unsigned int i_flags
;
425 unsigned char i_sock
;
427 atomic_t i_writecount
;
428 unsigned int i_attr_flags
;
431 struct minix_inode_info minix_i
;
432 struct ext2_inode_info ext2_i
;
433 struct hpfs_inode_info hpfs_i
;
434 struct ntfs_inode_info ntfs_i
;
435 struct msdos_inode_info msdos_i
;
436 struct umsdos_inode_info umsdos_i
;
437 struct iso_inode_info isofs_i
;
438 struct nfs_inode_info nfs_i
;
439 struct sysv_inode_info sysv_i
;
440 struct affs_inode_info affs_i
;
441 struct ufs_inode_info ufs_i
;
442 struct efs_inode_info efs_i
;
443 struct romfs_inode_info romfs_i
;
444 struct coda_inode_info coda_i
;
445 struct smb_inode_info smbfs_i
;
446 struct hfs_inode_info hfs_i
;
447 struct adfs_inode_info adfs_i
;
448 struct qnx4_inode_info qnx4_i
;
449 struct bfs_inode_info bfs_i
;
450 struct udf_inode_info udf_i
;
451 struct ncp_inode_info ncpfs_i
;
452 struct proc_inode_info proc_i
;
453 struct socket socket_i
;
454 struct usbdev_inode_info usbdev_i
;
459 /* Inode state bits.. */
460 #define I_DIRTY_SYNC 1 /* Not dirty enough for O_DATASYNC */
461 #define I_DIRTY_DATASYNC 2 /* Data-related inode changes pending */
466 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
468 extern void __mark_inode_dirty(struct inode
*, int);
469 static inline void mark_inode_dirty(struct inode
*inode
)
471 if ((inode
->i_state
& I_DIRTY
) != I_DIRTY
)
472 __mark_inode_dirty(inode
, I_DIRTY
);
475 static inline void mark_inode_dirty_sync(struct inode
*inode
)
477 if (!(inode
->i_state
& I_DIRTY_SYNC
))
478 __mark_inode_dirty(inode
, I_DIRTY_SYNC
);
482 int pid
; /* pid or -pgrp where SIGIO should be sent */
483 uid_t uid
, euid
; /* uid/euid of process setting the owner */
484 int signum
; /* posix.1b rt signal to be delivered on IO */
488 struct list_head f_list
;
489 struct dentry
*f_dentry
;
490 struct vfsmount
*f_vfsmnt
;
491 struct file_operations
*f_op
;
493 unsigned int f_flags
;
496 unsigned long f_reada
, f_ramax
, f_raend
, f_ralen
, f_rawin
;
497 struct fown_struct f_owner
;
498 unsigned int f_uid
, f_gid
;
501 unsigned long f_version
;
503 /* needed for tty driver, and maybe others */
506 extern spinlock_t files_lock
;
507 #define file_list_lock() spin_lock(&files_lock);
508 #define file_list_unlock() spin_unlock(&files_lock);
510 #define get_file(x) atomic_inc(&(x)->f_count)
511 #define file_count(x) atomic_read(&(x)->f_count)
513 extern int init_private_file(struct file
*, struct dentry
*, int);
517 #define FL_BROKEN 4 /* broken flock() emulation */
518 #define FL_ACCESS 8 /* for processes suspended by mandatory locking */
519 #define FL_LOCKD 16 /* lock held by rpc.lockd */
520 #define FL_LEASE 32 /* lease held on this file */
523 * The POSIX file lock owner is determined by
524 * the "struct files_struct" in the thread group
525 * (or NULL for no owner - BSD locks).
527 * Lockd stuffs a "host" pointer into this.
529 typedef struct files_struct
*fl_owner_t
;
532 struct file_lock
*fl_next
; /* singly linked list for this inode */
533 struct list_head fl_link
; /* doubly linked list of all locks */
534 struct list_head fl_block
; /* circular list of blocked processes */
537 wait_queue_head_t fl_wait
;
538 struct file
*fl_file
;
539 unsigned char fl_flags
;
540 unsigned char fl_type
;
544 void (*fl_notify
)(struct file_lock
*); /* unblock callback */
545 void (*fl_insert
)(struct file_lock
*); /* lock insertion callback */
546 void (*fl_remove
)(struct file_lock
*); /* lock removal callback */
548 struct fasync_struct
* fl_fasync
; /* for lease break notifications */
551 struct nfs_lock_info nfs_fl
;
555 /* The following constant reflects the upper bound of the file/locking space */
557 #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
558 #define OFFSET_MAX INT_LIMIT(loff_t)
559 #define OFFT_OFFSET_MAX INT_LIMIT(off_t)
562 extern struct list_head file_lock_list
;
564 #include <linux/fcntl.h>
566 extern int fcntl_getlk(unsigned int, struct flock
*);
567 extern int fcntl_setlk(unsigned int, unsigned int, struct flock
*);
569 extern int fcntl_getlk64(unsigned int, struct flock64
*);
570 extern int fcntl_setlk64(unsigned int, unsigned int, struct flock64
*);
573 extern void locks_init_lock(struct file_lock
*);
574 extern void locks_copy_lock(struct file_lock
*, struct file_lock
*);
575 extern void locks_remove_posix(struct file
*, fl_owner_t
);
576 extern void locks_remove_flock(struct file
*);
577 extern struct file_lock
*posix_test_lock(struct file
*, struct file_lock
*);
578 extern int posix_lock_file(struct file
*, struct file_lock
*, unsigned int);
579 extern void posix_block_lock(struct file_lock
*, struct file_lock
*);
580 extern void posix_unblock_lock(struct file_lock
*);
581 extern int __get_lease(struct inode
*inode
, unsigned int flags
);
582 extern time_t lease_get_mtime(struct inode
*);
583 extern int lock_may_read(struct inode
*, loff_t start
, unsigned long count
);
584 extern int lock_may_write(struct inode
*, loff_t start
, unsigned long count
);
586 struct fasync_struct
{
589 struct fasync_struct
*fa_next
; /* singly linked list */
590 struct file
*fa_file
;
593 #define FASYNC_MAGIC 0x4601
595 /* SMP safe fasync helpers: */
596 extern int fasync_helper(int, struct file
*, int, struct fasync_struct
**);
597 /* can be called from interrupts */
598 extern void kill_fasync(struct fasync_struct
**, int, int);
599 /* only for net: no internal synchronization */
600 extern void __kill_fasync(struct fasync_struct
*, int, int);
603 struct dentry
*dentry
;
604 struct vfsmount
*mnt
;
610 #define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */
611 #define DQUOT_GRP_ENABLED 0x02 /* Group diskquotas enabled */
613 struct quota_mount_options
615 unsigned int flags
; /* Flags for diskquotas on this device */
616 struct semaphore dqio_sem
; /* lock device while I/O in progress */
617 struct semaphore dqoff_sem
; /* serialize quota_off() and quota_on() on device */
618 struct file
*files
[MAXQUOTAS
]; /* fp's to quotafiles */
619 time_t inode_expire
[MAXQUOTAS
]; /* expiretime for inode-quota */
620 time_t block_expire
[MAXQUOTAS
]; /* expiretime for block-quota */
621 char rsquash
[MAXQUOTAS
]; /* for quotas threat root as any other user */
628 #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
630 #include <linux/minix_fs_sb.h>
631 #include <linux/ext2_fs_sb.h>
632 #include <linux/hpfs_fs_sb.h>
633 #include <linux/ntfs_fs_sb.h>
634 #include <linux/msdos_fs_sb.h>
635 #include <linux/iso_fs_sb.h>
636 #include <linux/nfs_fs_sb.h>
637 #include <linux/sysv_fs_sb.h>
638 #include <linux/affs_fs_sb.h>
639 #include <linux/ufs_fs_sb.h>
640 #include <linux/efs_fs_sb.h>
641 #include <linux/romfs_fs_sb.h>
642 #include <linux/smb_fs_sb.h>
643 #include <linux/hfs_fs_sb.h>
644 #include <linux/adfs_fs_sb.h>
645 #include <linux/qnx4_fs_sb.h>
646 #include <linux/bfs_fs_sb.h>
647 #include <linux/udf_fs_sb.h>
648 #include <linux/ncp_fs_sb.h>
649 #include <linux/usbdev_fs_sb.h>
651 extern struct list_head super_blocks
;
653 #define sb_entry(list) list_entry((list), struct super_block, s_list)
655 struct list_head s_list
; /* Keep this first */
657 unsigned long s_blocksize
;
658 unsigned char s_blocksize_bits
;
659 unsigned char s_lock
;
660 unsigned char s_dirt
;
661 struct file_system_type
*s_type
;
662 struct super_operations
*s_op
;
663 struct dquot_operations
*dq_op
;
664 unsigned long s_flags
;
665 unsigned long s_magic
;
666 struct dentry
*s_root
;
667 wait_queue_head_t s_wait
;
669 struct list_head s_dirty
; /* dirty inodes */
670 struct list_head s_files
;
672 struct block_device
*s_bdev
;
673 struct list_head s_mounts
; /* vfsmount(s) of this one */
674 struct quota_mount_options s_dquot
; /* Diskquota specific options */
677 struct minix_sb_info minix_sb
;
678 struct ext2_sb_info ext2_sb
;
679 struct hpfs_sb_info hpfs_sb
;
680 struct ntfs_sb_info ntfs_sb
;
681 struct msdos_sb_info msdos_sb
;
682 struct isofs_sb_info isofs_sb
;
683 struct nfs_sb_info nfs_sb
;
684 struct sysv_sb_info sysv_sb
;
685 struct affs_sb_info affs_sb
;
686 struct ufs_sb_info ufs_sb
;
687 struct efs_sb_info efs_sb
;
688 struct romfs_sb_info romfs_sb
;
689 struct smb_sb_info smbfs_sb
;
690 struct hfs_sb_info hfs_sb
;
691 struct adfs_sb_info adfs_sb
;
692 struct qnx4_sb_info qnx4_sb
;
693 struct bfs_sb_info bfs_sb
;
694 struct udf_sb_info udf_sb
;
695 struct ncp_sb_info ncpfs_sb
;
696 struct usbdev_sb_info usbdevfs_sb
;
700 * The next field is for VFS *only*. No filesystems have any business
701 * even looking at it. You had been warned.
703 struct semaphore s_vfs_rename_sem
; /* Kludge */
705 /* The next field is used by knfsd when converting a (inode number based)
706 * file handle into a dentry. As it builds a path in the dcache tree from
707 * the bottom up, there may for a time be a subpath of dentrys which is not
708 * connected to the main tree. This semaphore ensure that there is only ever
709 * one such free path per filesystem. Note that unconnected files (or other
710 * non-directories) are allowed, but not unconnected diretories.
712 struct semaphore s_nfsd_free_path_sem
;
716 * VFS helper functions..
718 extern int vfs_create(struct inode
*, struct dentry
*, int);
719 extern int vfs_mkdir(struct inode
*, struct dentry
*, int);
720 extern int vfs_mknod(struct inode
*, struct dentry
*, int, dev_t
);
721 extern int vfs_symlink(struct inode
*, struct dentry
*, const char *);
722 extern int vfs_link(struct dentry
*, struct inode
*, struct dentry
*);
723 extern int vfs_rmdir(struct inode
*, struct dentry
*);
724 extern int vfs_unlink(struct inode
*, struct dentry
*);
725 extern int vfs_rename(struct inode
*, struct dentry
*, struct inode
*, struct dentry
*);
741 * This is the "filldir" function type, used by readdir() to let
742 * the kernel specify what kind of dirent layout it wants to have.
743 * This allows the kernel to read directories into kernel space or
744 * to have different dirent layouts depending on the binary type.
746 typedef int (*filldir_t
)(void *, const char *, int, off_t
, ino_t
, unsigned);
748 struct block_device_operations
{
749 int (*open
) (struct inode
*, struct file
*);
750 int (*release
) (struct inode
*, struct file
*);
751 int (*ioctl
) (struct inode
*, struct file
*, unsigned, unsigned long);
752 int (*check_media_change
) (kdev_t
);
753 int (*revalidate
) (kdev_t
);
758 * read, write, poll, fsync, readv, writev can be called
759 * without the big kernel lock held in all filesystems.
761 struct file_operations
{
762 struct module
*owner
;
763 loff_t (*llseek
) (struct file
*, loff_t
, int);
764 ssize_t (*read
) (struct file
*, char *, size_t, loff_t
*);
765 ssize_t (*write
) (struct file
*, const char *, size_t, loff_t
*);
766 int (*readdir
) (struct file
*, void *, filldir_t
);
767 unsigned int (*poll
) (struct file
*, struct poll_table_struct
*);
768 int (*ioctl
) (struct inode
*, struct file
*, unsigned int, unsigned long);
769 int (*mmap
) (struct file
*, struct vm_area_struct
*);
770 int (*open
) (struct inode
*, struct file
*);
771 int (*flush
) (struct file
*);
772 int (*release
) (struct inode
*, struct file
*);
773 int (*fsync
) (struct file
*, struct dentry
*, int datasync
);
774 int (*fasync
) (int, struct file
*, int);
775 int (*lock
) (struct file
*, int, struct file_lock
*);
776 ssize_t (*readv
) (struct file
*, const struct iovec
*, unsigned long, loff_t
*);
777 ssize_t (*writev
) (struct file
*, const struct iovec
*, unsigned long, loff_t
*);
780 struct inode_operations
{
781 int (*create
) (struct inode
*,struct dentry
*,int);
782 struct dentry
* (*lookup
) (struct inode
*,struct dentry
*);
783 int (*link
) (struct dentry
*,struct inode
*,struct dentry
*);
784 int (*unlink
) (struct inode
*,struct dentry
*);
785 int (*symlink
) (struct inode
*,struct dentry
*,const char *);
786 int (*mkdir
) (struct inode
*,struct dentry
*,int);
787 int (*rmdir
) (struct inode
*,struct dentry
*);
788 int (*mknod
) (struct inode
*,struct dentry
*,int,int);
789 int (*rename
) (struct inode
*, struct dentry
*,
790 struct inode
*, struct dentry
*);
791 int (*readlink
) (struct dentry
*, char *,int);
792 int (*follow_link
) (struct dentry
*, struct nameidata
*);
793 void (*truncate
) (struct inode
*);
794 int (*permission
) (struct inode
*, int);
795 int (*revalidate
) (struct dentry
*);
796 int (*setattr
) (struct dentry
*, struct iattr
*);
797 int (*getattr
) (struct dentry
*, struct iattr
*);
801 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
802 * without the big kernel lock held in all filesystems.
804 struct super_operations
{
805 void (*read_inode
) (struct inode
*);
806 void (*write_inode
) (struct inode
*, int);
807 void (*put_inode
) (struct inode
*);
808 void (*delete_inode
) (struct inode
*);
809 void (*put_super
) (struct super_block
*);
810 void (*write_super
) (struct super_block
*);
811 int (*statfs
) (struct super_block
*, struct statfs
*);
812 int (*remount_fs
) (struct super_block
*, int *, char *);
813 void (*clear_inode
) (struct inode
*);
814 void (*umount_begin
) (struct super_block
*);
817 struct dquot_operations
{
818 void (*initialize
) (struct inode
*, short);
819 void (*drop
) (struct inode
*);
820 int (*alloc_block
) (const struct inode
*, unsigned long, char);
821 int (*alloc_inode
) (const struct inode
*, unsigned long);
822 void (*free_block
) (const struct inode
*, unsigned long);
823 void (*free_inode
) (const struct inode
*, unsigned long);
824 int (*transfer
) (struct dentry
*, struct iattr
*);
827 struct file_system_type
{
830 struct super_block
*(*read_super
) (struct super_block
*, void *, int);
831 struct module
*owner
;
832 struct vfsmount
*kern_mnt
; /* For kernel mount, if it's FS_SINGLE fs */
833 struct file_system_type
* next
;
836 #define DECLARE_FSTYPE(var,type,read,flags) \
837 struct file_system_type var = { \
841 owner: THIS_MODULE, \
844 #define DECLARE_FSTYPE_DEV(var,type,read) \
845 DECLARE_FSTYPE(var,type,read,FS_REQUIRES_DEV)
847 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
848 #define fops_get(fops) \
849 (((fops) && (fops)->owner) \
850 ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
853 #define fops_put(fops) \
855 if ((fops) && (fops)->owner) \
856 __MOD_DEC_USE_COUNT((fops)->owner); \
859 extern int register_filesystem(struct file_system_type
*);
860 extern int unregister_filesystem(struct file_system_type
*);
861 extern struct vfsmount
*kern_mount(struct file_system_type
*);
862 extern void kern_umount(struct vfsmount
*);
863 extern int may_umount(struct vfsmount
*);
864 extern long do_mount(char *, char *, char *, unsigned long, void *);
867 extern int vfs_statfs(struct super_block
*, struct statfs
*);
869 /* Return value for VFS lock functions - tells locks.c to lock conventionally
870 * REALLY kosha for root NFS and nfs_lock
872 #define LOCK_USE_CLNT 1
874 #define FLOCK_VERIFY_READ 1
875 #define FLOCK_VERIFY_WRITE 2
877 extern int locks_mandatory_locked(struct inode
*);
878 extern int locks_mandatory_area(int, struct inode
*, struct file
*, loff_t
, size_t);
881 * Candidates for mandatory locking have the setgid bit set
882 * but no group execute bit - an otherwise meaningless combination.
884 #define MANDATORY_LOCK(inode) \
885 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
887 static inline int locks_verify_locked(struct inode
*inode
)
889 if (MANDATORY_LOCK(inode
))
890 return locks_mandatory_locked(inode
);
894 static inline int locks_verify_area(int read_write
, struct inode
*inode
,
895 struct file
*filp
, loff_t offset
,
898 if (inode
->i_flock
&& MANDATORY_LOCK(inode
))
899 return locks_mandatory_area(read_write
, inode
, filp
, offset
, count
);
903 static inline int locks_verify_truncate(struct inode
*inode
,
907 if (inode
->i_flock
&& MANDATORY_LOCK(inode
))
908 return locks_mandatory_area(
909 FLOCK_VERIFY_WRITE
, inode
, filp
,
910 size
< inode
->i_size
? size
: inode
->i_size
,
911 (size
< inode
->i_size
? inode
->i_size
- size
912 : size
- inode
->i_size
)
917 extern inline int get_lease(struct inode
*inode
, unsigned int mode
)
919 if (inode
->i_flock
&& (inode
->i_flock
->fl_flags
& FL_LEASE
))
920 return __get_lease(inode
, mode
);
926 asmlinkage
long sys_open(const char *, int, int);
927 asmlinkage
long sys_close(unsigned int); /* yes, it's really unsigned */
928 extern int do_truncate(struct dentry
*, loff_t start
);
930 extern struct file
*filp_open(const char *, int, int);
931 extern struct file
* dentry_open(struct dentry
*, struct vfsmount
*, int);
932 extern int filp_close(struct file
*, fl_owner_t id
);
933 extern char * getname(const char *);
936 extern void vfs_caches_init(unsigned long);
938 #define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL)
939 #define putname(name) kmem_cache_free(names_cachep, (void *)(name))
941 enum {BDEV_FILE
, BDEV_SWAP
, BDEV_FS
, BDEV_RAW
};
942 extern int register_blkdev(unsigned int, const char *, struct block_device_operations
*);
943 extern int unregister_blkdev(unsigned int, const char *);
944 extern struct block_device
*bdget(dev_t
);
945 extern void bdput(struct block_device
*);
946 extern int blkdev_open(struct inode
*, struct file
*);
947 extern struct file_operations def_blk_fops
;
948 extern struct file_operations def_fifo_fops
;
949 extern int ioctl_by_bdev(struct block_device
*, unsigned, unsigned long);
950 extern int blkdev_get(struct block_device
*, mode_t
, unsigned, int);
951 extern int blkdev_put(struct block_device
*, int);
954 extern const struct block_device_operations
*get_blkfops(unsigned int);
955 extern int register_chrdev(unsigned int, const char *, struct file_operations
*);
956 extern int unregister_chrdev(unsigned int, const char *);
957 extern int chrdev_open(struct inode
*, struct file
*);
958 extern const char * bdevname(kdev_t
);
959 extern const char * cdevname(kdev_t
);
960 extern const char * kdevname(kdev_t
);
961 extern void init_special_inode(struct inode
*, umode_t
, int);
963 /* Invalid inode operations -- fs/bad_inode.c */
964 extern void make_bad_inode(struct inode
*);
965 extern int is_bad_inode(struct inode
*);
967 extern struct file_operations read_fifo_fops
;
968 extern struct file_operations write_fifo_fops
;
969 extern struct file_operations rdwr_fifo_fops
;
970 extern struct file_operations read_pipe_fops
;
971 extern struct file_operations write_pipe_fops
;
972 extern struct file_operations rdwr_pipe_fops
;
974 extern int fs_may_remount_ro(struct super_block
*);
976 extern int try_to_free_buffers(struct page
*, int);
977 extern void refile_buffer(struct buffer_head
* buf
);
980 #define BUF_LOCKED 1 /* Buffers scheduled for write */
981 #define BUF_DIRTY 2 /* Dirty buffers, not yet scheduled for write */
982 #define BUF_PROTECTED 3 /* Ramdisk persistent storage */
986 * This is called by bh->b_end_io() handlers when I/O has completed.
988 static inline void mark_buffer_uptodate(struct buffer_head
* bh
, int on
)
991 set_bit(BH_Uptodate
, &bh
->b_state
);
993 clear_bit(BH_Uptodate
, &bh
->b_state
);
996 #define atomic_set_buffer_clean(bh) test_and_clear_bit(BH_Dirty, &(bh)->b_state)
998 static inline void __mark_buffer_clean(struct buffer_head
*bh
)
1003 static inline void mark_buffer_clean(struct buffer_head
* bh
)
1005 if (atomic_set_buffer_clean(bh
))
1006 __mark_buffer_clean(bh
);
1009 #define atomic_set_buffer_protected(bh) test_and_set_bit(BH_Protected, &(bh)->b_state)
1011 static inline void __mark_buffer_protected(struct buffer_head
*bh
)
1016 static inline void mark_buffer_protected(struct buffer_head
* bh
)
1018 if (!atomic_set_buffer_protected(bh
))
1019 __mark_buffer_protected(bh
);
1022 extern void FASTCALL(__mark_buffer_dirty(struct buffer_head
*bh
));
1023 extern void FASTCALL(mark_buffer_dirty(struct buffer_head
*bh
));
1025 #define atomic_set_buffer_dirty(bh) test_and_set_bit(BH_Dirty, &(bh)->b_state)
1028 * If an error happens during the make_request, this function
1029 * has to be recalled. It marks the buffer as clean and not
1030 * uptodate, and it notifys the upper layer about the end
1033 static inline void buffer_IO_error(struct buffer_head
* bh
)
1035 mark_buffer_clean(bh
);
1037 * b_end_io has to clear the BH_Uptodate bitflag in the error case!
1039 bh
->b_end_io(bh
, 0);
1042 extern void buffer_insert_inode_queue(struct buffer_head
*, struct inode
*);
1043 static inline void mark_buffer_dirty_inode(struct buffer_head
*bh
, struct inode
*inode
)
1045 mark_buffer_dirty(bh
);
1046 buffer_insert_inode_queue(bh
, inode
);
1049 extern void balance_dirty(kdev_t
);
1050 extern int check_disk_change(kdev_t
);
1051 extern int invalidate_inodes(struct super_block
*);
1052 extern void invalidate_inode_pages(struct inode
*);
1053 extern void invalidate_inode_buffers(struct inode
*);
1054 #define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
1055 #define destroy_buffers(dev) __invalidate_buffers((dev), 1)
1056 extern void __invalidate_buffers(kdev_t dev
, int);
1057 extern void sync_inodes(kdev_t
);
1058 extern void write_inode_now(struct inode
*, int);
1059 extern void sync_dev(kdev_t
);
1060 extern int fsync_dev(kdev_t
);
1061 extern int fsync_inode_buffers(struct inode
*);
1062 extern int osync_inode_buffers(struct inode
*);
1063 extern int inode_has_buffers(struct inode
*);
1064 extern void sync_supers(kdev_t
);
1065 extern int bmap(struct inode
*, int);
1066 extern int notify_change(struct dentry
*, struct iattr
*);
1067 extern int permission(struct inode
*, int);
1068 extern int vfs_permission(struct inode
*, int);
1069 extern int get_write_access(struct inode
*);
1070 extern int deny_write_access(struct file
*);
1071 static inline void put_write_access(struct inode
* inode
)
1073 atomic_dec(&inode
->i_writecount
);
1075 static inline void allow_write_access(struct file
*file
)
1078 atomic_inc(&file
->f_dentry
->d_inode
->i_writecount
);
1080 extern int do_pipe(int *);
1082 extern int open_namei(const char *, int, int, struct nameidata
*);
1084 extern int kernel_read(struct file
*, unsigned long, char *, unsigned long);
1085 extern struct file
* open_exec(const char *);
1087 /* fs/dcache.c -- generic fs support functions */
1088 extern int is_subdir(struct dentry
*, struct dentry
*);
1089 extern ino_t
find_inode_number(struct dentry
*, struct qstr
*);
1092 * Kernel pointers have redundant information, so we can use a
1093 * scheme where we can return either an error code or a dentry
1094 * pointer with the same return value.
1096 * This should be a per-architecture thing, to allow different
1097 * error and pointer decisions.
1099 static inline void *ERR_PTR(long error
)
1101 return (void *) error
;
1104 static inline long PTR_ERR(const void *ptr
)
1109 static inline long IS_ERR(const void *ptr
)
1111 return (unsigned long)ptr
> (unsigned long)-1000L;
1115 * The bitmask for a lookup event:
1116 * - follow links at the end
1117 * - require a directory
1118 * - ending slashes ok even for nonexistent files
1119 * - internal "there are more path compnents" flag
1121 #define LOOKUP_FOLLOW (1)
1122 #define LOOKUP_DIRECTORY (2)
1123 #define LOOKUP_CONTINUE (4)
1124 #define LOOKUP_POSITIVE (8)
1125 #define LOOKUP_PARENT (16)
1126 #define LOOKUP_NOALT (32)
1128 * Type of the last component on LOOKUP_PARENT
1130 enum {LAST_NORM
, LAST_ROOT
, LAST_DOT
, LAST_DOTDOT
, LAST_BIND
};
1133 * "descriptor" for what we're up to with a read for sendfile().
1134 * This allows us to use the same read code yet
1135 * have multiple different users of the data that
1136 * we read from a file.
1138 * The simplest case just copies the data to user
1146 } read_descriptor_t
;
1148 typedef int (*read_actor_t
)(read_descriptor_t
*, struct page
*, unsigned long, unsigned long);
1150 /* needed for stackable file system support */
1151 extern loff_t
default_llseek(struct file
*file
, loff_t offset
, int origin
);
1153 extern int __user_walk(const char *, unsigned, struct nameidata
*);
1154 extern int path_init(const char *, unsigned, struct nameidata
*);
1155 extern int path_walk(const char *, struct nameidata
*);
1156 extern void path_release(struct nameidata
*);
1157 extern int follow_down(struct vfsmount
**, struct dentry
**);
1158 extern int follow_up(struct vfsmount
**, struct dentry
**);
1159 extern struct dentry
* lookup_one(const char *, struct dentry
*);
1160 extern struct dentry
* lookup_hash(struct qstr
*, struct dentry
*);
1161 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1162 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1164 extern void iput(struct inode
*);
1165 extern void force_delete(struct inode
*);
1166 extern struct inode
* igrab(struct inode
*);
1167 extern ino_t
iunique(struct super_block
*, ino_t
);
1169 typedef int (*find_inode_t
)(struct inode
*, unsigned long, void *);
1170 extern struct inode
* iget4(struct super_block
*, unsigned long, find_inode_t
, void *);
1171 static inline struct inode
*iget(struct super_block
*sb
, unsigned long ino
)
1173 return iget4(sb
, ino
, NULL
, NULL
);
1176 extern void clear_inode(struct inode
*);
1177 extern struct inode
* get_empty_inode(void);
1178 static inline struct inode
* new_inode(struct super_block
*sb
)
1180 struct inode
*inode
= get_empty_inode();
1183 inode
->i_dev
= sb
->s_dev
;
1188 extern void insert_inode_hash(struct inode
*);
1189 extern void remove_inode_hash(struct inode
*);
1190 extern struct file
* get_empty_filp(void);
1191 extern void file_move(struct file
*f
, struct list_head
*list
);
1192 extern void file_moveto(struct file
*new, struct file
*old
);
1193 extern struct buffer_head
* get_hash_table(kdev_t
, int, int);
1194 extern struct buffer_head
* getblk(kdev_t
, int, int);
1195 extern void ll_rw_block(int, int, struct buffer_head
* bh
[]);
1196 extern void submit_bh(int, struct buffer_head
*);
1197 extern int is_read_only(kdev_t
);
1198 extern void __brelse(struct buffer_head
*);
1199 static inline void brelse(struct buffer_head
*buf
)
1204 extern void __bforget(struct buffer_head
*);
1205 static inline void bforget(struct buffer_head
*buf
)
1210 extern void set_blocksize(kdev_t
, int);
1211 extern unsigned int get_hardblocksize(kdev_t
);
1212 extern struct buffer_head
* bread(kdev_t
, int, int);
1213 extern void wakeup_bdflush(int wait
);
1215 extern int brw_page(int, struct page
*, kdev_t
, int [], int);
1217 typedef int (get_block_t
)(struct inode
*,long,struct buffer_head
*,int);
1219 /* Generic buffer handling for block filesystems.. */
1220 extern int block_flushpage(struct page
*, unsigned long);
1221 extern int block_symlink(struct inode
*, const char *, int);
1222 extern int block_write_full_page(struct page
*, get_block_t
*);
1223 extern int block_read_full_page(struct page
*, get_block_t
*);
1224 extern int block_prepare_write(struct page
*, unsigned, unsigned, get_block_t
*);
1225 extern int cont_prepare_write(struct page
*, unsigned, unsigned, get_block_t
*,
1227 extern int block_sync_page(struct page
*);
1229 int generic_block_bmap(struct address_space
*, long, get_block_t
*);
1230 int generic_commit_write(struct file
*, struct page
*, unsigned, unsigned);
1231 int block_truncate_page(struct address_space
*, loff_t
, get_block_t
*);
1233 extern int generic_file_mmap(struct file
*, struct vm_area_struct
*);
1234 extern ssize_t
generic_file_read(struct file
*, char *, size_t, loff_t
*);
1235 extern ssize_t
generic_file_write(struct file
*, const char *, size_t, loff_t
*);
1236 extern void do_generic_file_read(struct file
*, loff_t
*, read_descriptor_t
*, read_actor_t
);
1238 extern ssize_t
generic_read_dir(struct file
*, char *, size_t, loff_t
*);
1240 extern struct file_operations generic_ro_fops
;
1242 extern int vfs_readlink(struct dentry
*, char *, int, const char *);
1243 extern int vfs_follow_link(struct nameidata
*, const char *);
1244 extern int page_readlink(struct dentry
*, char *, int);
1245 extern int page_follow_link(struct dentry
*, struct nameidata
*);
1246 extern struct inode_operations page_symlink_inode_operations
;
1248 extern int vfs_readdir(struct file
*, filldir_t
, void *);
1249 extern int dcache_readdir(struct file
*, void *, filldir_t
);
1251 extern struct file_system_type
*get_fs_type(const char *name
);
1252 extern struct super_block
*get_super(kdev_t
);
1253 struct super_block
*get_empty_super(void);
1254 extern void put_super(kdev_t
);
1255 unsigned long generate_cluster(kdev_t
, int b
[], int);
1256 unsigned long generate_cluster_swab32(kdev_t
, int b
[], int);
1257 extern kdev_t ROOT_DEV
;
1258 extern char root_device_name
[];
1261 extern void show_buffers(void);
1262 extern void mount_root(void);
1264 #ifdef CONFIG_BLK_DEV_INITRD
1265 extern kdev_t real_root_dev
;
1266 extern int change_root(kdev_t
, const char *);
1269 extern ssize_t
char_read(struct file
*, char *, size_t, loff_t
*);
1270 extern ssize_t
block_read(struct file
*, char *, size_t, loff_t
*);
1271 extern int read_ahead
[];
1273 extern ssize_t
char_write(struct file
*, const char *, size_t, loff_t
*);
1274 extern ssize_t
block_write(struct file
*, const char *, size_t, loff_t
*);
1276 extern int file_fsync(struct file
*, struct dentry
*, int);
1277 extern int generic_buffer_fdatasync(struct inode
*inode
, unsigned long start_idx
, unsigned long end_idx
);
1278 extern int generic_osync_inode(struct inode
*, int);
1280 extern int inode_change_ok(struct inode
*, struct iattr
*);
1281 extern void inode_setattr(struct inode
*, struct iattr
*);
1284 * Common dentry functions for inclusion in the VFS
1285 * or in other stackable file systems. Some of these
1286 * functions were in linux/fs/ C (VFS) files.
1291 * Locking the parent is needed to:
1292 * - serialize directory operations
1293 * - make sure the parent doesn't change from
1294 * under us in the middle of an operation.
1296 * NOTE! Right now we'd rather use a "struct inode"
1297 * for this, but as I expect things to move toward
1298 * using dentries instead for most things it is
1299 * probably better to start with the conceptually
1300 * better interface of relying on a path of dentries.
1302 static inline struct dentry
*lock_parent(struct dentry
*dentry
)
1304 struct dentry
*dir
= dget(dentry
->d_parent
);
1306 down(&dir
->d_inode
->i_sem
);
1310 static inline struct dentry
*get_parent(struct dentry
*dentry
)
1312 return dget(dentry
->d_parent
);
1315 static inline void unlock_dir(struct dentry
*dir
)
1317 up(&dir
->d_inode
->i_sem
);
1322 * Whee.. Deadlock country. Happily there are only two VFS
1323 * operations that does this..
1325 static inline void double_down(struct semaphore
*s1
, struct semaphore
*s2
)
1328 if ((unsigned long) s1
< (unsigned long) s2
) {
1329 struct semaphore
*tmp
= s2
;
1338 * Ewwwwwwww... _triple_ lock. We are guaranteed that the 3rd argument is
1339 * not equal to 1st and not equal to 2nd - the first case (target is parent of
1340 * source) would be already caught, the second is plain impossible (target is
1341 * its own parent and that case would be caught even earlier). Very messy.
1342 * I _think_ that it works, but no warranties - please, look it through.
1343 * Pox on bloody lusers who mandated overwriting rename() for directories...
1346 static inline void triple_down(struct semaphore
*s1
,
1347 struct semaphore
*s2
,
1348 struct semaphore
*s3
)
1351 if ((unsigned long) s1
< (unsigned long) s2
) {
1352 if ((unsigned long) s1
< (unsigned long) s3
) {
1353 struct semaphore
*tmp
= s3
;
1356 if ((unsigned long) s1
< (unsigned long) s2
) {
1357 struct semaphore
*tmp
= s2
;
1361 if ((unsigned long) s1
< (unsigned long) s3
) {
1362 struct semaphore
*tmp
= s3
;
1365 if ((unsigned long) s2
< (unsigned long) s3
) {
1366 struct semaphore
*tmp
= s3
;
1371 } else if ((unsigned long) s2
< (unsigned long) s3
) {
1372 struct semaphore
*tmp
= s3
;
1379 static inline void double_up(struct semaphore
*s1
, struct semaphore
*s2
)
1386 static inline void triple_up(struct semaphore
*s1
,
1387 struct semaphore
*s2
,
1388 struct semaphore
*s3
)
1396 static inline void double_lock(struct dentry
*d1
, struct dentry
*d2
)
1398 double_down(&d1
->d_inode
->i_sem
, &d2
->d_inode
->i_sem
);
1401 static inline void double_unlock(struct dentry
*d1
, struct dentry
*d2
)
1403 double_up(&d1
->d_inode
->i_sem
,&d2
->d_inode
->i_sem
);
1408 #endif /* __KERNEL__ */
1410 #endif /* _LINUX_FS_H */