Import 2.3.28
[davej-history.git] / include / linux / fs.h
blobff14cf67d53fbadf5b3b2b8dc91075d9eae1def5
1 #ifndef _LINUX_FS_H
2 #define _LINUX_FS_H
4 /*
5 * This file has definitions for some important file table
6 * structures etc.
7 */
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>
22 #include <asm/atomic.h>
23 #include <asm/bitops.h>
24 #include <asm/cache.h>
26 struct poll_table_struct;
30 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
31 * the file limit at runtime and only root can increase the per-process
32 * nr_file rlimit, so it's safe to set up a ridiculously high absolute
33 * upper limit on files-per-process.
35 * Some programs (notably those using select()) may have to be
36 * recompiled to take full advantage of the new limits..
39 /* Fixed constants first: */
40 #undef NR_OPEN
41 #define NR_OPEN (1024*1024) /* Absolute upper limit on fd num */
42 #define INR_OPEN 1024 /* Initial setting for nfile rlimits */
44 #define BLOCK_SIZE_BITS 10
45 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
47 /* And dynamically-tunable limits and defaults: */
48 extern int max_files, nr_files, nr_free_files;
49 extern int max_super_blocks, nr_super_blocks;
51 #define NR_FILE 8192 /* this can well be larger on a larger system */
52 #define NR_RESERVED_FILES 10 /* reserved for root */
53 #define NR_SUPER 256
55 #define MAY_EXEC 1
56 #define MAY_WRITE 2
57 #define MAY_READ 4
59 #define FMODE_READ 1
60 #define FMODE_WRITE 2
62 #define READ 0
63 #define WRITE 1
64 #define READA 2 /* read-ahead - don't block if no resources */
66 #define WRITERAW 5 /* raw write - don't play with buffer lists */
68 #ifndef NULL
69 #define NULL ((void *) 0)
70 #endif
72 #define NIL_FILP ((struct file *)0)
73 #define SEL_IN 1
74 #define SEL_OUT 2
75 #define SEL_EX 4
77 /* public flags for file_system_type */
78 #define FS_REQUIRES_DEV 1
79 #define FS_NO_DCACHE 2 /* Only dcache the necessary things. */
80 #define FS_NO_PRELIM 4 /* prevent preloading of dentries, even if
81 * FS_NO_DCACHE is not set.
83 #define FS_IBASKET 8 /* FS does callback to free_ibasket() if space gets low. */
86 * These are the fs-independent mount-flags: up to 16 flags are supported
88 #define MS_RDONLY 1 /* Mount read-only */
89 #define MS_NOSUID 2 /* Ignore suid and sgid bits */
90 #define MS_NODEV 4 /* Disallow access to device special files */
91 #define MS_NOEXEC 8 /* Disallow program execution */
92 #define MS_SYNCHRONOUS 16 /* Writes are synced at once */
93 #define MS_REMOUNT 32 /* Alter flags of a mounted FS */
94 #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
95 #define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
96 #define S_APPEND 256 /* Append-only file */
97 #define S_IMMUTABLE 512 /* Immutable file */
98 #define MS_NOATIME 1024 /* Do not update access times. */
99 #define MS_NODIRATIME 2048 /* Do not update directory access times */
101 #define MS_ODD_RENAME 32768 /* Temporary stuff; will go away as soon
102 * as nfs_rename() will be cleaned up
106 * Flags that can be altered by MS_REMOUNT
108 #define MS_RMT_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|\
109 MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
112 * Magic mount flag number. Has to be or-ed to the flag values.
114 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
115 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
118 * Note that nosuid etc flags are inode-specific: setting some file-system
119 * flags just means all the inodes inherit those flags by default. It might be
120 * possible to override it selectively if you really wanted to with some
121 * ioctl() that is not currently implemented.
123 * Exception: MS_RDONLY is always applied to the entire file system.
125 * Unfortunately, it is possible to change a filesystems flags with it mounted
126 * with files in use. This means that all of the inodes will not have their
127 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
128 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
130 #define __IS_FLG(inode,flg) (((inode)->i_sb && (inode)->i_sb->s_flags & (flg)) \
131 || (inode)->i_flags & (flg))
133 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
134 #define IS_NOSUID(inode) __IS_FLG(inode, MS_NOSUID)
135 #define IS_NODEV(inode) __IS_FLG(inode, MS_NODEV)
136 #define IS_NOEXEC(inode) __IS_FLG(inode, MS_NOEXEC)
137 #define IS_SYNC(inode) __IS_FLG(inode, MS_SYNCHRONOUS)
138 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
140 #define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
141 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
142 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
143 #define IS_NOATIME(inode) __IS_FLG(inode, MS_NOATIME)
144 #define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
147 /* the read-only stuff doesn't really belong here, but any other place is
148 probably as bad and I don't want to create yet another include file. */
150 #define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
151 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
152 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
153 #define BLKGETSIZE _IO(0x12,96) /* return device size */
154 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
155 #define BLKRASET _IO(0x12,98) /* Set read ahead for block device */
156 #define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
157 #define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
158 #define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
159 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
160 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
161 #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
162 #if 0
163 #define BLKPG _IO(0x12,105)/* See blkpg.h */
164 /* This was here just to show that the number is taken -
165 probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
166 #endif
169 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
170 #define FIBMAP _IO(0x00,1) /* bmap access */
171 #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
173 #ifdef __KERNEL__
175 #include <asm/semaphore.h>
176 #include <asm/byteorder.h>
178 extern void update_atime (struct inode *);
179 #define UPDATE_ATIME(inode) update_atime (inode)
181 extern void buffer_init(unsigned long);
182 extern void inode_init(void);
183 extern void file_table_init(void);
184 extern void dcache_init(void);
186 typedef char buffer_block[BLOCK_SIZE];
188 /* bh state bits */
189 #define BH_Uptodate 0 /* 1 if the buffer contains valid data */
190 #define BH_Dirty 1 /* 1 if the buffer is dirty */
191 #define BH_Lock 2 /* 1 if the buffer is locked */
192 #define BH_Req 3 /* 0 if the buffer has been invalidated */
193 #define BH_Mapped 4 /* 1 if the buffer has a disk mapping */
194 #define BH_New 5 /* 1 if the buffer is new and not yet written out */
195 #define BH_Protected 6 /* 1 if the buffer is protected */
198 * Try to keep the most commonly used fields in single cache lines (16
199 * bytes) to improve performance. This ordering should be
200 * particularly beneficial on 32-bit processors.
202 * We use the first 16 bytes for the data which is used in searches
203 * over the block hash lists (ie. getblk() and friends).
205 * The second 16 bytes we use for lru buffer scans, as used by
206 * sync_buffers() and refill_freelist(). -- sct
208 struct buffer_head {
209 /* First cache line: */
210 struct buffer_head *b_next; /* Hash queue list */
211 unsigned long b_blocknr; /* block number */
212 unsigned short b_size; /* block size */
213 unsigned short b_list; /* List that this buffer appears */
214 kdev_t b_dev; /* device (B_FREE = free) */
216 atomic_t b_count; /* users using this block */
217 kdev_t b_rdev; /* Real device */
218 unsigned long b_state; /* buffer state bitmap (see above) */
219 unsigned long b_flushtime; /* Time when (dirty) buffer should be written */
221 struct buffer_head *b_next_free;/* lru/free list linkage */
222 struct buffer_head *b_prev_free;/* doubly linked list of buffers */
223 struct buffer_head *b_this_page;/* circular list of buffers in one page */
224 struct buffer_head *b_reqnext; /* request queue */
226 struct buffer_head **b_pprev; /* doubly linked list of hash-queue */
227 char * b_data; /* pointer to data block (512 byte) */
228 struct page *b_page; /* the page this bh is mapped to */
229 void (*b_end_io)(struct buffer_head *bh, int uptodate); /* I/O completion */
230 void *b_dev_id;
232 unsigned long b_rsector; /* Real buffer location on disk */
233 wait_queue_head_t b_wait;
234 struct kiobuf * b_kiobuf; /* kiobuf which owns this IO */
237 typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
238 void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
240 #define __buffer_state(bh, state) (((bh)->b_state & (1UL << BH_##state)) != 0)
242 #define buffer_uptodate(bh) __buffer_state(bh,Uptodate)
243 #define buffer_dirty(bh) __buffer_state(bh,Dirty)
244 #define buffer_locked(bh) __buffer_state(bh,Lock)
245 #define buffer_req(bh) __buffer_state(bh,Req)
246 #define buffer_mapped(bh) __buffer_state(bh,Mapped)
247 #define buffer_new(bh) __buffer_state(bh,New)
248 #define buffer_protected(bh) __buffer_state(bh,Protected)
250 #define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
252 extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned int offset);
254 #define touch_buffer(bh) set_bit(PG_referenced, &bh->b_page->flags)
256 #include <linux/pipe_fs_i.h>
257 #include <linux/minix_fs_i.h>
258 #include <linux/ext2_fs_i.h>
259 #include <linux/hpfs_fs_i.h>
260 #include <linux/ntfs_fs_i.h>
261 #include <linux/msdos_fs_i.h>
262 #include <linux/umsdos_fs_i.h>
263 #include <linux/iso_fs_i.h>
264 #include <linux/nfs_fs_i.h>
265 #include <linux/sysv_fs_i.h>
266 #include <linux/affs_fs_i.h>
267 #include <linux/ufs_fs_i.h>
268 #include <linux/efs_fs_i.h>
269 #include <linux/coda_fs_i.h>
270 #include <linux/romfs_fs_i.h>
271 #include <linux/smb_fs_i.h>
272 #include <linux/hfs_fs_i.h>
273 #include <linux/adfs_fs_i.h>
274 #include <linux/qnx4_fs_i.h>
275 #include <linux/bfs_fs_i.h>
276 #include <linux/udf_fs_i.h>
277 #include <linux/ncp_fs_i.h>
278 #include <linux/proc_fs_i.h>
281 * Attribute flags. These should be or-ed together to figure out what
282 * has been changed!
284 #define ATTR_MODE 1
285 #define ATTR_UID 2
286 #define ATTR_GID 4
287 #define ATTR_SIZE 8
288 #define ATTR_ATIME 16
289 #define ATTR_MTIME 32
290 #define ATTR_CTIME 64
291 #define ATTR_ATIME_SET 128
292 #define ATTR_MTIME_SET 256
293 #define ATTR_FORCE 512 /* Not a change, but a change it */
294 #define ATTR_ATTR_FLAG 1024
297 * This is the Inode Attributes structure, used for notify_change(). It
298 * uses the above definitions as flags, to know which values have changed.
299 * Also, in this manner, a Filesystem can look at only the values it cares
300 * about. Basically, these are the attributes that the VFS layer can
301 * request to change from the FS layer.
303 * Derek Atkins <warlord@MIT.EDU> 94-10-20
305 struct iattr {
306 unsigned int ia_valid;
307 umode_t ia_mode;
308 uid_t ia_uid;
309 gid_t ia_gid;
310 loff_t ia_size;
311 time_t ia_atime;
312 time_t ia_mtime;
313 time_t ia_ctime;
314 unsigned int ia_attr_flags;
318 * This is the inode attributes flag definitions
320 #define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
321 #define ATTR_FLAG_NOATIME 2 /* Don't update atime */
322 #define ATTR_FLAG_APPEND 4 /* Append-only file */
323 #define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
324 #define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
327 * Includes for diskquotas and mount structures.
329 #include <linux/quota.h>
330 #include <linux/mount.h>
333 * oh the beauties of C type declarations.
335 struct page;
337 struct address_space {
338 struct list_head pages;
339 unsigned long nrpages;
342 struct inode {
343 struct list_head i_hash;
344 struct list_head i_list;
345 struct list_head i_dentry;
347 unsigned long i_ino;
348 unsigned int i_count;
349 kdev_t i_dev;
350 umode_t i_mode;
351 nlink_t i_nlink;
352 uid_t i_uid;
353 gid_t i_gid;
354 kdev_t i_rdev;
355 loff_t i_size;
356 time_t i_atime;
357 time_t i_mtime;
358 time_t i_ctime;
359 unsigned long i_blksize;
360 unsigned long i_blocks;
361 unsigned long i_version;
362 struct semaphore i_sem;
363 struct inode_operations *i_op;
364 struct super_block *i_sb;
365 wait_queue_head_t i_wait;
366 struct file_lock *i_flock;
367 struct vm_area_struct *i_mmap;
368 struct address_space i_data;
369 spinlock_t i_shared_lock;
370 struct dquot *i_dquot[MAXQUOTAS];
371 struct pipe_inode_info *i_pipe;
373 unsigned long i_state;
375 unsigned int i_flags;
376 unsigned char i_sock;
378 atomic_t i_writecount;
379 unsigned int i_attr_flags;
380 __u32 i_generation;
381 union {
382 struct minix_inode_info minix_i;
383 struct ext2_inode_info ext2_i;
384 struct hpfs_inode_info hpfs_i;
385 struct ntfs_inode_info ntfs_i;
386 struct msdos_inode_info msdos_i;
387 struct umsdos_inode_info umsdos_i;
388 struct iso_inode_info isofs_i;
389 struct nfs_inode_info nfs_i;
390 struct sysv_inode_info sysv_i;
391 struct affs_inode_info affs_i;
392 struct ufs_inode_info ufs_i;
393 struct efs_inode_info efs_i;
394 struct romfs_inode_info romfs_i;
395 struct coda_inode_info coda_i;
396 struct smb_inode_info smbfs_i;
397 struct hfs_inode_info hfs_i;
398 struct adfs_inode_info adfs_i;
399 struct qnx4_inode_info qnx4_i;
400 struct bfs_inode_info bfs_i;
401 struct udf_inode_info udf_i;
402 struct ncp_inode_info ncpfs_i;
403 struct proc_inode_info proc_i;
404 struct socket socket_i;
405 void *generic_ip;
406 } u;
409 /* Inode state bits.. */
410 #define I_DIRTY 1
411 #define I_LOCK 2
412 #define I_FREEING 4
414 extern void __mark_inode_dirty(struct inode *);
415 static inline void mark_inode_dirty(struct inode *inode)
417 if (!(inode->i_state & I_DIRTY))
418 __mark_inode_dirty(inode);
421 struct fown_struct {
422 int pid; /* pid or -pgrp where SIGIO should be sent */
423 uid_t uid, euid; /* uid/euid of process setting the owner */
424 int signum; /* posix.1b rt signal to be delivered on IO */
427 struct file {
428 struct list_head f_list;
429 struct dentry *f_dentry;
430 struct file_operations *f_op;
431 atomic_t f_count;
432 unsigned int f_flags;
433 mode_t f_mode;
434 loff_t f_pos;
435 unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
436 struct fown_struct f_owner;
437 unsigned int f_uid, f_gid;
438 int f_error;
440 unsigned long f_version;
442 /* needed for tty driver, and maybe others */
443 void *private_data;
445 extern spinlock_t files_lock;
446 #define file_list_lock() spin_lock(&files_lock);
447 #define file_list_unlock() spin_unlock(&files_lock);
449 #define get_file(x) atomic_inc(&(x)->f_count)
450 #define file_count(x) atomic_read(&(x)->f_count)
452 extern int init_private_file(struct file *, struct dentry *, int);
454 #define FL_POSIX 1
455 #define FL_FLOCK 2
456 #define FL_BROKEN 4 /* broken flock() emulation */
457 #define FL_ACCESS 8 /* for processes suspended by mandatory locking */
458 #define FL_LOCKD 16 /* lock held by rpc.lockd */
461 * The POSIX file lock owner is determined by
462 * the "struct files_struct" in the thread group
463 * (or NULL for no owner - BSD locks).
465 * Lockd stuffs a "host" pointer into this.
467 typedef struct files_struct *fl_owner_t;
469 struct file_lock {
470 struct file_lock *fl_next; /* singly linked list for this inode */
471 struct file_lock *fl_nextlink; /* doubly linked list of all locks */
472 struct file_lock *fl_prevlink; /* used to simplify lock removal */
473 struct file_lock *fl_nextblock; /* circular list of blocked processes */
474 struct file_lock *fl_prevblock;
475 fl_owner_t fl_owner;
476 unsigned int fl_pid;
477 wait_queue_head_t fl_wait;
478 struct file *fl_file;
479 unsigned char fl_flags;
480 unsigned char fl_type;
481 off_t fl_start;
482 off_t fl_end;
484 void (*fl_notify)(struct file_lock *); /* unblock callback */
486 union {
487 struct nfs_lock_info nfs_fl;
488 } fl_u;
491 extern struct file_lock *file_lock_table;
493 #include <linux/fcntl.h>
495 extern int fcntl_getlk(unsigned int, struct flock *);
496 extern int fcntl_setlk(unsigned int, unsigned int, struct flock *);
498 /* fs/locks.c */
499 extern void locks_remove_posix(struct file *, fl_owner_t);
500 extern void locks_remove_flock(struct file *);
501 extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
502 extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
503 extern void posix_block_lock(struct file_lock *, struct file_lock *);
504 extern void posix_unblock_lock(struct file_lock *);
506 struct fasync_struct {
507 int magic;
508 int fa_fd;
509 struct fasync_struct *fa_next; /* singly linked list */
510 struct file *fa_file;
513 #define FASYNC_MAGIC 0x4601
515 extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
517 #include <linux/minix_fs_sb.h>
518 #include <linux/ext2_fs_sb.h>
519 #include <linux/hpfs_fs_sb.h>
520 #include <linux/ntfs_fs_sb.h>
521 #include <linux/msdos_fs_sb.h>
522 #include <linux/iso_fs_sb.h>
523 #include <linux/nfs_fs_sb.h>
524 #include <linux/sysv_fs_sb.h>
525 #include <linux/affs_fs_sb.h>
526 #include <linux/ufs_fs_sb.h>
527 #include <linux/efs_fs_sb.h>
528 #include <linux/romfs_fs_sb.h>
529 #include <linux/smb_fs_sb.h>
530 #include <linux/hfs_fs_sb.h>
531 #include <linux/adfs_fs_sb.h>
532 #include <linux/qnx4_fs_sb.h>
533 #include <linux/bfs_fs_sb.h>
534 #include <linux/udf_fs_sb.h>
535 #include <linux/ncp_fs_sb.h>
537 extern struct list_head super_blocks;
539 #define sb_entry(list) list_entry((list), struct super_block, s_list)
540 struct super_block {
541 struct list_head s_list; /* Keep this first */
542 kdev_t s_dev;
543 unsigned long s_blocksize;
544 unsigned char s_blocksize_bits;
545 unsigned char s_lock;
546 unsigned char s_rd_only;
547 unsigned char s_dirt;
548 struct file_system_type *s_type;
549 struct super_operations *s_op;
550 struct dquot_operations *dq_op;
551 unsigned long s_flags;
552 unsigned long s_magic;
553 unsigned long s_time;
554 struct dentry *s_root;
555 wait_queue_head_t s_wait;
557 struct inode *s_ibasket;
558 short int s_ibasket_count;
559 short int s_ibasket_max;
560 struct list_head s_dirty; /* dirty inodes */
561 struct list_head s_files;
563 union {
564 struct minix_sb_info minix_sb;
565 struct ext2_sb_info ext2_sb;
566 struct hpfs_sb_info hpfs_sb;
567 struct ntfs_sb_info ntfs_sb;
568 struct msdos_sb_info msdos_sb;
569 struct isofs_sb_info isofs_sb;
570 struct nfs_sb_info nfs_sb;
571 struct sysv_sb_info sysv_sb;
572 struct affs_sb_info affs_sb;
573 struct ufs_sb_info ufs_sb;
574 struct efs_sb_info efs_sb;
575 struct romfs_sb_info romfs_sb;
576 struct smb_sb_info smbfs_sb;
577 struct hfs_sb_info hfs_sb;
578 struct adfs_sb_info adfs_sb;
579 struct qnx4_sb_info qnx4_sb;
580 struct bfs_sb_info bfs_sb;
581 struct udf_sb_info udf_sb;
582 struct ncp_sb_info ncpfs_sb;
583 void *generic_sbp;
584 } u;
586 * The next field is for VFS *only*. No filesystems have any business
587 * even looking at it. You had been warned.
589 struct semaphore s_vfs_rename_sem; /* Kludge */
593 * VFS helper functions..
595 extern int vfs_rmdir(struct inode *, struct dentry *);
596 extern int vfs_unlink(struct inode *, struct dentry *);
597 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
600 * This is the "filldir" function type, used by readdir() to let
601 * the kernel specify what kind of dirent layout it wants to have.
602 * This allows the kernel to read directories into kernel space or
603 * to have different dirent layouts depending on the binary type.
605 typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
607 struct file_operations {
608 loff_t (*llseek) (struct file *, loff_t, int);
609 ssize_t (*read) (struct file *, char *, size_t, loff_t *);
610 ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
611 int (*readdir) (struct file *, void *, filldir_t);
612 unsigned int (*poll) (struct file *, struct poll_table_struct *);
613 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
614 int (*mmap) (struct file *, struct vm_area_struct *);
615 int (*open) (struct inode *, struct file *);
616 int (*flush) (struct file *);
617 int (*release) (struct inode *, struct file *);
618 int (*fsync) (struct file *, struct dentry *);
619 int (*fasync) (int, struct file *, int);
620 int (*check_media_change) (kdev_t dev);
621 int (*revalidate) (kdev_t dev);
622 int (*lock) (struct file *, int, struct file_lock *);
625 struct inode_operations {
626 struct file_operations * default_file_ops;
627 int (*create) (struct inode *,struct dentry *,int);
628 struct dentry * (*lookup) (struct inode *,struct dentry *);
629 int (*link) (struct dentry *,struct inode *,struct dentry *);
630 int (*unlink) (struct inode *,struct dentry *);
631 int (*symlink) (struct inode *,struct dentry *,const char *);
632 int (*mkdir) (struct inode *,struct dentry *,int);
633 int (*rmdir) (struct inode *,struct dentry *);
634 int (*mknod) (struct inode *,struct dentry *,int,int);
635 int (*rename) (struct inode *, struct dentry *,
636 struct inode *, struct dentry *);
637 int (*readlink) (struct dentry *, char *,int);
638 struct dentry * (*follow_link) (struct dentry *, struct dentry *, unsigned int);
640 * the order of these functions within the VFS template has been
641 * changed because SMP locking has changed: from now on all get_block,
642 * readpage, writepage and flushpage functions are supposed to do
643 * whatever locking they need to get proper SMP operation - for
644 * now in most cases this means a lock/unlock_kernel at entry/exit.
645 * [The new order is also slightly more logical :)]
648 * Generic block allocator exported by the lowlevel fs. All metadata
649 * details are handled by the lowlevel fs, all 'logical data content'
650 * details are handled by the highlevel block layer.
652 int (*get_block) (struct inode *, long, struct buffer_head *, int);
654 int (*readpage) (struct file *, struct page *);
655 int (*writepage) (struct file *, struct page *);
656 int (*flushpage) (struct inode *, struct page *, unsigned long);
658 void (*truncate) (struct inode *);
659 int (*permission) (struct inode *, int);
660 int (*smap) (struct inode *,int);
661 int (*revalidate) (struct dentry *);
664 struct super_operations {
665 void (*read_inode) (struct inode *);
666 void (*write_inode) (struct inode *);
667 void (*put_inode) (struct inode *);
668 void (*delete_inode) (struct inode *);
669 int (*notify_change) (struct dentry *, struct iattr *);
670 void (*put_super) (struct super_block *);
671 void (*write_super) (struct super_block *);
672 int (*statfs) (struct super_block *, struct statfs *, int);
673 int (*remount_fs) (struct super_block *, int *, char *);
674 void (*clear_inode) (struct inode *);
675 void (*umount_begin) (struct super_block *);
678 struct dquot_operations {
679 void (*initialize) (struct inode *, short);
680 void (*drop) (struct inode *);
681 int (*alloc_block) (const struct inode *, unsigned long, uid_t, char);
682 int (*alloc_inode) (const struct inode *, unsigned long, uid_t);
683 void (*free_block) (const struct inode *, unsigned long);
684 void (*free_inode) (const struct inode *, unsigned long);
685 int (*transfer) (struct dentry *, struct iattr *, uid_t);
688 struct file_system_type {
689 const char *name;
690 int fs_flags;
691 struct super_block *(*read_super) (struct super_block *, void *, int);
692 struct file_system_type * next;
695 extern int register_filesystem(struct file_system_type *);
696 extern int unregister_filesystem(struct file_system_type *);
698 /* Return value for VFS lock functions - tells locks.c to lock conventionally
699 * REALLY kosha for root NFS and nfs_lock
701 #define LOCK_USE_CLNT 1
703 #define FLOCK_VERIFY_READ 1
704 #define FLOCK_VERIFY_WRITE 2
706 extern int locks_mandatory_locked(struct inode *);
707 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
710 * Candidates for mandatory locking have the setgid bit set
711 * but no group execute bit - an otherwise meaningless combination.
713 #define MANDATORY_LOCK(inode) \
714 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
716 static inline int locks_verify_locked(struct inode *inode)
718 if (MANDATORY_LOCK(inode))
719 return locks_mandatory_locked(inode);
720 return 0;
723 extern inline int locks_verify_area(int read_write, struct inode *inode,
724 struct file *filp, loff_t offset,
725 size_t count)
727 if (inode->i_flock && MANDATORY_LOCK(inode))
728 return locks_mandatory_area(read_write, inode, filp, offset, count);
729 return 0;
733 /* fs/open.c */
735 asmlinkage long sys_open(const char *, int, int);
736 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
737 extern int do_close(unsigned int, int); /* yes, it's really unsigned */
738 extern int do_truncate(struct dentry *, unsigned long);
739 extern int get_unused_fd(void);
740 extern void put_unused_fd(unsigned int);
742 extern struct file *filp_open(const char *, int, int);
743 extern int filp_close(struct file *, fl_owner_t id);
745 extern char * getname(const char *);
746 #define __getname() ((char *) __get_free_page(GFP_KERNEL))
747 #define putname(name) free_page((unsigned long)(name))
749 extern void kill_fasync(struct fasync_struct *, int, int);
750 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
751 extern int unregister_blkdev(unsigned int, const char *);
752 extern int blkdev_open(struct inode *, struct file *);
753 extern int blkdev_release (struct inode *);
754 extern struct file_operations def_blk_fops;
755 extern struct inode_operations blkdev_inode_operations;
757 /* fs/devices.c */
758 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
759 extern int unregister_chrdev(unsigned int, const char *);
760 extern int chrdev_open(struct inode *, struct file *);
761 extern struct file_operations def_chr_fops;
762 extern struct inode_operations chrdev_inode_operations;
763 extern char * bdevname(kdev_t);
764 extern char * cdevname(kdev_t);
765 extern char * kdevname(kdev_t);
766 extern void init_special_inode(struct inode *, umode_t, int);
768 extern void init_fifo(struct inode *);
769 extern struct inode_operations fifo_inode_operations;
771 /* Invalid inode operations -- fs/bad_inode.c */
772 extern void make_bad_inode(struct inode *);
773 extern int is_bad_inode(struct inode *);
775 extern struct file_operations connecting_fifo_fops;
776 extern struct file_operations read_fifo_fops;
777 extern struct file_operations write_fifo_fops;
778 extern struct file_operations rdwr_fifo_fops;
779 extern struct file_operations read_pipe_fops;
780 extern struct file_operations write_pipe_fops;
781 extern struct file_operations rdwr_pipe_fops;
783 extern struct file_system_type *get_fs_type(const char *);
785 extern int fs_may_remount_ro(struct super_block *);
786 extern int fs_may_mount(kdev_t);
788 extern int try_to_free_buffers(struct page *);
789 extern void refile_buffer(struct buffer_head * buf);
791 #define BUF_CLEAN 0
792 #define BUF_LOCKED 1 /* Buffers scheduled for write */
793 #define BUF_DIRTY 2 /* Dirty buffers, not yet scheduled for write */
794 #define NR_LIST 3
797 * This is called by bh->b_end_io() handlers when I/O has completed.
799 extern inline void mark_buffer_uptodate(struct buffer_head * bh, int on)
801 if (on)
802 set_bit(BH_Uptodate, &bh->b_state);
803 else
804 clear_bit(BH_Uptodate, &bh->b_state);
807 #define atomic_set_buffer_clean(bh) test_and_clear_bit(BH_Dirty, &(bh)->b_state)
809 extern inline void __mark_buffer_clean(struct buffer_head *bh)
811 refile_buffer(bh);
814 extern inline void mark_buffer_clean(struct buffer_head * bh)
816 if (atomic_set_buffer_clean(bh))
817 __mark_buffer_clean(bh);
820 extern void FASTCALL(__mark_buffer_dirty(struct buffer_head *bh, int flag));
822 #define atomic_set_buffer_dirty(bh) test_and_set_bit(BH_Dirty, &(bh)->b_state)
824 extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag)
826 if (!atomic_set_buffer_dirty(bh))
827 __mark_buffer_dirty(bh, flag);
830 extern void balance_dirty(kdev_t);
831 extern int check_disk_change(kdev_t);
832 extern int invalidate_inodes(struct super_block *);
833 extern void invalidate_inode_pages(struct inode *);
834 extern void invalidate_buffers(kdev_t);
835 extern int floppy_is_wp(int);
836 extern void sync_inodes(kdev_t);
837 extern void write_inode_now(struct inode *);
838 extern void sync_dev(kdev_t);
839 extern int fsync_dev(kdev_t);
840 extern void sync_supers(kdev_t);
841 extern int bmap(struct inode *, int);
842 extern int notify_change(struct dentry *, struct iattr *);
843 extern int permission(struct inode *, int);
844 extern int get_write_access(struct inode *);
845 extern void put_write_access(struct inode *);
846 extern struct dentry * open_namei(const char *, int, int);
847 extern struct dentry * do_mknod(const char *, int, dev_t);
848 extern int do_pipe(int *);
850 /* fs/dcache.c -- generic fs support functions */
851 extern int is_subdir(struct dentry *, struct dentry *);
852 extern ino_t find_inode_number(struct dentry *, struct qstr *);
855 * Kernel pointers have redundant information, so we can use a
856 * scheme where we can return either an error code or a dentry
857 * pointer with the same return value.
859 * This should be a per-architecture thing, to allow different
860 * error and pointer decisions.
862 #define ERR_PTR(err) ((void *)((long)(err)))
863 #define PTR_ERR(ptr) ((long)(ptr))
864 #define IS_ERR(ptr) ((unsigned long)(ptr) > (unsigned long)(-1000))
867 * The bitmask for a lookup event:
868 * - follow links at the end
869 * - require a directory
870 * - ending slashes ok even for nonexistent files
871 * - internal "there are more path compnents" flag
873 #define LOOKUP_FOLLOW (1)
874 #define LOOKUP_DIRECTORY (2)
875 #define LOOKUP_SLASHOK (4)
876 #define LOOKUP_CONTINUE (8)
879 * "descriptor" for what we're up to with a read for sendfile().
880 * This allows us to use the same read code yet
881 * have multiple different users of the data that
882 * we read from a file.
884 * The simplest case just copies the data to user
885 * mode.
887 typedef struct {
888 size_t written;
889 size_t count;
890 char * buf;
891 int error;
892 } read_descriptor_t;
894 typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
897 extern struct dentry * lookup_dentry(const char *, struct dentry *, unsigned int);
898 extern struct dentry * __namei(const char *, unsigned int);
900 #define namei(pathname) __namei(pathname, 1)
901 #define lnamei(pathname) __namei(pathname, 0)
903 extern void iput(struct inode *);
904 extern struct inode * igrab(struct inode *);
905 extern ino_t iunique(struct super_block *, ino_t);
907 typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
908 extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
909 static inline struct inode *iget(struct super_block *sb, unsigned long ino)
911 return iget4(sb, ino, NULL, NULL);
914 extern void clear_inode(struct inode *);
915 extern struct inode * get_empty_inode(void);
917 extern void insert_inode_hash(struct inode *);
918 extern void remove_inode_hash(struct inode *);
919 extern struct file * get_empty_filp(void);
920 extern void file_move(struct file *f, struct list_head *list);
921 extern void file_moveto(struct file *new, struct file *old);
922 extern struct buffer_head * get_hash_table(kdev_t, int, int);
923 extern struct buffer_head * getblk(kdev_t, int, int);
924 extern void ll_rw_block(int, int, struct buffer_head * bh[]);
925 extern int is_read_only(kdev_t);
926 extern void __brelse(struct buffer_head *);
927 extern inline void brelse(struct buffer_head *buf)
929 if (buf)
930 __brelse(buf);
932 extern void __bforget(struct buffer_head *);
933 extern inline void bforget(struct buffer_head *buf)
935 if (buf)
936 __bforget(buf);
938 extern void set_blocksize(kdev_t, int);
939 extern unsigned int get_hardblocksize(kdev_t);
940 extern struct buffer_head * bread(kdev_t, int, int);
941 extern struct buffer_head * breada(kdev_t, int, int, unsigned int, unsigned int);
942 extern void wakeup_bdflush(int wait);
944 extern int brw_page(int, struct page *, kdev_t, int [], int);
946 typedef int (*writepage_t)(struct file *, struct page *, unsigned long, unsigned long, const char *);
948 /* Generic buffer handling for block filesystems.. */
949 extern int block_read_full_page(struct file *, struct page *);
950 extern int block_write_full_page (struct file *, struct page *);
951 extern int block_write_partial_page (struct file *, struct page *, unsigned long, unsigned long, const char *);
952 extern int block_write_cont_page (struct file *, struct page *, unsigned long, unsigned long, const char *);
953 extern int block_flushpage(struct inode *, struct page *, unsigned long);
955 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
956 extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
957 extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *, writepage_t);
958 extern void do_generic_file_read(struct file * filp, loff_t *ppos, read_descriptor_t * desc, read_actor_t actor);
961 extern struct super_block *get_super(kdev_t);
962 struct super_block *get_empty_super(void);
963 void remove_vfsmnt(kdev_t dev);
964 extern void put_super(kdev_t);
965 unsigned long generate_cluster(kdev_t, int b[], int);
966 unsigned long generate_cluster_swab32(kdev_t, int b[], int);
967 extern kdev_t ROOT_DEV;
969 extern void show_buffers(void);
970 extern void mount_root(void);
972 #ifdef CONFIG_BLK_DEV_INITRD
973 extern kdev_t real_root_dev;
974 extern int change_root(kdev_t, const char *);
975 #endif
977 extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
978 extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
979 extern int read_ahead[];
981 extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
982 extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
984 extern int block_fsync(struct file *, struct dentry *);
985 extern int file_fsync(struct file *, struct dentry *);
986 extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start, unsigned long end);
988 extern int inode_change_ok(struct inode *, struct iattr *);
989 extern void inode_setattr(struct inode *, struct iattr *);
991 #endif /* __KERNEL__ */
993 #endif /* _LINUX_FS_H */