root/include/linux/fs.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. mark_buffer_clean
  2. mark_buffer_dirty
  3. iget

   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/linkage.h>
  10 #include <linux/limits.h>
  11 #include <linux/wait.h>
  12 #include <linux/types.h>
  13 #include <linux/dirent.h>
  14 #include <linux/vfs.h>
  15 #include <linux/net.h>
  16 
  17 /*
  18  * It's silly to have NR_OPEN bigger than NR_FILE, but I'll fix
  19  * that later. Anyway, now the file code is no longer dependent
  20  * on bitmaps in unsigned longs, but uses the new fd_set structure..
  21  *
  22  * Some programs (notably those using select()) may have to be 
  23  * recompiled to take full advantage of the new limits..
  24  */
  25 #undef NR_OPEN
  26 #define NR_OPEN 256
  27 
  28 #define NR_INODE 2048   /* this should be bigger than NR_FILE */
  29 #define NR_FILE 1024    /* this can well be larger on a larger system */
  30 #define NR_SUPER 32
  31 #define NR_IHASH 131
  32 #define NR_FILE_LOCKS 64
  33 #define BLOCK_SIZE 1024
  34 #define BLOCK_SIZE_BITS 10
  35 
  36 #define MAY_EXEC 1
  37 #define MAY_WRITE 2
  38 #define MAY_READ 4
  39 
  40 #define READ 0
  41 #define WRITE 1
  42 #define READA 2         /* read-ahead - don't pause */
  43 #define WRITEA 3        /* "write-ahead" - silly, but somewhat useful */
  44 
  45 extern void buffer_init(void);
  46 extern unsigned long inode_init(unsigned long start, unsigned long end);
  47 extern unsigned long file_table_init(unsigned long start, unsigned long end);
  48 
  49 #define MAJOR(a) (int)((unsigned short)(a) >> 8)
  50 #define MINOR(a) (int)((unsigned short)(a) & 0xFF)
  51 #define MKDEV(a,b) ((int)((((a) & 0xff) << 8) | ((b) & 0xff)))
  52 #define NODEV MKDEV(0,0)
  53 
  54 #ifndef NULL
  55 #define NULL ((void *) 0)
  56 #endif
  57 
  58 #define NIL_FILP        ((struct file *)0)
  59 #define SEL_IN          1
  60 #define SEL_OUT         2
  61 #define SEL_EX          4
  62 
  63 /*
  64  * These are the fs-independent mount-flags: up to 16 flags are supported
  65  */
  66 #define MS_RDONLY    1 /* mount read-only */
  67 #define MS_NOSUID    2 /* ignore suid and sgid bits */
  68 #define MS_NODEV     4 /* disallow access to device special files */
  69 #define MS_NOEXEC    8 /* disallow program execution */
  70 #define MS_SYNC     16 /* writes are synced at once */
  71 #define MS_REMOUNT  32 /* alter flags of a mounted FS */
  72 
  73 /*
  74  * Flags that can be altered by MS_REMOUNT
  75  */
  76 #define MS_RMT_MASK (MS_RDONLY)
  77 
  78 /*
  79  * Magic mount flag number. Has to be or-ed to the flag values.
  80  */
  81 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
  82 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
  83 
  84 /*
  85  * Note that read-only etc flags are inode-specific: setting some file-system
  86  * flags just means all the inodes inherit those flags by default. It might be
  87  * possible to overrride it sevelctively if you really wanted to with some
  88  * ioctl() that is not currently implemented.
  89  *
  90  * Exception: MS_RDONLY is always applied to the entire file system.
  91  */
  92 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
  93 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
  94 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
  95 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
  96 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC)
  97 
  98 /* the read-only stuff doesn't really belong here, but any other place is
  99    probably as bad and I don't want to create yet another include file. */
 100 
 101 #define BLKROSET 4701 /* set device read-only (0 = read-write) */
 102 #define BLKROGET 4702 /* get read-only status (0 = read_write) */
 103 #define BLKRRPART 4703 /* re-read partition table */
 104 #define BLKGETSIZE 4704 /* return device size */
 105 #define BLKFLSBUF 4705 /* flush buffer cache */
 106 #define BLKRASET 4706 /* Set read ahead for block device */
 107 
 108 /* These are a few other constants  only used by scsi  devices */
 109 
 110 #define SCSI_IOCTL_GET_IDLUN 0x5382
 111 
 112 /* Used to turn on and off tagged queueing for scsi devices */
 113 
 114 #define SCSI_IOCTL_TAGGED_ENABLE 0x5383
 115 #define SCSI_IOCTL_TAGGED_DISABLE 0x5384
 116 
 117 
 118 #define BMAP_IOCTL 1    /* obsolete - kept for compatibility */
 119 #define FIBMAP     1    /* bmap access */
 120 #define FIGETBSZ   2    /* get the block size used for bmap */
 121 
 122 /* these flags tell notify_change what is being changed */
 123 
 124 #define NOTIFY_SIZE     1
 125 #define NOTIFY_MODE     2
 126 #define NOTIFY_TIME     4
 127 #define NOTIFY_UIDGID   8
 128 
 129 typedef char buffer_block[BLOCK_SIZE];
 130 
 131 struct buffer_head {
 132         char * b_data;                  /* pointer to data block (1024 bytes) */
 133         unsigned long b_size;           /* block size */
 134         unsigned long b_blocknr;        /* block number */
 135         dev_t b_dev;                    /* device (0 = free) */
 136         unsigned short b_count;         /* users using this block */
 137         unsigned char b_uptodate;
 138         unsigned char b_dirt;           /* 0-clean,1-dirty */
 139         unsigned char b_lock;           /* 0 - ok, 1 -locked */
 140         unsigned char b_req;            /* 0 if the buffer has been invalidated */
 141         unsigned char b_list;           /* List that this buffer appears */
 142         unsigned char b_retain;         /* Expected number of times this will
 143                                            be used.  Put on freelist when 0 */
 144         unsigned long b_flushtime;      /* Time when this (dirty) buffer should be written */
 145         unsigned long b_lru_time;       /* Time when this buffer was last used. */
 146         struct wait_queue * b_wait;
 147         struct buffer_head * b_prev;            /* doubly linked list of hash-queue */
 148         struct buffer_head * b_next;
 149         struct buffer_head * b_prev_free;       /* doubly linked list of buffers */
 150         struct buffer_head * b_next_free;
 151         struct buffer_head * b_this_page;       /* circular list of buffers in one page */
 152         struct buffer_head * b_reqnext;         /* request queue */
 153 };
 154 
 155 #include <linux/pipe_fs_i.h>
 156 #include <linux/minix_fs_i.h>
 157 #include <linux/ext_fs_i.h>
 158 #include <linux/ext2_fs_i.h>
 159 #include <linux/hpfs_fs_i.h>
 160 #include <linux/msdos_fs_i.h>
 161 #include <linux/iso_fs_i.h>
 162 #include <linux/nfs_fs_i.h>
 163 #include <linux/xia_fs_i.h>
 164 #include <linux/sysv_fs_i.h>
 165 
 166 struct inode {
 167         dev_t           i_dev;
 168         unsigned long   i_ino;
 169         umode_t         i_mode;
 170         nlink_t         i_nlink;
 171         uid_t           i_uid;
 172         gid_t           i_gid;
 173         dev_t           i_rdev;
 174         off_t           i_size;
 175         time_t          i_atime;
 176         time_t          i_mtime;
 177         time_t          i_ctime;
 178         unsigned long   i_blksize;
 179         unsigned long   i_blocks;
 180         unsigned long   i_version;
 181         struct semaphore i_sem;
 182         struct inode_operations * i_op;
 183         struct super_block * i_sb;
 184         struct wait_queue * i_wait;
 185         struct file_lock * i_flock;
 186         struct vm_area_struct * i_mmap;
 187         struct inode * i_next, * i_prev;
 188         struct inode * i_hash_next, * i_hash_prev;
 189         struct inode * i_bound_to, * i_bound_by;
 190         struct inode * i_mount;
 191         struct socket * i_socket;
 192         unsigned short i_count;
 193         unsigned short i_flags;
 194         unsigned char i_lock;
 195         unsigned char i_dirt;
 196         unsigned char i_pipe;
 197         unsigned char i_seek;
 198         unsigned char i_update;
 199         union {
 200                 struct pipe_inode_info pipe_i;
 201                 struct minix_inode_info minix_i;
 202                 struct ext_inode_info ext_i;
 203                 struct ext2_inode_info ext2_i;
 204                 struct hpfs_inode_info hpfs_i;
 205                 struct msdos_inode_info msdos_i;
 206                 struct iso_inode_info isofs_i;
 207                 struct nfs_inode_info nfs_i;
 208                 struct xiafs_inode_info xiafs_i;
 209                 struct sysv_inode_info sysv_i;
 210                 void * generic_ip;
 211         } u;
 212 };
 213 
 214 struct file {
 215         mode_t f_mode;
 216         off_t f_pos;
 217         unsigned short f_flags;
 218         unsigned short f_count;
 219         off_t f_reada;
 220         struct file *f_next, *f_prev;
 221         int f_owner;            /* pid or -pgrp where SIGIO should be sent */
 222         struct inode * f_inode;
 223         struct file_operations * f_op;
 224         void *private_data;     /* needed for tty driver, and maybe others */
 225 };
 226 
 227 struct file_lock {
 228         struct file_lock *fl_next;      /* singly linked list */
 229         struct task_struct *fl_owner;   /* NULL if on free list, for sanity checks */
 230         unsigned int fl_fd;             /* File descriptor for this lock */
 231         struct wait_queue *fl_wait;
 232         char fl_type;
 233         char fl_whence;
 234         off_t fl_start;
 235         off_t fl_end;
 236 };
 237 
 238 struct fasync_struct {
 239         int    magic;
 240         struct fasync_struct    *fa_next; /* singly linked list */
 241         struct file             *fa_file;
 242 };
 243 
 244 #define FASYNC_MAGIC 0x4601
 245 
 246 #include <linux/minix_fs_sb.h>
 247 #include <linux/ext_fs_sb.h>
 248 #include <linux/ext2_fs_sb.h>
 249 #include <linux/hpfs_fs_sb.h>
 250 #include <linux/msdos_fs_sb.h>
 251 #include <linux/iso_fs_sb.h>
 252 #include <linux/nfs_fs_sb.h>
 253 #include <linux/xia_fs_sb.h>
 254 #include <linux/sysv_fs_sb.h>
 255 
 256 struct super_block {
 257         dev_t s_dev;
 258         unsigned long s_blocksize;
 259         unsigned char s_blocksize_bits;
 260         unsigned char s_lock;
 261         unsigned char s_rd_only;
 262         unsigned char s_dirt;
 263         struct super_operations *s_op;
 264         unsigned long s_flags;
 265         unsigned long s_magic;
 266         unsigned long s_time;
 267         struct inode * s_covered;
 268         struct inode * s_mounted;
 269         struct wait_queue * s_wait;
 270         union {
 271                 struct minix_sb_info minix_sb;
 272                 struct ext_sb_info ext_sb;
 273                 struct ext2_sb_info ext2_sb;
 274                 struct hpfs_sb_info hpfs_sb;
 275                 struct msdos_sb_info msdos_sb;
 276                 struct isofs_sb_info isofs_sb;
 277                 struct nfs_sb_info nfs_sb;
 278                 struct xiafs_sb_info xiafs_sb;
 279                 struct sysv_sb_info sysv_sb;
 280                 void *generic_sbp;
 281         } u;
 282 };
 283 
 284 struct file_operations {
 285         int (*lseek) (struct inode *, struct file *, off_t, int);
 286         int (*read) (struct inode *, struct file *, char *, int);
 287         int (*write) (struct inode *, struct file *, char *, int);
 288         int (*readdir) (struct inode *, struct file *, struct dirent *, int);
 289         int (*select) (struct inode *, struct file *, int, select_table *);
 290         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
 291         int (*mmap) (struct inode *, struct file *, unsigned long, size_t, int, unsigned long);
 292         int (*open) (struct inode *, struct file *);
 293         void (*release) (struct inode *, struct file *);
 294         int (*fsync) (struct inode *, struct file *);
 295         int (*fasync) (struct inode *, struct file *, int);
 296         int (*check_media_change) (dev_t dev);
 297         int (*revalidate) (dev_t dev);
 298 };
 299 
 300 struct inode_operations {
 301         struct file_operations * default_file_ops;
 302         int (*create) (struct inode *,const char *,int,int,struct inode **);
 303         int (*lookup) (struct inode *,const char *,int,struct inode **);
 304         int (*link) (struct inode *,struct inode *,const char *,int);
 305         int (*unlink) (struct inode *,const char *,int);
 306         int (*symlink) (struct inode *,const char *,int,const char *);
 307         int (*mkdir) (struct inode *,const char *,int,int);
 308         int (*rmdir) (struct inode *,const char *,int);
 309         int (*mknod) (struct inode *,const char *,int,int,int);
 310         int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int);
 311         int (*readlink) (struct inode *,char *,int);
 312         int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **);
 313         int (*bmap) (struct inode *,int);
 314         void (*truncate) (struct inode *);
 315         int (*permission) (struct inode *, int);
 316 };
 317 
 318 struct super_operations {
 319         void (*read_inode) (struct inode *);
 320         int (*notify_change) (int flags, struct inode *);
 321         void (*write_inode) (struct inode *);
 322         void (*put_inode) (struct inode *);
 323         void (*put_super) (struct super_block *);
 324         void (*write_super) (struct super_block *);
 325         void (*statfs) (struct super_block *, struct statfs *);
 326         int (*remount_fs) (struct super_block *, int *, char *);
 327 };
 328 
 329 struct file_system_type {
 330         struct super_block *(*read_super) (struct super_block *, void *, int);
 331         char *name;
 332         int requires_dev;
 333         struct file_system_type * next;
 334 };
 335 
 336 #ifdef __KERNEL__
 337 
 338 extern int register_filesystem(struct file_system_type *);
 339 extern int unregister_filesystem(struct file_system_type *);
 340 
 341 asmlinkage int sys_open(const char *, int, int);
 342 asmlinkage int sys_close(unsigned int);         /* yes, it's really unsigned */
 343 
 344 extern void kill_fasync(struct fasync_struct *fa, int sig);
 345 
 346 extern int getname(const char * filename, char **result);
 347 extern void putname(char * name);
 348 
 349 extern int register_blkdev(unsigned int, const char *, struct file_operations *);
 350 extern int unregister_blkdev(unsigned int major, const char * name);
 351 extern int blkdev_open(struct inode * inode, struct file * filp);
 352 extern struct file_operations def_blk_fops;
 353 extern struct inode_operations blkdev_inode_operations;
 354 
 355 extern int register_chrdev(unsigned int, const char *, struct file_operations *);
 356 extern int unregister_chrdev(unsigned int major, const char * name);
 357 extern int chrdev_open(struct inode * inode, struct file * filp);
 358 extern struct file_operations def_chr_fops;
 359 extern struct inode_operations chrdev_inode_operations;
 360 
 361 extern void init_fifo(struct inode * inode);
 362 
 363 extern struct file_operations connecting_fifo_fops;
 364 extern struct file_operations read_fifo_fops;
 365 extern struct file_operations write_fifo_fops;
 366 extern struct file_operations rdwr_fifo_fops;
 367 extern struct file_operations read_pipe_fops;
 368 extern struct file_operations write_pipe_fops;
 369 extern struct file_operations rdwr_pipe_fops;
 370 
 371 extern struct file_system_type *get_fs_type(char *name);
 372 
 373 extern int fs_may_mount(dev_t dev);
 374 extern int fs_may_umount(dev_t dev, struct inode * mount_root);
 375 extern int fs_may_remount_ro(dev_t dev);
 376 
 377 extern struct file *first_file;
 378 extern int nr_files;
 379 extern struct super_block super_blocks[NR_SUPER];
 380 
 381 extern int shrink_buffers(unsigned int priority);
 382 extern void refile_buffer(struct buffer_head * buf);
 383 extern void set_writetime(struct buffer_head * buf, int flag);
 384 extern void refill_freelist(int size);
 385 
 386 extern struct buffer_head ** buffer_pages;
 387 extern int nr_buffers;
 388 extern int buffermem;
 389 extern int nr_buffer_heads;
 390 
 391 #define BUF_CLEAN 0
 392 #define BUF_UNSHARED 1 /* Buffers that were shared but are not any more */
 393 #define BUF_LOCKED 2   /* Buffers scheduled for write */
 394 #define BUF_LOCKED1 3  /* Supers, inodes */
 395 #define BUF_DIRTY 4    /* Dirty buffers, not yet scheduled for write */
 396 #define BUF_SHARED 5   /* Buffers shared */
 397 #define NR_LIST 6
 398 
 399 extern inline void mark_buffer_clean(struct buffer_head * bh)
     /* [previous][next][first][last][top][bottom][index][help] */
 400 {
 401   if(bh->b_dirt) {
 402     bh->b_dirt = 0;
 403     if(bh->b_list == BUF_DIRTY) refile_buffer(bh);
 404   }
 405 }
 406 
 407 extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag)
     /* [previous][next][first][last][top][bottom][index][help] */
 408 {
 409   if(!bh->b_dirt) {
 410     bh->b_dirt = 1;
 411     set_writetime(bh, flag);
 412     if(bh->b_list != BUF_DIRTY) refile_buffer(bh);
 413   }
 414 }
 415 
 416 
 417 extern int check_disk_change(dev_t dev);
 418 extern void invalidate_inodes(dev_t dev);
 419 extern void invalidate_buffers(dev_t dev);
 420 extern void sync_inodes(dev_t dev);
 421 extern void sync_dev(dev_t dev);
 422 extern int fsync_dev(dev_t dev);
 423 extern void sync_supers(dev_t dev);
 424 extern int bmap(struct inode * inode,int block);
 425 extern int notify_change(int flags, struct inode * inode);
 426 extern int namei(const char * pathname, struct inode ** res_inode);
 427 extern int lnamei(const char * pathname, struct inode ** res_inode);
 428 extern int permission(struct inode * inode,int mask);
 429 extern int open_namei(const char * pathname, int flag, int mode,
 430         struct inode ** res_inode, struct inode * base);
 431 extern int do_mknod(const char * filename, int mode, dev_t dev);
 432 extern void iput(struct inode * inode);
 433 extern struct inode * __iget(struct super_block * sb,int nr,int crsmnt);
 434 extern struct inode * get_empty_inode(void);
 435 extern void insert_inode_hash(struct inode *);
 436 extern void clear_inode(struct inode *);
 437 extern struct inode * get_pipe_inode(void);
 438 extern struct file * get_empty_filp(void);
 439 extern struct buffer_head * get_hash_table(dev_t dev, int block, int size);
 440 extern struct buffer_head * getblk(dev_t dev, int block, int size);
 441 extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]);
 442 extern void ll_rw_page(int rw, int dev, int nr, char * buffer);
 443 extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer);
 444 extern void brelse(struct buffer_head * buf);
 445 extern void set_blocksize(dev_t dev, int size);
 446 extern struct buffer_head * bread(dev_t dev, int block, int size);
 447 extern unsigned long bread_page(unsigned long addr,dev_t dev,int b[],int size,int no_share);
 448 extern struct buffer_head * breada(dev_t dev,int block, int size, 
 449                                    unsigned int pos, unsigned int filesize);
 450 extern void put_super(dev_t dev);
 451 unsigned long generate_cluster(dev_t dev, int b[], int size);
 452 extern dev_t ROOT_DEV;
 453 
 454 extern void show_buffers(void);
 455 extern void mount_root(void);
 456 
 457 extern int char_read(struct inode *, struct file *, char *, int);
 458 extern int block_read(struct inode *, struct file *, char *, int);
 459 extern int read_ahead[];
 460 
 461 extern int char_write(struct inode *, struct file *, char *, int);
 462 extern int block_write(struct inode *, struct file *, char *, int);
 463 
 464 extern int generic_mmap(struct inode *, struct file *, unsigned long, size_t, int, unsigned long);
 465 
 466 extern int block_fsync(struct inode *, struct file *);
 467 extern int file_fsync(struct inode *, struct file *);
 468 
 469 extern inline struct inode * iget(struct super_block * sb,int nr)
     /* [previous][next][first][last][top][bottom][index][help] */
 470 {
 471         return __iget(sb,nr,1);
 472 }
 473 
 474 #endif /* __KERNEL__ */
 475 
 476 #endif

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