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/kdev_t.h>
16 #include <linux/ioctl.h>
17 #include <linux/list.h>
18 #include <linux/dcache.h>
19 #include <linux/stat.h>
20 #include <linux/cache.h>
21 #include <linux/radix-tree.h>
22 #include <asm/atomic.h>
26 struct pipe_inode_info
;
27 struct poll_table_struct
;
28 struct vm_area_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 */
82 #define READA 2 /* read-ahead - don't block if no resources */
83 #define SPECIAL 4 /* For non-blockdevice requests in request queue */
89 /* public flags for file_system_type */
90 #define FS_REQUIRES_DEV 1
91 #define FS_ODD_RENAME 32768 /* Temporary stuff; will go away as soon
92 * as nfs_rename() will be cleaned up
95 * These are the fs-independent mount-flags: up to 32 flags are supported
97 #define MS_RDONLY 1 /* Mount read-only */
98 #define MS_NOSUID 2 /* Ignore suid and sgid bits */
99 #define MS_NODEV 4 /* Disallow access to device special files */
100 #define MS_NOEXEC 8 /* Disallow program execution */
101 #define MS_SYNCHRONOUS 16 /* Writes are synced at once */
102 #define MS_REMOUNT 32 /* Alter flags of a mounted FS */
103 #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
104 #define MS_DIRSYNC 128 /* Directory modifications are synchronous */
105 #define MS_NOATIME 1024 /* Do not update access times. */
106 #define MS_NODIRATIME 2048 /* Do not update directory access times */
110 #define MS_VERBOSE 32768
111 #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
112 #define MS_ACTIVE (1<<30)
113 #define MS_NOUSER (1<<31)
116 * Superblock flags that can be altered by MS_REMOUNT
118 #define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
122 * Old magic mount flag and mask
124 #define MS_MGC_VAL 0xC0ED0000
125 #define MS_MGC_MSK 0xffff0000
127 /* Inode flags - they have nothing to superblock flags now */
129 #define S_SYNC 1 /* Writes are synced at once */
130 #define S_NOATIME 2 /* Do not update access times */
131 #define S_QUOTA 4 /* Quota initialized for file */
132 #define S_APPEND 8 /* Append-only file */
133 #define S_IMMUTABLE 16 /* Immutable file */
134 #define S_DEAD 32 /* removed, but still open directory */
135 #define S_NOQUOTA 64 /* Inode is not counted to quota */
136 #define S_DIRSYNC 128 /* Directory modifications are synchronous */
139 * Note that nosuid etc flags are inode-specific: setting some file-system
140 * flags just means all the inodes inherit those flags by default. It might be
141 * possible to override it selectively if you really wanted to with some
142 * ioctl() that is not currently implemented.
144 * Exception: MS_RDONLY is always applied to the entire file system.
146 * Unfortunately, it is possible to change a filesystems flags with it mounted
147 * with files in use. This means that all of the inodes will not have their
148 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
149 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
151 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
153 #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
154 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
155 ((inode)->i_flags & S_SYNC))
156 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
157 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
158 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
160 #define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
161 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
162 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
163 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
164 #define IS_NOATIME(inode) (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
165 #define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
166 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
168 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
170 /* the read-only stuff doesn't really belong here, but any other place is
171 probably as bad and I don't want to create yet another include file. */
173 #define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
174 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
175 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
176 #define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
177 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
178 #define BLKRASET _IO(0x12,98) /* set read ahead for block device */
179 #define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
180 #define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
181 #define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
182 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
183 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
184 #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
186 #define BLKPG _IO(0x12,105)/* See blkpg.h */
187 #define BLKELVGET _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */
188 #define BLKELVSET _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))/* elevator set */
189 /* This was here just to show that the number is taken -
190 probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
192 /* A jump here: 108-111 have been used for various private purposes. */
193 #define BLKBSZGET _IOR(0x12,112,sizeof(int))
194 #define BLKBSZSET _IOW(0x12,113,sizeof(int))
195 #define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64)) /* return device size in bytes (u64 *arg) */
197 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
198 #define FIBMAP _IO(0x00,1) /* bmap access */
199 #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
203 #include <asm/semaphore.h>
204 #include <asm/byteorder.h>
206 extern void update_atime (struct inode
*);
207 #define UPDATE_ATIME(inode) update_atime (inode)
209 extern void inode_init(unsigned long);
210 extern void mnt_init(unsigned long);
211 extern void files_init(unsigned long);
214 typedef int (get_block_t
)(struct inode
*inode
, sector_t iblock
,
215 struct buffer_head
*bh_result
, int create
);
216 typedef int (get_blocks_t
)(struct inode
*inode
, sector_t iblock
,
217 unsigned long max_blocks
,
218 struct buffer_head
*bh_result
, int create
);
221 * Attribute flags. These should be or-ed together to figure out what
228 #define ATTR_ATIME 16
229 #define ATTR_MTIME 32
230 #define ATTR_CTIME 64
231 #define ATTR_ATIME_SET 128
232 #define ATTR_MTIME_SET 256
233 #define ATTR_FORCE 512 /* Not a change, but a change it */
234 #define ATTR_ATTR_FLAG 1024
235 #define ATTR_KILL_SUID 2048
236 #define ATTR_KILL_SGID 4096
239 * This is the Inode Attributes structure, used for notify_change(). It
240 * uses the above definitions as flags, to know which values have changed.
241 * Also, in this manner, a Filesystem can look at only the values it cares
242 * about. Basically, these are the attributes that the VFS layer can
243 * request to change from the FS layer.
245 * Derek Atkins <warlord@MIT.EDU> 94-10-20
248 unsigned int ia_valid
;
253 struct timespec ia_atime
;
254 struct timespec ia_mtime
;
255 struct timespec ia_ctime
;
256 unsigned int ia_attr_flags
;
260 * This is the inode attributes flag definitions
262 #define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
263 #define ATTR_FLAG_NOATIME 2 /* Don't update atime */
264 #define ATTR_FLAG_APPEND 4 /* Append-only file */
265 #define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
266 #define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
269 * Includes for diskquotas.
271 #include <linux/quota.h>
274 * oh the beauties of C type declarations.
277 struct address_space
;
278 struct writeback_control
;
280 struct address_space_operations
{
281 int (*writepage
)(struct page
*);
282 int (*readpage
)(struct file
*, struct page
*);
283 int (*sync_page
)(struct page
*);
285 /* Write back some dirty pages from this mapping. */
286 int (*writepages
)(struct address_space
*, struct writeback_control
*);
288 /* Perform a writeback as a memory-freeing operation. */
289 int (*vm_writeback
)(struct page
*, struct writeback_control
*);
291 /* Set a page dirty */
292 int (*set_page_dirty
)(struct page
*page
);
294 int (*readpages
)(struct file
*filp
, struct address_space
*mapping
,
295 struct list_head
*pages
, unsigned nr_pages
);
298 * ext3 requires that a successful prepare_write() call be followed
299 * by a commit_write() call - they must be balanced
301 int (*prepare_write
)(struct file
*, struct page
*, unsigned, unsigned);
302 int (*commit_write
)(struct file
*, struct page
*, unsigned, unsigned);
303 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
304 sector_t (*bmap
)(struct address_space
*, sector_t
);
305 int (*invalidatepage
) (struct page
*, unsigned long);
306 int (*releasepage
) (struct page
*, int);
307 int (*direct_IO
)(int, struct file
*, const struct iovec
*iov
,
308 loff_t offset
, unsigned long nr_segs
);
311 struct backing_dev_info
;
312 struct address_space
{
313 struct inode
*host
; /* owner: inode, block_device */
314 struct radix_tree_root page_tree
; /* radix tree of all pages */
315 rwlock_t page_lock
; /* and rwlock protecting it */
316 struct list_head clean_pages
; /* list of clean pages */
317 struct list_head dirty_pages
; /* list of dirty pages */
318 struct list_head locked_pages
; /* list of locked pages */
319 struct list_head io_pages
; /* being prepared for I/O */
320 unsigned long nrpages
; /* number of total pages */
321 struct address_space_operations
*a_ops
; /* methods */
322 struct list_head i_mmap
; /* list of private mappings */
323 struct list_head i_mmap_shared
; /* list of private mappings */
324 spinlock_t i_shared_lock
; /* and spinlock protecting it */
325 unsigned long dirtied_when
; /* jiffies of first page dirtying */
326 int gfp_mask
; /* how to allocate the pages */
327 struct backing_dev_info
*backing_dev_info
; /* device readahead, etc */
328 spinlock_t private_lock
; /* for use by the address_space */
329 struct list_head private_list
; /* ditto */
330 struct address_space
*assoc_mapping
; /* ditto */
334 struct list_head hash
;
338 struct semaphore sem
;
341 struct block_device
{
342 struct list_head bd_hash
;
344 struct inode
* bd_inode
;
345 dev_t bd_dev
; /* not a kdev_t - it's a search key */
347 struct semaphore bd_sem
; /* open/close mutex */
348 struct list_head bd_inodes
;
351 struct block_device
* bd_contains
;
352 unsigned bd_block_size
;
354 unsigned bd_part_count
;
356 struct gendisk
* bd_disk
;
360 struct list_head i_hash
;
361 struct list_head i_list
;
362 struct list_head i_dentry
;
367 unsigned int i_nlink
;
372 struct timespec i_atime
;
373 struct timespec i_mtime
;
374 struct timespec i_ctime
;
375 unsigned int i_blkbits
;
376 unsigned long i_blksize
;
377 unsigned long i_blocks
;
378 unsigned long i_version
;
379 unsigned short i_bytes
;
380 struct semaphore i_sem
;
381 struct inode_operations
*i_op
;
382 struct file_operations
*i_fop
; /* former ->i_op->default_file_ops */
383 struct super_block
*i_sb
;
384 struct file_lock
*i_flock
;
385 struct address_space
*i_mapping
;
386 struct address_space i_data
;
387 struct dquot
*i_dquot
[MAXQUOTAS
];
388 /* These three should probably be a union */
389 struct list_head i_devices
;
390 struct pipe_inode_info
*i_pipe
;
391 struct block_device
*i_bdev
;
392 struct char_device
*i_cdev
;
394 unsigned long i_dnotify_mask
; /* Directory notify events */
395 struct dnotify_struct
*i_dnotify
; /* for directory notifications */
397 unsigned long i_state
;
399 unsigned int i_flags
;
400 unsigned char i_sock
;
402 atomic_t i_writecount
;
411 #include <linux/coda_fs_i.h>
414 rwlock_t lock
; /* protects pid, uid, euid fields */
415 int pid
; /* pid or -pgrp where SIGIO should be sent */
416 uid_t uid
, euid
; /* uid/euid of process setting the owner */
417 int signum
; /* posix.1b rt signal to be delivered on IO */
421 static inline void inode_add_bytes(struct inode
*inode
, loff_t bytes
)
423 inode
->i_blocks
+= bytes
>> 9;
425 inode
->i_bytes
+= bytes
;
426 if (inode
->i_bytes
>= 512) {
428 inode
->i_bytes
-= 512;
432 static inline void inode_sub_bytes(struct inode
*inode
, loff_t bytes
)
434 inode
->i_blocks
-= bytes
>> 9;
436 if (inode
->i_bytes
< bytes
) {
438 inode
->i_bytes
+= 512;
440 inode
->i_bytes
-= bytes
;
443 static inline loff_t
inode_get_bytes(struct inode
*inode
)
445 return (((loff_t
)inode
->i_blocks
) << 9) + inode
->i_bytes
;
448 static inline void inode_set_bytes(struct inode
*inode
, loff_t bytes
)
450 inode
->i_blocks
= bytes
>> 9;
451 inode
->i_bytes
= bytes
& 511;
455 * Track a single file's readahead state
457 struct file_ra_state
{
458 unsigned long start
; /* Current window */
460 unsigned long next_size
; /* Next window size */
461 unsigned long prev_page
; /* Cache last read() position */
462 unsigned long ahead_start
; /* Ahead window */
463 unsigned long ahead_size
;
464 unsigned long ra_pages
; /* Maximum readahead window */
468 struct list_head f_list
;
469 struct dentry
*f_dentry
;
470 struct vfsmount
*f_vfsmnt
;
471 struct file_operations
*f_op
;
473 unsigned int f_flags
;
476 struct fown_struct f_owner
;
477 unsigned int f_uid
, f_gid
;
479 struct file_ra_state f_ra
;
481 unsigned long f_version
;
484 /* needed for tty driver, and maybe others */
487 /* Used by fs/eventpoll.c to link all the hooks to this file */
488 struct list_head f_ep_links
;
489 spinlock_t f_ep_lock
;
491 extern spinlock_t files_lock
;
492 #define file_list_lock() spin_lock(&files_lock);
493 #define file_list_unlock() spin_unlock(&files_lock);
495 #define get_file(x) atomic_inc(&(x)->f_count)
496 #define file_count(x) atomic_read(&(x)->f_count)
498 extern int init_private_file(struct file
*, struct dentry
*, int);
500 #define MAX_NON_LFS ((1UL<<31) - 1)
502 /* Page cache limit. The filesystems should put that into their s_maxbytes
503 limits, otherwise bad things can happen in VM. */
504 #if BITS_PER_LONG==32
505 #define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
506 #elif BITS_PER_LONG==64
507 #define MAX_LFS_FILESIZE 0x7fffffffffffffff
512 #define FL_ACCESS 8 /* not trying to lock, just looking */
513 #define FL_LOCKD 16 /* lock held by rpc.lockd */
514 #define FL_LEASE 32 /* lease held on this file */
515 #define FL_SLEEP 128 /* A blocking lock */
518 * The POSIX file lock owner is determined by
519 * the "struct files_struct" in the thread group
520 * (or NULL for no owner - BSD locks).
522 * Lockd stuffs a "host" pointer into this.
524 typedef struct files_struct
*fl_owner_t
;
526 /* that will die - we need it for nfs_lock_info */
527 #include <linux/nfs_fs_i.h>
530 struct file_lock
*fl_next
; /* singly linked list for this inode */
531 struct list_head fl_link
; /* doubly linked list of all locks */
532 struct list_head fl_block
; /* circular list of blocked processes */
535 wait_queue_head_t fl_wait
;
536 struct file
*fl_file
;
537 unsigned char fl_flags
;
538 unsigned char fl_type
;
542 void (*fl_notify
)(struct file_lock
*); /* unblock callback */
543 void (*fl_insert
)(struct file_lock
*); /* lock insertion callback */
544 void (*fl_remove
)(struct file_lock
*); /* lock removal callback */
546 struct fasync_struct
* fl_fasync
; /* for lease break notifications */
547 unsigned long fl_break_time
; /* for nonblocking lease breaks */
550 struct nfs_lock_info nfs_fl
;
554 /* The following constant reflects the upper bound of the file/locking space */
556 #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
557 #define OFFSET_MAX INT_LIMIT(loff_t)
558 #define OFFT_OFFSET_MAX INT_LIMIT(off_t)
561 extern struct list_head file_lock_list
;
563 #include <linux/fcntl.h>
565 extern int fcntl_getlk(struct file
*, struct flock
*);
566 extern int fcntl_setlk(struct file
*, unsigned int, struct flock
*);
568 extern int fcntl_getlk64(struct file
*, struct flock64
*);
569 extern int fcntl_setlk64(struct file
*, unsigned int, struct flock64
*);
572 extern void locks_init_lock(struct file_lock
*);
573 extern void locks_copy_lock(struct file_lock
*, struct file_lock
*);
574 extern void locks_remove_posix(struct file
*, fl_owner_t
);
575 extern void locks_remove_flock(struct file
*);
576 extern struct file_lock
*posix_test_lock(struct file
*, struct file_lock
*);
577 extern int posix_lock_file(struct file
*, struct file_lock
*);
578 extern void posix_block_lock(struct file_lock
*, struct file_lock
*);
579 extern void posix_unblock_lock(struct file
*, struct file_lock
*);
580 extern int posix_locks_deadlock(struct file_lock
*, struct file_lock
*);
581 extern int __get_lease(struct inode
*inode
, unsigned int flags
);
582 extern void lease_get_mtime(struct inode
*, struct timespec
*time
);
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);
602 extern int f_setown(struct file
*filp
, unsigned long arg
, int force
);
603 extern void f_delown(struct file
*filp
);
604 extern int send_sigurg(struct fown_struct
*fown
);
610 #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
611 #define MNT_DETACH 0x00000002 /* Just detach from the tree */
613 extern struct list_head super_blocks
;
614 extern spinlock_t sb_lock
;
616 #define sb_entry(list) list_entry((list), struct super_block, s_list)
617 #define S_BIAS (1<<30)
619 struct list_head s_list
; /* Keep this first */
620 dev_t s_dev
; /* search index; _not_ kdev_t */
621 unsigned long s_blocksize
;
622 unsigned long s_old_blocksize
;
623 unsigned char s_blocksize_bits
;
624 unsigned char s_dirt
;
625 unsigned long long s_maxbytes
; /* Max file size */
626 struct file_system_type
*s_type
;
627 struct super_operations
*s_op
;
628 struct dquot_operations
*dq_op
;
629 struct quotactl_ops
*s_qcop
;
630 struct export_operations
*s_export_op
;
631 unsigned long s_flags
;
632 unsigned long s_magic
;
633 struct dentry
*s_root
;
634 struct rw_semaphore s_umount
;
635 struct semaphore s_lock
;
641 struct list_head s_dirty
; /* dirty inodes */
642 struct list_head s_io
; /* parked for writeback */
643 struct list_head s_anon
; /* anonymous dentries for (nfs) exporting */
644 struct list_head s_files
;
646 struct block_device
*s_bdev
;
647 struct list_head s_instances
;
648 struct quota_info s_dquot
; /* Diskquota specific options */
650 char s_id
[32]; /* Informational name */
652 void *s_fs_info
; /* Filesystem private info */
655 * The next field is for VFS *only*. No filesystems have any business
656 * even looking at it. You had been warned.
658 struct semaphore s_vfs_rename_sem
; /* Kludge */
662 * Superblock locking.
664 static inline void lock_super(struct super_block
* sb
)
669 static inline void unlock_super(struct super_block
* sb
)
675 * VFS helper functions..
677 extern int vfs_create(struct inode
*, struct dentry
*, int);
678 extern int vfs_mkdir(struct inode
*, struct dentry
*, int);
679 extern int vfs_mknod(struct inode
*, struct dentry
*, int, dev_t
);
680 extern int vfs_symlink(struct inode
*, struct dentry
*, const char *);
681 extern int vfs_link(struct dentry
*, struct inode
*, struct dentry
*);
682 extern int vfs_rmdir(struct inode
*, struct dentry
*);
683 extern int vfs_unlink(struct inode
*, struct dentry
*);
684 extern int vfs_rename(struct inode
*, struct dentry
*, struct inode
*, struct dentry
*);
689 * NOTE! These match bits 12..15 of stat.st_mode
690 * (ie "(i_mode >> 12) & 15").
703 * This is the "filldir" function type, used by readdir() to let
704 * the kernel specify what kind of dirent layout it wants to have.
705 * This allows the kernel to read directories into kernel space or
706 * to have different dirent layouts depending on the binary type.
708 typedef int (*filldir_t
)(void *, const char *, int, loff_t
, ino_t
, unsigned);
710 struct block_device_operations
{
711 int (*open
) (struct inode
*, struct file
*);
712 int (*release
) (struct inode
*, struct file
*);
713 int (*ioctl
) (struct inode
*, struct file
*, unsigned, unsigned long);
714 int (*media_changed
) (struct gendisk
*);
715 int (*revalidate_disk
) (struct gendisk
*);
716 struct module
*owner
;
720 * "descriptor" for what we're up to with a read for sendfile().
721 * This allows us to use the same read code yet
722 * have multiple different users of the data that
723 * we read from a file.
725 * The simplest case just copies the data to user
735 typedef int (*read_actor_t
)(read_descriptor_t
*, struct page
*, unsigned long, unsigned long);
739 * read, write, poll, fsync, readv, writev can be called
740 * without the big kernel lock held in all filesystems.
743 struct file_operations
{
744 struct module
*owner
;
745 loff_t (*llseek
) (struct file
*, loff_t
, int);
746 ssize_t (*read
) (struct file
*, char *, size_t, loff_t
*);
747 ssize_t (*aio_read
) (struct kiocb
*, char *, size_t, loff_t
);
748 ssize_t (*write
) (struct file
*, const char *, size_t, loff_t
*);
749 ssize_t (*aio_write
) (struct kiocb
*, const char *, size_t, loff_t
);
750 int (*readdir
) (struct file
*, void *, filldir_t
);
751 unsigned int (*poll
) (struct file
*, struct poll_table_struct
*);
752 int (*ioctl
) (struct inode
*, struct file
*, unsigned int, unsigned long);
753 int (*mmap
) (struct file
*, struct vm_area_struct
*);
754 int (*open
) (struct inode
*, struct file
*);
755 int (*flush
) (struct file
*);
756 int (*release
) (struct inode
*, struct file
*);
757 int (*fsync
) (struct file
*, struct dentry
*, int datasync
);
758 int (*aio_fsync
) (struct kiocb
*, int datasync
);
759 int (*fasync
) (int, struct file
*, int);
760 int (*lock
) (struct file
*, int, struct file_lock
*);
761 ssize_t (*readv
) (struct file
*, const struct iovec
*, unsigned long, loff_t
*);
762 ssize_t (*writev
) (struct file
*, const struct iovec
*, unsigned long, loff_t
*);
763 ssize_t (*sendfile
) (struct file
*, loff_t
*, size_t, read_actor_t
, void *);
764 ssize_t (*sendpage
) (struct file
*, struct page
*, int, size_t, loff_t
*, int);
765 unsigned long (*get_unmapped_area
)(struct file
*, unsigned long, unsigned long, unsigned long, unsigned long);
768 struct inode_operations
{
769 int (*create
) (struct inode
*,struct dentry
*,int);
770 struct dentry
* (*lookup
) (struct inode
*,struct dentry
*);
771 int (*link
) (struct dentry
*,struct inode
*,struct dentry
*);
772 int (*unlink
) (struct inode
*,struct dentry
*);
773 int (*symlink
) (struct inode
*,struct dentry
*,const char *);
774 int (*mkdir
) (struct inode
*,struct dentry
*,int);
775 int (*rmdir
) (struct inode
*,struct dentry
*);
776 int (*mknod
) (struct inode
*,struct dentry
*,int,int);
777 int (*rename
) (struct inode
*, struct dentry
*,
778 struct inode
*, struct dentry
*);
779 int (*readlink
) (struct dentry
*, char *,int);
780 int (*follow_link
) (struct dentry
*, struct nameidata
*);
781 void (*truncate
) (struct inode
*);
782 int (*permission
) (struct inode
*, int);
783 int (*setattr
) (struct dentry
*, struct iattr
*);
784 int (*getattr
) (struct vfsmount
*mnt
, struct dentry
*, struct kstat
*);
785 int (*setxattr
) (struct dentry
*, const char *, void *, size_t, int);
786 ssize_t (*getxattr
) (struct dentry
*, const char *, void *, size_t);
787 ssize_t (*listxattr
) (struct dentry
*, char *, size_t);
788 int (*removexattr
) (struct dentry
*, const char *);
793 extern ssize_t
vfs_read(struct file
*, char *, size_t, loff_t
*);
794 extern ssize_t
vfs_write(struct file
*, const char *, size_t, loff_t
*);
795 extern ssize_t
vfs_readv(struct file
*, const struct iovec
*,
796 unsigned long, loff_t
*);
797 extern ssize_t
vfs_writev(struct file
*, const struct iovec
*,
798 unsigned long, loff_t
*);
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 struct inode
*(*alloc_inode
)(struct super_block
*sb
);
806 void (*destroy_inode
)(struct inode
*);
808 void (*read_inode
) (struct inode
*);
810 void (*dirty_inode
) (struct inode
*);
811 void (*write_inode
) (struct inode
*, int);
812 void (*put_inode
) (struct inode
*);
813 void (*drop_inode
) (struct inode
*);
814 void (*delete_inode
) (struct inode
*);
815 void (*put_super
) (struct super_block
*);
816 void (*write_super
) (struct super_block
*);
817 void (*write_super_lockfs
) (struct super_block
*);
818 void (*unlockfs
) (struct super_block
*);
819 int (*statfs
) (struct super_block
*, struct statfs
*);
820 int (*remount_fs
) (struct super_block
*, int *, char *);
821 void (*clear_inode
) (struct inode
*);
822 void (*umount_begin
) (struct super_block
*);
824 int (*show_options
)(struct seq_file
*, struct vfsmount
*);
827 /* Inode state bits. Protected by inode_lock. */
828 #define I_DIRTY_SYNC 1 /* Not dirty enough for O_DATASYNC */
829 #define I_DIRTY_DATASYNC 2 /* Data-related inode changes pending */
830 #define I_DIRTY_PAGES 4 /* Data-related inode changes pending */
836 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
838 extern void __mark_inode_dirty(struct inode
*, int);
839 static inline void mark_inode_dirty(struct inode
*inode
)
841 __mark_inode_dirty(inode
, I_DIRTY
);
844 static inline void mark_inode_dirty_sync(struct inode
*inode
)
846 __mark_inode_dirty(inode
, I_DIRTY_SYNC
);
851 * &export_operations - for nfsd to communicate with file systems
852 * decode_fh: decode a file handle fragment and return a &struct dentry
853 * encode_fh: encode a file handle fragment from a dentry
854 * get_name: find the name for a given inode in a given directory
855 * get_parent: find the parent of a given directory
856 * get_dentry: find a dentry for the inode given a file handle sub-fragment
859 * The export_operations structure provides a means for nfsd to communicate
860 * with a particular exported file system - particularly enabling nfsd and
861 * the filesystem to co-operate when dealing with file handles.
863 * export_operations contains two basic operation for dealing with file handles,
864 * decode_fh() and encode_fh(), and allows for some other operations to be defined
865 * which standard helper routines use to get specific information from the
868 * nfsd encodes information use to determine which filesystem a filehandle
869 * applies to in the initial part of the file handle. The remainder, termed a
870 * file handle fragment, is controlled completely by the filesystem.
871 * The standard helper routines assume that this fragment will contain one or two
872 * sub-fragments, one which identifies the file, and one which may be used to
873 * identify the (a) directory containing the file.
875 * In some situations, nfsd needs to get a dentry which is connected into a
876 * specific part of the file tree. To allow for this, it passes the function
877 * acceptable() together with a @context which can be used to see if the dentry
878 * is acceptable. As there can be multiple dentrys for a given file, the filesystem
879 * should check each one for acceptability before looking for the next. As soon
880 * as an acceptable one is found, it should be returned.
883 * @decode_fh is given a &struct super_block (@sb), a file handle fragment (@fh, @fh_len)
884 * and an acceptability testing function (@acceptable, @context). It should return
885 * a &struct dentry which refers to the same file that the file handle fragment refers
886 * to, and which passes the acceptability test. If it cannot, it should return
887 * a %NULL pointer if the file was found but no acceptable &dentries were available, or
888 * a %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or %ENOMEM).
891 * @encode_fh should store in the file handle fragment @fh (using at most @max_len bytes)
892 * information that can be used by @decode_fh to recover the file refered to by the
893 * &struct dentry @de. If the @connectable flag is set, the encode_fh() should store
894 * sufficient information so that a good attempt can be made to find not only
895 * the file but also it's place in the filesystem. This typically means storing
896 * a reference to de->d_parent in the filehandle fragment.
897 * encode_fh() should return the number of bytes stored or a negative error code
901 * @get_name should find a name for the given @child in the given @parent directory.
902 * The name should be stored in the @name (with the understanding that it is already
903 * pointing to a a %NAME_MAX+1 sized buffer. get_name() should return %0 on success,
904 * a negative error code or error.
905 * @get_name will be called without @parent->i_sem held.
908 * @get_parent should find the parent directory for the given @child which is also
909 * a directory. In the event that it cannot be found, or storage space cannot be
910 * allocated, a %ERR_PTR should be returned.
913 * Given a &super_block (@sb) and a pointer to a file-system specific inode identifier,
914 * possibly an inode number, (@inump) get_dentry() should find the identified inode and
915 * return a dentry for that inode.
916 * Any suitable dentry can be returned including, if necessary, a new dentry created
917 * with d_alloc_root. The caller can then find any other extant dentrys by following the
918 * d_alias links. If a new dentry was created using d_alloc_root, DCACHE_NFSD_DISCONNECTED
919 * should be set, and the dentry should be d_rehash()ed.
921 * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code can be returned.
922 * The @inump will be whatever was passed to nfsd_find_fh_dentry() in either the
923 * @obj or @parent parameters.
926 * get_parent is called with child->d_inode->i_sem down
927 * get_name is not (which is possibly inconsistent)
930 struct export_operations
{
931 struct dentry
*(*decode_fh
)(struct super_block
*sb
, __u32
*fh
, int fh_len
, int fh_type
,
932 int (*acceptable
)(void *context
, struct dentry
*de
),
934 int (*encode_fh
)(struct dentry
*de
, __u32
*fh
, int *max_len
,
937 /* the following are only called from the filesystem itself */
938 int (*get_name
)(struct dentry
*parent
, char *name
,
939 struct dentry
*child
);
940 struct dentry
* (*get_parent
)(struct dentry
*child
);
941 struct dentry
* (*get_dentry
)(struct super_block
*sb
, void *inump
);
943 /* This is set by the exporting module to a standard helper */
944 struct dentry
* (*find_exported_dentry
)(
945 struct super_block
*sb
, void *obj
, void *parent
,
946 int (*acceptable
)(void *context
, struct dentry
*de
),
953 struct file_system_type
{
956 struct super_block
*(*get_sb
) (struct file_system_type
*, int, char *, void *);
957 void (*kill_sb
) (struct super_block
*);
958 struct module
*owner
;
959 struct file_system_type
* next
;
960 struct list_head fs_supers
;
963 struct super_block
*get_sb_bdev(struct file_system_type
*fs_type
,
964 int flags
, char *dev_name
, void * data
,
965 int (*fill_super
)(struct super_block
*, void *, int));
966 struct super_block
*get_sb_single(struct file_system_type
*fs_type
,
967 int flags
, void *data
,
968 int (*fill_super
)(struct super_block
*, void *, int));
969 struct super_block
*get_sb_nodev(struct file_system_type
*fs_type
,
970 int flags
, void *data
,
971 int (*fill_super
)(struct super_block
*, void *, int));
972 void generic_shutdown_super(struct super_block
*sb
);
973 void kill_block_super(struct super_block
*sb
);
974 void kill_anon_super(struct super_block
*sb
);
975 void kill_litter_super(struct super_block
*sb
);
976 void deactivate_super(struct super_block
*sb
);
977 int set_anon_super(struct super_block
*s
, void *data
);
978 struct super_block
*sget(struct file_system_type
*type
,
979 int (*test
)(struct super_block
*,void *),
980 int (*set
)(struct super_block
*,void *),
982 struct super_block
*get_sb_pseudo(struct file_system_type
*, char *,
983 struct super_operations
*ops
, unsigned long);
985 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
986 #define fops_get(fops) \
987 (((fops) && (fops)->owner) \
988 ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
991 #define fops_put(fops) \
993 if ((fops) && (fops)->owner) \
994 __MOD_DEC_USE_COUNT((fops)->owner); \
997 extern int register_filesystem(struct file_system_type
*);
998 extern int unregister_filesystem(struct file_system_type
*);
999 extern struct vfsmount
*kern_mount(struct file_system_type
*);
1000 extern int may_umount(struct vfsmount
*);
1001 extern long do_mount(char *, char *, char *, unsigned long, void *);
1003 #define kern_umount mntput
1005 extern int vfs_statfs(struct super_block
*, struct statfs
*);
1007 /* Return value for VFS lock functions - tells locks.c to lock conventionally
1008 * REALLY kosha for root NFS and nfs_lock
1010 #define LOCK_USE_CLNT 1
1012 #define FLOCK_VERIFY_READ 1
1013 #define FLOCK_VERIFY_WRITE 2
1015 extern int locks_mandatory_locked(struct inode
*);
1016 extern int locks_mandatory_area(int, struct inode
*, struct file
*, loff_t
, size_t);
1019 * Candidates for mandatory locking have the setgid bit set
1020 * but no group execute bit - an otherwise meaningless combination.
1022 #define MANDATORY_LOCK(inode) \
1023 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
1025 static inline int locks_verify_locked(struct inode
*inode
)
1027 if (MANDATORY_LOCK(inode
))
1028 return locks_mandatory_locked(inode
);
1032 static inline int locks_verify_area(int read_write
, struct inode
*inode
,
1033 struct file
*filp
, loff_t offset
,
1036 if (inode
->i_flock
&& MANDATORY_LOCK(inode
))
1037 return locks_mandatory_area(read_write
, inode
, filp
, offset
, count
);
1041 static inline int locks_verify_truncate(struct inode
*inode
,
1045 if (inode
->i_flock
&& MANDATORY_LOCK(inode
))
1046 return locks_mandatory_area(
1047 FLOCK_VERIFY_WRITE
, inode
, filp
,
1048 size
< inode
->i_size
? size
: inode
->i_size
,
1049 (size
< inode
->i_size
? inode
->i_size
- size
1050 : size
- inode
->i_size
)
1055 static inline int get_lease(struct inode
*inode
, unsigned int mode
)
1057 if (inode
->i_flock
&& (inode
->i_flock
->fl_flags
& FL_LEASE
))
1058 return __get_lease(inode
, mode
);
1064 asmlinkage
long sys_open(const char *, int, int);
1065 asmlinkage
long sys_close(unsigned int); /* yes, it's really unsigned */
1066 extern int do_truncate(struct dentry
*, loff_t start
);
1068 extern struct file
*filp_open(const char *, int, int);
1069 extern struct file
* dentry_open(struct dentry
*, struct vfsmount
*, int);
1070 extern int filp_close(struct file
*, fl_owner_t id
);
1071 extern char * getname(const char *);
1074 extern void vfs_caches_init(unsigned long);
1076 #define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL)
1077 #define putname(name) kmem_cache_free(names_cachep, (void *)(name))
1079 enum {BDEV_FILE
, BDEV_SWAP
, BDEV_FS
, BDEV_RAW
};
1080 extern int register_blkdev(unsigned int, const char *, struct block_device_operations
*);
1081 extern int unregister_blkdev(unsigned int, const char *);
1082 extern struct block_device
*bdget(dev_t
);
1083 extern int bd_acquire(struct inode
*inode
);
1084 extern void bd_forget(struct inode
*inode
);
1085 extern void bdput(struct block_device
*);
1086 extern struct char_device
*cdget(dev_t
);
1087 extern void cdput(struct char_device
*);
1088 extern int blkdev_open(struct inode
*, struct file
*);
1089 extern int blkdev_close(struct inode
*, struct file
*);
1090 extern struct file_operations def_blk_fops
;
1091 extern struct address_space_operations def_blk_aops
;
1092 extern struct file_operations def_fifo_fops
;
1093 extern int ioctl_by_bdev(struct block_device
*, unsigned, unsigned long);
1094 extern int blkdev_ioctl(struct inode
*, struct file
*, unsigned, unsigned long);
1095 extern int blkdev_get(struct block_device
*, mode_t
, unsigned, int);
1096 extern int blkdev_put(struct block_device
*, int);
1097 extern int bd_claim(struct block_device
*, void *);
1098 extern void bd_release(struct block_device
*);
1099 extern void blk_run_queues(void);
1102 extern int register_chrdev(unsigned int, const char *, struct file_operations
*);
1103 extern int unregister_chrdev(unsigned int, const char *);
1104 extern int chrdev_open(struct inode
*, struct file
*);
1105 extern const char *__bdevname(dev_t
);
1106 extern inline const char *bdevname(struct block_device
*bdev
)
1108 return __bdevname(bdev
->bd_dev
);
1110 extern const char * cdevname(kdev_t
);
1111 extern const char * kdevname(kdev_t
);
1112 extern void init_special_inode(struct inode
*, umode_t
, int);
1114 /* Invalid inode operations -- fs/bad_inode.c */
1115 extern void make_bad_inode(struct inode
*);
1116 extern int is_bad_inode(struct inode
*);
1118 extern struct file_operations read_fifo_fops
;
1119 extern struct file_operations write_fifo_fops
;
1120 extern struct file_operations rdwr_fifo_fops
;
1121 extern struct file_operations read_pipe_fops
;
1122 extern struct file_operations write_pipe_fops
;
1123 extern struct file_operations rdwr_pipe_fops
;
1125 extern int fs_may_remount_ro(struct super_block
*);
1128 * return READ, READA, or WRITE
1130 #define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK))
1133 * return data direction, READ or WRITE
1135 #define bio_data_dir(bio) ((bio)->bi_rw & 1)
1137 extern int check_disk_change(struct block_device
*);
1138 extern int full_check_disk_change(struct block_device
*);
1139 extern int __check_disk_change(dev_t
);
1140 extern int invalidate_inodes(struct super_block
*);
1141 extern int invalidate_device(kdev_t
, int);
1142 extern void invalidate_inode_pages(struct address_space
*mapping
);
1143 extern void invalidate_inode_pages2(struct address_space
*mapping
);
1144 extern void write_inode_now(struct inode
*, int);
1145 extern int filemap_fdatawrite(struct address_space
*);
1146 extern int filemap_fdatawait(struct address_space
*);
1147 extern void sync_supers(void);
1148 extern sector_t
bmap(struct inode
*, sector_t
);
1149 extern int setattr_mask(unsigned int);
1150 extern int notify_change(struct dentry
*, struct iattr
*);
1151 extern int permission(struct inode
*, int);
1152 extern int vfs_permission(struct inode
*, int);
1153 extern int get_write_access(struct inode
*);
1154 extern int deny_write_access(struct file
*);
1155 static inline void put_write_access(struct inode
* inode
)
1157 atomic_dec(&inode
->i_writecount
);
1159 static inline void allow_write_access(struct file
*file
)
1162 atomic_inc(&file
->f_dentry
->d_inode
->i_writecount
);
1164 extern int do_pipe(int *);
1166 extern int open_namei(const char *, int, int, struct nameidata
*);
1167 extern int may_open(struct nameidata
*, int, int);
1169 extern int kernel_read(struct file
*, unsigned long, char *, unsigned long);
1170 extern struct file
* open_exec(const char *);
1172 /* fs/dcache.c -- generic fs support functions */
1173 extern int is_subdir(struct dentry
*, struct dentry
*);
1174 extern ino_t
find_inode_number(struct dentry
*, struct qstr
*);
1176 #include <linux/err.h>
1178 /* needed for stackable file system support */
1179 extern loff_t
default_llseek(struct file
*file
, loff_t offset
, int origin
);
1181 extern void inode_init_once(struct inode
*);
1182 extern void iput(struct inode
*);
1183 extern struct inode
* igrab(struct inode
*);
1184 extern ino_t
iunique(struct super_block
*, ino_t
);
1185 extern int inode_needs_sync(struct inode
*inode
);
1186 extern void generic_delete_inode(struct inode
*inode
);
1188 extern struct inode
*ilookup5(struct super_block
*sb
, unsigned long hashval
,
1189 int (*test
)(struct inode
*, void *), void *data
);
1190 extern struct inode
*ilookup(struct super_block
*sb
, unsigned long ino
);
1192 extern struct inode
* iget5_locked(struct super_block
*, unsigned long, int (*test
)(struct inode
*, void *), int (*set
)(struct inode
*, void *), void *);
1193 extern struct inode
* iget_locked(struct super_block
*, unsigned long);
1194 extern void unlock_new_inode(struct inode
*);
1196 static inline struct inode
*iget(struct super_block
*sb
, unsigned long ino
)
1198 struct inode
*inode
= iget_locked(sb
, ino
);
1200 if (inode
&& (inode
->i_state
& I_NEW
)) {
1201 sb
->s_op
->read_inode(inode
);
1202 unlock_new_inode(inode
);
1208 extern void __iget(struct inode
* inode
);
1209 extern void clear_inode(struct inode
*);
1210 extern void destroy_inode(struct inode
*);
1211 extern struct inode
*new_inode(struct super_block
*);
1212 extern void remove_suid(struct dentry
*);
1214 extern void __insert_inode_hash(struct inode
*, unsigned long hashval
);
1215 extern void remove_inode_hash(struct inode
*);
1216 static inline void insert_inode_hash(struct inode
*inode
) {
1217 __insert_inode_hash(inode
, inode
->i_ino
);
1220 extern struct file
* get_empty_filp(void);
1221 extern void file_move(struct file
*f
, struct list_head
*list
);
1223 extern int submit_bio(int, struct bio
*);
1224 extern int bdev_read_only(struct block_device
*);
1225 extern int set_blocksize(struct block_device
*, int);
1226 extern int sb_set_blocksize(struct super_block
*, int);
1227 extern int sb_min_blocksize(struct super_block
*, int);
1229 extern int generic_file_mmap(struct file
*, struct vm_area_struct
*);
1230 extern int file_read_actor(read_descriptor_t
* desc
, struct page
*page
, unsigned long offset
, unsigned long size
);
1231 extern int file_send_actor(read_descriptor_t
* desc
, struct page
*page
, unsigned long offset
, unsigned long size
);
1232 extern ssize_t
generic_file_read(struct file
*, char *, size_t, loff_t
*);
1233 extern ssize_t
generic_file_write(struct file
*, const char *, size_t, loff_t
*);
1234 extern ssize_t
generic_file_aio_read(struct kiocb
*, char *, size_t, loff_t
);
1235 extern ssize_t
generic_file_aio_write(struct kiocb
*, const char *, size_t, loff_t
);
1236 extern ssize_t
do_sync_read(struct file
*filp
, char *buf
, size_t len
, loff_t
*ppos
);
1237 extern ssize_t
do_sync_write(struct file
*filp
, const char *buf
, size_t len
, loff_t
*ppos
);
1238 ssize_t
generic_file_write_nolock(struct file
*file
, const struct iovec
*iov
,
1239 unsigned long nr_segs
, loff_t
*ppos
);
1240 extern ssize_t
generic_file_sendfile(struct file
*, loff_t
*, size_t, read_actor_t
, void *);
1241 extern void do_generic_mapping_read(struct address_space
*, struct file_ra_state
*, struct file
*,
1242 loff_t
*, read_descriptor_t
*, read_actor_t
);
1244 file_ra_state_init(struct file_ra_state
*ra
, struct address_space
*mapping
);
1245 extern ssize_t
generic_file_direct_IO(int rw
, struct file
*file
,
1246 const struct iovec
*iov
, loff_t offset
, unsigned long nr_segs
);
1247 extern int generic_direct_IO(int rw
, struct inode
*inode
, struct block_device
*bdev
,
1248 const struct iovec
*iov
, loff_t offset
, unsigned long nr_segs
, get_blocks_t
*get_blocks
);
1249 extern ssize_t
generic_file_readv(struct file
*filp
, const struct iovec
*iov
,
1250 unsigned long nr_segs
, loff_t
*ppos
);
1251 ssize_t
generic_file_writev(struct file
*filp
, const struct iovec
*iov
,
1252 unsigned long nr_segs
, loff_t
*ppos
);
1253 extern loff_t
no_llseek(struct file
*file
, loff_t offset
, int origin
);
1254 extern loff_t
generic_file_llseek(struct file
*file
, loff_t offset
, int origin
);
1255 extern loff_t
remote_llseek(struct file
*file
, loff_t offset
, int origin
);
1256 extern int generic_file_open(struct inode
* inode
, struct file
* filp
);
1258 extern int generic_vm_writeback(struct page
*page
,
1259 struct writeback_control
*wbc
);
1261 static inline void do_generic_file_read(struct file
* filp
, loff_t
*ppos
,
1262 read_descriptor_t
* desc
,
1265 do_generic_mapping_read(filp
->f_dentry
->d_inode
->i_mapping
,
1273 extern struct file_operations generic_ro_fops
;
1275 extern int vfs_readlink(struct dentry
*, char *, int, const char *);
1276 extern int vfs_follow_link(struct nameidata
*, const char *);
1277 extern int page_readlink(struct dentry
*, char *, int);
1278 extern int page_follow_link(struct dentry
*, struct nameidata
*);
1279 extern int page_symlink(struct inode
*inode
, const char *symname
, int len
);
1280 extern struct inode_operations page_symlink_inode_operations
;
1281 extern void generic_fillattr(struct inode
*, struct kstat
*);
1282 extern int vfs_getattr(struct vfsmount
*, struct dentry
*, struct kstat
*);
1284 extern int vfs_readdir(struct file
*, filldir_t
, void *);
1286 extern int vfs_stat(char *, struct kstat
*);
1287 extern int vfs_lstat(char *, struct kstat
*);
1288 extern int vfs_fstat(unsigned int, struct kstat
*);
1290 extern struct file_system_type
*get_fs_type(const char *name
);
1291 extern struct super_block
*get_super(struct block_device
*);
1292 extern struct super_block
*user_get_super(dev_t
);
1293 extern void drop_super(struct super_block
*sb
);
1295 extern int dcache_dir_open(struct inode
*, struct file
*);
1296 extern int dcache_dir_close(struct inode
*, struct file
*);
1297 extern loff_t
dcache_dir_lseek(struct file
*, loff_t
, int);
1298 extern int dcache_readdir(struct file
*, void *, filldir_t
);
1299 extern int simple_statfs(struct super_block
*, struct statfs
*);
1300 extern int simple_link(struct dentry
*, struct inode
*, struct dentry
*);
1301 extern int simple_unlink(struct inode
*, struct dentry
*);
1302 extern int simple_rmdir(struct inode
*, struct dentry
*);
1303 extern int simple_rename(struct inode
*, struct dentry
*, struct inode
*, struct dentry
*);
1304 extern int simple_sync_file(struct file
*, struct dentry
*, int);
1305 extern int simple_empty(struct dentry
*);
1306 extern int simple_readpage(struct file
*file
, struct page
*page
);
1307 extern int simple_prepare_write(struct file
*file
, struct page
*page
,
1308 unsigned offset
, unsigned to
);
1309 extern int simple_commit_write(struct file
*file
, struct page
*page
,
1310 unsigned offset
, unsigned to
);
1312 extern struct dentry
*simple_lookup(struct inode
*, struct dentry
*);
1313 extern ssize_t
generic_read_dir(struct file
*, char *, size_t, loff_t
*);
1314 extern struct file_operations simple_dir_operations
;
1315 extern struct inode_operations simple_dir_inode_operations
;
1317 #ifdef CONFIG_BLK_DEV_INITRD
1318 extern unsigned int real_root_dev
;
1321 extern int inode_change_ok(struct inode
*, struct iattr
*);
1322 extern int inode_setattr(struct inode
*, struct iattr
*);
1324 extern void inode_update_time(struct inode
*inode
, int ctime_too
);
1326 static inline ino_t
parent_ino(struct dentry
*dentry
)
1329 read_lock(&dparent_lock
);
1330 res
= dentry
->d_parent
->d_inode
->i_ino
;
1331 read_unlock(&dparent_lock
);
1335 #endif /* __KERNEL__ */
1336 #endif /* _LINUX_FS_H */