Fork me on GitHub

root/include/fiwix/fs_ext2.h

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

INCLUDED FROM


   1 /*
   2  * fiwix/include/fiwix/fs_ext2.h
   3  *
   4  * This file from: Linux 2.0.40
   5  * Copyright (C) 1992, 1993, 1994, 1995
   6  * Remy Card (card@masi.ibp.fr)
   7  * Laboratoire MASI - Institut Blaise Pascal
   8  * Universite Pierre et Marie Curie (Paris VI)
   9  * Copyright (C) 1991, 1992  Linus Torvalds
  10  */
  11 
  12 #ifndef _FIWIX_FS_EXT2_H
  13 #define _FIWIX_FS_EXT2_H
  14 
  15 #include <fiwix/types.h>
  16 
  17 #define EXT2_ROOT_INO            2      /* Root inode */
  18 #define EXT2_SUPER_MAGIC        0xEF53
  19 
  20 /*
  21  * Macro-instructions used to manage several block sizes
  22  */
  23 #define EXT2_MIN_BLOCK_SIZE             1024
  24 #define EXT2_MAX_BLOCK_SIZE             4096
  25 #define EXT2_MIN_BLOCK_LOG_SIZE           10
  26 # define EXT2_BLOCK_SIZE(s)             ((s)->s_blocksize)
  27 # define EXT2_BLOCK_SIZE_BITS(s)        ((s)->s_blocksize_bits)
  28 
  29 /*
  30  * Structure of a blocks group descriptor
  31  */
  32 struct ext2_group_desc
  33 {
  34         __u32   bg_block_bitmap;        /* Blocks bitmap block */
  35         __u32   bg_inode_bitmap;        /* Inodes bitmap block */
  36         __u32   bg_inode_table;         /* Inodes table block */
  37         __u16   bg_free_blocks_count;   /* Free blocks count */
  38         __u16   bg_free_inodes_count;   /* Free inodes count */
  39         __u16   bg_used_dirs_count;     /* Directories count */
  40         __u16   bg_pad;
  41         __u32   bg_reserved[3];
  42 };
  43 
  44 /*
  45  * Macro-instructions used to manage group descriptors
  46  */
  47 #define EXT2_BLOCKS_PER_GROUP(s)        ((s)->u.ext2.sb.s_blocks_per_group)
  48 #define EXT2_INODES_PER_GROUP(s)        ((s)->u.ext2.sb.s_inodes_per_group)
  49 # define EXT2_DESC_PER_BLOCK_BITS(s)    ((s)->u.ext2_sb.s_desc_per_block_bits)
  50 #define EXT2_DESC_PER_BLOCK(s)          ((s)->u.ext2.desc_per_block)
  51 
  52 /*
  53  * Constants relative to the data blocks
  54  */
  55 #define EXT2_NDIR_BLOCKS                12
  56 #define EXT2_IND_BLOCK                  EXT2_NDIR_BLOCKS
  57 #define EXT2_DIND_BLOCK                 (EXT2_IND_BLOCK + 1)
  58 #define EXT2_TIND_BLOCK                 (EXT2_DIND_BLOCK + 1)
  59 #define EXT2_N_BLOCKS                   (EXT2_TIND_BLOCK + 1)
  60 
  61 /*
  62  * Structure of an inode on the disk
  63  */
  64 struct ext2_inode {
  65         __u16   i_mode;         /* File mode */
  66         __u16   i_uid;          /* Low 16 bits of Owner Uid */
  67         __u32   i_size;         /* Size in bytes */
  68         __u32   i_atime;        /* Access time */
  69         __u32   i_ctime;        /* Creation time */
  70         __u32   i_mtime;        /* Modification time */
  71         __u32   i_dtime;        /* Deletion Time */
  72         __u16   i_gid;          /* Low 16 bits of Group Id */
  73         __u16   i_links_count;  /* Links count */
  74         __u32   i_blocks;       /* Blocks count */
  75         __u32   i_flags;        /* File flags */
  76         union {
  77                 struct {
  78                         __u32  l_i_reserved1;
  79                 } linux1;
  80                 struct {
  81                         __u32  h_i_translator;
  82                 } hurd1;
  83                 struct {
  84                         __u32  m_i_reserved1;
  85                 } masix1;
  86         } osd1;                         /* OS dependent 1 */
  87         __u32   i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
  88         __u32   i_generation;   /* File version (for NFS) */
  89         __u32   i_file_acl;     /* File ACL */
  90         __u32   i_dir_acl;      /* Directory ACL */
  91         __u32   i_faddr;        /* Fragment address */
  92         union {
  93                 struct {
  94                         __u8    l_i_frag;       /* Fragment number */
  95                         __u8    l_i_fsize;      /* Fragment size */
  96                         __u16   i_pad1;
  97                         __u16   l_i_uid_high;   /* these 2 fields    */
  98                         __u16   l_i_gid_high;   /* were reserved2[0] */
  99                         __u32   l_i_reserved2;
 100                 } linux2;
 101                 struct {
 102                         __u8    h_i_frag;       /* Fragment number */
 103                         __u8    h_i_fsize;      /* Fragment size */
 104                         __u16   h_i_mode_high;
 105                         __u16   h_i_uid_high;
 106                         __u16   h_i_gid_high;
 107                         __u32   h_i_author;
 108                 } hurd2;
 109                 struct {
 110                         __u8    m_i_frag;       /* Fragment number */
 111                         __u8    m_i_fsize;      /* Fragment size */
 112                         __u16   m_pad1;
 113                         __u32   m_i_reserved2[2];
 114                 } masix2;
 115         } osd2;                         /* OS dependent 2 */
 116 };
 117 
 118 /*
 119  * File system states
 120  */
 121 #define EXT2_VALID_FS                   0x0001  /* Unmounted cleanly */
 122 #define EXT2_ERROR_FS                   0x0002  /* Errors detected */
 123 
 124 /*
 125  * Structure of the super block
 126  */
 127 struct ext2_super_block {
 128         __u32   s_inodes_count;         /* Inodes count */
 129         __u32   s_blocks_count;         /* Blocks count */
 130         __u32   s_r_blocks_count;       /* Reserved blocks count */
 131         __u32   s_free_blocks_count;    /* Free blocks count */
 132         __u32   s_free_inodes_count;    /* Free inodes count */
 133         __u32   s_first_data_block;     /* First Data Block */
 134         __u32   s_log_block_size;       /* Block size */
 135         __s32   s_log_frag_size;        /* Fragment size */
 136         __u32   s_blocks_per_group;     /* # Blocks per group */
 137         __u32   s_frags_per_group;      /* # Fragments per group */
 138         __u32   s_inodes_per_group;     /* # Inodes per group */
 139         __u32   s_mtime;                /* Mount time */
 140         __u32   s_wtime;                /* Write time */
 141         __u16   s_mnt_count;            /* Mount count */
 142         __s16   s_max_mnt_count;        /* Maximal mount count */
 143         __u16   s_magic;                /* Magic signature */
 144         __u16   s_state;                /* File system state */
 145         __u16   s_errors;               /* Behaviour when detecting errors */
 146         __u16   s_minor_rev_level;      /* minor revision level */
 147         __u32   s_lastcheck;            /* time of last check */
 148         __u32   s_checkinterval;        /* max. time between checks */
 149         __u32   s_creator_os;           /* OS */
 150         __u32   s_rev_level;            /* Revision level */
 151         __u16   s_def_resuid;           /* Default uid for reserved blocks */
 152         __u16   s_def_resgid;           /* Default gid for reserved blocks */
 153         /*
 154          * These fields are for EXT2_DYNAMIC_REV superblocks only.
 155          *
 156          * Note: the difference between the compatible feature set and
 157          * the incompatible feature set is that if there is a bit set
 158          * in the incompatible feature set that the kernel doesn't
 159          * know about, it should refuse to mount the filesystem.
 160          * 
 161          * e2fsck's requirements are more strict; if it doesn't know
 162          * about a feature in either the compatible or incompatible
 163          * feature set, it must abort and not try to meddle with
 164          * things it doesn't understand...
 165          */
 166         __u32   s_first_ino;            /* First non-reserved inode */
 167         __u16   s_inode_size;           /* size of inode structure */
 168         __u16   s_block_group_nr;       /* block group # of this superblock */
 169         __u32   s_feature_compat;       /* compatible feature set */
 170         __u32   s_feature_incompat;     /* incompatible feature set */
 171         __u32   s_feature_ro_compat;    /* readonly-compatible feature set */
 172         __u8    s_uuid[16];             /* 128-bit uuid for volume */
 173         char    s_volume_name[16];      /* volume name */
 174         char    s_last_mounted[64];     /* directory where last mounted */
 175         __u32   s_algorithm_usage_bitmap; /* For compression */
 176         /*
 177          * Performance hints.  Directory preallocation should only
 178          * happen if the EXT2_COMPAT_PREALLOC flag is on.
 179          */
 180         __u8    s_prealloc_blocks;      /* Nr of blocks to try to preallocate*/
 181         __u8    s_prealloc_dir_blocks;  /* Nr to preallocate for dirs */
 182         __u16   s_padding1;
 183         /*
 184          * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
 185          */
 186         __u8    s_journal_uuid[16];     /* uuid of journal superblock */
 187         __u32   s_journal_inum;         /* inode number of journal file */
 188         __u32   s_journal_dev;          /* device number of journal file */
 189         __u32   s_last_orphan;          /* start of list of inodes to delete */
 190         __u32   s_hash_seed[4];         /* HTREE hash seed */
 191         __u8    s_def_hash_version;     /* Default hash version to use */
 192         __u8    s_reserved_char_pad;
 193         __u16   s_reserved_word_pad;
 194         __u32   s_default_mount_opts;
 195         __u32   s_first_meta_bg;        /* First metablock block group */
 196         __u32   s_reserved[190];        /* Padding to the end of the block */
 197 };
 198 
 199 /*
 200  * Structure of a directory entry
 201  */
 202 #define EXT2_NAME_LEN 255
 203 
 204 struct ext2_dir_entry {
 205         __u32   inode;                  /* Inode number */
 206         __u16   rec_len;                /* Directory entry length */
 207         __u16   name_len;               /* Name length */
 208         char    name[EXT2_NAME_LEN];    /* File name */
 209 };
 210 
 211 /*
 212  * The new version of the directory entry.  Since EXT2 structures are
 213  * stored in intel byte order, and the name_len field could never be
 214  * bigger than 255 chars, it's safe to reclaim the extra byte for the
 215  * file_type field.
 216  */
 217 struct ext2_dir_entry_2 {
 218         __u32   inode;                  /* Inode number */
 219         __u16   rec_len;                /* Directory entry length */
 220         __u8    name_len;               /* Name length */
 221         __u8    file_type;
 222         char    name[EXT2_NAME_LEN];    /* File name */
 223 };
 224 
 225 /*
 226  * Ext2 directory file types.  Only the low 3 bits are used.  The
 227  * other bits are reserved for now.
 228  */
 229 #define EXT2_FT_UNKNOWN         0
 230 #define EXT2_FT_REG_FILE        1
 231 #define EXT2_FT_DIR             2
 232 #define EXT2_FT_CHRDEV          3
 233 #define EXT2_FT_BLKDEV          4
 234 #define EXT2_FT_FIFO            5
 235 #define EXT2_FT_SOCK            6
 236 #define EXT2_FT_SYMLINK         7
 237 
 238 /* superblock in memory */
 239 struct ext2_sb_info {
 240         unsigned int desc_per_block;
 241         unsigned int block_groups;
 242         struct ext2_super_block sb;
 243 };
 244 
 245 /* inode in memory */
 246 struct ext2_i_info {
 247         __u32   i_data[EXT2_N_BLOCKS];  /* Pointers to blocks */
 248         __u32   i_dtime;
 249 };
 250 
 251 #endif  /* _FIWIX_FS_EXT2_H */

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