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

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