Import 2.3.10pre1
[davej-history.git] / include / linux / fs.h
blob7d60fee3170d0d26964dfc75148d3870ce1c5f42
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 I'll fix
31 * that later. Anyway, now the file code is no longer dependent
32 * on bitmaps in unsigned longs, but uses the new fd_set structure..
34 * Some programs (notably those using select()) may have to be
35 * recompiled to take full advantage of the new limits..
38 /* Fixed constants first: */
39 #undef NR_OPEN
40 #define NR_OPEN 1024
42 #define BLOCK_SIZE_BITS 10
43 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
45 /* And dynamically-tunable limits and defaults: */
46 extern int max_inodes;
47 extern int max_files, nr_files, nr_free_files;
48 extern int max_super_blocks, nr_super_blocks;
50 #define NR_FILE 4096 /* this can well be larger on a larger system */
51 #define NR_RESERVED_FILES 10 /* reserved for root */
52 #define NR_SUPER 256
54 #define MAY_EXEC 1
55 #define MAY_WRITE 2
56 #define MAY_READ 4
58 #define FMODE_READ 1
59 #define FMODE_WRITE 2
61 #define READ 0
62 #define WRITE 1
63 #define READA 2 /* read-ahead - don't block if no resources */
64 #define WRITEA 3 /* write-ahead - don't block if no resources */
66 #ifndef NULL
67 #define NULL ((void *) 0)
68 #endif
70 #define NIL_FILP ((struct file *)0)
71 #define SEL_IN 1
72 #define SEL_OUT 2
73 #define SEL_EX 4
75 /* public flags for file_system_type */
76 #define FS_REQUIRES_DEV 1
77 #define FS_NO_DCACHE 2 /* Only dcache the necessary things. */
78 #define FS_NO_PRELIM 4 /* prevent preloading of dentries, even if
79 * FS_NO_DCACHE is not set.
81 #define FS_IBASKET 8 /* FS does callback to free_ibasket() if space gets low. */
84 * These are the fs-independent mount-flags: up to 16 flags are supported
86 #define MS_RDONLY 1 /* Mount read-only */
87 #define MS_NOSUID 2 /* Ignore suid and sgid bits */
88 #define MS_NODEV 4 /* Disallow access to device special files */
89 #define MS_NOEXEC 8 /* Disallow program execution */
90 #define MS_SYNCHRONOUS 16 /* Writes are synced at once */
91 #define MS_REMOUNT 32 /* Alter flags of a mounted FS */
92 #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
93 #define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
94 #define S_APPEND 256 /* Append-only file */
95 #define S_IMMUTABLE 512 /* Immutable file */
96 #define MS_NOATIME 1024 /* Do not update access times. */
97 #define MS_NODIRATIME 2048 /* Do not update directory access times */
99 #define MS_ODD_RENAME 32768 /* Temporary stuff; will go away as soon
100 * as nfs_rename() will be cleaned up
104 * Flags that can be altered by MS_REMOUNT
106 #define MS_RMT_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|\
107 MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
110 * Magic mount flag number. Has to be or-ed to the flag values.
112 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
113 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
116 * Note that nosuid etc flags are inode-specific: setting some file-system
117 * flags just means all the inodes inherit those flags by default. It might be
118 * possible to override it selectively if you really wanted to with some
119 * ioctl() that is not currently implemented.
121 * Exception: MS_RDONLY is always applied to the entire file system.
123 * Unfortunately, it is possible to change a filesystems flags with it mounted
124 * with files in use. This means that all of the inodes will not have their
125 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
126 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
128 #define __IS_FLG(inode,flg) (((inode)->i_sb && (inode)->i_sb->s_flags & (flg)) \
129 || (inode)->i_flags & (flg))
131 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
132 #define IS_NOSUID(inode) __IS_FLG(inode, MS_NOSUID)
133 #define IS_NODEV(inode) __IS_FLG(inode, MS_NODEV)
134 #define IS_NOEXEC(inode) __IS_FLG(inode, MS_NOEXEC)
135 #define IS_SYNC(inode) __IS_FLG(inode, MS_SYNCHRONOUS)
136 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
138 #define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
139 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
140 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
141 #define IS_NOATIME(inode) __IS_FLG(inode, MS_NOATIME)
142 #define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
145 /* the read-only stuff doesn't really belong here, but any other place is
146 probably as bad and I don't want to create yet another include file. */
148 #define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
149 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
150 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
151 #define BLKGETSIZE _IO(0x12,96) /* return device size */
152 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
153 #define BLKRASET _IO(0x12,98) /* Set read ahead for block device */
154 #define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
155 #define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
156 #define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
157 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
158 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
159 #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
160 #if 0
161 #define BLKPG _IO(0x12,105)/* See blkpg.h */
162 /* This was here just to show that the number is taken -
163 probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
164 #endif
167 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
168 #define FIBMAP _IO(0x00,1) /* bmap access */
169 #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
171 #ifdef __KERNEL__
173 #include <asm/semaphore.h>
174 #include <asm/byteorder.h>
176 extern void update_atime (struct inode *);
177 #define UPDATE_ATIME(inode) update_atime (inode)
179 extern void buffer_init(unsigned long);
180 extern void inode_init(void);
181 extern void file_table_init(void);
182 extern void dcache_init(void);
184 typedef char buffer_block[BLOCK_SIZE];
186 /* bh state bits */
187 #define BH_Uptodate 0 /* 1 if the buffer contains valid data */
188 #define BH_Dirty 1 /* 1 if the buffer is dirty */
189 #define BH_Lock 2 /* 1 if the buffer is locked */
190 #define BH_Req 3 /* 0 if the buffer has been invalidated */
191 #define BH_Mapped 4 /* 1 if the buffer has a disk mapping */
192 #define BH_New 5 /* 1 if the buffer is new and not yet written out */
193 #define BH_Protected 6 /* 1 if the buffer is protected */
196 * Try to keep the most commonly used fields in single cache lines (16
197 * bytes) to improve performance. This ordering should be
198 * particularly beneficial on 32-bit processors.
200 * We use the first 16 bytes for the data which is used in searches
201 * over the block hash lists (ie. getblk() and friends).
203 * The second 16 bytes we use for lru buffer scans, as used by
204 * sync_buffers() and refill_freelist(). -- sct
206 struct buffer_head {
207 /* First cache line: */
208 struct buffer_head *b_next; /* Hash queue list */
209 unsigned long b_blocknr; /* block number */
210 unsigned short b_size; /* block size */
211 unsigned short b_list; /* List that this buffer appears */
212 kdev_t b_dev; /* device (B_FREE = free) */
214 atomic_t b_count; /* users using this block */
215 kdev_t b_rdev; /* Real device */
216 unsigned long b_state; /* buffer state bitmap (see above) */
217 unsigned long b_flushtime; /* Time when (dirty) buffer should be written */
219 struct buffer_head *b_next_free;/* lru/free list linkage */
220 struct buffer_head *b_prev_free;/* doubly linked list of buffers */
221 struct buffer_head *b_this_page;/* circular list of buffers in one page */
222 struct buffer_head *b_reqnext; /* request queue */
224 struct buffer_head **b_pprev; /* doubly linked list of hash-queue */
225 char *b_data; /* pointer to data block (1024 bytes) */
226 void (*b_end_io)(struct buffer_head *bh, int uptodate); /* I/O completion */
227 void *b_dev_id;
229 unsigned long b_rsector; /* Real buffer location on disk */
230 wait_queue_head_t b_wait;
233 typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
234 void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
236 #define __buffer_state(bh, state) (((bh)->b_state & (1UL << BH_##state)) != 0)
238 #define buffer_uptodate(bh) __buffer_state(bh,Uptodate)
239 #define buffer_dirty(bh) __buffer_state(bh,Dirty)
240 #define buffer_locked(bh) __buffer_state(bh,Lock)
241 #define buffer_req(bh) __buffer_state(bh,Req)
242 #define buffer_mapped(bh) __buffer_state(bh,Mapped)
243 #define buffer_new(bh) __buffer_state(bh,New)
244 #define buffer_protected(bh) __buffer_state(bh,Protected)
246 #define buffer_page(bh) (mem_map + MAP_NR((bh)->b_data))
247 #define touch_buffer(bh) set_bit(PG_referenced, &buffer_page(bh)->flags)
249 #include <linux/pipe_fs_i.h>
250 #include <linux/minix_fs_i.h>
251 #include <linux/ext2_fs_i.h>
252 #include <linux/hpfs_fs_i.h>
253 #include <linux/ntfs_fs_i.h>
254 #include <linux/msdos_fs_i.h>
255 #include <linux/umsdos_fs_i.h>
256 #include <linux/iso_fs_i.h>
257 #include <linux/nfs_fs_i.h>
258 #include <linux/sysv_fs_i.h>
259 #include <linux/affs_fs_i.h>
260 #include <linux/ufs_fs_i.h>
261 #include <linux/efs_fs_i.h>
262 #include <linux/coda_fs_i.h>
263 #include <linux/romfs_fs_i.h>
264 #include <linux/smb_fs_i.h>
265 #include <linux/hfs_fs_i.h>
266 #include <linux/adfs_fs_i.h>
267 #include <linux/qnx4_fs_i.h>
270 * Attribute flags. These should be or-ed together to figure out what
271 * has been changed!
273 #define ATTR_MODE 1
274 #define ATTR_UID 2
275 #define ATTR_GID 4
276 #define ATTR_SIZE 8
277 #define ATTR_ATIME 16
278 #define ATTR_MTIME 32
279 #define ATTR_CTIME 64
280 #define ATTR_ATIME_SET 128
281 #define ATTR_MTIME_SET 256
282 #define ATTR_FORCE 512 /* Not a change, but a change it */
283 #define ATTR_ATTR_FLAG 1024
286 * This is the Inode Attributes structure, used for notify_change(). It
287 * uses the above definitions as flags, to know which values have changed.
288 * Also, in this manner, a Filesystem can look at only the values it cares
289 * about. Basically, these are the attributes that the VFS layer can
290 * request to change from the FS layer.
292 * Derek Atkins <warlord@MIT.EDU> 94-10-20
294 struct iattr {
295 unsigned int ia_valid;
296 umode_t ia_mode;
297 uid_t ia_uid;
298 gid_t ia_gid;
299 off_t ia_size;
300 time_t ia_atime;
301 time_t ia_mtime;
302 time_t ia_ctime;
303 unsigned int ia_attr_flags;
307 * This is the inode attributes flag definitions
309 #define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
310 #define ATTR_FLAG_NOATIME 2 /* Don't update atime */
311 #define ATTR_FLAG_APPEND 4 /* Append-only file */
312 #define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
313 #define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
316 * Includes for diskquotas and mount structures.
318 #include <linux/quota.h>
319 #include <linux/mount.h>
321 struct inode {
322 struct list_head i_hash;
323 struct list_head i_list;
324 struct list_head i_dentry;
326 unsigned long i_ino;
327 unsigned int i_count;
328 kdev_t i_dev;
329 umode_t i_mode;
330 nlink_t i_nlink;
331 uid_t i_uid;
332 gid_t i_gid;
333 kdev_t i_rdev;
334 off_t i_size;
335 time_t i_atime;
336 time_t i_mtime;
337 time_t i_ctime;
338 unsigned long i_blksize;
339 unsigned long i_blocks;
340 unsigned long i_version;
341 unsigned long i_nrpages;
342 struct semaphore i_sem;
343 struct inode_operations *i_op;
344 struct super_block *i_sb;
345 wait_queue_head_t i_wait;
346 struct file_lock *i_flock;
347 struct vm_area_struct *i_mmap;
348 struct page *i_pages;
349 struct dquot *i_dquot[MAXQUOTAS];
350 struct pipe_inode_info *i_pipe;
352 unsigned long i_state;
354 unsigned int i_flags;
355 unsigned char i_sock;
357 int i_writecount;
358 unsigned int i_attr_flags;
359 __u32 i_generation;
360 union {
361 struct minix_inode_info minix_i;
362 struct ext2_inode_info ext2_i;
363 struct hpfs_inode_info hpfs_i;
364 struct ntfs_inode_info ntfs_i;
365 struct msdos_inode_info msdos_i;
366 struct umsdos_inode_info umsdos_i;
367 struct iso_inode_info isofs_i;
368 struct nfs_inode_info nfs_i;
369 struct sysv_inode_info sysv_i;
370 struct affs_inode_info affs_i;
371 struct ufs_inode_info ufs_i;
372 struct efs_inode_info efs_i;
373 struct romfs_inode_info romfs_i;
374 struct coda_inode_info coda_i;
375 struct smb_inode_info smbfs_i;
376 struct hfs_inode_info hfs_i;
377 struct adfs_inode_info adfs_i;
378 struct qnx4_inode_info qnx4_i;
379 struct socket socket_i;
380 void *generic_ip;
381 } u;
384 /* Inode state bits.. */
385 #define I_DIRTY 1
386 #define I_LOCK 2
387 #define I_FREEING 4
389 extern void __mark_inode_dirty(struct inode *);
390 static inline void mark_inode_dirty(struct inode *inode)
392 if (!(inode->i_state & I_DIRTY))
393 __mark_inode_dirty(inode);
396 struct fown_struct {
397 int pid; /* pid or -pgrp where SIGIO should be sent */
398 uid_t uid, euid; /* uid/euid of process setting the owner */
399 int signum; /* posix.1b rt signal to be delivered on IO */
402 struct file {
403 struct file *f_next, **f_pprev;
404 struct dentry *f_dentry;
405 struct file_operations *f_op;
406 atomic_t f_count;
407 unsigned int f_flags;
408 mode_t f_mode;
409 loff_t f_pos;
410 unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
411 struct fown_struct f_owner;
412 unsigned int f_uid, f_gid;
413 int f_error;
415 unsigned long f_version;
417 /* needed for tty driver, and maybe others */
418 void *private_data;
421 #define get_file(x) atomic_inc(&(x)->f_count)
422 #define file_count(x) atomic_read(&(x)->f_count)
424 extern int init_private_file(struct file *, struct dentry *, int);
426 #define FL_POSIX 1
427 #define FL_FLOCK 2
428 #define FL_BROKEN 4 /* broken flock() emulation */
429 #define FL_ACCESS 8 /* for processes suspended by mandatory locking */
430 #define FL_LOCKD 16 /* lock held by rpc.lockd */
433 * The POSIX file lock owner is determined by
434 * the "struct files_struct" in the thread group
435 * (or NULL for no owner - BSD locks).
437 * Lockd stuffs a "host" pointer into this.
439 typedef struct files_struct *fl_owner_t;
441 struct file_lock {
442 struct file_lock *fl_next; /* singly linked list for this inode */
443 struct file_lock *fl_nextlink; /* doubly linked list of all locks */
444 struct file_lock *fl_prevlink; /* used to simplify lock removal */
445 struct file_lock *fl_nextblock; /* circular list of blocked processes */
446 struct file_lock *fl_prevblock;
447 fl_owner_t fl_owner;
448 unsigned int fl_pid;
449 wait_queue_head_t fl_wait;
450 struct file *fl_file;
451 unsigned char fl_flags;
452 unsigned char fl_type;
453 off_t fl_start;
454 off_t fl_end;
456 void (*fl_notify)(struct file_lock *); /* unblock callback */
458 union {
459 struct nfs_lock_info nfs_fl;
460 } fl_u;
463 extern struct file_lock *file_lock_table;
465 #include <linux/fcntl.h>
467 extern int fcntl_getlk(unsigned int, struct flock *);
468 extern int fcntl_setlk(unsigned int, unsigned int, struct flock *);
470 /* fs/locks.c */
471 extern void locks_remove_posix(struct file *, fl_owner_t);
472 extern void locks_remove_flock(struct file *);
473 extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
474 extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
475 extern void posix_block_lock(struct file_lock *, struct file_lock *);
476 extern void posix_unblock_lock(struct file_lock *);
478 struct fasync_struct {
479 int magic;
480 int fa_fd;
481 struct fasync_struct *fa_next; /* singly linked list */
482 struct file *fa_file;
485 #define FASYNC_MAGIC 0x4601
487 extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
489 #include <linux/minix_fs_sb.h>
490 #include <linux/ext2_fs_sb.h>
491 #include <linux/hpfs_fs_sb.h>
492 #include <linux/ntfs_fs_sb.h>
493 #include <linux/msdos_fs_sb.h>
494 #include <linux/iso_fs_sb.h>
495 #include <linux/nfs_fs_sb.h>
496 #include <linux/sysv_fs_sb.h>
497 #include <linux/affs_fs_sb.h>
498 #include <linux/ufs_fs_sb.h>
499 #include <linux/efs_fs_sb.h>
500 #include <linux/romfs_fs_sb.h>
501 #include <linux/smb_fs_sb.h>
502 #include <linux/hfs_fs_sb.h>
503 #include <linux/adfs_fs_sb.h>
504 #include <linux/qnx4_fs_sb.h>
506 extern struct list_head super_blocks;
508 #define sb_entry(list) list_entry((list), struct super_block, s_list)
509 struct super_block {
510 struct list_head s_list; /* Keep this first */
511 kdev_t s_dev;
512 unsigned long s_blocksize;
513 unsigned char s_blocksize_bits;
514 unsigned char s_lock;
515 unsigned char s_rd_only;
516 unsigned char s_dirt;
517 struct file_system_type *s_type;
518 struct super_operations *s_op;
519 struct dquot_operations *dq_op;
520 unsigned long s_flags;
521 unsigned long s_magic;
522 unsigned long s_time;
523 struct dentry *s_root;
524 wait_queue_head_t s_wait;
526 struct inode *s_ibasket;
527 short int s_ibasket_count;
528 short int s_ibasket_max;
529 struct list_head s_dirty; /* dirty inodes */
531 union {
532 struct minix_sb_info minix_sb;
533 struct ext2_sb_info ext2_sb;
534 struct hpfs_sb_info hpfs_sb;
535 struct ntfs_sb_info ntfs_sb;
536 struct msdos_sb_info msdos_sb;
537 struct isofs_sb_info isofs_sb;
538 struct nfs_sb_info nfs_sb;
539 struct sysv_sb_info sysv_sb;
540 struct affs_sb_info affs_sb;
541 struct ufs_sb_info ufs_sb;
542 struct efs_sb_info efs_sb;
543 struct romfs_sb_info romfs_sb;
544 struct smb_sb_info smbfs_sb;
545 struct hfs_sb_info hfs_sb;
546 struct adfs_sb_info adfs_sb;
547 struct qnx4_sb_info qnx4_sb;
548 void *generic_sbp;
549 } u;
551 * The next field is for VFS *only*. No filesystems have any business
552 * even looking at it. You had been warned.
554 struct semaphore s_vfs_rename_sem; /* Kludge */
558 * VFS helper functions..
560 extern int vfs_rmdir(struct inode *, struct dentry *);
561 extern int vfs_unlink(struct inode *, struct dentry *);
562 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
565 * This is the "filldir" function type, used by readdir() to let
566 * the kernel specify what kind of dirent layout it wants to have.
567 * This allows the kernel to read directories into kernel space or
568 * to have different dirent layouts depending on the binary type.
570 typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
572 struct file_operations {
573 loff_t (*llseek) (struct file *, loff_t, int);
574 ssize_t (*read) (struct file *, char *, size_t, loff_t *);
575 ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
576 int (*readdir) (struct file *, void *, filldir_t);
577 unsigned int (*poll) (struct file *, struct poll_table_struct *);
578 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
579 int (*mmap) (struct file *, struct vm_area_struct *);
580 int (*open) (struct inode *, struct file *);
581 int (*flush) (struct file *);
582 int (*release) (struct inode *, struct file *);
583 int (*fsync) (struct file *, struct dentry *);
584 int (*fasync) (int, struct file *, int);
585 int (*check_media_change) (kdev_t dev);
586 int (*revalidate) (kdev_t dev);
587 int (*lock) (struct file *, int, struct file_lock *);
590 struct inode_operations {
591 struct file_operations * default_file_ops;
592 int (*create) (struct inode *,struct dentry *,int);
593 struct dentry * (*lookup) (struct inode *,struct dentry *);
594 int (*link) (struct dentry *,struct inode *,struct dentry *);
595 int (*unlink) (struct inode *,struct dentry *);
596 int (*symlink) (struct inode *,struct dentry *,const char *);
597 int (*mkdir) (struct inode *,struct dentry *,int);
598 int (*rmdir) (struct inode *,struct dentry *);
599 int (*mknod) (struct inode *,struct dentry *,int,int);
600 int (*rename) (struct inode *, struct dentry *,
601 struct inode *, struct dentry *);
602 int (*readlink) (struct dentry *, char *,int);
603 struct dentry * (*follow_link) (struct dentry *, struct dentry *, unsigned int);
605 * the order of these functions within the VFS template has been
606 * changed because SMP locking has changed: from now on all get_block,
607 * readpage, writepage and flushpage functions are supposed to do
608 * whatever locking they need to get proper SMP operation - for
609 * now in most cases this means a lock/unlock_kernel at entry/exit.
610 * [The new order is also slightly more logical :)]
613 * Generic block allocator exported by the lowlevel fs. All metadata
614 * details are handled by the lowlevel fs, all 'logical data content'
615 * details are handled by the highlevel block layer.
617 int (*get_block) (struct inode *, long, struct buffer_head *, int);
619 int (*readpage) (struct file *, struct page *);
620 int (*writepage) (struct file *, struct page *);
621 int (*flushpage) (struct inode *, struct page *, unsigned long);
623 void (*truncate) (struct inode *);
624 int (*permission) (struct inode *, int);
625 int (*smap) (struct inode *,int);
626 int (*revalidate) (struct dentry *);
629 struct super_operations {
630 void (*read_inode) (struct inode *);
631 void (*write_inode) (struct inode *);
632 void (*put_inode) (struct inode *);
633 void (*delete_inode) (struct inode *);
634 int (*notify_change) (struct dentry *, struct iattr *);
635 void (*put_super) (struct super_block *);
636 void (*write_super) (struct super_block *);
637 int (*statfs) (struct super_block *, struct statfs *, int);
638 int (*remount_fs) (struct super_block *, int *, char *);
639 void (*clear_inode) (struct inode *);
640 void (*umount_begin) (struct super_block *);
643 struct dquot_operations {
644 void (*initialize) (struct inode *, short);
645 void (*drop) (struct inode *);
646 int (*alloc_block) (const struct inode *, unsigned long, uid_t, char);
647 int (*alloc_inode) (const struct inode *, unsigned long, uid_t);
648 void (*free_block) (const struct inode *, unsigned long);
649 void (*free_inode) (const struct inode *, unsigned long);
650 int (*transfer) (struct inode *, struct iattr *, char, uid_t);
653 struct file_system_type {
654 const char *name;
655 int fs_flags;
656 struct super_block *(*read_super) (struct super_block *, void *, int);
657 struct file_system_type * next;
660 extern int register_filesystem(struct file_system_type *);
661 extern int unregister_filesystem(struct file_system_type *);
664 #define FLOCK_VERIFY_READ 1
665 #define FLOCK_VERIFY_WRITE 2
667 extern int locks_mandatory_locked(struct inode *);
668 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
671 * Candidates for mandatory locking have the setgid bit set
672 * but no group execute bit - an otherwise meaningless combination.
674 #define MANDATORY_LOCK(inode) \
675 (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
677 static inline int locks_verify_locked(struct inode *inode)
679 if (MANDATORY_LOCK(inode))
680 return locks_mandatory_locked(inode);
681 return 0;
684 extern inline int locks_verify_area(int read_write, struct inode *inode,
685 struct file *filp, loff_t offset,
686 size_t count)
688 if (inode->i_flock && MANDATORY_LOCK(inode))
689 return locks_mandatory_area(read_write, inode, filp, offset, count);
690 return 0;
694 /* fs/open.c */
696 asmlinkage int sys_open(const char *, int, int);
697 asmlinkage int sys_close(unsigned int); /* yes, it's really unsigned */
698 extern int do_truncate(struct dentry *, unsigned long);
699 extern int get_unused_fd(void);
700 extern void put_unused_fd(unsigned int);
702 extern struct file *filp_open(const char *, int, int);
703 extern int filp_close(struct file *, fl_owner_t id);
705 extern char * getname(const char *);
706 #define __getname() ((char *) __get_free_page(GFP_KERNEL))
707 #define putname(name) free_page((unsigned long)(name))
709 extern void kill_fasync(struct fasync_struct *, int);
710 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
711 extern int unregister_blkdev(unsigned int, const char *);
712 extern int blkdev_open(struct inode *, struct file *);
713 extern int blkdev_release (struct inode *);
714 extern struct file_operations def_blk_fops;
715 extern struct inode_operations blkdev_inode_operations;
717 /* fs/devices.c */
718 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
719 extern int unregister_chrdev(unsigned int, const char *);
720 extern int chrdev_open(struct inode *, struct file *);
721 extern struct file_operations def_chr_fops;
722 extern struct inode_operations chrdev_inode_operations;
723 extern char * bdevname(kdev_t);
724 extern char * cdevname(kdev_t);
725 extern char * kdevname(kdev_t);
726 extern void init_special_inode(struct inode *, umode_t, int);
728 extern void init_fifo(struct inode *);
729 extern struct inode_operations fifo_inode_operations;
731 /* Invalid inode operations -- fs/bad_inode.c */
732 extern void make_bad_inode(struct inode *);
733 extern int is_bad_inode(struct inode *);
735 extern struct file_operations connecting_fifo_fops;
736 extern struct file_operations read_fifo_fops;
737 extern struct file_operations write_fifo_fops;
738 extern struct file_operations rdwr_fifo_fops;
739 extern struct file_operations read_pipe_fops;
740 extern struct file_operations write_pipe_fops;
741 extern struct file_operations rdwr_pipe_fops;
743 extern struct file_system_type *get_fs_type(const char *);
745 extern int fs_may_remount_ro(struct super_block *);
746 extern int fs_may_mount(kdev_t);
748 extern struct file *inuse_filps;
750 extern int try_to_free_buffers(struct page *);
751 extern void refile_buffer(struct buffer_head * buf);
753 extern atomic_t buffermem;
755 #define BUF_CLEAN 0
756 #define BUF_LOCKED 1 /* Buffers scheduled for write */
757 #define BUF_DIRTY 2 /* Dirty buffers, not yet scheduled for write */
758 #define NR_LIST 3
761 * This is called by bh->b_end_io() handlers when I/O has completed.
763 extern inline void mark_buffer_uptodate(struct buffer_head * bh, int on)
765 if (on)
766 set_bit(BH_Uptodate, &bh->b_state);
767 else
768 clear_bit(BH_Uptodate, &bh->b_state);
771 #define atomic_set_buffer_clean(bh) test_and_clear_bit(BH_Dirty, &(bh)->b_state)
773 extern inline void __mark_buffer_clean(struct buffer_head *bh)
775 refile_buffer(bh);
778 extern inline void mark_buffer_clean(struct buffer_head * bh)
780 if (atomic_set_buffer_clean(bh))
781 __mark_buffer_clean(bh);
784 extern void FASTCALL(__mark_buffer_dirty(struct buffer_head *bh, int flag));
786 #define atomic_set_buffer_dirty(bh) test_and_set_bit(BH_Dirty, &(bh)->b_state)
788 extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag)
790 if (!atomic_set_buffer_dirty(bh))
791 __mark_buffer_dirty(bh, flag);
794 extern void balance_dirty(kdev_t);
795 extern int check_disk_change(kdev_t);
796 extern int invalidate_inodes(struct super_block *);
797 extern void invalidate_inode_pages(struct inode *);
798 extern void invalidate_buffers(kdev_t);
799 extern int floppy_is_wp(int);
800 extern void sync_inodes(kdev_t);
801 extern void write_inode_now(struct inode *);
802 extern void sync_dev(kdev_t);
803 extern int fsync_dev(kdev_t);
804 extern void sync_supers(kdev_t);
805 extern int bmap(struct inode *, int);
806 extern int notify_change(struct dentry *, struct iattr *);
807 extern int permission(struct inode *, int);
808 extern int get_write_access(struct inode *);
809 extern void put_write_access(struct inode *);
810 extern struct dentry * open_namei(const char *, int, int);
811 extern struct dentry * do_mknod(const char *, int, dev_t);
812 extern int do_pipe(int *);
814 /* fs/dcache.c -- generic fs support functions */
815 extern int is_subdir(struct dentry *, struct dentry *);
816 extern ino_t find_inode_number(struct dentry *, struct qstr *);
819 * Kernel pointers have redundant information, so we can use a
820 * scheme where we can return either an error code or a dentry
821 * pointer with the same return value.
823 * This should be a per-architecture thing, to allow different
824 * error and pointer decisions.
826 #define ERR_PTR(err) ((void *)((long)(err)))
827 #define PTR_ERR(ptr) ((long)(ptr))
828 #define IS_ERR(ptr) ((unsigned long)(ptr) > (unsigned long)(-1000))
831 * The bitmask for a lookup event:
832 * - follow links at the end
833 * - require a directory
834 * - ending slashes ok even for nonexistent files
835 * - internal "there are more path compnents" flag
837 #define LOOKUP_FOLLOW (1)
838 #define LOOKUP_DIRECTORY (2)
839 #define LOOKUP_SLASHOK (4)
840 #define LOOKUP_CONTINUE (8)
842 extern struct dentry * lookup_dentry(const char *, struct dentry *, unsigned int);
843 extern struct dentry * __namei(const char *, unsigned int);
845 #define namei(pathname) __namei(pathname, 1)
846 #define lnamei(pathname) __namei(pathname, 0)
848 extern void iput(struct inode *);
849 extern struct inode * igrab(struct inode *);
850 extern ino_t iunique(struct super_block *, ino_t);
851 extern struct inode * iget(struct super_block *, unsigned long);
852 extern void clear_inode(struct inode *);
853 extern struct inode * get_empty_inode(void);
855 extern void insert_inode_hash(struct inode *);
856 extern void remove_inode_hash(struct inode *);
857 extern struct file * get_empty_filp(void);
858 extern struct buffer_head * get_hash_table(kdev_t, int, int);
859 extern struct buffer_head * getblk(kdev_t, int, int);
860 extern void ll_rw_block(int, int, struct buffer_head * bh[]);
861 extern int is_read_only(kdev_t);
862 extern void __brelse(struct buffer_head *);
863 extern inline void brelse(struct buffer_head *buf)
865 if (buf)
866 __brelse(buf);
868 extern void __bforget(struct buffer_head *);
869 extern inline void bforget(struct buffer_head *buf)
871 if (buf)
872 __bforget(buf);
874 extern void set_blocksize(kdev_t, int);
875 extern unsigned int get_hardblocksize(kdev_t);
876 extern struct buffer_head * bread(kdev_t, int, int);
877 extern struct buffer_head * breada(kdev_t, int, int, unsigned int, unsigned int);
879 extern int brw_page(int, struct page *, kdev_t, int [], int, int);
881 typedef int (*writepage_t)(struct file *, struct page *, unsigned long, unsigned long, const char *);
883 /* Generic buffer handling for block filesystems.. */
884 extern int block_read_full_page(struct file *, struct page *);
885 extern int block_write_full_page (struct file *, struct page *);
886 extern int block_write_partial_page (struct file *, struct page *, unsigned long, unsigned long, const char *);
887 extern int block_flushpage(struct inode *, struct page *, unsigned long);
889 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
890 extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
891 extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *, writepage_t);
894 extern struct super_block *get_super(kdev_t);
895 extern void put_super(kdev_t);
896 unsigned long generate_cluster(kdev_t, int b[], int);
897 unsigned long generate_cluster_swab32(kdev_t, int b[], int);
898 extern kdev_t ROOT_DEV;
900 extern void mount_root(void);
902 #ifdef CONFIG_BLK_DEV_INITRD
903 extern kdev_t real_root_dev;
904 extern int change_root(kdev_t, const char *);
905 #endif
907 extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
908 extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
909 extern int read_ahead[];
911 extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
912 extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
914 extern int block_fsync(struct file *, struct dentry *);
915 extern int file_fsync(struct file *, struct dentry *);
916 extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start, unsigned long end);
918 extern int inode_change_ok(struct inode *, struct iattr *);
919 extern void inode_setattr(struct inode *, struct iattr *);
921 /* kludge to get SCSI modules working */
922 #include <linux/minix_fs.h>
923 #include <linux/minix_fs_sb.h>
925 #endif /* __KERNEL__ */
927 #endif /* _LINUX_FS_H */