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 - unused (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 - unnamed pipes
  26  * 8 - /dev/sd
  27  * 9 - /dev/st
  28  */
  29 
  30 #define IS_SEEKABLE(x) ((x)>=1 && (x)<=3 || (x)==8)
  31 
  32 #define MAY_EXEC 1
  33 #define MAY_WRITE 2
  34 #define MAY_READ 4
  35 
  36 #define READ 0
  37 #define WRITE 1
  38 #define READA 2         /* read-ahead - don't pause */
  39 #define WRITEA 3        /* "write-ahead" - silly, but somewhat useful */
  40 
  41 extern void buffer_init(void);
  42 
  43 #define MAJOR(a) (((unsigned)(a))>>8)
  44 #define MINOR(a) ((a)&0xff)
  45 
  46 #ifndef NULL
  47 #define NULL ((void *) 0)
  48 #endif
  49 
  50 #define PIPE_READ_WAIT(inode) ((inode).i_wait)
  51 #define PIPE_WRITE_WAIT(inode) ((inode).i_wait2)
  52 #define PIPE_HEAD(inode) ((inode).i_data[0])
  53 #define PIPE_TAIL(inode) ((inode).i_data[1])
  54 #define PIPE_READERS(inode) ((inode).i_data[2])
  55 #define PIPE_WRITERS(inode) ((inode).i_data[3])
  56 #define PIPE_SIZE(inode) ((PIPE_HEAD(inode)-PIPE_TAIL(inode))&(PAGE_SIZE-1))
  57 #define PIPE_EMPTY(inode) (PIPE_HEAD(inode)==PIPE_TAIL(inode))
  58 #define PIPE_FULL(inode) (PIPE_SIZE(inode)==(PAGE_SIZE-1))
  59 
  60 #define NIL_FILP        ((struct file *)0)
  61 #define SEL_IN          1
  62 #define SEL_OUT         2
  63 #define SEL_EX          4
  64 
  65 /*
  66  * These are the fs-independent mount-flags: up to 16 flags are supported
  67  */
  68 #define MS_RDONLY    1 /* mount read-only */
  69 #define MS_NOSUID    2 /* ignore suid and sgid bits */
  70 #define MS_NODEV     4 /* disallow access to device special files */
  71 #define MS_NOEXEC    8 /* disallow program execution */
  72 #define MS_SYNC     16 /* writes are synced at once */
  73 
  74 /*
  75  * Note that read-only etc flags are inode-specific: setting some file-system
  76  * flags just means all the inodes inherit those flags by default. It might be
  77  * possible to overrride it sevelctively if you really wanted to with some
  78  * ioctl() that is not currently implemented.
  79  */
  80 #define IS_RDONLY(inode) ((inode)->i_flags & MS_RDONLY)
  81 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
  82 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
  83 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
  84 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC)
  85 
  86 /* the read-only stuff doesn't really belong here, but any other place is
  87    probably as bad and I don't want to create yet another include file. */
  88 
  89 #define BLKROSET 4701 /* set device read-only (0 = read-write) */
  90 #define BLKROGET 4702 /* get read-only status (0 = read_write) */
  91 
  92 #define BMAP_IOCTL 1
  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         unsigned short 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 struct inode {
 115         dev_t           i_dev;
 116         unsigned long   i_ino;
 117         umode_t         i_mode;
 118         nlink_t         i_nlink;
 119         uid_t           i_uid;
 120         gid_t           i_gid;
 121         dev_t           i_rdev;
 122         off_t           i_size;
 123         time_t          i_atime;
 124         time_t          i_mtime;
 125         time_t          i_ctime;
 126         unsigned long i_data[16];
 127         struct inode_operations * i_op;
 128         struct super_block * i_sb;
 129         struct wait_queue * i_wait;
 130         struct wait_queue * i_wait2;    /* for pipes */
 131         unsigned short i_count;
 132         unsigned short i_flags;
 133         unsigned char i_lock;
 134         unsigned char i_dirt;
 135         unsigned char i_pipe;
 136         unsigned char i_mount;
 137         unsigned char i_seek;
 138         unsigned char i_update;
 139 };
 140 
 141 struct file {
 142         unsigned short f_mode;
 143         unsigned short f_flags;
 144         unsigned short f_count;
 145         unsigned short f_reada;
 146         unsigned short f_rdev;          /* needed for /dev/tty */
 147         struct inode * f_inode;
 148         struct file_operations * f_op;
 149         off_t f_pos;
 150 };
 151 
 152 #include <linux/minix_fs_sb.h>
 153 #include <linux/ext_fs_sb.h>
 154 #include <linux/msdos_fs_sb.h>
 155 
 156 struct super_block {
 157         unsigned short s_dev;
 158         unsigned long s_blocksize;
 159         unsigned char s_lock;
 160         unsigned char s_rd_only;
 161         unsigned char s_dirt;
 162         struct super_operations *s_op;
 163         unsigned long s_flags;
 164         unsigned long s_magic;
 165         unsigned long s_time;
 166         struct inode * s_covered;
 167         struct inode * s_mounted;
 168         struct wait_queue * s_wait;
 169         union {
 170                 struct minix_sb_info minix_sb;
 171                 struct ext_sb_info ext_sb;
 172                 struct msdos_sb_info msdos_sb;
 173         } u;
 174 };
 175 
 176 struct file_operations {
 177         int (*lseek) (struct inode *, struct file *, off_t, int);
 178         int (*read) (struct inode *, struct file *, char *, int);
 179         int (*write) (struct inode *, struct file *, char *, int);
 180         int (*readdir) (struct inode *, struct file *, struct dirent *, int count);
 181         int (*select) (struct inode *, struct file *, int, select_table *);
 182         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned int);
 183         int (*open) (struct inode *, struct file *);
 184         void (*release) (struct inode *, struct file *);
 185 };
 186 
 187 struct inode_operations {
 188         struct file_operations * default_file_ops;
 189         int (*create) (struct inode *,const char *,int,int,struct inode **);
 190         int (*lookup) (struct inode *,const char *,int,struct inode **);
 191         int (*link) (struct inode *,struct inode *,const char *,int);
 192         int (*unlink) (struct inode *,const char *,int);
 193         int (*symlink) (struct inode *,const char *,int,const char *);
 194         int (*mkdir) (struct inode *,const char *,int,int);
 195         int (*rmdir) (struct inode *,const char *,int);
 196         int (*mknod) (struct inode *,const char *,int,int,int);
 197         int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
 198         int (*readlink) (struct inode *,char *,int);
 199         struct inode * (*follow_link) (struct inode *, struct inode *);
 200         int (*bmap) (struct inode *,int);
 201         void (*truncate) (struct inode *);
 202 };
 203 
 204 struct super_operations {
 205         void (*read_inode)(struct inode *inode);
 206         void (*write_inode) (struct inode *inode);
 207         void (*put_inode) (struct inode *inode);
 208         void (*put_super)(struct super_block *sb);
 209         void (*write_super) (struct super_block *sb);
 210         void (*statfs) (struct super_block *sb, struct statfs *buf);
 211 };
 212 
 213 struct file_system_type {
 214         struct super_block *(*read_super)(struct super_block *sb,void *mode);
 215         char *name;
 216 };
 217 
 218 extern struct file_operations * chrdev_fops[MAX_CHRDEV];
 219 extern struct file_operations * blkdev_fops[MAX_BLKDEV];
 220 
 221 extern struct file_system_type *get_fs_type(char *name);
 222 
 223 extern struct inode inode_table[NR_INODE];
 224 extern struct file file_table[NR_FILE];
 225 extern struct super_block super_block[NR_SUPER];
 226 
 227 extern void grow_buffers(int size);
 228 extern int shrink_buffers(void);
 229 
 230 extern int nr_buffers;
 231 extern int nr_buffer_heads;
 232 
 233 extern void check_disk_change(int dev);
 234 extern void invalidate_inodes(int dev);
 235 extern int floppy_change(struct buffer_head * first_block);
 236 extern int ticks_to_floppy_on(unsigned int dev);
 237 extern void floppy_on(unsigned int dev);
 238 extern void floppy_off(unsigned int dev);
 239 extern void sync_inodes(void);
 240 extern void wait_on(struct inode * inode);
 241 extern int bmap(struct inode * inode,int block);
 242 extern struct inode * namei(const char * pathname);
 243 extern struct inode * lnamei(const char * pathname);
 244 extern int permission(struct inode * inode,int mask);
 245 extern struct inode * _namei(const char * filename, struct inode * base,
 246         int follow_links);
 247 extern int open_namei(const char * pathname, int flag, int mode,
 248         struct inode ** res_inode);
 249 extern int do_mknod(const char * filename, int mode, int dev);
 250 extern void iput(struct inode * inode);
 251 extern struct inode * iget(int dev,int nr);
 252 extern struct inode * get_empty_inode(void);
 253 extern struct inode * get_pipe_inode(void);
 254 extern struct file * get_empty_filp(void);
 255 extern struct buffer_head * get_hash_table(int dev, int block, int size);
 256 extern struct buffer_head * getblk(int dev, int block, int size);
 257 extern void ll_rw_block(int rw, struct buffer_head * bh);
 258 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
 259 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
 260 extern void brelse(struct buffer_head * buf);
 261 extern struct buffer_head * bread(int dev, int block, int size);
 262 extern void bread_page(unsigned long addr,int dev,int b[4]);
 263 extern struct buffer_head * breada(int dev,int block,...);
 264 extern int sync_dev(int dev);
 265 extern struct super_block * get_super(int dev);
 266 extern void put_super(int dev);
 267 extern int ROOT_DEV;
 268 
 269 extern void mount_root(void);
 270 extern void lock_super(struct super_block * sb);
 271 extern void free_super(struct super_block * sb);
 272 
 273 extern int char_read(struct inode *, struct file *, char *, int);
 274 extern int block_read(struct inode *, struct file *, char *, int);
 275 
 276 extern int char_write(struct inode *, struct file *, char *, int);
 277 extern int block_write(struct inode *, struct file *, char *, int);
 278 
 279 #endif

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