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

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