root/include/linux/fs.h

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

INCLUDED FROM


   1 /*
   2  * This file has definitions for some important file table
   3  * structures etc.
   4  */
   5 
   6 #ifndef _FS_H
   7 #define _FS_H
   8 
   9 #include <sys/types.h>
  10 #include <sys/dirent.h>
  11 
  12 /* devices are as follows: (same as minix, so we can use the minix
  13  * file system. These are major numbers.)
  14  *
  15  * 0 - unused (nodev)
  16  * 1 - /dev/mem
  17  * 2 - /dev/fd
  18  * 3 - /dev/hd
  19  * 4 - /dev/ttyx
  20  * 5 - /dev/tty
  21  * 6 - /dev/lp
  22  * 7 - unnamed pipes
  23  */
  24 
  25 #define IS_SEEKABLE(x) ((x)>=1 && (x)<=3)
  26 
  27 #define MAY_EXEC 1
  28 #define MAY_WRITE 2
  29 #define MAY_READ 4
  30 
  31 #define READ 0
  32 #define WRITE 1
  33 #define READA 2         /* read-ahead - don't pause */
  34 #define WRITEA 3        /* "write-ahead" - silly, but somewhat useful */
  35 
  36 void buffer_init(long buffer_end);
  37 
  38 #define MAJOR(a) (((unsigned)(a))>>8)
  39 #define MINOR(a) ((a)&0xff)
  40 
  41 #define NR_OPEN 20
  42 #define NR_INODE 128
  43 #define NR_FILE 64
  44 #define NR_SUPER 8
  45 #define NR_HASH 307
  46 #define NR_BUFFERS nr_buffers
  47 #define BLOCK_SIZE 1024
  48 #define BLOCK_SIZE_BITS 10
  49 #ifndef NULL
  50 #define NULL ((void *) 0)
  51 #endif
  52 
  53 #define PIPE_READ_WAIT(inode) ((inode).i_wait)
  54 #define PIPE_WRITE_WAIT(inode) ((inode).i_wait2)
  55 #define PIPE_HEAD(inode) ((inode).i_data[0])
  56 #define PIPE_TAIL(inode) ((inode).i_data[1])
  57 #define PIPE_SIZE(inode) ((PIPE_HEAD(inode)-PIPE_TAIL(inode))&(PAGE_SIZE-1))
  58 #define PIPE_EMPTY(inode) (PIPE_HEAD(inode)==PIPE_TAIL(inode))
  59 #define PIPE_FULL(inode) (PIPE_SIZE(inode)==(PAGE_SIZE-1))
  60 
  61 #define NIL_FILP        ((struct file *)0)
  62 #define SEL_IN          1
  63 #define SEL_OUT         2
  64 #define SEL_EX          4
  65 
  66 typedef char buffer_block[BLOCK_SIZE];
  67 
  68 struct buffer_head {
  69         char * b_data;                  /* pointer to data block (1024 bytes) */
  70         unsigned long b_blocknr;        /* block number */
  71         unsigned short b_dev;           /* device (0 = free) */
  72         unsigned char b_uptodate;
  73         unsigned char b_dirt;           /* 0-clean,1-dirty */
  74         unsigned char b_count;          /* users using this block */
  75         unsigned char b_lock;           /* 0 - ok, 1 -locked */
  76         struct task_struct * b_wait;
  77         struct buffer_head * b_prev;
  78         struct buffer_head * b_next;
  79         struct buffer_head * b_prev_free;
  80         struct buffer_head * b_next_free;
  81 };
  82 
  83 struct inode {
  84         dev_t   i_dev;
  85         ino_t   i_ino;
  86         umode_t i_mode;
  87         nlink_t i_nlink;
  88         uid_t   i_uid;
  89         gid_t   i_gid;
  90         dev_t   i_rdev;
  91         off_t   i_size;
  92         time_t  i_atime;
  93         time_t  i_mtime;
  94         time_t  i_ctime;
  95         unsigned long i_data[16];
  96         struct inode_operations * i_op;
  97         struct super_block * i_sb;
  98         struct task_struct * i_wait;
  99         struct task_struct * i_wait2;   /* for pipes */
 100         unsigned short i_count;
 101         unsigned char i_lock;
 102         unsigned char i_dirt;
 103         unsigned char i_pipe;
 104         unsigned char i_mount;
 105         unsigned char i_seek;
 106         unsigned char i_update;
 107 };
 108 
 109 struct file {
 110         unsigned short f_mode;
 111         unsigned short f_flags;
 112         unsigned short f_count;
 113         struct inode * f_inode;
 114         struct file_operations * f_op;
 115         off_t f_pos;
 116 };
 117 
 118 struct super_block {
 119         unsigned short s_ninodes;
 120         unsigned short s_nzones;
 121         unsigned short s_imap_blocks;
 122         unsigned short s_zmap_blocks;
 123         unsigned short s_firstdatazone;
 124         unsigned short s_log_zone_size;
 125         unsigned long s_max_size;
 126         unsigned short s_magic;
 127 /* These are only in memory */
 128         struct buffer_head * s_imap[8];
 129         struct buffer_head * s_zmap[8];
 130         unsigned short s_dev;
 131         struct inode * s_covered;
 132         struct inode * s_mounted;
 133         unsigned long s_time;
 134         struct task_struct * s_wait;
 135         unsigned char s_lock;
 136         unsigned char s_rd_only;
 137         unsigned char s_dirt;
 138         /* TUBE */
 139         struct super_operations *s_op;
 140 };
 141 
 142 struct file_operations {
 143         int (*lseek) (struct inode *, struct file *, off_t, int);
 144         int (*read) (struct inode *, struct file *, char *, int);
 145         int (*write) (struct inode *, struct file *, char *, int);
 146         int (*readdir) (struct inode *, struct file *, struct dirent *);
 147 };
 148 
 149 struct inode_operations {
 150         int (*create) (struct inode *,const char *,int,int,struct inode **);
 151         int (*lookup) (struct inode *,const char *,int,struct inode **);
 152         int (*link) (struct inode *,struct inode *,const char *,int);
 153         int (*unlink) (struct inode *,const char *,int);
 154         int (*symlink) (struct inode *,const char *,int,const char *);
 155         int (*mkdir) (struct inode *,const char *,int,int);
 156         int (*rmdir) (struct inode *,const char *,int);
 157         int (*mknod) (struct inode *,const char *,int,int,int);
 158         int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
 159         int (*readlink) (struct inode *,char *,int);
 160         int (*open) (struct inode *, struct file *);
 161         void (*release) (struct inode *, struct file *);
 162         struct inode * (*follow_link) (struct inode *, struct inode *);
 163         int (*bmap) (struct inode *,int);
 164         void (*truncate) (struct inode *);
 165         /* added by entropy */
 166         void (*write_inode)(struct inode *inode);
 167         void (*put_inode)(struct inode *inode);
 168 };
 169 
 170 struct super_operations {
 171         void (*read_inode)(struct inode *inode);
 172         void (*put_super)(struct super_block *sb);
 173 };
 174 
 175 struct file_system_type {
 176         struct super_block *(*read_super)(struct super_block *sb,void *mode);
 177         char *name;
 178 };
 179 
 180 extern struct file_system_type *get_fs_type(char *name);
 181 
 182 extern struct inode inode_table[NR_INODE];
 183 extern struct file file_table[NR_FILE];
 184 extern struct super_block super_block[NR_SUPER];
 185 extern struct buffer_head * start_buffer;
 186 extern int nr_buffers;
 187 
 188 extern void check_disk_change(int dev);
 189 extern int floppy_change(struct buffer_head * first_block);
 190 extern int ticks_to_floppy_on(unsigned int dev);
 191 extern void floppy_on(unsigned int dev);
 192 extern void floppy_off(unsigned int dev);
 193 extern void truncate(struct inode * inode);
 194 extern void sync_inodes(void);
 195 extern void wait_on(struct inode * inode);
 196 extern int bmap(struct inode * inode,int block);
 197 extern struct inode * namei(const char * pathname);
 198 extern struct inode * lnamei(const char * pathname);
 199 extern int permission(struct inode * inode,int mask);
 200 extern struct inode * _namei(const char * filename, struct inode * base,
 201         int follow_links);
 202 extern int open_namei(const char * pathname, int flag, int mode,
 203         struct inode ** res_inode);
 204 extern void iput(struct inode * inode);
 205 extern struct inode * iget(int dev,int nr);
 206 extern struct inode * get_empty_inode(void);
 207 extern struct inode * get_pipe_inode(void);
 208 extern struct buffer_head * get_hash_table(int dev, int block);
 209 extern struct buffer_head * getblk(int dev, int block);
 210 extern void ll_rw_block(int rw, struct buffer_head * bh);
 211 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
 212 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
 213 extern void brelse(struct buffer_head * buf);
 214 extern struct buffer_head * bread(int dev,int block);
 215 extern void bread_page(unsigned long addr,int dev,int b[4]);
 216 extern struct buffer_head * breada(int dev,int block,...);
 217 extern int sync_dev(int dev);
 218 extern struct super_block * get_super(int dev);
 219 extern int ROOT_DEV;
 220 
 221 extern void mount_root(void);
 222 extern void lock_super(struct super_block * sb);
 223 extern void free_super(struct super_block * sb);
 224 
 225 extern int pipe_read(struct inode *, struct file *, char *, int);
 226 extern int char_read(struct inode *, struct file *, char *, int);
 227 extern int block_read(struct inode *, struct file *, char *, int);
 228 
 229 extern int pipe_write(struct inode *, struct file *, char *, int);
 230 extern int char_write(struct inode *, struct file *, char *, int);
 231 extern int block_write(struct inode *, struct file *, char *, int);
 232 
 233 #endif

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