linux-bk/include/linux/fs.h
<<
>>
Prefs
   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/config.h>
  10#include <linux/linkage.h>
  11#include <linux/limits.h>
  12#include <linux/wait.h>
  13#include <linux/types.h>
  14#include <linux/vfs.h>
  15#include <linux/net.h>
  16#include <linux/kdev_t.h>
  17#include <linux/ioctl.h>
  18#include <linux/list.h>
  19#include <linux/dcache.h>
  20#include <linux/stat.h>
  21#include <linux/cache.h>
  22#include <linux/stddef.h>
  23#include <linux/string.h>
  24#include <linux/radix-tree.h>
  25#include <linux/bitops.h>
  26
  27#include <asm/atomic.h>
  28
  29struct poll_table_struct;
  30struct nameidata;
  31
  32
  33/*
  34 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
  35 * the file limit at runtime and only root can increase the per-process
  36 * nr_file rlimit, so it's safe to set up a ridiculously high absolute
  37 * upper limit on files-per-process.
  38 *
  39 * Some programs (notably those using select()) may have to be 
  40 * recompiled to take full advantage of the new limits..  
  41 */
  42
  43/* Fixed constants first: */
  44#undef NR_OPEN
  45#define NR_OPEN (1024*1024)     /* Absolute upper limit on fd num */
  46#define INR_OPEN 1024           /* Initial setting for nfile rlimits */
  47
  48#define BLOCK_SIZE_BITS 10
  49#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
  50
  51/* And dynamically-tunable limits and defaults: */
  52struct files_stat_struct {
  53        int nr_files;           /* read only */
  54        int nr_free_files;      /* read only */
  55        int max_files;          /* tunable */
  56};
  57extern struct files_stat_struct files_stat;
  58
  59struct inodes_stat_t {
  60        int nr_inodes;
  61        int nr_unused;
  62        int dummy[5];
  63};
  64extern struct inodes_stat_t inodes_stat;
  65
  66extern int leases_enable, dir_notify_enable, lease_break_time;
  67
  68#define NR_FILE  8192   /* this can well be larger on a larger system */
  69#define NR_RESERVED_FILES 10 /* reserved for root */
  70#define NR_SUPER 256
  71
  72#define MAY_EXEC 1
  73#define MAY_WRITE 2
  74#define MAY_READ 4
  75
  76#define FMODE_READ 1
  77#define FMODE_WRITE 2
  78
  79#define RW_MASK         1
  80#define RWA_MASK        2
  81#define READ 0
  82#define WRITE 1
  83#define READA 2         /* read-ahead  - don't block if no resources */
  84#define SPECIAL 4       /* For non-blockdevice requests in request queue */
  85
  86#define SEL_IN          1
  87#define SEL_OUT         2
  88#define SEL_EX          4
  89
  90/* public flags for file_system_type */
  91#define FS_REQUIRES_DEV 1 
  92#define FS_ODD_RENAME   32768   /* Temporary stuff; will go away as soon
  93                                  * as nfs_rename() will be cleaned up
  94                                  */
  95/*
  96 * These are the fs-independent mount-flags: up to 32 flags are supported
  97 */
  98#define MS_RDONLY        1      /* Mount read-only */
  99#define MS_NOSUID        2      /* Ignore suid and sgid bits */
 100#define MS_NODEV         4      /* Disallow access to device special files */
 101#define MS_NOEXEC        8      /* Disallow program execution */
 102#define MS_SYNCHRONOUS  16      /* Writes are synced at once */
 103#define MS_REMOUNT      32      /* Alter flags of a mounted FS */
 104#define MS_MANDLOCK     64      /* Allow mandatory locks on an FS */
 105#define MS_DIRSYNC      128     /* Directory modifications are synchronous */
 106#define MS_NOATIME      1024    /* Do not update access times. */
 107#define MS_NODIRATIME   2048    /* Do not update directory access times */
 108#define MS_BIND         4096
 109#define MS_MOVE         8192
 110#define MS_REC          16384
 111#define MS_VERBOSE      32768
 112#define MS_ACTIVE       (1<<30)
 113#define MS_NOUSER       (1<<31)
 114
 115/*
 116 * Superblock flags that can be altered by MS_REMOUNT
 117 */
 118#define MS_RMT_MASK     (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
 119                         MS_NODIRATIME)
 120
 121/*
 122 * Old magic mount flag and mask
 123 */
 124#define MS_MGC_VAL 0xC0ED0000
 125#define MS_MGC_MSK 0xffff0000
 126
 127/* Inode flags - they have nothing to superblock flags now */
 128
 129#define S_SYNC          1       /* Writes are synced at once */
 130#define S_NOATIME       2       /* Do not update access times */
 131#define S_QUOTA         4       /* Quota initialized for file */
 132#define S_APPEND        8       /* Append-only file */
 133#define S_IMMUTABLE     16      /* Immutable file */
 134#define S_DEAD          32      /* removed, but still open directory */
 135#define S_NOQUOTA       64      /* Inode is not counted to quota */
 136#define S_DIRSYNC       128     /* Directory modifications are synchronous */
 137
 138/*
 139 * Note that nosuid etc flags are inode-specific: setting some file-system
 140 * flags just means all the inodes inherit those flags by default. It might be
 141 * possible to override it selectively if you really wanted to with some
 142 * ioctl() that is not currently implemented.
 143 *
 144 * Exception: MS_RDONLY is always applied to the entire file system.
 145 *
 146 * Unfortunately, it is possible to change a filesystems flags with it mounted
 147 * with files in use.  This means that all of the inodes will not have their
 148 * i_flags updated.  Hence, i_flags no longer inherit the superblock mount
 149 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
 150 */
 151#define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
 152
 153#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
 154#define IS_SYNC(inode)          (__IS_FLG(inode, MS_SYNCHRONOUS) || \
 155                                        ((inode)->i_flags & S_SYNC))
 156#define IS_DIRSYNC(inode)       (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
 157                                        ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
 158#define IS_MANDLOCK(inode)      __IS_FLG(inode, MS_MANDLOCK)
 159
 160#define IS_QUOTAINIT(inode)     ((inode)->i_flags & S_QUOTA)
 161#define IS_NOQUOTA(inode)       ((inode)->i_flags & S_NOQUOTA)
 162#define IS_APPEND(inode)        ((inode)->i_flags & S_APPEND)
 163#define IS_IMMUTABLE(inode)     ((inode)->i_flags & S_IMMUTABLE)
 164#define IS_NOATIME(inode)       (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
 165#define IS_NODIRATIME(inode)    __IS_FLG(inode, MS_NODIRATIME)
 166
 167#define IS_DEADDIR(inode)       ((inode)->i_flags & S_DEAD)
 168
 169/* the read-only stuff doesn't really belong here, but any other place is
 170   probably as bad and I don't want to create yet another include file. */
 171
 172#define BLKROSET   _IO(0x12,93) /* set device read-only (0 = read-write) */
 173#define BLKROGET   _IO(0x12,94) /* get read-only status (0 = read_write) */
 174#define BLKRRPART  _IO(0x12,95) /* re-read partition table */
 175#define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
 176#define BLKFLSBUF  _IO(0x12,97) /* flush buffer cache */
 177#define BLKRASET   _IO(0x12,98) /* set read ahead for block device */
 178#define BLKRAGET   _IO(0x12,99) /* get current read ahead setting */
 179#define BLKFRASET  _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
 180#define BLKFRAGET  _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
 181#define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
 182#define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
 183#define BLKSSZGET  _IO(0x12,104)/* get block device sector size */
 184#if 0
 185#define BLKPG      _IO(0x12,105)/* See blkpg.h */
 186#define BLKELVGET  _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */
 187#define BLKELVSET  _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))/* elevator set */
 188/* This was here just to show that the number is taken -
 189   probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
 190#endif
 191/* A jump here: 108-111 have been used for various private purposes. */
 192#define BLKBSZGET  _IOR(0x12,112,sizeof(int))
 193#define BLKBSZSET  _IOW(0x12,113,sizeof(int))
 194#define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64)) /* return device size in bytes (u64 *arg) */
 195
 196#define BMAP_IOCTL 1            /* obsolete - kept for compatibility */
 197#define FIBMAP     _IO(0x00,1)  /* bmap access */
 198#define FIGETBSZ   _IO(0x00,2)  /* get the block size used for bmap */
 199
 200#ifdef __KERNEL__
 201
 202#include <asm/semaphore.h>
 203#include <asm/byteorder.h>
 204
 205extern void update_atime (struct inode *);
 206#define UPDATE_ATIME(inode) update_atime (inode)
 207
 208extern void inode_init(unsigned long);
 209extern void mnt_init(unsigned long);
 210extern void files_init(unsigned long);
 211
 212struct buffer_head;
 213typedef int (get_block_t)(struct inode*,sector_t,struct buffer_head*,int);
 214
 215#include <linux/pipe_fs_i.h>
 216/* #include <linux/umsdos_fs_i.h> */
 217
 218/*
 219 * Attribute flags.  These should be or-ed together to figure out what
 220 * has been changed!
 221 */
 222#define ATTR_MODE       1
 223#define ATTR_UID        2
 224#define ATTR_GID        4
 225#define ATTR_SIZE       8
 226#define ATTR_ATIME      16
 227#define ATTR_MTIME      32
 228#define ATTR_CTIME      64
 229#define ATTR_ATIME_SET  128
 230#define ATTR_MTIME_SET  256
 231#define ATTR_FORCE      512     /* Not a change, but a change it */
 232#define ATTR_ATTR_FLAG  1024
 233#define ATTR_KILL_SUID  2048
 234#define ATTR_KILL_SGID  4096
 235
 236/*
 237 * This is the Inode Attributes structure, used for notify_change().  It
 238 * uses the above definitions as flags, to know which values have changed.
 239 * Also, in this manner, a Filesystem can look at only the values it cares
 240 * about.  Basically, these are the attributes that the VFS layer can
 241 * request to change from the FS layer.
 242 *
 243 * Derek Atkins <warlord@MIT.EDU> 94-10-20
 244 */
 245struct iattr {
 246        unsigned int    ia_valid;
 247        umode_t         ia_mode;
 248        uid_t           ia_uid;
 249        gid_t           ia_gid;
 250        loff_t          ia_size;
 251        time_t          ia_atime;
 252        time_t          ia_mtime;
 253        time_t          ia_ctime;
 254        unsigned int    ia_attr_flags;
 255};
 256
 257/*
 258 * This is the inode attributes flag definitions
 259 */
 260#define ATTR_FLAG_SYNCRONOUS    1       /* Syncronous write */
 261#define ATTR_FLAG_NOATIME       2       /* Don't update atime */
 262#define ATTR_FLAG_APPEND        4       /* Append-only file */
 263#define ATTR_FLAG_IMMUTABLE     8       /* Immutable file */
 264#define ATTR_FLAG_NODIRATIME    16      /* Don't update atime for directory */
 265
 266/*
 267 * Includes for diskquotas and mount structures.
 268 */
 269#include <linux/quota.h>
 270#include <linux/mount.h>
 271
 272/*
 273 * oh the beauties of C type declarations.
 274 */
 275struct page;
 276struct address_space;
 277
 278struct address_space_operations {
 279        int (*writepage)(struct page *);
 280        int (*readpage)(struct file *, struct page *);
 281        int (*sync_page)(struct page *);
 282
 283        /* Write back some dirty pages from this mapping. */
 284        int (*writepages)(struct address_space *, int *nr_to_write);
 285
 286        /* Perform a writeback as a memory-freeing operation. */
 287        int (*vm_writeback)(struct page *, int *nr_to_write);
 288
 289        /* Set a page dirty */
 290        int (*set_page_dirty)(struct page *page);
 291
 292        int (*readpages)(struct address_space *mapping,
 293                        struct list_head *pages, unsigned nr_pages);
 294
 295        /*
 296         * ext3 requires that a successful prepare_write() call be followed
 297         * by a commit_write() call - they must be balanced
 298         */
 299        int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
 300        int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
 301        /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
 302        int (*bmap)(struct address_space *, long);
 303        int (*invalidatepage) (struct page *, unsigned long);
 304        int (*releasepage) (struct page *, int);
 305        int (*direct_IO)(int, struct inode *, char *buf,
 306                                loff_t offset, size_t count);
 307};
 308
 309struct backing_dev_info;
 310struct address_space {
 311        struct inode            *host;          /* owner: inode, block_device */
 312        struct radix_tree_root  page_tree;      /* radix tree of all pages */
 313        rwlock_t                page_lock;      /* and rwlock protecting it */
 314        struct list_head        clean_pages;    /* list of clean pages */
 315        struct list_head        dirty_pages;    /* list of dirty pages */
 316        struct list_head        locked_pages;   /* list of locked pages */
 317        struct list_head        io_pages;       /* being prepared for I/O */
 318        unsigned long           nrpages;        /* number of total pages */
 319        struct address_space_operations *a_ops; /* methods */
 320        list_t                  i_mmap;         /* list of private mappings */
 321        list_t                  i_mmap_shared;  /* list of private mappings */
 322        spinlock_t              i_shared_lock;  /* and spinlock protecting it */
 323        unsigned long           dirtied_when;   /* jiffies of first page dirtying */
 324        int                     gfp_mask;       /* how to allocate the pages */
 325        struct backing_dev_info *backing_dev_info; /* device readahead, etc */
 326        spinlock_t              private_lock;   /* for use by the address_space */
 327        struct list_head        private_list;   /* ditto */
 328        struct address_space    *assoc_mapping; /* ditto */
 329};
 330
 331struct char_device {
 332        struct list_head        hash;
 333        atomic_t                count;
 334        dev_t                   dev;
 335        atomic_t                openers;
 336        struct semaphore        sem;
 337};
 338
 339struct block_device {
 340        struct list_head        bd_hash;
 341        atomic_t                bd_count;
 342        struct inode *          bd_inode;
 343        dev_t                   bd_dev;  /* not a kdev_t - it's a search key */
 344        int                     bd_openers;
 345        struct block_device_operations *bd_op;
 346        struct request_queue    *bd_queue;
 347        struct semaphore        bd_sem; /* open/close mutex */
 348        struct list_head        bd_inodes;
 349        void *                  bd_holder;
 350        int                     bd_holders;
 351        struct block_device *   bd_contains;
 352        unsigned                bd_block_size;
 353        unsigned long           bd_offset;
 354        struct semaphore        bd_part_sem;
 355        unsigned                bd_part_count;
 356};
 357
 358struct inode {
 359        struct list_head        i_hash;
 360        struct list_head        i_list;
 361        struct list_head        i_dentry;
 362        unsigned long           i_ino;
 363        atomic_t                i_count;
 364        dev_t                   i_dev;
 365        umode_t                 i_mode;
 366        nlink_t                 i_nlink;
 367        uid_t                   i_uid;
 368        gid_t                   i_gid;
 369        kdev_t                  i_rdev;
 370        loff_t                  i_size;
 371        time_t                  i_atime;
 372        time_t                  i_mtime;
 373        time_t                  i_ctime;
 374        unsigned int            i_blkbits;
 375        unsigned long           i_blksize;
 376        unsigned long           i_blocks;
 377        unsigned long           i_version;
 378        unsigned short          i_bytes;
 379        struct semaphore        i_sem;
 380        struct inode_operations *i_op;
 381        struct file_operations  *i_fop; /* former ->i_op->default_file_ops */
 382        struct super_block      *i_sb;
 383        struct file_lock        *i_flock;
 384        struct address_space    *i_mapping;
 385        struct address_space    i_data;
 386        struct dquot            *i_dquot[MAXQUOTAS];
 387        /* These three should probably be a union */
 388        struct list_head        i_devices;
 389        struct pipe_inode_info  *i_pipe;
 390        struct block_device     *i_bdev;
 391        struct char_device      *i_cdev;
 392
 393        unsigned long           i_dnotify_mask; /* Directory notify events */
 394        struct dnotify_struct   *i_dnotify; /* for directory notifications */
 395
 396        unsigned long           i_state;
 397
 398        unsigned int            i_flags;
 399        unsigned char           i_sock;
 400
 401        atomic_t                i_writecount;
 402        __u32                   i_generation;
 403        union {
 404                void                            *generic_ip;
 405        } u;
 406};
 407
 408struct socket_alloc {
 409        struct socket socket;
 410        struct inode vfs_inode;
 411};
 412
 413static inline struct socket *SOCKET_I(struct inode *inode)
 414{
 415        return &container_of(inode, struct socket_alloc, vfs_inode)->socket;
 416}
 417
 418static inline struct inode *SOCK_INODE(struct socket *socket)
 419{
 420        return &container_of(socket, struct socket_alloc, socket)->vfs_inode;
 421}
 422
 423/* will die */
 424#include <linux/coda_fs_i.h>
 425#include <linux/ext3_fs_i.h>
 426#include <linux/efs_fs_i.h>
 427
 428struct fown_struct {
 429        int pid;                /* pid or -pgrp where SIGIO should be sent */
 430        uid_t uid, euid;        /* uid/euid of process setting the owner */
 431        int signum;             /* posix.1b rt signal to be delivered on IO */
 432};
 433
 434static inline void inode_add_bytes(struct inode *inode, loff_t bytes)
 435{
 436        inode->i_blocks += bytes >> 9;
 437        bytes &= 511;
 438        inode->i_bytes += bytes;
 439        if (inode->i_bytes >= 512) {
 440                inode->i_blocks++;
 441                inode->i_bytes -= 512;
 442        }
 443}
 444
 445static inline void inode_sub_bytes(struct inode *inode, loff_t bytes)
 446{
 447        inode->i_blocks -= bytes >> 9;
 448        bytes &= 511;
 449        if (inode->i_bytes < bytes) {
 450                inode->i_blocks--;
 451                inode->i_bytes += 512;
 452        }
 453        inode->i_bytes -= bytes;
 454}
 455
 456static inline loff_t inode_get_bytes(struct inode *inode)
 457{
 458        return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
 459}
 460
 461static inline void inode_set_bytes(struct inode *inode, loff_t bytes)
 462{
 463        inode->i_blocks = bytes >> 9;
 464        inode->i_bytes = bytes & 511;
 465}
 466
 467/*
 468 * Track a single file's readahead state
 469 */
 470struct file_ra_state {
 471        unsigned long start;            /* Current window */
 472        unsigned long size;
 473        unsigned long next_size;        /* Next window size */
 474        unsigned long prev_page;        /* Cache last read() position */
 475        unsigned long ahead_start;      /* Ahead window */
 476        unsigned long ahead_size;
 477        unsigned long ra_pages;         /* Maximum readahead window */
 478};
 479
 480struct file {
 481        struct list_head        f_list;
 482        struct dentry           *f_dentry;
 483        struct vfsmount         *f_vfsmnt;
 484        struct file_operations  *f_op;
 485        atomic_t                f_count;
 486        unsigned int            f_flags;
 487        mode_t                  f_mode;
 488        loff_t                  f_pos;
 489        struct fown_struct      f_owner;
 490        unsigned int            f_uid, f_gid;
 491        int                     f_error;
 492        struct file_ra_state    f_ra;
 493
 494        unsigned long           f_version;
 495
 496        /* needed for tty driver, and maybe others */
 497        void                    *private_data;
 498};
 499extern spinlock_t files_lock;
 500#define file_list_lock() spin_lock(&files_lock);
 501#define file_list_unlock() spin_unlock(&files_lock);
 502
 503#define get_file(x)     atomic_inc(&(x)->f_count)
 504#define file_count(x)   atomic_read(&(x)->f_count)
 505
 506extern int init_private_file(struct file *, struct dentry *, int);
 507
 508#define MAX_NON_LFS     ((1UL<<31) - 1)
 509
 510/* Page cache limit. The filesystems should put that into their s_maxbytes 
 511   limits, otherwise bad things can happen in VM. */ 
 512#if BITS_PER_LONG==32
 513#define MAX_LFS_FILESIZE        (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 
 514#elif BITS_PER_LONG==64
 515#define MAX_LFS_FILESIZE        0x7fffffffffffffff
 516#endif
 517
 518#define FL_POSIX        1
 519#define FL_FLOCK        2
 520#define FL_BROKEN       4       /* broken flock() emulation */
 521#define FL_ACCESS       8       /* for processes suspended by mandatory locking */
 522#define FL_LOCKD        16      /* lock held by rpc.lockd */
 523#define FL_LEASE        32      /* lease held on this file */
 524
 525/*
 526 * The POSIX file lock owner is determined by
 527 * the "struct files_struct" in the thread group
 528 * (or NULL for no owner - BSD locks).
 529 *
 530 * Lockd stuffs a "host" pointer into this.
 531 */
 532typedef struct files_struct *fl_owner_t;
 533
 534/* that will die - we need it for nfs_lock_info */
 535#include <linux/nfs_fs_i.h>
 536
 537struct file_lock {
 538        struct file_lock *fl_next;      /* singly linked list for this inode  */
 539        struct list_head fl_link;       /* doubly linked list of all locks */
 540        struct list_head fl_block;      /* circular list of blocked processes */
 541        fl_owner_t fl_owner;
 542        unsigned int fl_pid;
 543        wait_queue_head_t fl_wait;
 544        struct file *fl_file;
 545        unsigned char fl_flags;
 546        unsigned char fl_type;
 547        loff_t fl_start;
 548        loff_t fl_end;
 549
 550        void (*fl_notify)(struct file_lock *);  /* unblock callback */
 551        void (*fl_insert)(struct file_lock *);  /* lock insertion callback */
 552        void (*fl_remove)(struct file_lock *);  /* lock removal callback */
 553
 554        struct fasync_struct *  fl_fasync; /* for lease break notifications */
 555        unsigned long fl_break_time;    /* for nonblocking lease breaks */
 556
 557        union {
 558                struct nfs_lock_info    nfs_fl;
 559        } fl_u;
 560};
 561
 562/* The following constant reflects the upper bound of the file/locking space */
 563#ifndef OFFSET_MAX
 564#define INT_LIMIT(x)    (~((x)1 << (sizeof(x)*8 - 1)))
 565#define OFFSET_MAX      INT_LIMIT(loff_t)
 566#define OFFT_OFFSET_MAX INT_LIMIT(off_t)
 567#endif
 568
 569extern struct list_head file_lock_list;
 570
 571#include <linux/fcntl.h>
 572
 573extern int fcntl_getlk(struct file *, struct flock *);
 574extern int fcntl_setlk(struct file *, unsigned int, struct flock *);
 575
 576extern int fcntl_getlk64(struct file *, struct flock64 *);
 577extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 *);
 578
 579/* fs/locks.c */
 580extern void locks_init_lock(struct file_lock *);
 581extern void locks_copy_lock(struct file_lock *, struct file_lock *);
 582extern void locks_remove_posix(struct file *, fl_owner_t);
 583extern void locks_remove_flock(struct file *);
 584extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
 585extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
 586extern void posix_block_lock(struct file_lock *, struct file_lock *);
 587extern void posix_unblock_lock(struct file_lock *);
 588extern int posix_locks_deadlock(struct file_lock *, struct file_lock *);
 589extern int __get_lease(struct inode *inode, unsigned int flags);
 590extern time_t lease_get_mtime(struct inode *);
 591extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
 592extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
 593
 594struct fasync_struct {
 595        int     magic;
 596        int     fa_fd;
 597        struct  fasync_struct   *fa_next; /* singly linked list */
 598        struct  file            *fa_file;
 599};
 600
 601#define FASYNC_MAGIC 0x4601
 602
 603/* SMP safe fasync helpers: */
 604extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
 605/* can be called from interrupts */
 606extern void kill_fasync(struct fasync_struct **, int, int);
 607/* only for net: no internal synchronization */
 608extern void __kill_fasync(struct fasync_struct *, int, int);
 609
 610/*
 611 *      Umount options
 612 */
 613
 614#define MNT_FORCE       0x00000001      /* Attempt to forcibily umount */
 615#define MNT_DETACH      0x00000002      /* Just detach from the tree */
 616
 617#include <linux/ext3_fs_sb.h>
 618#include <linux/hpfs_fs_sb.h>
 619#include <linux/ufs_fs_sb.h>
 620#include <linux/romfs_fs_sb.h>
 621
 622extern struct list_head super_blocks;
 623extern spinlock_t sb_lock;
 624
 625#define sb_entry(list)  list_entry((list), struct super_block, s_list)
 626#define S_BIAS (1<<30)
 627struct super_block {
 628        struct list_head        s_list;         /* Keep this first */
 629        dev_t                   s_dev;          /* search index; _not_ kdev_t */
 630        unsigned long           s_blocksize;
 631        unsigned long           s_old_blocksize;
 632        unsigned char           s_blocksize_bits;
 633        unsigned char           s_dirt;
 634        unsigned long long      s_maxbytes;     /* Max file size */
 635        struct file_system_type *s_type;
 636        struct super_operations *s_op;
 637        struct dquot_operations *dq_op;
 638        struct quotactl_ops     *s_qcop;
 639        struct export_operations *s_export_op;
 640        unsigned long           s_flags;
 641        unsigned long           s_magic;
 642        struct dentry           *s_root;
 643        struct rw_semaphore     s_umount;
 644        struct semaphore        s_lock;
 645        int                     s_count;
 646        int                     s_syncing;
 647        atomic_t                s_active;
 648
 649        struct list_head        s_dirty;        /* dirty inodes */
 650        struct list_head        s_io;           /* parked for writeback */
 651        struct list_head        s_locked_inodes;/* inodes being synced */
 652        struct list_head        s_anon;         /* anonymous dentries for (nfs) exporting */
 653        struct list_head        s_files;
 654
 655        struct block_device     *s_bdev;
 656        struct list_head        s_instances;
 657        struct quota_info       s_dquot;        /* Diskquota specific options */
 658
 659        char s_id[32];                          /* Informational name */
 660
 661        union {
 662                struct ext3_sb_info     ext3_sb;
 663                struct hpfs_sb_info     hpfs_sb;
 664                struct ufs_sb_info      ufs_sb;
 665                struct romfs_sb_info    romfs_sb;
 666                void                    *generic_sbp;
 667        } u;
 668        /*
 669         * The next field is for VFS *only*. No filesystems have any business
 670         * even looking at it. You had been warned.
 671         */
 672        struct semaphore s_vfs_rename_sem;      /* Kludge */
 673};
 674
 675/*
 676 * Superblock locking.
 677 */
 678static inline void lock_super(struct super_block * sb)
 679{
 680        down(&sb->s_lock);
 681}
 682
 683static inline void unlock_super(struct super_block * sb)
 684{
 685        up(&sb->s_lock);
 686}
 687
 688/*
 689 * VFS helper functions..
 690 */
 691extern int vfs_create(struct inode *, struct dentry *, int);
 692extern int vfs_mkdir(struct inode *, struct dentry *, int);
 693extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
 694extern int vfs_symlink(struct inode *, struct dentry *, const char *);
 695extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
 696extern int vfs_rmdir(struct inode *, struct dentry *);
 697extern int vfs_unlink(struct inode *, struct dentry *);
 698extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
 699
 700/*
 701 * File types
 702 *
 703 * NOTE! These match bits 12..15 of stat.st_mode
 704 * (ie "(i_mode >> 12) & 15").
 705 */
 706#define DT_UNKNOWN      0
 707#define DT_FIFO         1
 708#define DT_CHR          2
 709#define DT_DIR          4
 710#define DT_BLK          6
 711#define DT_REG          8
 712#define DT_LNK          10
 713#define DT_SOCK         12
 714#define DT_WHT          14
 715
 716/*
 717 * This is the "filldir" function type, used by readdir() to let
 718 * the kernel specify what kind of dirent layout it wants to have.
 719 * This allows the kernel to read directories into kernel space or
 720 * to have different dirent layouts depending on the binary type.
 721 */
 722typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
 723
 724struct block_device_operations {
 725        int (*open) (struct inode *, struct file *);
 726        int (*release) (struct inode *, struct file *);
 727        int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
 728        int (*check_media_change) (kdev_t);
 729        int (*revalidate) (kdev_t);
 730        struct module *owner;
 731};
 732
 733/*
 734 * NOTE:
 735 * read, write, poll, fsync, readv, writev can be called
 736 *   without the big kernel lock held in all filesystems.
 737 */
 738struct file_operations {
 739        struct module *owner;
 740        loff_t (*llseek) (struct file *, loff_t, int);
 741        ssize_t (*read) (struct file *, char *, size_t, loff_t *);
 742        ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
 743        int (*readdir) (struct file *, void *, filldir_t);
 744        unsigned int (*poll) (struct file *, struct poll_table_struct *);
 745        int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
 746        int (*mmap) (struct file *, struct vm_area_struct *);
 747        int (*open) (struct inode *, struct file *);
 748        int (*flush) (struct file *);
 749        int (*release) (struct inode *, struct file *);
 750        int (*fsync) (struct file *, struct dentry *, int datasync);
 751        int (*fasync) (int, struct file *, int);
 752        int (*lock) (struct file *, int, struct file_lock *);
 753        ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
 754        ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
 755        ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
 756        unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 757};
 758
 759struct inode_operations {
 760        int (*create) (struct inode *,struct dentry *,int);
 761        struct dentry * (*lookup) (struct inode *,struct dentry *);
 762        int (*link) (struct dentry *,struct inode *,struct dentry *);
 763        int (*unlink) (struct inode *,struct dentry *);
 764        int (*symlink) (struct inode *,struct dentry *,const char *);
 765        int (*mkdir) (struct inode *,struct dentry *,int);
 766        int (*rmdir) (struct inode *,struct dentry *);
 767        int (*mknod) (struct inode *,struct dentry *,int,int);
 768        int (*rename) (struct inode *, struct dentry *,
 769                        struct inode *, struct dentry *);
 770        int (*readlink) (struct dentry *, char *,int);
 771        int (*follow_link) (struct dentry *, struct nameidata *);
 772        void (*truncate) (struct inode *);
 773        int (*permission) (struct inode *, int);
 774        int (*setattr) (struct dentry *, struct iattr *);
 775        int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
 776        int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
 777        ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
 778        ssize_t (*listxattr) (struct dentry *, char *, size_t);
 779        int (*removexattr) (struct dentry *, const char *);
 780};
 781
 782struct seq_file;
 783
 784extern ssize_t vfs_read(struct file *, char *, size_t, loff_t *);
 785extern ssize_t vfs_write(struct file *, const char *, size_t, loff_t *);
 786
 787/*
 788 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
 789 * without the big kernel lock held in all filesystems.
 790 */
 791struct super_operations {
 792        struct inode *(*alloc_inode)(struct super_block *sb);
 793        void (*destroy_inode)(struct inode *);
 794
 795        void (*read_inode) (struct inode *);
 796  
 797        void (*dirty_inode) (struct inode *);
 798        void (*write_inode) (struct inode *, int);
 799        void (*put_inode) (struct inode *);
 800        void (*drop_inode) (struct inode *);
 801        void (*delete_inode) (struct inode *);
 802        void (*put_super) (struct super_block *);
 803        void (*write_super) (struct super_block *);
 804        void (*write_super_lockfs) (struct super_block *);
 805        void (*unlockfs) (struct super_block *);
 806        int (*statfs) (struct super_block *, struct statfs *);
 807        int (*remount_fs) (struct super_block *, int *, char *);
 808        void (*clear_inode) (struct inode *);
 809        void (*umount_begin) (struct super_block *);
 810
 811        int (*show_options)(struct seq_file *, struct vfsmount *);
 812};
 813
 814/* Inode state bits.  Protected by inode_lock. */
 815#define I_DIRTY_SYNC            1 /* Not dirty enough for O_DATASYNC */
 816#define I_DIRTY_DATASYNC        2 /* Data-related inode changes pending */
 817#define I_DIRTY_PAGES           4 /* Data-related inode changes pending */
 818#define I_LOCK                  8
 819#define I_FREEING               16
 820#define I_CLEAR                 32
 821#define I_NEW                   64
 822
 823#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
 824
 825extern void __mark_inode_dirty(struct inode *, int);
 826static inline void mark_inode_dirty(struct inode *inode)
 827{
 828        __mark_inode_dirty(inode, I_DIRTY);
 829}
 830
 831static inline void mark_inode_dirty_sync(struct inode *inode)
 832{
 833        __mark_inode_dirty(inode, I_DIRTY_SYNC);
 834}
 835
 836
 837/**
 838 * &export_operations - for nfsd to communicate with file systems
 839 * decode_fh:      decode a file handle fragment and return a &struct dentry
 840 * encode_fh:      encode a file handle fragment from a dentry
 841 * get_name:       find the name for a given inode in a given directory
 842 * get_parent:     find the parent of a given directory
 843 * get_dentry:     find a dentry for the inode given a file handle sub-fragment
 844 *
 845 * Description:
 846 *    The export_operations structure provides a means for nfsd to communicate
 847 *    with a particular exported file system  - particularly enabling nfsd and
 848 *    the filesystem to co-operate when dealing with file handles.
 849 *
 850 *    export_operations contains two basic operation for dealing with file handles,
 851 *    decode_fh() and encode_fh(), and allows for some other operations to be defined
 852 *    which standard helper routines use to get specific information from the
 853 *    filesystem.
 854 *
 855 *    nfsd encodes information use to determine which filesystem a filehandle
 856 *    applies to in the initial part of the file handle.  The remainder, termed a
 857 *    file handle fragment, is controlled completely by the filesystem.
 858 *    The standard helper routines assume that this fragment will contain one or two
 859 *    sub-fragments, one which identifies the file, and one which may be used to
 860 *    identify the (a) directory containing the file.
 861 *
 862 *    In some situations, nfsd needs to get a dentry which is connected into a
 863 *    specific part of the file tree.  To allow for this, it passes the function
 864 *    acceptable() together with a @context which can be used to see if the dentry
 865 *    is acceptable.  As there can be multiple dentrys for a given file, the filesystem
 866 *    should check each one for acceptability before looking for the next.  As soon
 867 *    as an acceptable one is found, it should be returned.
 868 *
 869 * decode_fh:
 870 *    @decode_fh is given a &struct super_block (@sb), a file handle fragment (@fh, @fh_len)
 871 *    and an acceptability testing function (@acceptable, @context).  It should return
 872 *    a &struct dentry which refers to the same file that the file handle fragment refers
 873 *    to,  and which passes the acceptability test.  If it cannot, it should return
 874 *    a %NULL pointer if the file was found but no acceptable &dentries were available, or
 875 *    a %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or %ENOMEM).
 876 *
 877 * encode_fh:
 878 *    @encode_fh should store in the file handle fragment @fh (using at most @max_len bytes)
 879 *    information that can be used by @decode_fh to recover the file refered to by the
 880 *    &struct dentry @de.  If the @connectable flag is set, the encode_fh() should store
 881 *    sufficient information so that a good attempt can be made to find not only
 882 *    the file but also it's place in the filesystem.   This typically means storing
 883 *    a reference to de->d_parent in the filehandle fragment.
 884 *    encode_fh() should return the number of bytes stored or a negative error code
 885 *    such as %-ENOSPC
 886 *
 887 * get_name:
 888 *    @get_name should find a name for the given @child in the given @parent directory.
 889 *    The name should be stored in the @name (with the understanding that it is already
 890 *    pointing to a a %NAME_MAX+1 sized buffer.   get_name() should return %0 on success,
 891 *    a negative error code or error.
 892 *    @get_name will be called without @parent->i_sem held.
 893 *
 894 * get_parent:
 895 *    @get_parent should find the parent directory for the given @child which is also
 896 *    a directory.  In the event that it cannot be found, or storage space cannot be
 897 *    allocated, a %ERR_PTR should be returned.
 898 *
 899 * get_dentry:
 900 *    Given a &super_block (@sb) and a pointer to a file-system specific inode identifier,
 901 *    possibly an inode number, (@inump) get_dentry() should find the identified inode and
 902 *    return a dentry for that inode.
 903 *    Any suitable dentry can be returned including, if necessary, a new dentry created
 904 *    with d_alloc_root.  The caller can then find any other extant dentrys by following the
 905 *    d_alias links.  If a new dentry was created using d_alloc_root, DCACHE_NFSD_DISCONNECTED
 906 *    should be set, and the dentry should be d_rehash()ed.
 907 *
 908 *    If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code can be returned.
 909 *    The @inump will be whatever was passed to nfsd_find_fh_dentry() in either the
 910 *    @obj or @parent parameters.
 911 *
 912 * Locking rules:
 913 *  get_parent is called with child->d_inode->i_sem down
 914 *  get_name is not (which is possibly inconsistent)
 915 */
 916
 917struct export_operations {
 918        struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
 919                         int (*acceptable)(void *context, struct dentry *de),
 920                         void *context);
 921        int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
 922                         int connectable);
 923
 924        /* the following are only called from the filesystem itself */
 925        int (*get_name)(struct dentry *parent, char *name,
 926                        struct dentry *child);
 927        struct dentry * (*get_parent)(struct dentry *child);
 928        struct dentry * (*get_dentry)(struct super_block *sb, void *inump);
 929
 930        /* This is set by the exporting module to a standard helper */
 931        struct dentry * (*find_exported_dentry)(
 932                struct super_block *sb, void *obj, void *parent,
 933                int (*acceptable)(void *context, struct dentry *de),
 934                void *context);
 935
 936
 937};
 938
 939
 940struct file_system_type {
 941        const char *name;
 942        int fs_flags;
 943        struct super_block *(*get_sb) (struct file_system_type *, int, char *, void *);
 944        void (*kill_sb) (struct super_block *);
 945        struct module *owner;
 946        struct file_system_type * next;
 947        struct list_head fs_supers;
 948};
 949
 950struct super_block *get_sb_bdev(struct file_system_type *fs_type,
 951        int flags, char *dev_name, void * data,
 952        int (*fill_super)(struct super_block *, void *, int));
 953struct super_block *get_sb_single(struct file_system_type *fs_type,
 954        int flags, void *data,
 955        int (*fill_super)(struct super_block *, void *, int));
 956struct super_block *get_sb_nodev(struct file_system_type *fs_type,
 957        int flags, void *data,
 958        int (*fill_super)(struct super_block *, void *, int));
 959void generic_shutdown_super(struct super_block *sb);
 960void kill_block_super(struct super_block *sb);
 961void kill_anon_super(struct super_block *sb);
 962void kill_litter_super(struct super_block *sb);
 963void deactivate_super(struct super_block *sb);
 964int set_anon_super(struct super_block *s, void *data);
 965struct super_block *sget(struct file_system_type *type,
 966                        int (*test)(struct super_block *,void *),
 967                        int (*set)(struct super_block *,void *),
 968                        void *data);
 969struct super_block *get_sb_pseudo(struct file_system_type *, char *,
 970                        struct super_operations *ops, unsigned long);
 971
 972/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
 973#define fops_get(fops) \
 974        (((fops) && (fops)->owner)      \
 975                ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
 976                : (fops))
 977
 978#define fops_put(fops) \
 979do {    \
 980        if ((fops) && (fops)->owner) \
 981                __MOD_DEC_USE_COUNT((fops)->owner);     \
 982} while(0)
 983
 984extern int register_filesystem(struct file_system_type *);
 985extern int unregister_filesystem(struct file_system_type *);
 986extern struct vfsmount *kern_mount(struct file_system_type *);
 987extern int may_umount(struct vfsmount *);
 988extern long do_mount(char *, char *, char *, unsigned long, void *);
 989
 990#define kern_umount mntput
 991
 992extern int vfs_statfs(struct super_block *, struct statfs *);
 993
 994/* Return value for VFS lock functions - tells locks.c to lock conventionally
 995 * REALLY kosha for root NFS and nfs_lock
 996 */ 
 997#define LOCK_USE_CLNT 1
 998
 999#define FLOCK_VERIFY_READ  1
1000#define FLOCK_VERIFY_WRITE 2
1001
1002extern int locks_mandatory_locked(struct inode *);
1003extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
1004
1005/*
1006 * Candidates for mandatory locking have the setgid bit set
1007 * but no group execute bit -  an otherwise meaningless combination.
1008 */
1009#define MANDATORY_LOCK(inode) \
1010        (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
1011
1012static inline int locks_verify_locked(struct inode *inode)
1013{
1014        if (MANDATORY_LOCK(inode))
1015                return locks_mandatory_locked(inode);
1016        return 0;
1017}
1018
1019static inline int locks_verify_area(int read_write, struct inode *inode,
1020                                    struct file *filp, loff_t offset,
1021                                    size_t count)
1022{
1023        if (inode->i_flock && MANDATORY_LOCK(inode))
1024                return locks_mandatory_area(read_write, inode, filp, offset, count);
1025        return 0;
1026}
1027
1028static inline int locks_verify_truncate(struct inode *inode,
1029                                    struct file *filp,
1030                                    loff_t size)
1031{
1032        if (inode->i_flock && MANDATORY_LOCK(inode))
1033                return locks_mandatory_area(
1034                        FLOCK_VERIFY_WRITE, inode, filp,
1035                        size < inode->i_size ? size : inode->i_size,
1036                        (size < inode->i_size ? inode->i_size - size
1037                         : size - inode->i_size)
1038                );
1039        return 0;
1040}
1041
1042static inline int get_lease(struct inode *inode, unsigned int mode)
1043{
1044        if (inode->i_flock && (inode->i_flock->fl_flags & FL_LEASE))
1045                return __get_lease(inode, mode);
1046        return 0;
1047}
1048
1049/* fs/open.c */
1050
1051asmlinkage long sys_open(const char *, int, int);
1052asmlinkage long sys_close(unsigned int);        /* yes, it's really unsigned */
1053extern int do_truncate(struct dentry *, loff_t start);
1054
1055extern struct file *filp_open(const char *, int, int);
1056extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1057extern int filp_close(struct file *, fl_owner_t id);
1058extern char * getname(const char *);
1059
1060/* fs/dcache.c */
1061extern void vfs_caches_init(unsigned long);
1062
1063#define __getname()     kmem_cache_alloc(names_cachep, SLAB_KERNEL)
1064#define putname(name)   kmem_cache_free(names_cachep, (void *)(name))
1065
1066enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW};
1067extern int register_blkdev(unsigned int, const char *, struct block_device_operations *);
1068extern int unregister_blkdev(unsigned int, const char *);
1069extern struct block_device *bdget(dev_t);
1070extern int bd_acquire(struct inode *inode);
1071extern void bd_forget(struct inode *inode);
1072extern void bdput(struct block_device *);
1073extern struct char_device *cdget(dev_t);
1074extern void cdput(struct char_device *);
1075extern int blkdev_open(struct inode *, struct file *);
1076extern int blkdev_close(struct inode *, struct file *);
1077extern struct file_operations def_blk_fops;
1078extern struct address_space_operations def_blk_aops;
1079extern struct file_operations def_fifo_fops;
1080extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1081extern int blkdev_get(struct block_device *, mode_t, unsigned, int);
1082extern int blkdev_put(struct block_device *, int);
1083extern int bd_claim(struct block_device *, void *);
1084extern void bd_release(struct block_device *);
1085extern void blk_run_queues(void);
1086
1087/* fs/devices.c */
1088extern struct block_device_operations *get_blkfops(unsigned int);
1089extern int register_chrdev(unsigned int, const char *, struct file_operations *);
1090extern int unregister_chrdev(unsigned int, const char *);
1091extern int chrdev_open(struct inode *, struct file *);
1092extern const char *__bdevname(kdev_t);
1093extern inline const char *bdevname(struct block_device *bdev)
1094{
1095        return __bdevname(to_kdev_t(bdev->bd_dev));
1096}
1097extern const char * cdevname(kdev_t);
1098extern const char * kdevname(kdev_t);
1099extern void init_special_inode(struct inode *, umode_t, int);
1100
1101/* Invalid inode operations -- fs/bad_inode.c */
1102extern void make_bad_inode(struct inode *);
1103extern int is_bad_inode(struct inode *);
1104
1105extern struct file_operations read_fifo_fops;
1106extern struct file_operations write_fifo_fops;
1107extern struct file_operations rdwr_fifo_fops;
1108extern struct file_operations read_pipe_fops;
1109extern struct file_operations write_pipe_fops;
1110extern struct file_operations rdwr_pipe_fops;
1111
1112extern int fs_may_remount_ro(struct super_block *);
1113
1114/*
1115 * return READ, READA, or WRITE
1116 */
1117#define bio_rw(bio)             ((bio)->bi_rw & (RW_MASK | RWA_MASK))
1118
1119/*
1120 * return data direction, READ or WRITE
1121 */
1122#define bio_data_dir(bio)       ((bio)->bi_rw & 1)
1123
1124extern int check_disk_change(kdev_t);
1125extern int invalidate_inodes(struct super_block *);
1126extern int invalidate_device(kdev_t, int);
1127extern void invalidate_inode_pages(struct inode *);
1128extern void invalidate_inode_pages2(struct address_space *mapping);
1129extern void write_inode_now(struct inode *, int);
1130extern int filemap_fdatawrite(struct address_space *);
1131extern int filemap_fdatawait(struct address_space *);
1132extern void sync_supers(void);
1133extern int bmap(struct inode *, int);
1134extern int notify_change(struct dentry *, struct iattr *);
1135extern int permission(struct inode *, int);
1136extern int vfs_permission(struct inode *, int);
1137extern int get_write_access(struct inode *);
1138extern int deny_write_access(struct file *);
1139static inline void put_write_access(struct inode * inode)
1140{
1141        atomic_dec(&inode->i_writecount);
1142}
1143static inline void allow_write_access(struct file *file)
1144{
1145        if (file)
1146                atomic_inc(&file->f_dentry->d_inode->i_writecount);
1147}
1148extern int do_pipe(int *);
1149
1150extern int open_namei(const char *, int, int, struct nameidata *);
1151extern int may_open(struct nameidata *, int, int);
1152
1153extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
1154extern struct file * open_exec(const char *);
1155 
1156/* fs/dcache.c -- generic fs support functions */
1157extern int is_subdir(struct dentry *, struct dentry *);
1158extern ino_t find_inode_number(struct dentry *, struct qstr *);
1159
1160#include <linux/err.h>
1161
1162/*
1163 * "descriptor" for what we're up to with a read for sendfile().
1164 * This allows us to use the same read code yet
1165 * have multiple different users of the data that
1166 * we read from a file.
1167 *
1168 * The simplest case just copies the data to user
1169 * mode.
1170 */
1171typedef struct {
1172        size_t written;
1173        size_t count;
1174        char * buf;
1175        int error;
1176} read_descriptor_t;
1177
1178typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
1179
1180/* needed for stackable file system support */
1181extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1182
1183extern void inode_init_once(struct inode *);
1184extern void iput(struct inode *);
1185extern struct inode * igrab(struct inode *);
1186extern ino_t iunique(struct super_block *, ino_t);
1187extern int inode_needs_sync(struct inode *inode);
1188extern void generic_delete_inode(struct inode *inode);
1189
1190extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
1191extern struct inode * iget_locked(struct super_block *, unsigned long);
1192extern void unlock_new_inode(struct inode *);
1193
1194static inline struct inode *iget(struct super_block *sb, unsigned long ino)
1195{
1196        struct inode *inode = iget_locked(sb, ino);
1197        
1198        if (inode && (inode->i_state & I_NEW)) {
1199                sb->s_op->read_inode(inode);
1200                unlock_new_inode(inode);
1201        }
1202
1203        return inode;
1204}
1205
1206extern void __iget(struct inode * inode);
1207extern void clear_inode(struct inode *);
1208extern struct inode *new_inode(struct super_block *);
1209extern void remove_suid(struct dentry *);
1210
1211extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1212extern void remove_inode_hash(struct inode *);
1213static inline void insert_inode_hash(struct inode *inode) {
1214        __insert_inode_hash(inode, inode->i_ino);
1215}
1216
1217extern struct file * get_empty_filp(void);
1218extern void file_move(struct file *f, struct list_head *list);
1219extern void ll_rw_block(int, int, struct buffer_head * bh[]);
1220extern int submit_bh(int, struct buffer_head *);
1221struct bio;
1222extern int submit_bio(int, struct bio *);
1223extern int bdev_read_only(struct block_device *);
1224extern int set_blocksize(struct block_device *, int);
1225extern int sb_set_blocksize(struct super_block *, int);
1226extern int sb_min_blocksize(struct super_block *, int);
1227
1228extern int generic_file_mmap(struct file *, struct vm_area_struct *);
1229extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
1230extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
1231extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *);
1232extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, read_actor_t);
1233ssize_t generic_file_direct_IO(int rw, struct inode *inode, char *buf,
1234                                loff_t offset, size_t count);
1235int generic_direct_IO(int rw, struct inode *inode, char *buf,
1236                        loff_t offset, size_t count, get_block_t *get_block);
1237
1238extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
1239extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
1240extern loff_t remote_llseek(struct file *file, loff_t offset, int origin);
1241extern int generic_file_open(struct inode * inode, struct file * filp);
1242
1243extern int generic_vm_writeback(struct page *page, int *nr_to_write);
1244
1245extern struct file_operations generic_ro_fops;
1246
1247extern int vfs_readlink(struct dentry *, char *, int, const char *);
1248extern int vfs_follow_link(struct nameidata *, const char *);
1249extern int page_readlink(struct dentry *, char *, int);
1250extern int page_follow_link(struct dentry *, struct nameidata *);
1251extern int page_symlink(struct inode *inode, const char *symname, int len);
1252extern struct inode_operations page_symlink_inode_operations;
1253extern void generic_fillattr(struct inode *, struct kstat *);
1254extern int vfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
1255
1256extern int vfs_readdir(struct file *, filldir_t, void *);
1257
1258extern int vfs_stat(char *, struct kstat *);
1259extern int vfs_lstat(char *, struct kstat *);
1260extern int vfs_fstat(unsigned int, struct kstat *);
1261
1262extern struct file_system_type *get_fs_type(const char *name);
1263extern struct super_block *get_super(struct block_device *);
1264extern struct super_block *user_get_super(dev_t);
1265extern void drop_super(struct super_block *sb);
1266
1267extern int dcache_dir_open(struct inode *, struct file *);
1268extern int dcache_dir_close(struct inode *, struct file *);
1269extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
1270extern int dcache_readdir(struct file *, void *, filldir_t);
1271extern int simple_statfs(struct super_block *, struct statfs *);
1272extern struct dentry *simple_lookup(struct inode *, struct dentry *);
1273extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
1274extern struct file_operations simple_dir_operations;
1275extern struct inode_operations simple_dir_inode_operations;
1276
1277#ifdef CONFIG_BLK_DEV_INITRD
1278extern unsigned int real_root_dev;
1279#endif
1280
1281extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
1282extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
1283extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
1284extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
1285
1286extern int inode_change_ok(struct inode *, struct iattr *);
1287extern int inode_setattr(struct inode *, struct iattr *);
1288
1289static inline ino_t parent_ino(struct dentry *dentry)
1290{
1291        ino_t res;
1292        read_lock(&dparent_lock);
1293        res = dentry->d_parent->d_inode->i_ino;
1294        read_unlock(&dparent_lock);
1295        return res;
1296}
1297
1298/* NOTE NOTE NOTE: this interface _will_ change in a couple of patches */
1299
1300static inline int dev_lock_part(kdev_t dev)
1301{
1302        struct block_device *bdev = bdget(kdev_t_to_nr(dev));
1303        if (!bdev)
1304                return -ENOMEM;
1305        if (!down_trylock(&bdev->bd_part_sem)) {
1306                if (!bdev->bd_part_count)
1307                        return 0;
1308                up(&bdev->bd_part_sem);
1309        }
1310        bdput(bdev);
1311        return -EBUSY;
1312}
1313
1314static inline void dev_unlock_part(kdev_t dev)
1315{
1316        struct block_device *bdev = bdget(kdev_t_to_nr(dev));
1317        if (!bdev)
1318                BUG();
1319        up(&bdev->bd_part_sem);
1320        bdput(bdev);
1321        bdput(bdev);
1322}
1323
1324#endif /* __KERNEL__ */
1325#endif /* _LINUX_FS_H */
1326
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.