home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Include / Linux / fs.h < prev    next >
C/C++ Source or Header  |  2002-04-26  |  9KB  |  258 lines

  1. /* $Id: fs.h,v 1.2 2002/04/26 23:09:05 smilcke Exp $ */
  2.  
  3. #ifndef _LINUX_FS_H
  4. #define _LINUX_FS_H
  5.  
  6. /*
  7.  * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
  8.  * the file limit at runtime and only root can increase the per-process
  9.  * nr_file rlimit, so it's safe to set up a ridiculously high absolute
  10.  * upper limit on files-per-process.
  11.  *
  12.  * Some programs (notably those using select()) may have to be
  13.  * recompiled to take full advantage of the new limits..
  14.  */
  15.  
  16. #include <linux/types.h>
  17. #include <linux/fcntl.h>
  18. #include <linux/signal.h>
  19. #include <linux/kdev_t.h>
  20. #include <linux/wait.h>
  21. #include <linux/list.h>
  22. #include <linux/dcache.h>
  23. #include <linux/vmalloc.h>
  24. #include <linux/tqueue.h>
  25.  
  26. #define FALSE    0
  27. #define TRUE    1
  28.  
  29. /* Fixed constants first: */
  30. #undef NR_OPEN
  31. #define NR_OPEN (1024*1024)    /* Absolute upper limit on fd num */
  32. #define INR_OPEN 1024        /* Initial setting for nfile rlimits */
  33.  
  34. #define BLOCK_SIZE_BITS 10
  35. #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
  36.  
  37. #include <asm/semaphor.h>
  38. #include <asm/bitops.h>
  39.  
  40. #define NR_FILE  8192    /* this can well be larger on a larger system */
  41. #define NR_RESERVED_FILES 10 /* reserved for root */
  42. #define NR_SUPER 256
  43.  
  44. #define MAY_EXEC 1
  45. #define MAY_WRITE 2
  46. #define MAY_READ 4
  47.  
  48. #define FMODE_READ 1
  49. #define FMODE_WRITE 2
  50.  
  51. #define READ 0
  52. #define WRITE 1
  53. #define READA 2        /* read-ahead  - don't block if no resources */
  54.  
  55. #define WRITERAW 5    /* raw write - don't play with buffer lists */
  56.  
  57. #ifndef NULL
  58. #define NULL ((void *) 0)
  59. #endif
  60.  
  61. #define NIL_FILP    ((struct file *)0)
  62. #define SEL_IN        1
  63. #define SEL_OUT        2
  64. #define SEL_EX        4
  65.  
  66. /* public flags for file_system_type */
  67. #define FS_REQUIRES_DEV 1
  68. #define FS_NO_DCACHE    2 /* Only dcache the necessary things. */
  69. #define FS_NO_PRELIM    4 /* prevent preloading of dentries, even if
  70.                * FS_NO_DCACHE is not set.
  71.                */
  72. #define FS_IBASKET    8 /* FS does callback to free_ibasket() if space gets low. */
  73.  
  74. /*
  75.  * These are the fs-independent mount-flags: up to 16 flags are supported
  76.  */
  77. #define MS_RDONLY     1    /* Mount read-only */
  78. #define MS_NOSUID     2    /* Ignore suid and sgid bits */
  79. #define MS_NODEV     4    /* Disallow access to device special files */
  80. #define MS_NOEXEC     8    /* Disallow program execution */
  81. #define MS_SYNCHRONOUS    16    /* Writes are synced at once */
  82. #define MS_REMOUNT    32    /* Alter flags of a mounted FS */
  83. #define MS_MANDLOCK    64    /* Allow mandatory locks on an FS */
  84. #define S_QUOTA        128    /* Quota initialized for file/directory/symlink */
  85. #define S_APPEND    256    /* Append-only file */
  86. #define S_IMMUTABLE    512    /* Immutable file */
  87. #define MS_NOATIME    1024    /* Do not update access times. */
  88. #define MS_NODIRATIME    2048    /* Do not update directory access times */
  89.  
  90. #define MS_ODD_RENAME    32768    /* Temporary stuff; will go away as soon
  91.                   * as nfs_rename() will be cleaned up
  92.                   */
  93.  
  94. /*
  95.  * Flags that can be altered by MS_REMOUNT
  96.  */
  97. #define MS_RMT_MASK    (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|\
  98.             MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
  99.  
  100. /*
  101.  * Magic mount flag number. Has to be or-ed to the flag values.
  102.  */
  103. #define MS_MGC_VAL 0xC0ED0000    /* magic flag number to indicate "new" flags */
  104. #define MS_MGC_MSK 0xffff0000    /* magic flag number mask */
  105.  
  106. /*
  107.  * Note that nosuid etc flags are inode-specific: setting some file-system
  108.  * flags just means all the inodes inherit those flags by default. It might be
  109.  * possible to override it selectively if you really wanted to with some
  110.  * ioctl() that is not currently implemented.
  111.  *
  112.  * Exception: MS_RDONLY is always applied to the entire file system.
  113.  *
  114.  * Unfortunately, it is possible to change a filesystems flags with it mounted
  115.  * with files in use.  This means that all of the inodes will not have their
  116.  * i_flags updated.  Hence, i_flags no longer inherit the superblock mount
  117.  * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
  118.  */
  119. #define __IS_FLG(inode,flg) (((inode)->i_sb && (inode)->i_sb->s_flags & (flg)) \
  120.                 || (inode)->i_flags & (flg))
  121.  
  122. #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
  123. #define IS_NOSUID(inode)    __IS_FLG(inode, MS_NOSUID)
  124. #define IS_NODEV(inode)        __IS_FLG(inode, MS_NODEV)
  125. #define IS_NOEXEC(inode)    __IS_FLG(inode, MS_NOEXEC)
  126. #define IS_SYNC(inode)        __IS_FLG(inode, MS_SYNCHRONOUS)
  127. #define IS_MANDLOCK(inode)    __IS_FLG(inode, MS_MANDLOCK)
  128.  
  129. #define IS_QUOTAINIT(inode)    ((inode)->i_flags & S_QUOTA)
  130. #define IS_APPEND(inode)    ((inode)->i_flags & S_APPEND)
  131. #define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
  132. #define IS_NOATIME(inode)    __IS_FLG(inode, MS_NOATIME)
  133. #define IS_NODIRATIME(inode)    __IS_FLG(inode, MS_NODIRATIME)
  134.  
  135.  
  136. /* the read-only stuff doesn't really belong here, but any other place is
  137.    probably as bad and I don't want to create yet another include file. */
  138.  
  139. #define BLKROSET   _IO(0x12,93)    /* set device read-only (0 = read-write) */
  140. #define BLKROGET   _IO(0x12,94)    /* get read-only status (0 = read_write) */
  141. #define BLKRRPART  _IO(0x12,95)    /* re-read partition table */
  142. #define BLKGETSIZE _IO(0x12,96)    /* return device size */
  143. #define BLKFLSBUF  _IO(0x12,97)    /* flush buffer cache */
  144. #define BLKRASET   _IO(0x12,98)    /* Set read ahead for block device */
  145. #define BLKRAGET   _IO(0x12,99)    /* get current read ahead setting */
  146. #define BLKFRASET  _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
  147. #define BLKFRAGET  _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
  148. #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
  149. #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
  150. #define BLKSSZGET  _IO(0x12,104)/* get block device sector size */
  151. #if 0
  152. #define BLKPG      _IO(0x12,105)/* See blkpg.h */
  153. /* This was here just to show that the number is taken -
  154.    probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
  155. #endif
  156.  
  157.  
  158. #define BMAP_IOCTL 1        /* obsolete - kept for compatibility */
  159. #define FIBMAP       _IO(0x00,1)    /* bmap access */
  160. #define FIGETBSZ   _IO(0x00,2)    /* get the block size used for bmap */
  161.  
  162. struct fown_struct {
  163.     int pid;        /* pid or -pgrp where SIGIO should be sent */
  164.     uid_t uid, euid;    /* uid/euid of process setting the owner */
  165.     int signum;        /* posix.1b rt signal to be delivered on IO */
  166. };
  167.  
  168. struct file {
  169.      void *    f_list;
  170.     struct dentry        *f_dentry;
  171.     struct file_operations    *f_op;
  172.     atomic_t        f_count;
  173.     unsigned int         f_flags;
  174.     mode_t            f_mode;
  175.     loff_t            f_pos;
  176.     unsigned long         f_reada, f_ramax, f_raend, f_ralen, f_rawin;
  177.     struct fown_struct    f_owner;
  178.     unsigned int        f_uid, f_gid;
  179.     int            f_error;
  180.  
  181.     unsigned long        f_version;
  182.  
  183.     /* needed for tty driver, and maybe others */
  184.     void            *private_data;
  185. };
  186.  
  187. struct inode {
  188. #ifdef TARGET_OS2
  189.     kdev_t            i_rdev;
  190.         struct semaphore        i_sem;
  191. #else
  192.      void *    i_hash;
  193.      void *    i_list;
  194.      void *    i_dentry;
  195.     unsigned long        i_ino;
  196.     unsigned int        i_count;
  197.     kdev_t            i_dev;
  198.     umode_t            i_mode;
  199.     nlink_t            i_nlink;
  200.     uid_t            i_uid;
  201.     gid_t            i_gid;
  202.     kdev_t            i_rdev;
  203.     loff_t            i_size;
  204.     time_t            i_atime;
  205.     time_t            i_mtime;
  206.     time_t            i_ctime;
  207.     unsigned long        i_blksize;
  208.     unsigned long        i_blocks;
  209.     unsigned long        i_version;
  210.     struct semaphore    i_sem;
  211.     struct inode_operations    *i_op;
  212.     struct super_block    *i_sb;
  213.     struct file_lock    *i_flock;
  214.     struct vm_area_struct    *i_mmap;
  215.     struct pipe_inode_info    *i_pipe;
  216.     unsigned long        i_state;
  217.  
  218.     unsigned int        i_flags;
  219.     unsigned char        i_sock;
  220.  
  221.     atomic_t        i_writecount;
  222.     unsigned int        i_attr_flags;
  223.     __u32            i_generation;
  224.     union {
  225.         void                *generic_ip;
  226.     } u;
  227. #endif
  228. };
  229.  
  230. typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
  231.  
  232. struct file_operations {
  233.     loff_t (*llseek) (struct file *, loff_t, int);
  234.     int (*read) (struct file *, char *, size_t, loff_t *);
  235.     int (*write) (struct file *, const char *, size_t, loff_t *);
  236.     int (*readdir) (struct file *, void *, filldir_t);
  237.     unsigned int (*poll) (struct file *, struct poll_table_struct *);
  238.     int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
  239.     int (*mmap) (struct file *, struct vm_area_struct *);
  240.     int (*open) (struct inode *, struct file *);
  241.     int (*flush) (struct file *);
  242.     int (*release) (struct inode *, struct file *);
  243.     int (*fsync) (struct file *, struct dentry *);
  244.     int (*fasync) (int, struct file *, int);
  245.     int (*check_media_change) (kdev_t dev);
  246.     int (*revalidate) (kdev_t dev);
  247.     int (*lock) (struct file *, int, struct file_lock *);
  248. };
  249.  
  250. /* Inode state bits.. */
  251. #define I_DIRTY        1
  252. #define I_LOCK        2
  253. #define I_FREEING    4
  254.  
  255. #include <linux/poll.h>
  256.  
  257. #endif /* _LINUX_FS_H */
  258.