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

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