root/include/linux/fs.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef _LINUX_FS_H
   2 #define _LINUX_FS_H
   3 
   4 /*
   5  * This file has definitions for some important file table
   6  * structures etc.
   7  */
   8 
   9 #include <linux/limits.h>
  10 #include <linux/wait.h>
  11 #include <linux/types.h>
  12 #include <linux/dirent.h>
  13 #include <linux/vfs.h>
  14 
  15 /*
  16  * It's silly to have NR_OPEN bigger than NR_FILE, but I'll fix
  17  * that later. Anyway, now the file code is no longer dependent
  18  * on bitmaps in unsigned longs, but uses the new fd_set structure..
  19  *
  20  * Some programs (notably those using select()) may have to be 
  21  * recompiled to take full advantage of the new limits..
  22  */
  23 #undef NR_OPEN
  24 #define NR_OPEN 256
  25 
  26 #define NR_INODE 256
  27 #define NR_FILE 128
  28 #define NR_SUPER 16
  29 #define NR_HASH 997
  30 #define NR_FILE_LOCKS 32
  31 #define BLOCK_SIZE 1024
  32 #define BLOCK_SIZE_BITS 10
  33 #define MAX_CHRDEV 32
  34 #define MAX_BLKDEV 32
  35 
  36 /* devices are as follows: (same as minix, so we can use the minix
  37  * file system. These are major numbers.)
  38  *
  39  *  0 - unnamed (minor 0 = true nodev)
  40  *  1 - /dev/mem
  41  *  2 - /dev/fd
  42  *  3 - /dev/hd
  43  *  4 - /dev/ttyx
  44  *  5 - /dev/tty
  45  *  6 - /dev/lp
  46  *  7 -
  47  *  8 - /dev/sd
  48  *  9 - /dev/st
  49  * 10 - mice
  50  * 11 - scsi cdrom
  51  * 12 -
  52  * 13 -
  53  * 14 - sound card (?)
  54  * 15 -
  55  */
  56 
  57 #define UNNAMED_MAJOR 0
  58 
  59 #define MAY_EXEC 1
  60 #define MAY_WRITE 2
  61 #define MAY_READ 4
  62 
  63 #define READ 0
  64 #define WRITE 1
  65 #define READA 2         /* read-ahead - don't pause */
  66 #define WRITEA 3        /* "write-ahead" - silly, but somewhat useful */
  67 
  68 extern void buffer_init(void);
  69 extern unsigned long inode_init(unsigned long start, unsigned long end);
  70 
  71 #define MAJOR(a) (((unsigned)(a))>>8)
  72 #define MINOR(a) ((a)&0xff)
  73 
  74 #ifndef NULL
  75 #define NULL ((void *) 0)
  76 #endif
  77 
  78 #define NIL_FILP        ((struct file *)0)
  79 #define SEL_IN          1
  80 #define SEL_OUT         2
  81 #define SEL_EX          4
  82 
  83 /*
  84  * These are the fs-independent mount-flags: up to 16 flags are supported
  85  */
  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_SYNC     16 /* writes are synced at once */
  91 #define MS_REMOUNT  32 /* alter flags of a mounted FS */
  92 
  93 /*
  94  * Flags that can be altered by MS_REMOUNT
  95  */
  96 #define MS_RMT_MASK (MS_RDONLY)
  97 
  98 /*
  99  * Magic mount flag number. Has to be or-ed to the flag values.
 100  */
 101 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
 102 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
 103 
 104 /*
 105  * Note that read-only etc flags are inode-specific: setting some file-system
 106  * flags just means all the inodes inherit those flags by default. It might be
 107  * possible to overrride it sevelctively if you really wanted to with some
 108  * ioctl() that is not currently implemented.
 109  *
 110  * Exception: MS_RDONLY is always applied to the entire file system.
 111  */
 112 #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
 113 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
 114 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
 115 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
 116 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC)
 117 
 118 /* the read-only stuff doesn't really belong here, but any other place is
 119    probably as bad and I don't want to create yet another include file. */
 120 
 121 #define BLKROSET 4701 /* set device read-only (0 = read-write) */
 122 #define BLKROGET 4702 /* get read-only status (0 = read_write) */
 123 #define BLKRRPART 4703 /* re-read partition table */
 124 #define BLKGETSIZE 4704 /* return device size */
 125 
 126 #define BMAP_IOCTL 1    /* obsolete - kept for compatibility */
 127 #define FIBMAP     1    /* bmap access */
 128 #define FIGETBSZ   2    /* get the block size used for bmap */
 129 
 130 typedef char buffer_block[BLOCK_SIZE];
 131 
 132 struct buffer_head {
 133         char * b_data;                  /* pointer to data block (1024 bytes) */
 134         unsigned long b_size;           /* block size */
 135         unsigned long b_blocknr;        /* block number */
 136         dev_t b_dev;                    /* device (0 = free) */
 137         unsigned short b_count;         /* users using this block */
 138         unsigned char b_uptodate;
 139         unsigned char b_dirt;           /* 0-clean,1-dirty */
 140         unsigned char b_lock;           /* 0 - ok, 1 -locked */
 141         struct wait_queue * b_wait;
 142         struct buffer_head * b_prev;            /* doubly linked list of hash-queue */
 143         struct buffer_head * b_next;
 144         struct buffer_head * b_prev_free;       /* doubly linked list of buffers */
 145         struct buffer_head * b_next_free;
 146         struct buffer_head * b_this_page;       /* circular list of buffers in one page */
 147         struct buffer_head * b_reqnext;         /* request queue */
 148 };
 149 
 150 #include <linux/pipe_fs_i.h>
 151 #include <linux/minix_fs_i.h>
 152 #include <linux/ext_fs_i.h>
 153 #include <linux/msdos_fs_i.h>
 154 #include <linux/iso_fs_i.h>
 155 #include <linux/nfs_fs_i.h>
 156 
 157 struct inode {
 158         dev_t           i_dev;
 159         unsigned long   i_ino;
 160         umode_t         i_mode;
 161         nlink_t         i_nlink;
 162         uid_t           i_uid;
 163         gid_t           i_gid;
 164         dev_t           i_rdev;
 165         off_t           i_size;
 166         time_t          i_atime;
 167         time_t          i_mtime;
 168         time_t          i_ctime;
 169         unsigned long   i_blksize;
 170         unsigned long   i_blocks;
 171         struct inode_operations * i_op;
 172         struct super_block * i_sb;
 173         struct wait_queue * i_wait;
 174         struct file_lock * i_flock;
 175         struct vm_area_struct * i_mmap;
 176         struct inode * i_next, * i_prev;
 177         struct inode * i_hash_next, * i_hash_prev;
 178         struct inode * i_bound_to, * i_bound_by;
 179         unsigned short i_count;
 180         unsigned short i_flags;
 181         unsigned char i_lock;
 182         unsigned char i_dirt;
 183         unsigned char i_pipe;
 184         unsigned char i_mount;
 185         unsigned char i_seek;
 186         unsigned char i_update;
 187         union {
 188                 struct pipe_inode_info pipe_i;
 189                 struct minix_inode_info minix_i;
 190                 struct ext_inode_info ext_i;
 191                 struct msdos_inode_info msdos_i;
 192                 struct iso_inode_info isofs_i;
 193                 struct nfs_inode_info nfs_i;
 194         } u;
 195 };
 196 
 197 struct file {
 198         mode_t f_mode;
 199         dev_t f_rdev;                   /* needed for /dev/tty */
 200         off_t f_pos;
 201         unsigned short f_flags;
 202         unsigned short f_count;
 203         unsigned short f_reada;
 204         struct inode * f_inode;
 205         struct file_operations * f_op;
 206 };
 207 
 208 struct file_lock {
 209         struct file_lock *fl_next;      /* singly linked list */
 210         struct task_struct *fl_owner;   /* NULL if on free list, for sanity checks */
 211         struct wait_queue *fl_wait;
 212         char fl_type;
 213         char fl_whence;
 214         off_t fl_start;
 215         off_t fl_end;
 216 };
 217 
 218 #include <linux/minix_fs_sb.h>
 219 #include <linux/ext_fs_sb.h>
 220 #include <linux/msdos_fs_sb.h>
 221 #include <linux/iso_fs_sb.h>
 222 #include <linux/nfs_fs_sb.h>
 223 
 224 struct super_block {
 225         dev_t s_dev;
 226         unsigned long s_blocksize;
 227         unsigned char s_lock;
 228         unsigned char s_rd_only;
 229         unsigned char s_dirt;
 230         struct super_operations *s_op;
 231         unsigned long s_flags;
 232         unsigned long s_magic;
 233         unsigned long s_time;
 234         struct inode * s_covered;
 235         struct inode * s_mounted;
 236         struct wait_queue * s_wait;
 237         union {
 238                 struct minix_sb_info minix_sb;
 239                 struct ext_sb_info ext_sb;
 240                 struct msdos_sb_info msdos_sb;
 241                 struct isofs_sb_info isofs_sb;
 242                 struct nfs_sb_info nfs_sb;
 243         } u;
 244 };
 245 
 246 struct file_operations {
 247         int (*lseek) (struct inode *, struct file *, off_t, int);
 248         int (*read) (struct inode *, struct file *, char *, int);
 249         int (*write) (struct inode *, struct file *, char *, int);
 250         int (*readdir) (struct inode *, struct file *, struct dirent *, int);
 251         int (*select) (struct inode *, struct file *, int, select_table *);
 252         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned int);
 253         int (*mmap) (void);
 254         int (*open) (struct inode *, struct file *);
 255         void (*release) (struct inode *, struct file *);
 256 };
 257 
 258 struct inode_operations {
 259         struct file_operations * default_file_ops;
 260         int (*create) (struct inode *,const char *,int,int,struct inode **);
 261         int (*lookup) (struct inode *,const char *,int,struct inode **);
 262         int (*link) (struct inode *,struct inode *,const char *,int);
 263         int (*unlink) (struct inode *,const char *,int);
 264         int (*symlink) (struct inode *,const char *,int,const char *);
 265         int (*mkdir) (struct inode *,const char *,int,int);
 266         int (*rmdir) (struct inode *,const char *,int);
 267         int (*mknod) (struct inode *,const char *,int,int,int);
 268         int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
 269         int (*readlink) (struct inode *,char *,int);
 270         int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
 271         int (*bmap) (struct inode *,int);
 272         void (*truncate) (struct inode *);
 273         int (*permission) (struct inode *, int);
 274 };
 275 
 276 struct super_operations {
 277         void (*read_inode) (struct inode *);
 278         int (*notify_change) (struct inode *);
 279         void (*write_inode) (struct inode *);
 280         void (*put_inode) (struct inode *);
 281         void (*put_super) (struct super_block *);
 282         void (*write_super) (struct super_block *);
 283         void (*statfs) (struct super_block *, struct statfs *);
 284 };
 285 
 286 struct file_system_type {
 287         struct super_block *(*read_super) (struct super_block *, void *);
 288         char *name;
 289         int requires_dev;
 290 };
 291 
 292 extern struct file_operations * chrdev_fops[MAX_CHRDEV];
 293 extern struct file_operations * blkdev_fops[MAX_BLKDEV];
 294 
 295 extern struct file_system_type *get_fs_type(char *name);
 296 
 297 extern int fs_may_mount(dev_t dev);
 298 extern int fs_may_umount(dev_t dev, struct inode * mount_root);
 299 
 300 extern struct file file_table[NR_FILE];
 301 extern struct super_block super_block[NR_SUPER];
 302 
 303 extern void grow_buffers(int size);
 304 extern int shrink_buffers(unsigned int priority);
 305 
 306 extern int nr_buffers;
 307 extern int buffermem;
 308 extern int nr_buffer_heads;
 309 
 310 extern void check_disk_change(dev_t dev);
 311 extern void invalidate_inodes(dev_t dev);
 312 extern void invalidate_buffers(dev_t dev);
 313 extern int floppy_change(struct buffer_head * first_block);
 314 extern int ticks_to_floppy_on(unsigned int dev);
 315 extern void floppy_on(unsigned int dev);
 316 extern void floppy_off(unsigned int dev);
 317 extern void sync_inodes(dev_t dev);
 318 extern void sync_dev(dev_t dev);
 319 extern void sync_supers(dev_t dev);
 320 extern int bmap(struct inode * inode,int block);
 321 extern int notify_change(struct inode * inode);
 322 extern int namei(const char * pathname, struct inode ** res_inode);
 323 extern int lnamei(const char * pathname, struct inode ** res_inode);
 324 extern int permission(struct inode * inode,int mask);
 325 extern int open_namei(const char * pathname, int flag, int mode,
 326         struct inode ** res_inode, struct inode * base);
 327 extern int do_mknod(const char * filename, int mode, dev_t dev);
 328 extern void iput(struct inode * inode);
 329 extern struct inode * iget(struct super_block * sb,int nr);
 330 extern struct inode * get_empty_inode(void);
 331 extern void clear_inode(struct inode *);
 332 extern struct inode * get_pipe_inode(void);
 333 extern struct file * get_empty_filp(void);
 334 extern struct buffer_head * get_hash_table(dev_t dev, int block, int size);
 335 extern struct buffer_head * getblk(dev_t dev, int block, int size);
 336 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
 337 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
 338 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
 339 extern void brelse(struct buffer_head * buf);
 340 extern struct buffer_head * bread(dev_t dev, int block, int size);
 341 extern void bread_page(unsigned long addr,dev_t dev,int b[4]);
 342 extern struct buffer_head * breada(dev_t dev,int block,...);
 343 extern void put_super(dev_t dev);
 344 extern dev_t ROOT_DEV;
 345 
 346 extern void mount_root(void);
 347 
 348 extern int char_read(struct inode *, struct file *, char *, int);
 349 extern int block_read(struct inode *, struct file *, char *, int);
 350 extern int read_ahead[];
 351 
 352 extern int char_write(struct inode *, struct file *, char *, int);
 353 extern int block_write(struct inode *, struct file *, char *, int);
 354 
 355 #endif

/* [previous][next][first][last][top][bottom][index][help] */