Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

fs.h

Go to the documentation of this file.
00001 #ifndef _LINUX_FS_H
00002 #define _LINUX_FS_H
00003 
00004 /*
00005  * This file has definitions for some important file table
00006  * structures etc.
00007  */
00008 
00009 #include <linux/config.h>
00010 #include <linux/linkage.h>
00011 #include <linux/limits.h>
00012 #include <linux/wait.h>
00013 #include <linux/types.h>
00014 #include <linux/vfs.h>
00015 #include <linux/net.h>
00016 #include <linux/kdev_t.h>
00017 #include <linux/ioctl.h>
00018 #include <linux/list.h>
00019 #include <linux/dcache.h>
00020 #include <linux/stat.h>
00021 
00022 #include <asm/atomic.h>
00023 #include <linux/bitops.h>
00024 #include <asm/cache.h>
00025 #include <linux/stddef.h>       /* just in case the #define NULL previously in here was needed */
00026 
00027 struct poll_table_struct;
00028 
00029 
00030 /*
00031  * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
00032  * the file limit at runtime and only root can increase the per-process
00033  * nr_file rlimit, so it's safe to set up a ridiculously high absolute
00034  * upper limit on files-per-process.
00035  *
00036  * Some programs (notably those using select()) may have to be 
00037  * recompiled to take full advantage of the new limits..  
00038  */
00039 
00040 /* Fixed constants first: */
00041 #undef NR_OPEN
00042 #define NR_OPEN (1024*1024)     /* Absolute upper limit on fd num */
00043 #define INR_OPEN 1024           /* Initial setting for nfile rlimits */
00044 
00045 #define BLOCK_SIZE_BITS 10
00046 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
00047 
00048 /* And dynamically-tunable limits and defaults: */
00049 extern int max_inodes;
00050 struct files_stat_struct {
00051         int nr_files;           /* read only */
00052         int nr_free_files;      /* read only */
00053         int max_files;          /* tunable */
00054 };
00055 extern struct files_stat_struct files_stat; /* fs/file_table.c */
00056 extern int max_super_blocks, nr_super_blocks;
00057 
00058 #define NR_FILE  4096   /* this can well be larger on a larger system */
00059 #define NR_RESERVED_FILES 10 /* reserved for root */
00060 #define NR_SUPER 256
00061 
00062 #define MAY_EXEC 1
00063 #define MAY_WRITE 2
00064 #define MAY_READ 4
00065 
00066 #define FMODE_READ 1
00067 #define FMODE_WRITE 2
00068 
00069 #define READ 0
00070 #define WRITE 1
00071 #define READA 2         /* read-ahead  - don't block if no resources */
00072 #define WRITEA 3        /* write-ahead - don't block if no resources */
00073 
00074 #define NIL_FILP        ((struct file *)0)
00075 #define SEL_IN          1
00076 #define SEL_OUT         2
00077 #define SEL_EX          4
00078 
00079 /* public flags for file_system_type */
00080 #define FS_REQUIRES_DEV 1 
00081 #define FS_NO_DCACHE    2 /* Only dcache the necessary things. */
00082 #define FS_NO_PRELIM    4 /* prevent preloading of dentries, even if
00083                            * FS_NO_DCACHE is not set.
00084                            */
00085 #define FS_IBASKET      8 /* FS does callback to free_ibasket() if space gets low. */
00086 
00087 /*
00088  * These are the fs-independent mount-flags: up to 16 flags are supported
00089  */
00090 #define MS_RDONLY        1      /* Mount read-only */
00091 #define MS_NOSUID        2      /* Ignore suid and sgid bits */
00092 #define MS_NODEV         4      /* Disallow access to device special files */
00093 #define MS_NOEXEC        8      /* Disallow program execution */
00094 #define MS_SYNCHRONOUS  16      /* Writes are synced at once */
00095 #define MS_REMOUNT      32      /* Alter flags of a mounted FS */
00096 #define MS_MANDLOCK     64      /* Allow mandatory locks on an FS */
00097 #define S_QUOTA         128     /* Quota initialized for file/directory/symlink */
00098 #define S_APPEND        256     /* Append-only file */
00099 #define S_IMMUTABLE     512     /* Immutable file */
00100 #define MS_NOATIME      1024    /* Do not update access times. */
00101 #define MS_NODIRATIME   2048    /* Do not update directory access times */
00102 
00103 #define MS_ODD_RENAME   32768    /* Temporary stuff; will go away as soon
00104                                   * as nfs_rename() will be cleaned up
00105                                   */
00106 
00107 /*
00108  * Flags that can be altered by MS_REMOUNT
00109  */
00110 #define MS_RMT_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
00111 
00112 /*
00113  * Magic mount flag number. Has to be or-ed to the flag values.
00114  */
00115 #define MS_MGC_VAL 0xC0ED0000   /* magic flag number to indicate "new" flags */
00116 #define MS_MGC_MSK 0xffff0000   /* magic flag number mask */
00117 
00118 /*
00119  * Note that read-only etc flags are inode-specific: setting some file-system
00120  * flags just means all the inodes inherit those flags by default. It might be
00121  * possible to override it selectively if you really wanted to with some
00122  * ioctl() that is not currently implemented.
00123  *
00124  * Exception: MS_RDONLY is always applied to the entire file system.
00125  *
00126  * Unfortunately, it is possible to change a filesystems flags with it mounted
00127  * with files in use.  This means that all of the inodes will not have their
00128  * i_flags updated.  Hence, i_flags no longer inherit the superblock mount
00129  * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
00130  */
00131 #define __IS_FLG(inode,flg) (((inode)->i_sb && (inode)->i_sb->s_flags & (flg)) \
00132                                 || (inode)->i_flags & (flg))
00133 
00134 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
00135 #define IS_NOSUID(inode)        __IS_FLG(inode, MS_NOSUID)
00136 #define IS_NODEV(inode)         __IS_FLG(inode, MS_NODEV)
00137 #define IS_NOEXEC(inode)        __IS_FLG(inode, MS_NOEXEC)
00138 #define IS_SYNC(inode)          __IS_FLG(inode, MS_SYNCHRONOUS)
00139 #define IS_MANDLOCK(inode)      __IS_FLG(inode, MS_MANDLOCK)
00140 
00141 #define IS_QUOTAINIT(inode)     ((inode)->i_flags & S_QUOTA)
00142 #define IS_APPEND(inode)        ((inode)->i_flags & S_APPEND)
00143 #define IS_IMMUTABLE(inode)     ((inode)->i_flags & S_IMMUTABLE)
00144 #define IS_NOATIME(inode)       __IS_FLG(inode, MS_NOATIME)
00145 #define IS_NODIRATIME(inode)    __IS_FLG(inode, MS_NODIRATIME)
00146 
00147 /* the read-only stuff doesn't really belong here, but any other place is
00148    probably as bad and I don't want to create yet another include file. */
00149 
00150 #define BLKROSET   _IO(0x12,93) /* set device read-only (0 = read-write) */
00151 #define BLKROGET   _IO(0x12,94) /* get read-only status (0 = read_write) */
00152 #define BLKRRPART  _IO(0x12,95) /* re-read partition table */
00153 #define BLKGETSIZE _IO(0x12,96) /* return device size */
00154 #define BLKFLSBUF  _IO(0x12,97) /* flush buffer cache */
00155 #define BLKRASET   _IO(0x12,98) /* Set read ahead for block device */
00156 #define BLKRAGET   _IO(0x12,99) /* get current read ahead setting */
00157 #define BLKFRASET  _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
00158 #define BLKFRAGET  _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
00159 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
00160 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
00161 #define BLKSSZGET  _IO(0x12,104) /* get block device sector size */
00162 #if 0
00163 #define BLKELVGET  _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */
00164 #define BLKELVSET  _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))/* elevator set */
00165 #endif
00166 
00167 #define BMAP_IOCTL 1            /* obsolete - kept for compatibility */
00168 #define FIBMAP     _IO(0x00,1)  /* bmap access */
00169 #define FIGETBSZ   _IO(0x00,2)  /* get the block size used for bmap */
00170 
00171 #ifdef __KERNEL__
00172 
00173 #include <asm/semaphore.h>
00174 #include <asm/byteorder.h>
00175 #include <asm/bitops.h>
00176 
00177 extern void update_atime (struct inode *inode);
00178 #define UPDATE_ATIME(inode) update_atime (inode)
00179 
00180 extern void buffer_init(unsigned long);
00181 extern void inode_init(void);
00182 extern void file_table_init(void);
00183 extern void dcache_init(void);
00184 
00185 typedef char buffer_block[BLOCK_SIZE];
00186 
00187 /* bh state bits */
00188 #define BH_Uptodate     0       /* 1 if the buffer contains valid data */
00189 #define BH_Dirty        1       /* 1 if the buffer is dirty */
00190 #define BH_Lock         2       /* 1 if the buffer is locked */
00191 #define BH_Req          3       /* 0 if the buffer has been invalidated */
00192 #define BH_Protected    6       /* 1 if the buffer is protected */
00193 #define BH_Wait_IO      7       /* 1 if we should throttle on this buffer */
00194 
00195 /*
00196  * Try to keep the most commonly used fields in single cache lines (16
00197  * bytes) to improve performance.  This ordering should be
00198  * particularly beneficial on 32-bit processors.
00199  * 
00200  * We use the first 16 bytes for the data which is used in searches
00201  * over the block hash lists (ie. getblk(), find_buffer() and
00202  * friends).
00203  * 
00204  * The second 16 bytes we use for lru buffer scans, as used by
00205  * sync_buffers() and refill_freelist().  -- sct
00206  */
00207 struct buffer_head {
00208         /* First cache line: */
00209         struct buffer_head * b_next;    /* Hash queue list */
00210         unsigned long b_blocknr;        /* block number */
00211         unsigned long b_size;           /* block size */
00212         kdev_t b_dev;                   /* device (B_FREE = free) */
00213         kdev_t b_rdev;                  /* Real device */
00214         unsigned long b_rsector;        /* Real buffer location on disk */
00215         struct buffer_head * b_this_page;       /* circular list of buffers in one page */
00216         unsigned long b_state;          /* buffer state bitmap (see above) */
00217         struct buffer_head * b_next_free;
00218         unsigned int b_count;           /* users using this block */
00219 
00220         /* Non-performance-critical data follows. */
00221         char * b_data;                  /* pointer to data block (1024 bytes) */
00222         unsigned int b_list;            /* List that this buffer appears */
00223         unsigned long b_flushtime;      /* Time when this (dirty) buffer
00224                                          * should be written */
00225         struct wait_queue * b_wait;
00226         struct buffer_head ** b_pprev;          /* doubly linked list of hash-queue */
00227         struct buffer_head * b_prev_free;       /* doubly linked list of buffers */
00228         struct buffer_head * b_reqnext;         /* request queue */
00229 
00230         /*
00231          * I/O completion
00232          */
00233         void (*b_end_io)(struct buffer_head *bh, int uptodate);
00234         void *b_dev_id;
00235 };
00236 
00237 typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
00238 void init_buffer(struct buffer_head *bh, kdev_t dev, int block,
00239                  bh_end_io_t *handler, void *dev_id);
00240 
00241 static inline int buffer_uptodate(struct buffer_head * bh)
00242 {
00243         return test_bit(BH_Uptodate, &bh->b_state);
00244 }       
00245 
00246 static inline int buffer_dirty(struct buffer_head * bh)
00247 {
00248         return test_bit(BH_Dirty, &bh->b_state);
00249 }
00250 
00251 static inline int buffer_locked(struct buffer_head * bh)
00252 {
00253         return test_bit(BH_Lock, &bh->b_state);
00254 }
00255 
00256 static inline int buffer_req(struct buffer_head * bh)
00257 {
00258         return test_bit(BH_Req, &bh->b_state);
00259 }
00260 
00261 static inline int buffer_protected(struct buffer_head * bh)
00262 {
00263         return test_bit(BH_Protected, &bh->b_state);
00264 }
00265 
00266 #define buffer_page(bh)         (mem_map + MAP_NR((bh)->b_data))
00267 #define touch_buffer(bh)        set_bit(PG_referenced, &buffer_page(bh)->flags)
00268 
00269 #include <linux/pipe_fs_i.h>
00270 #include <linux/minix_fs_i.h>
00271 #include <linux/ext2_fs_i.h>
00272 #include <linux/hpfs_fs_i.h>
00273 #include <linux/ntfs_fs_i.h>
00274 #include <linux/msdos_fs_i.h>
00275 #include <linux/umsdos_fs_i.h>
00276 #include <linux/iso_fs_i.h>
00277 #include <linux/nfs_fs_i.h>
00278 #include <linux/sysv_fs_i.h>
00279 #include <linux/affs_fs_i.h>
00280 #include <linux/ufs_fs_i.h>
00281 #include <linux/efs_fs_i.h>
00282 #include <linux/coda_fs_i.h>
00283 #include <linux/romfs_fs_i.h>
00284 #include <linux/smb_fs_i.h>
00285 #include <linux/hfs_fs_i.h>
00286 #include <linux/adfs_fs_i.h>
00287 #include <linux/qnx4_fs_i.h>
00288 #include <linux/usbdev_fs_i.h>
00289 
00290 /*
00291  * Attribute flags.  These should be or-ed together to figure out what
00292  * has been changed!
00293  */
00294 #define ATTR_MODE       1
00295 #define ATTR_UID        2
00296 #define ATTR_GID        4
00297 #define ATTR_SIZE       8
00298 #define ATTR_ATIME      16
00299 #define ATTR_MTIME      32
00300 #define ATTR_CTIME      64
00301 #define ATTR_ATIME_SET  128
00302 #define ATTR_MTIME_SET  256
00303 #define ATTR_FORCE      512     /* Not a change, but a change it */
00304 #define ATTR_ATTR_FLAG  1024
00305 
00306 /*
00307  * This is the Inode Attributes structure, used for notify_change().  It
00308  * uses the above definitions as flags, to know which values have changed.
00309  * Also, in this manner, a Filesystem can look at only the values it cares
00310  * about.  Basically, these are the attributes that the VFS layer can
00311  * request to change from the FS layer.
00312  *
00313  * Derek Atkins <warlord@MIT.EDU> 94-10-20
00314  */
00315 struct iattr {
00316         unsigned int    ia_valid;
00317         umode_t         ia_mode;
00318         uid_t           ia_uid;
00319         gid_t           ia_gid;
00320         off_t           ia_size;
00321         time_t          ia_atime;
00322         time_t          ia_mtime;
00323         time_t          ia_ctime;
00324         unsigned int    ia_attr_flags;
00325 };
00326 
00327 /*
00328  * This is the inode attributes flag definitions
00329  */
00330 #define ATTR_FLAG_SYNCRONOUS    1       /* Syncronous write */
00331 #define ATTR_FLAG_NOATIME       2       /* Don't update atime */
00332 #define ATTR_FLAG_APPEND        4       /* Append-only file */
00333 #define ATTR_FLAG_IMMUTABLE     8       /* Immutable file */
00334 #define ATTR_FLAG_NODIRATIME    16      /* Don't update atime for directory */
00335 
00336 /*
00337  * Includes for diskquotas and mount structures.
00338  */
00339 #include <linux/quota.h>
00340 #include <linux/mount.h>
00341 
00342 struct inode {
00343         struct list_head        i_hash;
00344         struct list_head        i_list;
00345         struct list_head        i_dentry;
00346 
00347         unsigned long           i_ino;
00348         unsigned int            i_count;
00349         kdev_t                  i_dev;
00350         umode_t                 i_mode;
00351         nlink_t                 i_nlink;
00352         uid_t                   i_uid;
00353         gid_t                   i_gid;
00354         kdev_t                  i_rdev;
00355         off_t                   i_size;
00356         time_t                  i_atime;
00357         time_t                  i_mtime;
00358         time_t                  i_ctime;
00359         unsigned long           i_blksize;
00360         unsigned long           i_blocks;
00361         unsigned long           i_version;
00362         unsigned long           i_nrpages;
00363         struct semaphore        i_sem;
00364         struct semaphore        i_atomic_write;
00365         struct inode_operations *i_op;
00366         struct super_block      *i_sb;
00367         struct wait_queue       *i_wait;
00368         struct file_lock        *i_flock;
00369         struct vm_area_struct   *i_mmap;
00370         struct vm_area_struct   *i_mmap_shared;
00371         struct page             *i_pages;
00372         struct dquot            *i_dquot[MAXQUOTAS];
00373 
00374         unsigned long           i_state;
00375 
00376         unsigned int            i_flags;
00377         unsigned char           i_pipe;
00378         unsigned char           i_sock;
00379 
00380         int                     i_writecount;
00381         unsigned int            i_attr_flags;
00382         __u32                   i_generation;
00383         union {
00384                 struct pipe_inode_info          pipe_i;
00385                 struct minix_inode_info         minix_i;
00386                 struct ext2_inode_info          ext2_i;
00387                 struct hpfs_inode_info          hpfs_i;
00388                 struct ntfs_inode_info          ntfs_i;
00389                 struct msdos_inode_info         msdos_i;
00390                 struct umsdos_inode_info        umsdos_i;
00391                 struct iso_inode_info           isofs_i;
00392                 struct nfs_inode_info           nfs_i;
00393                 struct sysv_inode_info          sysv_i;
00394                 struct affs_inode_info          affs_i;
00395                 struct ufs_inode_info           ufs_i;
00396                 struct efs_inode_info           efs_i;
00397                 struct romfs_inode_info         romfs_i;
00398                 struct coda_inode_info          coda_i;
00399                 struct smb_inode_info           smbfs_i;
00400                 struct hfs_inode_info           hfs_i;
00401                 struct adfs_inode_info          adfs_i;
00402                 struct qnx4_inode_info          qnx4_i;
00403                 struct usbdev_inode_info        usbdev_i;
00404                 struct socket                   socket_i;
00405                 void                            *generic_ip;
00406         } u;
00407 };
00408 
00409 /* Inode state bits.. */
00410 #define I_DIRTY         1
00411 #define I_LOCK          2
00412 #define I_FREEING       4
00413 
00414 extern void __mark_inode_dirty(struct inode *);
00415 static inline void mark_inode_dirty(struct inode *inode)
00416 {
00417         if (!(inode->i_state & I_DIRTY))
00418                 __mark_inode_dirty(inode);
00419 }
00420 
00421 struct fown_struct {
00422         int pid;                /* pid or -pgrp where SIGIO should be sent */
00423         uid_t uid, euid;        /* uid/euid of process setting the owner */
00424         int signum;             /* posix.1b rt signal to be delivered on IO */
00425 };
00426 
00427 struct file {
00428         struct file             *f_next, **f_pprev;
00429         struct dentry           *f_dentry;
00430         struct file_operations  *f_op;
00431         mode_t                  f_mode;
00432         loff_t                  f_pos;
00433         unsigned int            f_count, f_flags;
00434         unsigned long           f_reada, f_ramax, f_raend, f_ralen, f_rawin;
00435         struct fown_struct      f_owner;
00436         unsigned int            f_uid, f_gid;
00437         int                     f_error;
00438 
00439         unsigned long           f_version;
00440 
00441         /* needed for tty driver, and maybe others */
00442         void                    *private_data;
00443 };
00444 
00445 extern int init_private_file(struct file *, struct dentry *, int);
00446 
00447 #define FL_POSIX        1
00448 #define FL_FLOCK        2
00449 #define FL_BROKEN       4       /* broken flock() emulation */
00450 #define FL_ACCESS       8       /* for processes suspended by mandatory locking */
00451 #define FL_LOCKD        16      /* lock held by rpc.lockd */
00452 
00453 /*
00454  * The POSIX file lock owner is determined by
00455  * the "struct files_struct" in the thread group
00456  * (or NULL for no owner - BSD locks).
00457  *
00458  * Lockd stuffs a "host" pointer into this.
00459  */
00460 typedef struct files_struct *fl_owner_t;
00461 
00462 struct file_lock {
00463         struct file_lock *fl_next;      /* singly linked list for this inode  */
00464         struct file_lock *fl_nextlink;  /* doubly linked list of all locks */
00465         struct file_lock *fl_prevlink;  /* used to simplify lock removal */
00466         struct file_lock *fl_nextblock; /* circular list of blocked processes */
00467         struct file_lock *fl_prevblock;
00468         fl_owner_t fl_owner;
00469         unsigned int fl_pid;
00470         struct wait_queue *fl_wait;
00471         struct file *fl_file;
00472         unsigned char fl_flags;
00473         unsigned char fl_type;
00474         off_t fl_start;
00475         off_t fl_end;
00476 
00477         void (*fl_notify)(struct file_lock *);  /* unblock callback */
00478         void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
00479         void (*fl_remove)(struct file_lock *);  /* lock removal callback */
00480 
00481         union {
00482                 struct nfs_lock_info    nfs_fl;
00483         } fl_u;
00484 };
00485 
00486 extern struct file_lock                 *file_lock_table;
00487 
00488 #include <linux/fcntl.h>
00489 
00490 extern int fcntl_getlk(unsigned int fd, struct flock *l);
00491 extern int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l);
00492 
00493 /* fs/locks.c */
00494 extern void locks_remove_posix(struct file *, fl_owner_t id);
00495 extern void locks_remove_flock(struct file *);
00496 extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
00497 extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
00498 extern void posix_block_lock(struct file_lock *, struct file_lock *);
00499 extern void posix_unblock_lock(struct file_lock *);
00500 
00501 struct fasync_struct {
00502         int    magic;
00503         int    fa_fd;
00504         struct fasync_struct    *fa_next; /* singly linked list */
00505         struct file             *fa_file;
00506 };
00507 
00508 #define FASYNC_MAGIC 0x4601
00509 
00510 extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
00511 
00512 #include <linux/minix_fs_sb.h>
00513 #include <linux/ext2_fs_sb.h>
00514 #include <linux/hpfs_fs_sb.h>
00515 #include <linux/ntfs_fs_sb.h>
00516 #include <linux/msdos_fs_sb.h>
00517 #include <linux/iso_fs_sb.h>
00518 #include <linux/nfs_fs_sb.h>
00519 #include <linux/sysv_fs_sb.h>
00520 #include <linux/affs_fs_sb.h>
00521 #include <linux/ufs_fs_sb.h>
00522 #include <linux/efs_fs_sb.h>
00523 #include <linux/romfs_fs_sb.h>
00524 #include <linux/smb_fs_sb.h>
00525 #include <linux/hfs_fs_sb.h>
00526 #include <linux/adfs_fs_sb.h>
00527 #include <linux/qnx4_fs_sb.h>
00528 #include <linux/usbdev_fs_sb.h>
00529 
00530 extern struct list_head super_blocks;
00531 
00532 #define sb_entry(list)  list_entry((list), struct super_block, s_list)
00533 struct super_block {
00534         struct list_head        s_list;         /* Keep this first */
00535         kdev_t                  s_dev;
00536         unsigned long           s_blocksize;
00537         unsigned char           s_blocksize_bits;
00538         unsigned char           s_lock;
00539         unsigned char           s_rd_only;
00540         unsigned char           s_dirt;
00541         struct file_system_type *s_type;
00542         struct super_operations *s_op;
00543         struct dquot_operations *dq_op;
00544         unsigned long           s_flags;
00545         unsigned long           s_magic;
00546         unsigned long           s_time;
00547         struct dentry           *s_root;
00548         struct wait_queue       *s_wait;
00549 
00550         struct inode            *s_ibasket;
00551         short int               s_ibasket_count;
00552         short int               s_ibasket_max;
00553         struct list_head        s_dirty;        /* dirty inodes */
00554 
00555         union {
00556                 struct minix_sb_info    minix_sb;
00557                 struct ext2_sb_info     ext2_sb;
00558                 struct hpfs_sb_info     hpfs_sb;
00559                 struct ntfs_sb_info     ntfs_sb;
00560                 struct msdos_sb_info    msdos_sb;
00561                 struct isofs_sb_info    isofs_sb;
00562                 struct nfs_sb_info      nfs_sb;
00563                 struct sysv_sb_info     sysv_sb;
00564                 struct affs_sb_info     affs_sb;
00565                 struct ufs_sb_info      ufs_sb;
00566                 struct efs_sb_info      efs_sb;
00567                 struct romfs_sb_info    romfs_sb;
00568                 struct smb_sb_info      smbfs_sb;
00569                 struct hfs_sb_info      hfs_sb;
00570                 struct adfs_sb_info     adfs_sb;
00571                 struct qnx4_sb_info     qnx4_sb;           
00572                 struct usbdev_sb_info   usbdevfs_sb;
00573                 void                    *generic_sbp;
00574         } u;
00575         /*
00576          * The next field is for VFS *only*. No filesystems have any business
00577          * even looking at it. You had been warned.
00578          */
00579         struct semaphore s_vfs_rename_sem;      /* Kludge */
00580 
00581         /* The next field is used by knfsd when converting a (inode number based)
00582          * file handle into a dentry. As it builds a path in the dcache tree from
00583          * the bottom up, there may for a time be a subpath of dentrys which is not
00584          * connected to the main tree.  This semaphore ensure that there is only ever
00585          * one such free path per filesystem.  Note that unconnected files (or other
00586          * non-directories) are allowed, but not unconnected diretories.
00587          */
00588         struct semaphore s_nfsd_free_path_sem;
00589 };
00590 
00591 /*
00592  * VFS helper functions..
00593  */
00594 extern int vfs_rmdir(struct inode *, struct dentry *);
00595 extern int vfs_unlink(struct inode *, struct dentry *);
00596 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
00597 
00598 /*
00599  * This is the "filldir" function type, used by readdir() to let
00600  * the kernel specify what kind of dirent layout it wants to have.
00601  * This allows the kernel to read directories into kernel space or
00602  * to have different dirent layouts depending on the binary type.
00603  */
00604 typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
00605         
00606 struct file_operations {
00607         loff_t (*llseek) (struct file *, loff_t, int);
00608         ssize_t (*read) (struct file *, char *, size_t, loff_t *);
00609         ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
00610         int (*readdir) (struct file *, void *, filldir_t);
00611         unsigned int (*poll) (struct file *, struct poll_table_struct *);
00612         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
00613         int (*mmap) (struct file *, struct vm_area_struct *);
00614         int (*open) (struct inode *, struct file *);
00615         int (*flush) (struct file *);
00616         int (*release) (struct inode *, struct file *);
00617         int (*fsync) (struct file *, struct dentry *);
00618         int (*fasync) (int, struct file *, int);
00619         int (*check_media_change) (kdev_t dev);
00620         int (*revalidate) (kdev_t dev);
00621         int (*lock) (struct file *, int, struct file_lock *);
00622 };
00623 
00624 struct inode_operations {
00625         struct file_operations * default_file_ops;
00626         int (*create) (struct inode *,struct dentry *,int);
00627         struct dentry * (*lookup) (struct inode *,struct dentry *);
00628         int (*link) (struct dentry *,struct inode *,struct dentry *);
00629         int (*unlink) (struct inode *,struct dentry *);
00630         int (*symlink) (struct inode *,struct dentry *,const char *);
00631         int (*mkdir) (struct inode *,struct dentry *,int);
00632         int (*rmdir) (struct inode *,struct dentry *);
00633         int (*mknod) (struct inode *,struct dentry *,int,int);
00634         int (*rename) (struct inode *, struct dentry *,
00635                         struct inode *, struct dentry *);
00636         int (*readlink) (struct dentry *, char *,int);
00637         struct dentry * (*follow_link) (struct dentry *, struct dentry *, unsigned int);
00638         int (*readpage) (struct file *, struct page *);
00639         int (*writepage) (struct file *, struct page *);
00640         int (*bmap) (struct inode *,int);
00641         void (*truncate) (struct inode *);
00642         int (*permission) (struct inode *, int);
00643         int (*smap) (struct inode *,int);
00644         int (*updatepage) (struct file *, struct page *, unsigned long, unsigned int, int);
00645         int (*revalidate) (struct dentry *);
00646         int (*prepare_write) (struct file *, struct page *, unsigned, unsigned);
00647         int (*sync_page) (struct page *);
00648 };
00649 
00650 struct super_operations {
00651         void (*read_inode) (struct inode *);
00652         void (*write_inode) (struct inode *);
00653         void (*put_inode) (struct inode *);
00654         void (*delete_inode) (struct inode *);
00655         int (*notify_change) (struct dentry *, struct iattr *);
00656         void (*put_super) (struct super_block *);
00657         void (*write_super) (struct super_block *);
00658         int (*statfs) (struct super_block *, struct statfs *, int);
00659         int (*remount_fs) (struct super_block *, int *, char *);
00660         void (*clear_inode) (struct inode *);
00661         void (*umount_begin) (struct super_block *);
00662 };
00663 
00664 struct dquot_operations {
00665         void (*initialize) (struct inode *, short);
00666         void (*drop) (struct inode *);
00667         int (*alloc_block) (const struct inode *, unsigned long, uid_t, char);
00668         int (*alloc_inode) (const struct inode *, unsigned long, uid_t);
00669         void (*free_block) (const struct inode *, unsigned long);
00670         void (*free_inode) (const struct inode *, unsigned long);
00671         int (*transfer) (struct dentry *, struct iattr *, uid_t);
00672 };
00673 
00674 struct file_system_type {
00675         const char *name;
00676         int fs_flags;
00677         struct super_block *(*read_super) (struct super_block *, void *, int);
00678         struct file_system_type * next;
00679 };
00680 
00681 #define DECLARE_FSTYPE(var,type,read,flags) \
00682 struct file_system_type var = { \
00683         name:           type, \
00684         read_super:     read, \
00685         fs_flags:       flags, \
00686 }
00687 
00688 extern int register_filesystem(struct file_system_type *);
00689 extern int unregister_filesystem(struct file_system_type *);
00690 
00691 /* Return value for VFS lock functions - tells locks.c to lock conventionally
00692  * REALLY kosha for root NFS and nfs_lock
00693  */ 
00694 #define LOCK_USE_CLNT 1
00695 
00696 #define FLOCK_VERIFY_READ  1
00697 #define FLOCK_VERIFY_WRITE 2
00698 
00699 extern int locks_mandatory_locked(struct inode *inode);
00700 extern int locks_mandatory_area(int read_write, struct inode *inode,
00701                                 struct file *filp, loff_t offset,
00702                                 size_t count);
00703 
00704 extern inline int locks_verify_locked(struct inode *inode)
00705 {
00706         /* Candidates for mandatory locking have the setgid bit set
00707          * but no group execute bit -  an otherwise meaningless combination.
00708          */
00709         if (IS_MANDLOCK(inode) &&
00710             (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
00711                 return (locks_mandatory_locked(inode));
00712         return (0);
00713 }
00714 
00715 extern inline int locks_verify_area(int read_write, struct inode *inode,
00716                                     struct file *filp, loff_t offset,
00717                                     size_t count)
00718 {
00719         /* Candidates for mandatory locking have the setgid bit set
00720          * but no group execute bit -  an otherwise meaningless combination.
00721          */
00722         if (IS_MANDLOCK(inode) &&
00723             (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
00724                 return (locks_mandatory_area(read_write, inode, filp, offset,
00725                                              count));
00726         return (0);
00727 }
00728 
00729 
00730 /* fs/open.c */
00731 
00732 asmlinkage int sys_open(const char *, int, int);
00733 asmlinkage int sys_close(unsigned int);         /* yes, it's really unsigned */
00734 extern int do_truncate(struct dentry *, unsigned long);
00735 
00736 extern struct file *filp_open(const char *, int, int);
00737 extern int filp_close(struct file *, fl_owner_t id);
00738 
00739 extern char * getname(const char * filename);
00740 #define __getname()     ((char *) __get_free_page(GFP_KERNEL))
00741 #define putname(name)   free_page((unsigned long)(name))
00742 
00743 extern void kill_fasync(struct fasync_struct *fa, int sig);
00744 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
00745 extern int unregister_blkdev(unsigned int major, const char * name);
00746 extern int blkdev_open(struct inode * inode, struct file * filp);
00747 extern int blkdev_release (struct inode * inode);
00748 extern struct file_operations def_blk_fops;
00749 extern struct inode_operations blkdev_inode_operations;
00750 
00751 /* fs/devices.c */
00752 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
00753 extern int unregister_chrdev(unsigned int major, const char * name);
00754 extern int chrdev_open(struct inode * inode, struct file * filp);
00755 extern struct file_operations def_chr_fops;
00756 extern struct inode_operations chrdev_inode_operations;
00757 extern char * bdevname(kdev_t dev);
00758 extern char * cdevname(kdev_t dev);
00759 extern char * kdevname(kdev_t dev);
00760 
00761 
00762 extern void init_fifo(struct inode * inode);
00763 extern struct inode_operations fifo_inode_operations;
00764 
00765 /* Invalid inode operations -- fs/bad_inode.c */
00766 extern void make_bad_inode(struct inode * inode);
00767 extern int is_bad_inode(struct inode * inode);
00768 
00769 extern struct file_operations connecting_fifo_fops;
00770 extern struct file_operations read_fifo_fops;
00771 extern struct file_operations write_fifo_fops;
00772 extern struct file_operations rdwr_fifo_fops;
00773 extern struct file_operations read_pipe_fops;
00774 extern struct file_operations write_pipe_fops;
00775 extern struct file_operations rdwr_pipe_fops;
00776 
00777 extern struct file_system_type *get_fs_type(const char *name);
00778 
00779 extern int fs_may_remount_ro(struct super_block *);
00780 extern int fs_may_mount(kdev_t dev);
00781 
00782 extern struct file *inuse_filps;
00783 
00784 extern void refile_buffer(struct buffer_head * buf);
00785 extern void set_writetime(struct buffer_head * buf, int flag);
00786 extern int try_to_free_buffers(struct page *, int);
00787 
00788 extern int nr_buffers;
00789 extern long buffermem;
00790 extern int nr_buffer_heads;
00791 
00792 #define BUF_CLEAN       0
00793 #define BUF_LOCKED      1       /* Buffers scheduled for write */
00794 #define BUF_DIRTY       2       /* Dirty buffers, not yet scheduled for write */
00795 #define BUF_PROTECTED   3       /* Ramdisk persistent storage */
00796 #define NR_LIST         4
00797 
00798 void mark_buffer_uptodate(struct buffer_head * bh, int on);
00799 
00800 extern inline void mark_buffer_protected(struct buffer_head * bh)
00801 {
00802         if (!test_and_set_bit(BH_Protected, &bh->b_state)) {
00803                 if (bh->b_list != BUF_PROTECTED)
00804                         refile_buffer(bh);
00805         }
00806 }
00807 
00808 extern inline void mark_buffer_clean(struct buffer_head * bh)
00809 {
00810         if (test_and_clear_bit(BH_Dirty, &bh->b_state)) {
00811                 if (bh->b_list == BUF_DIRTY)
00812                         refile_buffer(bh);
00813                 clear_bit(BH_Wait_IO, &bh->b_state);
00814         }
00815 }
00816 
00817 extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag)
00818 {
00819         if (!test_and_set_bit(BH_Dirty, &bh->b_state)) {
00820                 set_writetime(bh, flag);
00821                 if (bh->b_list != BUF_DIRTY)
00822                         refile_buffer(bh);
00823         }
00824 }
00825 
00826 extern int check_disk_change(kdev_t dev);
00827 extern int invalidate_inodes(struct super_block * sb);
00828 extern void invalidate_inode_pages(struct inode *);
00829 #define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
00830 #define destroy_buffers(dev)    __invalidate_buffers((dev), 1)
00831 extern void __invalidate_buffers(kdev_t dev, int);
00832 extern int floppy_is_wp(int minor);
00833 extern void sync_inodes(kdev_t dev);
00834 extern void write_inode_now(struct inode *inode);
00835 extern void sync_dev(kdev_t dev);
00836 extern int fsync_dev(kdev_t dev);
00837 extern void sync_supers(kdev_t dev);
00838 extern int bmap(struct inode * inode,int block);
00839 extern int notify_change(struct dentry *, struct iattr *);
00840 extern int vfs_permission(struct inode * inode,int mask);
00841 extern int permission(struct inode * inode,int mask);
00842 extern int get_write_access(struct inode *inode);
00843 extern void put_write_access(struct inode *inode);
00844 extern struct dentry * open_namei(const char * pathname, int flag, int mode);
00845 extern struct dentry * do_mknod(const char * filename, int mode, dev_t dev);
00846 extern int do_pipe(int *);
00847 
00848 /* fs/dcache.c -- generic fs support functions */
00849 extern int is_subdir(struct dentry *, struct dentry *);
00850 extern ino_t find_inode_number(struct dentry *, struct qstr *);
00851 
00852 /*
00853  * Kernel pointers have redundant information, so we can use a
00854  * scheme where we can return either an error code or a dentry
00855  * pointer with the same return value.
00856  *
00857  * This should be a per-architecture thing, to allow different
00858  * error and pointer decisions.
00859  */
00860 #define ERR_PTR(err)    ((void *)((long)(err)))
00861 #define PTR_ERR(ptr)    ((long)(ptr))
00862 #define IS_ERR(ptr)     ((unsigned long)(ptr) > (unsigned long)(-1000))
00863 
00864 /*
00865  * The bitmask for a lookup event:
00866  *  - follow links at the end
00867  *  - require a directory
00868  *  - ending slashes ok even for nonexistent files
00869  *  - internal "there are more path compnents" flag
00870  */
00871 #define LOOKUP_FOLLOW           (1)
00872 #define LOOKUP_DIRECTORY        (2)
00873 #define LOOKUP_SLASHOK          (4)
00874 #define LOOKUP_CONTINUE         (8)
00875 #define LOOKUP_INSYMLINK        (16)
00876 
00877 extern struct dentry * lookup_dentry(const char *, struct dentry *, unsigned int);
00878 extern struct dentry * __namei(const char *, unsigned int);
00879 
00880 #define namei(pathname)         __namei(pathname, 1)
00881 #define lnamei(pathname)        __namei(pathname, 0)
00882 
00883 extern void iput(struct inode *);
00884 extern struct inode * igrab(struct inode *inode);
00885 extern ino_t iunique(struct super_block *, ino_t);
00886 
00887 typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
00888 extern struct inode * iget4(struct super_block *, unsigned long, find_inode_t, void *);
00889 extern struct inode * iget(struct super_block *sb, unsigned long ino);
00890 extern struct inode * iget_in_use (struct super_block *, unsigned long);
00891 extern void clear_inode(struct inode *);
00892 extern struct inode * get_empty_inode(void);
00893 
00894 extern void insert_inode_hash(struct inode *);
00895 extern void remove_inode_hash(struct inode *);
00896 extern struct file * get_empty_filp(void);
00897 extern struct buffer_head * get_hash_table(kdev_t, int, int);
00898 extern struct buffer_head * getblk(kdev_t, int, int);
00899 extern struct buffer_head * find_buffer(kdev_t dev, int block, int size);
00900 extern void ll_rw_block(int, int, struct buffer_head * bh[]);
00901 extern int is_read_only(kdev_t);
00902 extern void __brelse(struct buffer_head *);
00903 extern inline void brelse(struct buffer_head *buf)
00904 {
00905         if (buf)
00906                 __brelse(buf);
00907 }
00908 extern void __bforget(struct buffer_head *buf);
00909 extern inline void bforget(struct buffer_head *buf)
00910 {
00911         if (buf)
00912                 __bforget(buf);
00913 }
00914 extern void set_blocksize(kdev_t dev, int size);
00915 extern unsigned int get_hardblocksize(kdev_t dev);
00916 extern struct buffer_head * bread(kdev_t dev, int block, int size);
00917 extern struct buffer_head * breada(kdev_t dev,int block, int size, 
00918                                    unsigned int pos, unsigned int filesize);
00919 
00920 extern int brw_page(int, struct page *, kdev_t, int [], int, int);
00921 
00922 extern int generic_readpage(struct file *, struct page *);
00923 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
00924 extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
00925 extern ssize_t generic_file_write(struct file *, const char*, size_t, loff_t*);
00926 
00927 extern struct super_block *get_super(kdev_t dev);
00928 extern void put_super(kdev_t dev);
00929 unsigned long generate_cluster(kdev_t dev, int b[], int size);
00930 unsigned long generate_cluster_swab32(kdev_t dev, int b[], int size);
00931 extern kdev_t ROOT_DEV;
00932 
00933 extern void show_buffers(void);
00934 extern void mount_root(void);
00935 
00936 #ifdef CONFIG_BLK_DEV_INITRD
00937 extern kdev_t real_root_dev;
00938 extern int change_root(kdev_t new_root_dev,const char *put_old);
00939 #endif
00940 
00941 extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
00942 extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
00943 extern int read_ahead[];
00944 
00945 extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
00946 extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
00947 
00948 extern int block_fsync(struct file *, struct dentry *dir);
00949 extern int file_fsync(struct file *, struct dentry *dir);
00950 
00951 extern int inode_change_ok(struct inode *, struct iattr *);
00952 extern void inode_setattr(struct inode *, struct iattr *);
00953 
00954 extern __u32 inode_generation_count;
00955 
00956 #define fs_down(sem)    do { current->fs_locks++; down(sem); } while (0)
00957 #define fs_up(sem)      do { up(sem); current->fs_locks--; } while (0)
00958 
00959 #endif /* __KERNEL__ */
00960 
00961 #endif