Import 2.1.118
[davej-history.git] / include / linux / fs.h
blob40728572ca5e706870abcd3be728d173575b79d4
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 */
100 * Flags that can be altered by MS_REMOUNT
102 #define MS_RMT_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
105 * Magic mount flag number. Has to be or-ed to the flag values.
107 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
108 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
111 * Note that read-only etc flags are inode-specific: setting some file-system
112 * flags just means all the inodes inherit those flags by default. It might be
113 * possible to override it selectively if you really wanted to with some
114 * ioctl() that is not currently implemented.
116 * Exception: MS_RDONLY is always applied to the entire file system.
118 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
119 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
120 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
121 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
122 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNCHRONOUS)
123 #define IS_MANDLOCK(inode) ((inode)->i_flags & MS_MANDLOCK)
125 #define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
126 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
127 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
128 #define IS_NOATIME(inode) ((inode)->i_flags & MS_NOATIME)
129 #define IS_NODIRATIME(inode) ((inode)->i_flags & MS_NODIRATIME)
131 /* the read-only stuff doesn't really belong here, but any other place is
132 probably as bad and I don't want to create yet another include file. */
134 #define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
135 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
136 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
137 #define BLKGETSIZE _IO(0x12,96) /* return device size */
138 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
139 #define BLKRASET _IO(0x12,98) /* Set read ahead for block device */
140 #define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
141 #define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
142 #define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
143 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
144 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
146 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
147 #define FIBMAP _IO(0x00,1) /* bmap access */
148 #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
150 #ifdef __KERNEL__
152 #include <asm/semaphore.h>
153 #include <asm/byteorder.h>
154 #include <asm/bitops.h>
156 extern void update_atime (struct inode *inode);
157 #define UPDATE_ATIME(inode) update_atime (inode)
159 extern void buffer_init(void);
160 extern void inode_init(void);
161 extern void file_table_init(void);
162 extern void dcache_init(void);
164 typedef char buffer_block[BLOCK_SIZE];
166 /* bh state bits */
167 #define BH_Uptodate 0 /* 1 if the buffer contains valid data */
168 #define BH_Dirty 1 /* 1 if the buffer is dirty */
169 #define BH_Lock 2 /* 1 if the buffer is locked */
170 #define BH_Req 3 /* 0 if the buffer has been invalidated */
171 #define BH_Touched 4 /* 1 if the buffer has been touched (aging) */
172 #define BH_Has_aged 5 /* 1 if the buffer has been aged (aging) */
173 #define BH_Protected 6 /* 1 if the buffer is protected */
176 * Try to keep the most commonly used fields in single cache lines (16
177 * bytes) to improve performance. This ordering should be
178 * particularly beneficial on 32-bit processors.
180 * We use the first 16 bytes for the data which is used in searches
181 * over the block hash lists (ie. getblk(), find_buffer() and
182 * friends).
184 * The second 16 bytes we use for lru buffer scans, as used by
185 * sync_buffers() and refill_freelist(). -- sct
187 struct buffer_head {
188 /* First cache line: */
189 struct buffer_head * b_next; /* Hash queue list */
190 unsigned long b_blocknr; /* block number */
191 unsigned long b_size; /* block size */
192 kdev_t b_dev; /* device (B_FREE = free) */
193 kdev_t b_rdev; /* Real device */
194 unsigned long b_rsector; /* Real buffer location on disk */
195 struct buffer_head * b_this_page; /* circular list of buffers in one page */
196 unsigned long b_state; /* buffer state bitmap (see above) */
197 struct buffer_head * b_next_free;
198 unsigned int b_count; /* users using this block */
200 /* Non-performance-critical data follows. */
201 char * b_data; /* pointer to data block (1024 bytes) */
202 unsigned int b_list; /* List that this buffer appears */
203 unsigned long b_flushtime; /* Time when this (dirty) buffer
204 * should be written */
205 unsigned long b_lru_time; /* Time when this buffer was
206 * last used. */
207 struct wait_queue * b_wait;
208 struct buffer_head ** b_pprev; /* doubly linked list of hash-queue */
209 struct buffer_head * b_prev_free; /* doubly linked list of buffers */
210 struct buffer_head * b_reqnext; /* request queue */
213 * I/O completion
215 void (*b_end_io)(struct buffer_head *bh, int uptodate);
216 void *b_dev_id;
219 typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
220 void init_buffer(struct buffer_head *bh, kdev_t dev, int block,
221 bh_end_io_t *handler, void *dev_id);
223 static inline int buffer_uptodate(struct buffer_head * bh)
225 return test_bit(BH_Uptodate, &bh->b_state);
228 static inline int buffer_dirty(struct buffer_head * bh)
230 return test_bit(BH_Dirty, &bh->b_state);
233 static inline int buffer_locked(struct buffer_head * bh)
235 return test_bit(BH_Lock, &bh->b_state);
238 static inline int buffer_req(struct buffer_head * bh)
240 return test_bit(BH_Req, &bh->b_state);
243 static inline int buffer_touched(struct buffer_head * bh)
245 return test_bit(BH_Touched, &bh->b_state);
248 static inline int buffer_has_aged(struct buffer_head * bh)
250 return test_bit(BH_Has_aged, &bh->b_state);
253 static inline int buffer_protected(struct buffer_head * bh)
255 return test_bit(BH_Protected, &bh->b_state);
258 #include <linux/pipe_fs_i.h>
259 #include <linux/minix_fs_i.h>
260 #include <linux/ext2_fs_i.h>
261 #include <linux/hpfs_fs_i.h>
262 #include <linux/ntfs_fs_i.h>
263 #include <linux/msdos_fs_i.h>
264 #include <linux/umsdos_fs_i.h>
265 #include <linux/iso_fs_i.h>
266 #include <linux/nfs_fs_i.h>
267 #include <linux/sysv_fs_i.h>
268 #include <linux/affs_fs_i.h>
269 #include <linux/ufs_fs_i.h>
270 #include <linux/coda_fs_i.h>
271 #include <linux/romfs_fs_i.h>
272 #include <linux/smb_fs_i.h>
273 #include <linux/hfs_fs_i.h>
274 #include <linux/adfs_fs_i.h>
277 * Attribute flags. These should be or-ed together to figure out what
278 * has been changed!
280 #define ATTR_MODE 1
281 #define ATTR_UID 2
282 #define ATTR_GID 4
283 #define ATTR_SIZE 8
284 #define ATTR_ATIME 16
285 #define ATTR_MTIME 32
286 #define ATTR_CTIME 64
287 #define ATTR_ATIME_SET 128
288 #define ATTR_MTIME_SET 256
289 #define ATTR_FORCE 512 /* Not a change, but a change it */
290 #define ATTR_ATTR_FLAG 1024
293 * This is the Inode Attributes structure, used for notify_change(). It
294 * uses the above definitions as flags, to know which values have changed.
295 * Also, in this manner, a Filesystem can look at only the values it cares
296 * about. Basically, these are the attributes that the VFS layer can
297 * request to change from the FS layer.
299 * Derek Atkins <warlord@MIT.EDU> 94-10-20
301 struct iattr {
302 unsigned int ia_valid;
303 umode_t ia_mode;
304 uid_t ia_uid;
305 gid_t ia_gid;
306 off_t ia_size;
307 time_t ia_atime;
308 time_t ia_mtime;
309 time_t ia_ctime;
310 unsigned int ia_attr_flags;
314 * This is the inode attributes flag definitions
316 #define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
317 #define ATTR_FLAG_NOATIME 2 /* Don't update atime */
318 #define ATTR_FLAG_APPEND 4 /* Append-only file */
319 #define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
320 #define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
323 * Includes for diskquotas and mount structures.
325 #include <linux/quota.h>
326 #include <linux/mount.h>
328 struct inode {
329 struct list_head i_hash;
330 struct list_head i_list;
331 struct list_head i_dentry;
333 unsigned long i_ino;
334 unsigned int i_count;
335 kdev_t i_dev;
336 umode_t i_mode;
337 nlink_t i_nlink;
338 uid_t i_uid;
339 gid_t i_gid;
340 kdev_t i_rdev;
341 off_t i_size;
342 time_t i_atime;
343 time_t i_mtime;
344 time_t i_ctime;
345 unsigned long i_blksize;
346 unsigned long i_blocks;
347 unsigned long i_version;
348 unsigned long i_nrpages;
349 struct semaphore i_sem;
350 struct inode_operations *i_op;
351 struct super_block *i_sb;
352 struct wait_queue *i_wait;
353 struct file_lock *i_flock;
354 struct vm_area_struct *i_mmap;
355 struct page *i_pages;
356 struct dquot *i_dquot[MAXQUOTAS];
358 unsigned long i_state;
360 unsigned int i_flags;
361 unsigned char i_pipe;
362 unsigned char i_sock;
364 int i_writecount;
365 unsigned int i_attr_flags;
366 union {
367 struct pipe_inode_info pipe_i;
368 struct minix_inode_info minix_i;
369 struct ext2_inode_info ext2_i;
370 struct hpfs_inode_info hpfs_i;
371 struct ntfs_inode_info ntfs_i;
372 struct msdos_inode_info msdos_i;
373 struct umsdos_inode_info umsdos_i;
374 struct iso_inode_info isofs_i;
375 struct nfs_inode_info nfs_i;
376 struct sysv_inode_info sysv_i;
377 struct affs_inode_info affs_i;
378 struct ufs_inode_info ufs_i;
379 struct romfs_inode_info romfs_i;
380 struct coda_inode_info coda_i;
381 struct smb_inode_info smbfs_i;
382 struct hfs_inode_info hfs_i;
383 struct adfs_inode_info adfs_i;
384 struct socket socket_i;
385 void *generic_ip;
386 } u;
389 /* Inode state bits.. */
390 #define I_DIRTY 1
391 #define I_LOCK 2
392 #define I_FREEING 4
394 extern void __mark_inode_dirty(struct inode *);
395 static inline void mark_inode_dirty(struct inode *inode)
397 if (!(inode->i_state & I_DIRTY))
398 __mark_inode_dirty(inode);
401 struct fown_struct {
402 int pid; /* pid or -pgrp where SIGIO should be sent */
403 uid_t uid, euid; /* uid/euid of process setting the owner */
404 int signum; /* posix.1b rt signal to be delivered on IO */
407 struct file {
408 struct file *f_next, **f_pprev;
409 struct dentry *f_dentry;
410 struct file_operations *f_op;
411 mode_t f_mode;
412 loff_t f_pos;
413 unsigned short f_count, f_flags;
414 unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
415 struct fown_struct f_owner;
417 unsigned long f_version;
419 /* needed for tty driver, and maybe others */
420 void *private_data;
423 extern int init_private_file(struct file *, struct dentry *, int);
425 #define FL_POSIX 1
426 #define FL_FLOCK 2
427 #define FL_BROKEN 4 /* broken flock() emulation */
428 #define FL_ACCESS 8 /* for processes suspended by mandatory locking */
429 #define FL_LOCKD 16 /* lock held by rpc.lockd */
432 * The POSIX file lock owner is determined by
433 * the "struct files_struct" in the thread group
434 * (or NULL for no owner - BSD locks).
436 * Lockd stuffs a "host" pointer into this.
438 typedef struct files_struct *fl_owner_t;
440 struct file_lock {
441 struct file_lock *fl_next; /* singly linked list for this inode */
442 struct file_lock *fl_nextlink; /* doubly linked list of all locks */
443 struct file_lock *fl_prevlink; /* used to simplify lock removal */
444 struct file_lock *fl_nextblock; /* circular list of blocked processes */
445 struct file_lock *fl_prevblock;
446 fl_owner_t fl_owner;
447 unsigned int fl_pid;
448 struct wait_queue *fl_wait;
449 struct file *fl_file;
450 unsigned char fl_flags;
451 unsigned char fl_type;
452 off_t fl_start;
453 off_t fl_end;
455 void (*fl_notify)(struct file_lock *); /* unblock callback */
457 union {
458 struct nfs_lock_info nfs_fl;
459 } fl_u;
462 extern struct file_lock *file_lock_table;
464 #include <linux/fcntl.h>
466 extern int fcntl_getlk(unsigned int fd, struct flock *l);
467 extern int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l);
469 /* fs/locks.c */
470 extern void locks_remove_posix(struct file *, fl_owner_t id);
471 extern void locks_remove_flock(struct file *);
472 extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
473 extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
474 extern void posix_block_lock(struct file_lock *, struct file_lock *);
475 extern void posix_unblock_lock(struct file_lock *);
477 #include <linux/stat.h>
479 #define FLOCK_VERIFY_READ 1
480 #define FLOCK_VERIFY_WRITE 2
482 extern int locks_mandatory_locked(struct inode *inode);
483 extern int locks_mandatory_area(int read_write, struct inode *inode,
484 struct file *filp, loff_t offset,
485 size_t count);
487 extern inline int locks_verify_locked(struct inode *inode)
489 /* Candidates for mandatory locking have the setgid bit set
490 * but no group execute bit - an otherwise meaningless combination.
492 if (IS_MANDLOCK(inode) &&
493 (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
494 return (locks_mandatory_locked(inode));
495 return (0);
498 extern inline int locks_verify_area(int read_write, struct inode *inode,
499 struct file *filp, loff_t offset,
500 size_t count)
502 /* Candidates for mandatory locking have the setgid bit set
503 * but no group execute bit - an otherwise meaningless combination.
505 if (IS_MANDLOCK(inode) &&
506 (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
507 return (locks_mandatory_area(read_write, inode, filp, offset,
508 count));
509 return (0);
512 struct fasync_struct {
513 int magic;
514 int fa_fd;
515 struct fasync_struct *fa_next; /* singly linked list */
516 struct file *fa_file;
519 #define FASYNC_MAGIC 0x4601
521 extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
523 #include <linux/minix_fs_sb.h>
524 #include <linux/ext2_fs_sb.h>
525 #include <linux/hpfs_fs_sb.h>
526 #include <linux/ntfs_fs_sb.h>
527 #include <linux/msdos_fs_sb.h>
528 #include <linux/iso_fs_sb.h>
529 #include <linux/nfs_fs_sb.h>
530 #include <linux/sysv_fs_sb.h>
531 #include <linux/affs_fs_sb.h>
532 #include <linux/ufs_fs_sb.h>
533 #include <linux/romfs_fs_sb.h>
534 #include <linux/smb_fs_sb.h>
535 #include <linux/hfs_fs_sb.h>
536 #include <linux/adfs_fs_sb.h>
538 extern struct list_head super_blocks;
540 #define sb_entry(list) list_entry((list), struct super_block, s_list)
541 struct super_block {
542 struct list_head s_list; /* Keep this first */
543 kdev_t s_dev;
544 unsigned long s_blocksize;
545 unsigned char s_blocksize_bits;
546 unsigned char s_lock;
547 unsigned char s_rd_only;
548 unsigned char s_dirt;
549 struct file_system_type *s_type;
550 struct super_operations *s_op;
551 struct dquot_operations *dq_op;
552 unsigned long s_flags;
553 unsigned long s_magic;
554 unsigned long s_time;
555 struct dentry *s_root;
556 struct wait_queue *s_wait;
558 struct inode *s_ibasket;
559 short int s_ibasket_count;
560 short int s_ibasket_max;
561 struct list_head s_dirty; /* dirty inodes */
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 romfs_sb_info romfs_sb;
575 struct smb_sb_info smbfs_sb;
576 struct hfs_sb_info hfs_sb;
577 struct adfs_sb_info adfs_sb;
578 void *generic_sbp;
579 } u;
583 * This is the "filldir" function type, used by readdir() to let
584 * the kernel specify what kind of dirent layout it wants to have.
585 * This allows the kernel to read directories into kernel space or
586 * to have different dirent layouts depending on the binary type.
588 typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
590 struct file_operations {
591 loff_t (*llseek) (struct file *, loff_t, int);
592 ssize_t (*read) (struct file *, char *, size_t, loff_t *);
593 ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
594 int (*readdir) (struct file *, void *, filldir_t);
595 unsigned int (*poll) (struct file *, struct poll_table_struct *);
596 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
597 int (*mmap) (struct file *, struct vm_area_struct *);
598 int (*open) (struct inode *, struct file *);
599 int (*flush) (struct file *);
600 int (*release) (struct inode *, struct file *);
601 int (*fsync) (struct file *, struct dentry *);
602 int (*fasync) (int, struct file *, int);
603 int (*check_media_change) (kdev_t dev);
604 int (*revalidate) (kdev_t dev);
605 int (*lock) (struct file *, int, struct file_lock *);
608 struct inode_operations {
609 struct file_operations * default_file_ops;
610 int (*create) (struct inode *,struct dentry *,int);
611 int (*lookup) (struct inode *,struct dentry *);
612 int (*link) (struct dentry *,struct inode *,struct dentry *);
613 int (*unlink) (struct inode *,struct dentry *);
614 int (*symlink) (struct inode *,struct dentry *,const char *);
615 int (*mkdir) (struct inode *,struct dentry *,int);
616 int (*rmdir) (struct inode *,struct dentry *);
617 int (*mknod) (struct inode *,struct dentry *,int,int);
618 int (*rename) (struct inode *, struct dentry *,
619 struct inode *, struct dentry *);
620 int (*readlink) (struct dentry *, char *,int);
621 struct dentry * (*follow_link) (struct dentry *, struct dentry *);
622 int (*readpage) (struct file *, struct page *);
623 int (*writepage) (struct file *, struct page *);
624 int (*bmap) (struct inode *,int);
625 void (*truncate) (struct inode *);
626 int (*permission) (struct inode *, int);
627 int (*smap) (struct inode *,int);
628 int (*updatepage) (struct file *, struct page *, const char *,
629 unsigned long, unsigned int, int);
630 int (*revalidate) (struct dentry *);
633 struct super_operations {
634 void (*read_inode) (struct inode *);
635 void (*write_inode) (struct inode *);
636 void (*put_inode) (struct inode *);
637 void (*delete_inode) (struct inode *);
638 int (*notify_change) (struct dentry *, struct iattr *);
639 void (*put_super) (struct super_block *);
640 void (*write_super) (struct super_block *);
641 int (*statfs) (struct super_block *, struct statfs *, int);
642 int (*remount_fs) (struct super_block *, int *, char *);
643 void (*clear_inode) (struct inode *);
644 void (*umount_begin) (struct super_block *);
647 struct dquot_operations {
648 void (*initialize) (struct inode *, short);
649 void (*drop) (struct inode *);
650 int (*alloc_block) (const struct inode *, unsigned long, uid_t, char);
651 int (*alloc_inode) (const struct inode *, unsigned long, uid_t);
652 void (*free_block) (const struct inode *, unsigned long);
653 void (*free_inode) (const struct inode *, unsigned long);
654 int (*transfer) (struct inode *, struct iattr *, char, uid_t);
657 struct file_system_type {
658 const char *name;
659 int fs_flags;
660 struct super_block *(*read_super) (struct super_block *, void *, int);
661 struct file_system_type * next;
664 extern int register_filesystem(struct file_system_type *);
665 extern int unregister_filesystem(struct file_system_type *);
667 /* fs/open.c */
669 asmlinkage int sys_open(const char *, int, int);
670 asmlinkage int sys_close(unsigned int); /* yes, it's really unsigned */
671 extern int do_truncate(struct dentry *, unsigned long);
672 extern int get_unused_fd(void);
673 extern void put_unused_fd(unsigned int);
674 extern int close_fp(struct file *, fl_owner_t id);
676 extern char * getname(const char * filename);
677 extern void putname(char * name);
679 extern void kill_fasync(struct fasync_struct *fa, int sig);
680 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
681 extern int unregister_blkdev(unsigned int major, const char * name);
682 extern int blkdev_open(struct inode * inode, struct file * filp);
683 extern int blkdev_release (struct inode * inode);
684 extern struct file_operations def_blk_fops;
685 extern struct inode_operations blkdev_inode_operations;
687 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
688 extern int unregister_chrdev(unsigned int major, const char * name);
689 extern int chrdev_open(struct inode * inode, struct file * filp);
690 extern struct file_operations def_chr_fops;
691 extern struct inode_operations chrdev_inode_operations;
693 extern void init_fifo(struct inode * inode);
694 extern struct inode_operations fifo_inode_operations;
696 /* Invalid inode operations -- fs/bad_inode.c */
697 extern void make_bad_inode(struct inode * inode);
698 extern int is_bad_inode(struct inode * inode);
700 extern struct file_operations connecting_fifo_fops;
701 extern struct file_operations read_fifo_fops;
702 extern struct file_operations write_fifo_fops;
703 extern struct file_operations rdwr_fifo_fops;
704 extern struct file_operations read_pipe_fops;
705 extern struct file_operations write_pipe_fops;
706 extern struct file_operations rdwr_pipe_fops;
708 extern struct file_system_type *get_fs_type(const char *name);
710 extern int fs_may_remount_ro(struct super_block *);
711 extern int fs_may_mount(kdev_t dev);
713 extern struct file *inuse_filps;
715 extern void refile_buffer(struct buffer_head * buf);
716 extern void set_writetime(struct buffer_head * buf, int flag);
717 extern int try_to_free_buffer(struct buffer_head*, struct buffer_head**, int);
719 extern int nr_buffers;
720 extern int buffermem;
721 extern int nr_buffer_heads;
723 #define BUF_CLEAN 0
724 #define BUF_LOCKED 1 /* Buffers scheduled for write */
725 #define BUF_DIRTY 2 /* Dirty buffers, not yet scheduled for write */
726 #define NR_LIST 3
728 void mark_buffer_uptodate(struct buffer_head * bh, int on);
730 extern inline void mark_buffer_clean(struct buffer_head * bh)
732 if (test_and_clear_bit(BH_Dirty, &bh->b_state)) {
733 if (bh->b_list == BUF_DIRTY)
734 refile_buffer(bh);
738 extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag)
740 if (!test_and_set_bit(BH_Dirty, &bh->b_state)) {
741 set_writetime(bh, flag);
742 if (bh->b_list != BUF_DIRTY)
743 refile_buffer(bh);
747 extern int check_disk_change(kdev_t dev);
748 extern int invalidate_inodes(struct super_block * sb);
749 extern void invalidate_inode_pages(struct inode *);
750 extern void invalidate_buffers(kdev_t dev);
751 extern int floppy_is_wp(int minor);
752 extern void sync_inodes(kdev_t dev);
753 extern void write_inode_now(struct inode *inode);
754 extern void sync_dev(kdev_t dev);
755 extern int fsync_dev(kdev_t dev);
756 extern void sync_supers(kdev_t dev);
757 extern int bmap(struct inode * inode,int block);
758 extern int notify_change(struct dentry *, struct iattr *);
759 extern int permission(struct inode * inode,int mask);
760 extern int get_write_access(struct inode *inode);
761 extern void put_write_access(struct inode *inode);
762 extern struct dentry * open_namei(const char * pathname, int flag, int mode);
763 extern struct dentry * do_mknod(const char * filename, int mode, dev_t dev);
764 extern int do_pipe(int *);
766 /* fs/dcache.c -- generic fs support functions */
767 extern int is_subdir(struct dentry *, struct dentry *);
768 extern ino_t find_inode_number(struct dentry *, struct qstr *);
771 * Kernel pointers have redundant information, so we can use a
772 * scheme where we can return either an error code or a dentry
773 * pointer with the same return value.
775 * This should be a per-architecture thing, to allow different
776 * error and pointer decisions.
778 #define ERR_PTR(err) ((void *)((long)(err)))
779 #define PTR_ERR(ptr) ((long)(ptr))
780 #define IS_ERR(ptr) ((unsigned long)(ptr) > (unsigned long)(-1000))
782 extern struct dentry * lookup_dentry(const char *, struct dentry *, int);
783 extern struct dentry * __namei(const char *, int);
785 #define namei(pathname) __namei(pathname, 1)
786 #define lnamei(pathname) __namei(pathname, 0)
788 extern void iput(struct inode *);
789 extern struct inode * iget(struct super_block *, unsigned long);
790 extern void clear_inode(struct inode *);
791 extern struct inode * get_empty_inode(void);
793 extern void insert_inode_hash(struct inode *);
794 extern void remove_inode_hash(struct inode *);
795 extern struct file * get_empty_filp(void);
796 extern struct buffer_head * get_hash_table(kdev_t, int, int);
797 extern struct buffer_head * getblk(kdev_t, int, int);
798 extern struct buffer_head * find_buffer(kdev_t dev, int block, int size);
799 extern void ll_rw_block(int, int, struct buffer_head * bh[]);
800 extern void ll_rw_page(int, kdev_t, unsigned long, char *);
801 extern void ll_rw_swap_file(int, kdev_t, unsigned int *, int, char *);
802 extern int is_read_only(kdev_t);
803 extern void __brelse(struct buffer_head *);
804 extern inline void brelse(struct buffer_head *buf)
806 if (buf)
807 __brelse(buf);
809 extern void __bforget(struct buffer_head *buf);
810 extern inline void bforget(struct buffer_head *buf)
812 if (buf)
813 __bforget(buf);
815 extern void set_blocksize(kdev_t dev, int size);
816 extern unsigned int get_hardblocksize(kdev_t dev);
817 extern struct buffer_head * bread(kdev_t dev, int block, int size);
818 extern struct buffer_head * breada(kdev_t dev,int block, int size,
819 unsigned int pos, unsigned int filesize);
821 extern int brw_page(int, struct page *, kdev_t, int [], int, int);
823 extern int generic_readpage(struct file *, struct page *);
824 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
825 extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
826 extern ssize_t generic_file_write(struct file *, const char*, size_t, loff_t*);
828 extern struct super_block *get_super(kdev_t dev);
829 extern void put_super(kdev_t dev);
830 unsigned long generate_cluster(kdev_t dev, int b[], int size);
831 unsigned long generate_cluster_swab32(kdev_t dev, int b[], int size);
832 extern kdev_t ROOT_DEV;
834 extern void show_buffers(void);
835 extern void mount_root(void);
837 #ifdef CONFIG_BLK_DEV_INITRD
838 extern kdev_t real_root_dev;
839 extern int change_root(kdev_t new_root_dev,const char *put_old);
840 #endif
842 extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
843 extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
844 extern int read_ahead[];
846 extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
847 extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
849 extern int block_fsync(struct file *, struct dentry *dir);
850 extern int file_fsync(struct file *, struct dentry *dir);
852 extern int inode_change_ok(struct inode *, struct iattr *);
853 extern void inode_setattr(struct inode *, struct iattr *);
855 /* kludge to get SCSI modules working */
856 #include <linux/minix_fs.h>
857 #include <linux/minix_fs_sb.h>
859 #endif /* __KERNEL__ */
861 #endif