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     /* don't change - fd_set etc depend on this */
  25 
  26 #define NR_INODE 256    /* this should be bigger than NR_FILE */
  27 #define NR_FILE 128     /* this can well be larger on a larger system */
  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 extern unsigned long file_table_init(unsigned long start, unsigned long end);
  71 
  72 #define MAJOR(a) (((unsigned)(a))>>8)
  73 #define MINOR(a) ((a)&0xff)
  74 
  75 #ifndef NULL
  76 #define NULL ((void *) 0)
  77 #endif
  78 
  79 #define NIL_FILP        ((struct file *)0)
  80 #define SEL_IN          1
  81 #define SEL_OUT         2
  82 #define SEL_EX          4
  83 
  84 /*
  85  * These are the fs-independent mount-flags: up to 16 flags are supported
  86  */
  87 #define MS_RDONLY    1 /* mount read-only */
  88 #define MS_NOSUID    2 /* ignore suid and sgid bits */
  89 #define MS_NODEV     4 /* disallow access to device special files */
  90 #define MS_NOEXEC    8 /* disallow program execution */
  91 #define MS_SYNC     16 /* writes are synced at once */
  92 #define MS_REMOUNT  32 /* alter flags of a mounted FS */
  93 
  94 /*
  95  * Flags that can be altered by MS_REMOUNT
  96  */
  97 #define MS_RMT_MASK (MS_RDONLY)
  98 
  99 /*
 100  * Magic mount flag number. Has to be or-ed to the flag values.
 101  */
 102 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
 103 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
 104 
 105 /*
 106  * Note that read-only etc flags are inode-specific: setting some file-system
 107  * flags just means all the inodes inherit those flags by default. It might be
 108  * possible to overrride it sevelctively if you really wanted to with some
 109  * ioctl() that is not currently implemented.
 110  *
 111  * Exception: MS_RDONLY is always applied to the entire file system.
 112  */
 113 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
 114 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
 115 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
 116 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
 117 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC)
 118 
 119 /* the read-only stuff doesn't really belong here, but any other place is
 120    probably as bad and I don't want to create yet another include file. */
 121 
 122 #define BLKROSET 4701 /* set device read-only (0 = read-write) */
 123 #define BLKROGET 4702 /* get read-only status (0 = read_write) */
 124 #define BLKRRPART 4703 /* re-read partition table */
 125 #define BLKGETSIZE 4704 /* return device size */
 126 
 127 #define BMAP_IOCTL 1    /* obsolete - kept for compatibility */
 128 #define FIBMAP     1    /* bmap access */
 129 #define FIGETBSZ   2    /* get the block size used for bmap */
 130 
 131 /* these flags tell notify_change what is being changed */
 132 
 133 #define NOTIFY_SIZE     1
 134 #define NOTIFY_MODE     2
 135 #define NOTIFY_TIME     4
 136 #define NOTIFY_UIDGID   8
 137 
 138 typedef char buffer_block[BLOCK_SIZE];
 139 
 140 struct buffer_head {
 141         char * b_data;                  /* pointer to data block (1024 bytes) */
 142         unsigned long b_size;           /* block size */
 143         unsigned long b_blocknr;        /* block number */
 144         dev_t b_dev;                    /* device (0 = free) */
 145         unsigned short b_count;         /* users using this block */
 146         unsigned char b_uptodate;
 147         unsigned char b_dirt;           /* 0-clean,1-dirty */
 148         unsigned char b_lock;           /* 0 - ok, 1 -locked */
 149         struct wait_queue * b_wait;
 150         struct buffer_head * b_prev;            /* doubly linked list of hash-queue */
 151         struct buffer_head * b_next;
 152         struct buffer_head * b_prev_free;       /* doubly linked list of buffers */
 153         struct buffer_head * b_next_free;
 154         struct buffer_head * b_this_page;       /* circular list of buffers in one page */
 155         struct buffer_head * b_reqnext;         /* request queue */
 156 };
 157 
 158 #include <linux/pipe_fs_i.h>
 159 #include <linux/minix_fs_i.h>
 160 #include <linux/ext_fs_i.h>
 161 #include <linux/ext2_fs_i.h>
 162 #include <linux/msdos_fs_i.h>
 163 #include <linux/iso_fs_i.h>
 164 #include <linux/nfs_fs_i.h>
 165 #include <linux/xia_fs_i.h>
 166 
 167 struct inode {
 168         dev_t           i_dev;
 169         unsigned long   i_ino;
 170         umode_t         i_mode;
 171         nlink_t         i_nlink;
 172         uid_t           i_uid;
 173         gid_t           i_gid;
 174         dev_t           i_rdev;
 175         off_t           i_size;
 176         time_t          i_atime;
 177         time_t          i_mtime;
 178         time_t          i_ctime;
 179         unsigned long   i_blksize;
 180         unsigned long   i_blocks;
 181         struct inode_operations * i_op;
 182         struct super_block * i_sb;
 183         struct wait_queue * i_wait;
 184         struct file_lock * i_flock;
 185         struct vm_area_struct * i_mmap;
 186         struct inode * i_next, * i_prev;
 187         struct inode * i_hash_next, * i_hash_prev;
 188         struct inode * i_bound_to, * i_bound_by;
 189         unsigned short i_count;
 190         unsigned short i_flags;
 191         unsigned char i_lock;
 192         unsigned char i_dirt;
 193         unsigned char i_pipe;
 194         unsigned char i_mount;
 195         unsigned char i_seek;
 196         unsigned char i_update;
 197         union {
 198                 struct pipe_inode_info pipe_i;
 199                 struct minix_inode_info minix_i;
 200                 struct ext_inode_info ext_i;
 201                 struct ext2_inode_info ext2_i;
 202                 struct msdos_inode_info msdos_i;
 203                 struct iso_inode_info isofs_i;
 204                 struct nfs_inode_info nfs_i;
 205                 struct xiafs_inode_info xiafs_i;
 206         } u;
 207 };
 208 
 209 struct file {
 210         mode_t f_mode;
 211         dev_t f_rdev;                   /* needed for /dev/tty */
 212         off_t f_pos;
 213         unsigned short f_flags;
 214         unsigned short f_count;
 215         unsigned short f_reada;
 216         struct inode * f_inode;
 217         struct file_operations * f_op;
 218 };
 219 
 220 struct file_lock {
 221         struct file_lock *fl_next;      /* singly linked list */
 222         struct task_struct *fl_owner;   /* NULL if on free list, for sanity checks */
 223         struct wait_queue *fl_wait;
 224         char fl_type;
 225         char fl_whence;
 226         off_t fl_start;
 227         off_t fl_end;
 228 };
 229 
 230 #include <linux/minix_fs_sb.h>
 231 #include <linux/ext_fs_sb.h>
 232 #include <linux/ext2_fs_sb.h>
 233 #include <linux/msdos_fs_sb.h>
 234 #include <linux/iso_fs_sb.h>
 235 #include <linux/nfs_fs_sb.h>
 236 #include <linux/xia_fs_sb.h>
 237 
 238 struct super_block {
 239         dev_t s_dev;
 240         unsigned long s_blocksize;
 241         unsigned char s_lock;
 242         unsigned char s_rd_only;
 243         unsigned char s_dirt;
 244         struct super_operations *s_op;
 245         unsigned long s_flags;
 246         unsigned long s_magic;
 247         unsigned long s_time;
 248         struct inode * s_covered;
 249         struct inode * s_mounted;
 250         struct wait_queue * s_wait;
 251         union {
 252                 struct minix_sb_info minix_sb;
 253                 struct ext_sb_info ext_sb;
 254                 struct ext2_sb_info ext2_sb;
 255                 struct msdos_sb_info msdos_sb;
 256                 struct isofs_sb_info isofs_sb;
 257                 struct nfs_sb_info nfs_sb;
 258                 struct xiafs_sb_info xiafs_sb;
 259         } u;
 260 };
 261 
 262 struct file_operations {
 263         int (*lseek) (struct inode *, struct file *, off_t, int);
 264         int (*read) (struct inode *, struct file *, char *, int);
 265         int (*write) (struct inode *, struct file *, char *, int);
 266         int (*readdir) (struct inode *, struct file *, struct dirent *, int);
 267         int (*select) (struct inode *, struct file *, int, select_table *);
 268         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
 269         int (*mmap) (struct inode *, struct file *, unsigned long, size_t, int, unsigned long);
 270         int (*open) (struct inode *, struct file *);
 271         void (*release) (struct inode *, struct file *);
 272         int (*fsync) (struct inode *, struct file *);
 273 };
 274 
 275 struct inode_operations {
 276         struct file_operations * default_file_ops;
 277         int (*create) (struct inode *,const char *,int,int,struct inode **);
 278         int (*lookup) (struct inode *,const char *,int,struct inode **);
 279         int (*link) (struct inode *,struct inode *,const char *,int);
 280         int (*unlink) (struct inode *,const char *,int);
 281         int (*symlink) (struct inode *,const char *,int,const char *);
 282         int (*mkdir) (struct inode *,const char *,int,int);
 283         int (*rmdir) (struct inode *,const char *,int);
 284         int (*mknod) (struct inode *,const char *,int,int,int);
 285         int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
 286         int (*readlink) (struct inode *,char *,int);
 287         int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
 288         int (*bmap) (struct inode *,int);
 289         void (*truncate) (struct inode *);
 290         int (*permission) (struct inode *, int);
 291 };
 292 
 293 struct super_operations {
 294         void (*read_inode) (struct inode *);
 295         int (*notify_change) (int flags, struct inode *);
 296         void (*write_inode) (struct inode *);
 297         void (*put_inode) (struct inode *);
 298         void (*put_super) (struct super_block *);
 299         void (*write_super) (struct super_block *);
 300         void (*statfs) (struct super_block *, struct statfs *);
 301 };
 302 
 303 struct file_system_type {
 304         struct super_block *(*read_super) (struct super_block *, void *, int);
 305         char *name;
 306         int requires_dev;
 307 };
 308 
 309 extern int getname(const char * filename, char **result);
 310 extern void putname(char * name);
 311 
 312 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
 313 extern int blkdev_open(struct inode * inode, struct file * filp);
 314 extern struct file_operations def_blk_fops;
 315 extern struct inode_operations blkdev_inode_operations;
 316 
 317 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
 318 extern int chrdev_open(struct inode * inode, struct file * filp);
 319 extern struct file_operations def_chr_fops;
 320 extern struct inode_operations chrdev_inode_operations;
 321 
 322 extern void init_fifo(struct inode * inode);
 323 
 324 extern struct file_system_type *get_fs_type(char *name);
 325 
 326 extern int fs_may_mount(dev_t dev);
 327 extern int fs_may_umount(dev_t dev, struct inode * mount_root);
 328 
 329 extern struct file file_table[NR_FILE];
 330 extern struct super_block super_block[NR_SUPER];
 331 
 332 extern void grow_buffers(int size);
 333 extern int shrink_buffers(unsigned int priority);
 334 
 335 extern int nr_buffers;
 336 extern int buffermem;
 337 extern int nr_buffer_heads;
 338 
 339 extern void check_disk_change(dev_t dev);
 340 extern void invalidate_inodes(dev_t dev);
 341 extern void invalidate_buffers(dev_t dev);
 342 extern int floppy_change(struct buffer_head * first_block);
 343 extern int ticks_to_floppy_on(unsigned int dev);
 344 extern void floppy_on(unsigned int dev);
 345 extern void floppy_off(unsigned int dev);
 346 extern void sync_inodes(dev_t dev);
 347 extern void sync_dev(dev_t dev);
 348 extern void sync_supers(dev_t dev);
 349 extern int bmap(struct inode * inode,int block);
 350 extern int notify_change(int flags, struct inode * inode);
 351 extern int namei(const char * pathname, struct inode ** res_inode);
 352 extern int lnamei(const char * pathname, struct inode ** res_inode);
 353 extern int permission(struct inode * inode,int mask);
 354 extern int open_namei(const char * pathname, int flag, int mode,
 355         struct inode ** res_inode, struct inode * base);
 356 extern int do_mknod(const char * filename, int mode, dev_t dev);
 357 extern void iput(struct inode * inode);
 358 extern struct inode * iget(struct super_block * sb,int nr);
 359 extern struct inode * get_empty_inode(void);
 360 extern void clear_inode(struct inode *);
 361 extern struct inode * get_pipe_inode(void);
 362 extern struct file * get_empty_filp(void);
 363 extern struct buffer_head * get_hash_table(dev_t dev, int block, int size);
 364 extern struct buffer_head * getblk(dev_t dev, int block, int size);
 365 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
 366 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
 367 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
 368 extern void brelse(struct buffer_head * buf);
 369 extern struct buffer_head * bread(dev_t dev, int block, int size);
 370 extern unsigned long bread_page(unsigned long addr,dev_t dev,int b[],int size,int prot);
 371 extern struct buffer_head * breada(dev_t dev,int block,...);
 372 extern void put_super(dev_t dev);
 373 extern dev_t ROOT_DEV;
 374 
 375 extern void mount_root(void);
 376 
 377 extern int char_read(struct inode *, struct file *, char *, int);
 378 extern int block_read(struct inode *, struct file *, char *, int);
 379 extern int read_ahead[];
 380 
 381 extern int char_write(struct inode *, struct file *, char *, int);
 382 extern int block_write(struct inode *, struct file *, char *, int);
 383 
 384 #endif

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