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.2c, 93/03/06"
  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 short i_faddr;         /* Fragment address */
 142         unsigned char i_frag;           /* Fragment number */
 143         unsigned char i_fsize;          /* Fragment size */
 144         unsigned long i_reserved2[3];
 145 };
 146 
 147 /*
 148  * Structure of the super block
 149  */
 150 struct ext2_super_block {
 151         unsigned long s_inodes_count;   /* Inodes count */
 152         unsigned long s_blocks_count;   /* Blocks count */
 153         unsigned long s_r_blocks_count; /* Reserved blocks count */
 154         unsigned long s_free_blocks_count;/* Free blocks count */
 155         unsigned long s_free_inodes_count;/* Free inodes count */
 156         unsigned long s_first_data_block;/* First Data Block */
 157         unsigned long s_log_block_size; /* Block size */
 158         unsigned long s_log_frag_size;  /* Fragment size */
 159         unsigned long s_blocks_per_group;/* # Blocks per group */
 160         unsigned long s_frags_per_group;/* # Fragments per group */
 161         unsigned long s_inodes_per_group;/* # Inodes per group */
 162         unsigned long s_mtime;          /* Mount time */
 163         unsigned long s_wtime;          /* Write time */
 164         unsigned long s_pad;            /* Padding to get the magic signature*/
 165                                         /* at the same offset as in the */
 166                                         /* previous ext fs */
 167         unsigned short s_magic;         /* Magic signature */
 168         unsigned short s_valid;         /* Flag */
 169         unsigned long s_reserved[243];  /* Padding to the end of the block */
 170 };
 171 
 172 /*
 173  * Structure of a directory entry
 174  */
 175 #define EXT2_NAME_LEN 255
 176 
 177 struct ext2_dir_entry {
 178         unsigned long inode;            /* Inode number */
 179         unsigned short rec_len;         /* Directory entry length */
 180         unsigned short name_len;        /* Name length */
 181         char name[EXT2_NAME_LEN];       /* File name */
 182 };
 183 
 184 /*
 185  * EXT2_DIR_PAD defines the directory entries boundaries
 186  *
 187  * NOTE: It must be a multiple of 4
 188  */
 189 #define EXT2_DIR_PAD                    4
 190 #define EXT2_DIR_ROUND                  (EXT2_DIR_PAD - 1)
 191 #define EXT2_DIR_REC_LEN(name_len)      (((name_len) + 8 + EXT2_DIR_ROUND) & \
 192                                          ~EXT2_DIR_ROUND)
 193 
 194 /*
 195  * Function prototypes
 196  */
 197 
 198 /* balloc.c */
 199 extern int ext2_new_block (struct super_block *, unsigned long);
 200 extern void ext2_free_block (struct super_block *, unsigned long);
 201 extern unsigned long ext2_count_free_blocks (struct super_block *);
 202 
 203 /* bitmap.c */
 204 extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
 205 
 206 /* dcache.c */
 207 extern void ext2_dcache_invalidate (unsigned short);
 208 extern unsigned long ext2_dcache_lookup (unsigned short, unsigned long,
 209                                          const char *, int);
 210 extern void ext2_dcache_add (unsigned short, unsigned long, const char *,
 211                              int, int);
 212 extern void ext2_dcache_remove (unsigned short, unsigned long, const char *,
 213                                 int);
 214 
 215 /* file.c */
 216 extern int ext2_read (struct inode *, struct file *, char *, int);
 217 extern int ext2_write (struct inode *, struct file *, char *, int);
 218 
 219 /* ialloc.c */
 220 extern struct inode * ext2_new_inode (const struct inode *, int);
 221 extern void ext2_free_inode (struct inode *);
 222 extern unsigned long ext2_count_free_inodes (struct super_block *);
 223 
 224 /* inode.c */
 225 extern int ext2_bmap (struct inode *, int);
 226 
 227 extern struct buffer_head * ext2_getblk (struct inode *, int, int);
 228 extern struct buffer_head * ext2_bread (struct inode *, int, int);
 229 
 230 extern void ext2_truncate (struct inode *);
 231 extern void ext2_put_super (struct super_block *);
 232 extern void ext2_write_super (struct super_block *);
 233 extern struct super_block * ext2_read_super (struct super_block *,void *);
 234 extern void ext2_read_inode (struct inode *);
 235 extern void ext2_write_inode (struct inode *);
 236 extern void ext2_put_inode (struct inode *);
 237 extern void ext2_statfs (struct super_block *, struct statfs *);
 238 
 239 /* namei.c */
 240 extern int ext2_open (struct inode *, struct file *);
 241 extern void ext2_release (struct inode *, struct file *);
 242 extern int ext2_lookup (struct inode *,const char *, int, struct inode **);
 243 extern int ext2_create (struct inode *,const char *, int, int,
 244                         struct inode **);
 245 extern int ext2_mkdir (struct inode *, const char *, int, int);
 246 extern int ext2_rmdir (struct inode *, const char *, int);
 247 extern int ext2_unlink (struct inode *, const char *, int);
 248 extern int ext2_symlink (struct inode *, const char *, int, const char *);
 249 extern int ext2_link (struct inode *, struct inode *, const char *, int);
 250 extern int ext2_mknod (struct inode *, const char *, int, int, int);
 251 extern int ext2_rename (struct inode *, const char *, int,
 252                         struct inode *, const char *, int);
 253 
 254 /*
 255  * Inodes and files operations
 256  */
 257 
 258 /* blkdev.c */
 259 extern struct inode_operations ext2_blkdev_inode_operations;
 260 
 261 /* chrdev.c */
 262 extern struct inode_operations ext2_chrdev_inode_operations;
 263 
 264 /* dir.c */
 265 extern struct inode_operations ext2_dir_inode_operations;
 266 extern struct file_operations ext2_dir_operations;
 267 
 268 /* fifo.c */
 269 extern struct inode_operations ext2_fifo_inode_operations;
 270 
 271 /* file.c */
 272 extern struct inode_operations ext2_file_inode_operations;
 273 extern struct file_operations ext2_file_operations;
 274 
 275 /* symlink.c */
 276 extern struct inode_operations ext2_symlink_inode_operations;
 277 
 278 #endif

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