root/include/linux/ext2_fs.h

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

INCLUDED FROM


   1 #ifndef _LINUX_EXT2_FS_H
   2 #define _LINUX_EXT2_FS_H
   3 
   4 /*
   5  * The second extended filesystem constants/structures
   6  */
   7 
   8 /*
   9  * Define EXT2FS_DEBUG to produce debug messages
  10  */
  11 #undef EXT2FS_DEBUG
  12 
  13 /*
  14  * Define DONT_USE_DCACHE to inhibit the directory cache
  15  */
  16 #undef DONT_USE_DCACHE
  17 
  18 /*
  19  * Define EXT2FS_DEBUG_CACHE to produce cache debug messages
  20  */
  21 #undef EXT2FS_DEBUG_CACHE
  22 
  23 /*
  24  * The second extended file system version
  25  */
  26 #define EXT2FS_VERSION  "0.2d, 93/03/30"
  27 
  28 /*
  29  * Special inodes numbers
  30  */
  31 #define EXT2_BAD_INO             1      /* Bad blocks inode */
  32 #define EXT2_ROOT_INO            2      /* Root inode */
  33 #define EXT2_ACL_INO             3      /* ACL inode */
  34 #define EXT2_FIRST_INO          11      /* First non reserved inode */
  35 
  36 /*
  37  * The second extended file system magic number
  38  */
  39 #define EXT2_OLD_SUPER_MAGIC    0xEF51
  40 #define EXT2_SUPER_MAGIC        0xEF53
  41 
  42 /*
  43  * Macro-instructions used to manage several block sizes
  44  */
  45 #define EXT2_MIN_BLOCK_SIZE             1024
  46 #define EXT2_MAX_BLOCK_SIZE             4096
  47 #define EXT2_MIN_BLOCK_LOG_SIZE           10
  48 #ifdef KERNEL
  49 # define EXT2_BLOCK_SIZE(s)             ((s)->s_blocksize)
  50 #else
  51 # define EXT2_BLOCK_SIZE(s)             (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  52 #endif
  53 #define EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long))
  54 #ifdef KERNEL
  55 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->u.ext2_sb.s_log_block_size + 10)
  56 #else
  57 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->s_log_block_size + 10)
  58 #endif
  59 #define EXT2_INODES_PER_BLOCK(s)        (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode))
  60 
  61 /*
  62  * Macro-instructions used to manage fragments
  63  */
  64 #define EXT2_MIN_FRAG_SIZE              1024
  65 #define EXT2_MAX_FRAG_SIZE              1024
  66 #define EXT2_MIN_FRAG_LOG_SIZE            10
  67 #ifdef KERNEL
  68 # define EXT2_FRAG_SIZE(s)              ((s)->u.ext2_sb.s_frag_size)
  69 # define EXT2_FRAGS_PER_BLOCK(s)        ((s)->u.ext2_sb.s_frags_per_block)
  70 #else
  71 # define EXT2_FRAG_SIZE(s)              (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
  72 # define EXT2_FRAGS_PER_BLOCK(s)        (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
  73 #endif
  74 
  75 /*
  76  * Structure of a blocks group descriptor
  77  */
  78 struct ext2_old_group_desc
  79 {
  80         unsigned long bg_block_bitmap;          /* Blocks bitmap block */
  81         unsigned long bg_inode_bitmap;          /* Inodes bitmap block */
  82         unsigned long bg_inode_table;           /* Inodes table block */
  83         unsigned short bg_free_blocks_count;    /* Free blocks count */
  84         unsigned short bg_free_inodes_count;    /* Free inodes count */
  85 };
  86 
  87 struct ext2_group_desc
  88 {
  89         unsigned long bg_block_bitmap;          /* Blocks bitmap block */
  90         unsigned long bg_inode_bitmap;          /* Inodes bitmap block */
  91         unsigned long bg_inode_table;           /* Inodes table block */
  92         unsigned short bg_free_blocks_count;    /* Free blocks count */
  93         unsigned short bg_free_inodes_count;    /* Free inodes count */
  94         unsigned short bg_used_dirs_count;      /* Directories count */
  95         unsigned short bg_pad;
  96         unsigned long bg_reserved[3];
  97 };
  98 
  99 /*
 100  * Macro-instructions used to manage group descriptors
 101  */
 102 #ifdef KERNEL
 103 # define EXT2_BLOCKS_PER_GROUP(s)       ((s)->u.ext2_sb.s_blocks_per_group)
 104 # define EXT2_DESC_PER_BLOCK(s)         ((s)->u.ext2_sb.s_desc_per_block)
 105 # define EXT2_INODES_PER_GROUP(s)       ((s)->u.ext2_sb.s_inodes_per_group)
 106 #else
 107 # define EXT2_BLOCKS_PER_GROUP(s)       ((s)->s_blocks_per_group)
 108 # define EXT2_DESC_PER_BLOCK(s)         (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
 109 # define EXT2_INODES_PER_GROUP(s)       ((s)->s_inodes_per_group)
 110 #endif
 111 
 112 /*
 113  * Constants relative to the data blocks
 114  */
 115 #define EXT2_NDIR_BLOCKS        12
 116 #define EXT2_IND_BLOCK          EXT2_NDIR_BLOCKS
 117 #define EXT2_DIND_BLOCK         (EXT2_IND_BLOCK + 1)
 118 #define EXT2_TIND_BLOCK         (EXT2_DIND_BLOCK + 1)
 119 #define EXT2_N_BLOCKS           (EXT2_TIND_BLOCK + 1)
 120 
 121 /*
 122  * Structure of an inode on the disk
 123  */
 124 struct ext2_inode {
 125         unsigned short i_mode;          /* File mode */
 126         unsigned short i_uid;           /* Owner Uid */
 127         unsigned long i_size;           /* Size in bytes */
 128         unsigned long i_atime;          /* Access time */
 129         unsigned long i_ctime;          /* Creation time */
 130         unsigned long i_mtime;          /* Modification time */
 131         unsigned long i_dtime;          /* Deletion Time */
 132         unsigned short i_gid;           /* Group Id */
 133         unsigned short i_links_count;   /* Links count */
 134         unsigned long i_blocks;         /* Blocks count */
 135         unsigned long i_flags;          /* File flags */
 136         unsigned long i_reserved1;
 137         unsigned long i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
 138         unsigned long i_version;        /* File version (for NFS) */
 139         unsigned long i_file_acl;       /* File ACL */
 140         unsigned long i_dir_acl;        /* Directory ACL */
 141         unsigned long i_faddr;          /* Fragment address */
 142         unsigned char i_frag;           /* Fragment number */
 143         unsigned char i_fsize;          /* Fragment size */
 144         unsigned short i_pad1;
 145         unsigned long i_reserved2[2];
 146 };
 147 
 148 /*
 149  * Structure of the super block
 150  */
 151 struct ext2_super_block {
 152         unsigned long s_inodes_count;   /* Inodes count */
 153         unsigned long s_blocks_count;   /* Blocks count */
 154         unsigned long s_r_blocks_count; /* Reserved blocks count */
 155         unsigned long s_free_blocks_count;/* Free blocks count */
 156         unsigned long s_free_inodes_count;/* Free inodes count */
 157         unsigned long s_first_data_block;/* First Data Block */
 158         unsigned long s_log_block_size; /* Block size */
 159         long s_log_frag_size;           /* Fragment size */
 160         unsigned long s_blocks_per_group;/* # Blocks per group */
 161         unsigned long s_frags_per_group;/* # Fragments per group */
 162         unsigned long s_inodes_per_group;/* # Inodes per group */
 163         unsigned long s_mtime;          /* Mount time */
 164         unsigned long s_wtime;          /* Write time */
 165         unsigned long s_pad;            /* Padding to get the magic signature*/
 166                                         /* at the same offset as in the */
 167                                         /* previous ext fs */
 168         unsigned short s_magic;         /* Magic signature */
 169         unsigned short s_valid;         /* Flag */
 170         unsigned long s_reserved[243];  /* Padding to the end of the block */
 171 };
 172 
 173 /*
 174  * Structure of a directory entry
 175  */
 176 #define EXT2_NAME_LEN 255
 177 
 178 struct ext2_dir_entry {
 179         unsigned long inode;            /* Inode number */
 180         unsigned short rec_len;         /* Directory entry length */
 181         unsigned short name_len;        /* Name length */
 182         char name[EXT2_NAME_LEN];       /* File name */
 183 };
 184 
 185 /*
 186  * EXT2_DIR_PAD defines the directory entries boundaries
 187  *
 188  * NOTE: It must be a multiple of 4
 189  */
 190 #define EXT2_DIR_PAD                    4
 191 #define EXT2_DIR_ROUND                  (EXT2_DIR_PAD - 1)
 192 #define EXT2_DIR_REC_LEN(name_len)      (((name_len) + 8 + EXT2_DIR_ROUND) & \
 193                                          ~EXT2_DIR_ROUND)
 194 
 195 /*
 196  * Function prototypes
 197  */
 198 
 199 /* balloc.c */
 200 extern int ext2_new_block (struct super_block *, unsigned long);
 201 extern void ext2_free_block (struct super_block *, unsigned long);
 202 extern unsigned long ext2_count_free_blocks (struct super_block *);
 203 
 204 /* bitmap.c */
 205 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
 206 
 207 /* dcache.c */
 208 extern void ext2_dcache_invalidate (unsigned short);
 209 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
 210                                          const char *, int);
 211 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
 212                              int, int);
 213 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
 214                                 int);
 215 
 216 /* dir.c */
 217 extern int ext2_check_dir_entry (char *, struct inode *,
 218                                  struct ext2_dir_entry *, struct buffer_head *,
 219                                  unsigned int);
 220 
 221 /* file.c */
 222 extern int ext2_read (struct inode *, struct file *, char *, int);
 223 extern int ext2_write (struct inode *, struct file *, char *, int);
 224 
 225 /* ialloc.c */
 226 extern struct inode * ext2_new_inode (const struct inode *, int);
 227 extern void ext2_free_inode (struct inode *);
 228 extern unsigned long ext2_count_free_inodes (struct super_block *);
 229 
 230 /* inode.c */
 231 extern int ext2_bmap (struct inode *, int);
 232 
 233 extern struct buffer_head * ext2_getblk (struct inode *, int, int);
 234 extern struct buffer_head * ext2_bread (struct inode *, int, int);
 235 
 236 extern void ext2_truncate (struct inode *);
 237 extern void ext2_put_super (struct super_block *);
 238 extern void ext2_write_super (struct super_block *);
 239 extern struct super_block * ext2_read_super (struct super_block *,void *,int);
 240 extern void ext2_read_inode (struct inode *);
 241 extern void ext2_write_inode (struct inode *);
 242 extern void ext2_put_inode (struct inode *);
 243 extern void ext2_statfs (struct super_block *, struct statfs *);
 244 
 245 /* namei.c */
 246 extern int ext2_open (struct inode *, struct file *);
 247 extern void ext2_release (struct inode *, struct file *);
 248 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
 249 extern int ext2_create (struct inode *,const char *, int, int,
 250                         struct inode **);
 251 extern int ext2_mkdir (struct inode *, const char *, int, int);
 252 extern int ext2_rmdir (struct inode *, const char *, int);
 253 extern int ext2_unlink (struct inode *, const char *, int);
 254 extern int ext2_symlink (struct inode *, const char *, int, const char *);
 255 extern int ext2_link (struct inode *, struct inode *, const char *, int);
 256 extern int ext2_mknod (struct inode *, const char *, int, int, int);
 257 extern int ext2_rename (struct inode *, const char *, int,
 258                         struct inode *, const char *, int);
 259 
 260 /*
 261  * Inodes and files operations
 262  */
 263 
 264 /* dir.c */
 265 extern struct inode_operations ext2_dir_inode_operations;
 266 extern struct file_operations ext2_dir_operations;
 267 
 268 /* file.c */
 269 extern struct inode_operations ext2_file_inode_operations;
 270 extern struct file_operations ext2_file_operations;
 271 
 272 /* symlink.c */
 273 extern struct inode_operations ext2_symlink_inode_operations;
 274 
 275 #endif

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