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

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