Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b53a733 in mainline


Ignore:
Timestamp:
2012-03-07T09:33:14Z (10 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master
Children:
e2629b08
Parents:
a872fc09
Message:

Data types definitions groupped to one file

Location:
uspace/lib/ext4
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4.h

    ra872fc09 rb53a733  
    4545#include "libext4_inode.h"
    4646#include "libext4_superblock.h"
     47#include "libext4_types.h"
    4748
    4849#include <stdio.h>
  • uspace/lib/ext4/libext4_balloc.h

    ra872fc09 rb53a733  
    3535
    3636#include <sys/types.h>
    37 #include "libext4_filesystem.h"
     37#include "libext4_types.h"
    3838
    3939extern int ext4_balloc_free_block(ext4_filesystem_t *,
  • uspace/lib/ext4/libext4_block_group.h

    ra872fc09 rb53a733  
    3636#include <libblock.h>
    3737#include <sys/types.h>
    38 #include "libext4_block_group.h"
    39 #include "libext4_superblock.h"
    40 /*
    41  * Structure of a blocks group descriptor
    42  */
    43 typedef struct ext4_block_group {
    44         uint32_t block_bitmap_lo; // Blocks bitmap block
    45         uint32_t inode_bitmap_lo; // Inodes bitmap block
    46         uint32_t inode_table_first_block_lo; // Inodes table block
    47         uint16_t free_blocks_count_lo; // Free blocks count
    48         uint16_t free_inodes_count_lo; // Free inodes count
    49         uint16_t used_dirs_count_lo; // Directories count
    50         uint16_t flags; // EXT4_BG_flags (INODE_UNINIT, etc)
    51         uint32_t reserved[2]; // Likely block/inode bitmap checksum
    52         uint16_t itable_unused_lo; // Unused inodes count
    53         uint16_t checksum; // crc16(sb_uuid+group+desc)
    54         /* -------------- */
    55         uint32_t block_bitmap_hi; // Blocks bitmap block MSB
    56         uint32_t inode_bitmap_hi; // Inodes bitmap block MSB
    57         uint32_t inode_table_first_block_hi; // Inodes table block MSB
    58         uint16_t free_blocks_count_hi; // Free blocks count MSB
    59         uint16_t free_inodes_count_hi; // Free inodes count MSB
    60         uint16_t used_dirs_count_hi; // Directories count MSB
    61         uint16_t itable_unused_hi;  // Unused inodes count MSB
    62         uint32_t reserved2[3]; // Padding
    63 } ext4_block_group_t;
    64 
    65 typedef struct ext4_block_group_ref {
    66         block_t *block; // Reference to a block containing this block group descr
    67         ext4_block_group_t *block_group;
    68         bool dirty;
    69 } ext4_block_group_ref_t;
    70 
    71 #define EXT4_BLOCK_MIN_GROUP_DESCRIPTOR_SIZE 32
    72 #define EXT4_BLOCK_MAX_GROUP_DESCRIPTOR_SIZE 64
     38#include "libext4_types.h"
    7339
    7440extern uint64_t ext4_block_group_get_block_bitmap(ext4_block_group_t *,
  • uspace/lib/ext4/libext4_directory.h

    ra872fc09 rb53a733  
    3434#define LIBEXT4_LIBEXT4_DIRECTORY_H_
    3535
    36 #include "libext4_filesystem.h"
    37 #include "libext4_inode.h"
    38 
    39 #define EXT4_DIRECTORY_FILENAME_LEN     255
    40 
    41 #define EXT4_DIRECTORY_FILETYPE_UNKNOWN         0
    42 #define EXT4_DIRECTORY_FILETYPE_REG_FILE        1
    43 #define EXT4_DIRECTORY_FILETYPE_DIR             2
    44 #define EXT4_DIRECTORY_FILETYPE_CHRDEV          3
    45 #define EXT4_DIRECTORY_FILETYPE_BLKDEV          4
    46 #define EXT4_DIRECTORY_FILETYPE_FIFO            5
    47 #define EXT4_DIRECTORY_FILETYPE_SOCK            6
    48 #define EXT4_DIRECTORY_FILETYPE_SYMLINK         7
    49 
    50 /**
    51  * Linked list directory entry structure
    52  */
    53 typedef struct ext4_directory_entry_ll {
    54         uint32_t inode; // Inode for the entry
    55         uint16_t entry_length; // Distance to the next directory entry
    56         uint8_t name_length; // Lower 8 bits of name length
    57         union {
    58                 uint8_t name_length_high; // Higher 8 bits of name length
    59                 uint8_t inode_type; // Type of referenced inode (in rev >= 0.5)
    60         } __attribute__ ((packed));
    61         uint8_t name[EXT4_DIRECTORY_FILENAME_LEN]; // Entry name
    62 } __attribute__ ((packed)) ext4_directory_entry_ll_t;
    63 
    64 typedef struct ext4_directory_iterator {
    65         ext4_filesystem_t *fs;
    66         ext4_inode_ref_t *inode_ref;
    67         block_t *current_block;
    68         aoff64_t current_offset;
    69         ext4_directory_entry_ll_t *current;
    70 } ext4_directory_iterator_t;
    71 
    72 typedef struct ext4_directory_search_result {
    73         block_t *block;
    74         ext4_directory_entry_ll_t *dentry;
    75 } ext4_directory_search_result_t;
     36#include "libext4_types.h"
    7637
    7738extern uint32_t ext4_directory_entry_ll_get_inode(ext4_directory_entry_ll_t *);
  • uspace/lib/ext4/libext4_directory_index.h

    ra872fc09 rb53a733  
    3434#define LIBEXT4_LIBEXT4_DIRECTORY_INDEX_H_
    3535
    36 /* Structures for indexed directory */
    37 
    38 typedef struct ext4_directory_dx_countlimit {
    39         uint16_t limit;
    40     uint16_t count;
    41 } ext4_directory_dx_countlimit_t;
    42 
    43 typedef struct ext4_directory_dx_dot_entry {
    44         uint32_t inode;
    45         uint16_t entry_length;
    46     uint8_t name_length;
    47     uint8_t inode_type;
    48     uint8_t name[4];
    49 } ext4_directory_dx_dot_entry_t;
    50 
    51 typedef struct ext4_directory_dx_root_info {
    52         uint32_t reserved_zero;
    53         uint8_t hash_version;
    54         uint8_t info_length;
    55         uint8_t indirect_levels;
    56         uint8_t unused_flags;
    57 } ext4_directory_dx_root_info_t;
    58 
    59 typedef struct ext4_directory_dx_entry {
    60         uint32_t hash;
    61         uint32_t block;
    62 } ext4_directory_dx_entry_t;
    63 
    64 typedef struct ext4_directory_dx_root {
    65                 ext4_directory_dx_dot_entry_t dots[2];
    66                 ext4_directory_dx_root_info_t info;
    67                 ext4_directory_dx_entry_t entries[0];
    68 } ext4_directory_dx_root_t;
    69 
    70 typedef struct ext4_fake_directory_entry {
    71         uint32_t inode;
    72         uint16_t entry_length;
    73         uint8_t name_length;
    74         uint8_t inode_type;
    75 } ext4_fake_directory_entry_t;
    76 
    77 typedef struct ext4_directory_dx_node {
    78         ext4_fake_directory_entry_t fake;
    79         ext4_directory_dx_entry_t entries[0];
    80 } ext4_directory_dx_node_t;
    81 
    82 
    83 typedef struct ext4_directory_dx_block {
    84         block_t *block;
    85         ext4_directory_dx_entry_t *entries;
    86         ext4_directory_dx_entry_t *position;
    87 } ext4_directory_dx_block_t;
    88 
    89 
    90 
    91 #define EXT4_ERR_BAD_DX_DIR                     (-75000)
    92 #define EXT4_DIRECTORY_HTREE_EOF        (uint32_t)0x7fffffff
    93 
     36#include "libext4_types.h"
    9437
    9538extern uint8_t ext4_directory_dx_root_info_get_hash_version(
  • uspace/lib/ext4/libext4_extent.h

    ra872fc09 rb53a733  
    3434#define LIBEXT4_LIBEXT4_EXTENT_H_
    3535
    36 /*
    37  * This is the extent on-disk structure.
    38  * It's used at the bottom of the tree.
    39  */
    40 typedef struct ext4_extent {
    41         uint32_t first_block; // First logical block extent covers
    42         uint16_t block_count; // Number of blocks covered by extent
    43         uint16_t start_hi;    // High 16 bits of physical block
    44         uint32_t start_lo;    // Low 32 bits of physical block
    45 } ext4_extent_t;
    46 
    47 /*
    48  * This is index on-disk structure.
    49  * It's used at all the levels except the bottom.
    50  */
    51 typedef struct ext4_extent_index {
    52         uint32_t first_block; // Index covers logical blocks from 'block'
    53         uint32_t leaf_lo; /* Pointer to the physical block of the next
    54                                            * level. leaf or next index could be there */
    55         uint16_t leaf_hi;     /* high 16 bits of physical block */
    56         uint16_t padding;
    57 } ext4_extent_index_t;
    58 
    59 /*
    60  * Each block (leaves and indexes), even inode-stored has header.
    61  */
    62 typedef struct ext4_extent_header {
    63         uint16_t magic;
    64         uint16_t entries_count; // Number of valid entries
    65         uint16_t max_entries_count; // Capacity of store in entries
    66         uint16_t depth; // Has tree real underlying blocks?
    67         uint32_t generation; // generation of the tree
    68 } ext4_extent_header_t;
    69 
    70 #define EXT4_EXTENT_MAGIC       0xF30A
    71 #define EXT4_EXTENT_FIRST(header)       \
    72                 ((ext4_extent_t *) (((void *) (header)) + sizeof(ext4_extent_header_t)))
    73 #define EXT4_EXTENT_FIRST_INDEX(header) \
    74                 ((ext4_extent_index_t *) (((void *) (header)) + sizeof(ext4_extent_header_t)))
     36#include "libext4_types.h"
    7537
    7638extern uint32_t ext4_extent_get_first_block(ext4_extent_t *);
  • uspace/lib/ext4/libext4_filesystem.h

    ra872fc09 rb53a733  
    3535
    3636#include <libblock.h>
    37 #include "libext4_block_group.h"
    38 #include "libext4_inode.h"
    39 #include "libext4_superblock.h"
    40 
    41 typedef struct ext4_filesystem {
    42         service_id_t device;
    43         ext4_superblock_t *     superblock;
    44         aoff64_t inode_block_limits[4];
    45         aoff64_t inode_blocks_per_level[4];
    46 } ext4_filesystem_t;
    47 
    48 #define EXT4_MIN_BLOCK_SIZE             1024  //1 KiB
    49 #define EXT4_MAX_BLOCK_SIZE     65536 //64 KiB
    50 #define EXT4_REV0_INODE_SIZE    128
    51 
     37#include "libext4_types.h"
    5238
    5339extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t);
  • uspace/lib/ext4/libext4_hash.h

    ra872fc09 rb53a733  
    3535
    3636#include <sys/types.h>
    37 
    38 #define EXT4_HASH_VERSION_LEGACY                        0
    39 #define EXT4_HASH_VERSION_HALF_MD4                      1
    40 #define EXT4_HASH_VERSION_TEA                           2
    41 #define EXT4_HASH_VERSION_LEGACY_UNSIGNED       3
    42 #define EXT4_HASH_VERSION_HALF_MD4_UNSIGNED     4
    43 #define EXT4_HASH_VERSION_TEA_UNSIGNED          5
    44 
    45 typedef struct ext4_hash_info {
    46         uint32_t hash;
    47         uint32_t minor_hash;
    48         uint32_t hash_version;
    49         uint32_t *seed;
    50 } ext4_hash_info_t;
     37#include "libext4_types.h"
    5138
    5239extern int ext4_hash_string(ext4_hash_info_t *, int, const char *);
  • uspace/lib/ext4/libext4_ialloc.h

    ra872fc09 rb53a733  
    3434#define LIBEXT4_LIBEXT4_IALLOC_H_
    3535
    36 #include "libext4_filesystem.h"
    37 #include "libext4_inode.h"
     36#include "libext4_types.h"
    3837
    3938extern int ext4_ialloc_free_inode(ext4_filesystem_t *, uint32_t, bool);
  • uspace/lib/ext4/libext4_inode.h

    ra872fc09 rb53a733  
    3636#include <libblock.h>
    3737#include <sys/types.h>
    38 #include "libext4_extent.h"
    39 #include "libext4_superblock.h"
    40 
    41 #define EXT4_INODE_BLOCK_SIZE                           512
    42 
    43 #define EXT4_INODE_DIRECT_BLOCK_COUNT           12
    44 #define EXT4_INODE_INDIRECT_BLOCK                       EXT4_INODE_DIRECT_BLOCK_COUNT
    45 #define EXT4_INODE_DOUBLE_INDIRECT_BLOCK        (EXT4_INODE_INDIRECT_BLOCK + 1)
    46 #define EXT4_INODE_TRIPPLE_INDIRECT_BLOCK       (EXT4_INODE_DOUBLE_INDIRECT_BLOCK + 1)
    47 #define EXT4_INODE_BLOCKS                                       (EXT4_INODE_TRIPPLE_INDIRECT_BLOCK + 1)
    48 #define EXT4_INODE_INDIRECT_BLOCK_COUNT         (EXT4_INODE_BLOCKS - EXT4_INODE_DIRECT_BLOCK_COUNT)
    49 
    50 /*
    51  * Structure of an inode on the disk
    52  */
    53 typedef struct ext4_inode {
    54         uint16_t mode; // File mode
    55         uint16_t uid; // Low 16 bits of owner uid
    56         uint32_t size_lo; // Size in bytes
    57         uint32_t access_time; // Access time
    58         uint32_t change_inode_time; // Inode change time
    59         uint32_t modification_time; // Modification time
    60         uint32_t deletion_time; // Deletion time
    61         uint16_t gid; // Low 16 bits of group id
    62         uint16_t links_count; // Links count
    63         uint32_t blocks_count_lo; // Blocks count
    64         uint32_t flags; // File flags
    65         uint32_t unused_osd1; // OS dependent - not used in HelenOS
    66     uint32_t blocks[EXT4_INODE_BLOCKS]; // Pointers to blocks
    67     uint32_t generation; // File version (for NFS)
    68     uint32_t file_acl_lo; // File ACL
    69     uint32_t size_hi;
    70     uint32_t obso_faddr; // Obsoleted fragment address
    71     union {
    72         struct {
    73                 uint16_t blocks_high; /* were l_i_reserved1 */
    74                 uint16_t file_acl_high;
    75                 uint16_t uid_high;   /* these 2 fields */
    76                 uint16_t gid_high;   /* were reserved2[0] */
    77                 uint32_t reserved2;
    78         } linux2;
    79         struct {
    80                 uint16_t reserved1;  /* Obsoleted fragment number/size which are removed in ext4 */
    81                 uint16_t mode_high;
    82                 uint16_t uid_high;
    83                 uint16_t gid_high;
    84                 uint32_t author;
    85         } hurd2;
    86     } __attribute__ ((packed)) osd2;
    87 
    88     uint16_t extra_isize;
    89     uint16_t pad1;
    90     uint32_t ctime_extra; // Extra change time (nsec << 2 | epoch)
    91     uint32_t mtime_extra; // Extra Modification time (nsec << 2 | epoch)
    92     uint32_t atime_extra; // Extra Access time (nsec << 2 | epoch)
    93     uint32_t crtime; // File creation time
    94     uint32_t crtime_extra; // Extra file creation time (nsec << 2 | epoch)
    95     uint32_t version_hi;   // High 32 bits for 64-bit version
    96 } __attribute__ ((packed)) ext4_inode_t;
    97 
    98 #define EXT4_INODE_MODE_FIFO            0x1000
    99 #define EXT4_INODE_MODE_CHARDEV         0x2000
    100 #define EXT4_INODE_MODE_DIRECTORY       0x4000
    101 #define EXT4_INODE_MODE_BLOCKDEV        0x6000
    102 #define EXT4_INODE_MODE_FILE            0x8000
    103 #define EXT4_INODE_MODE_SOFTLINK        0xA000
    104 #define EXT4_INODE_MODE_SOCKET          0xC000
    105 #define EXT4_INODE_MODE_TYPE_MASK       0xF000
    106 
    107 /*
    108  * Inode flags
    109  */
    110 #define EXT4_INODE_FLAG_SECRM           0x00000001 // Secure deletion
    111 #define EXT4_INODE_FLAG_UNRM            0x00000002 // Undelete
    112 #define EXT4_INODE_FLAG_COMPR           0x00000004 // Compress file
    113 #define EXT4_INODE_FLAG_SYNC            0x00000008 // Synchronous updates
    114 #define EXT4_INODE_FLAG_IMMUTABLE   0x00000010 // Immutable file
    115 #define EXT4_INODE_FLAG_APPEND          0x00000020 // writes to file may only append
    116 #define EXT4_INODE_FLAG_NODUMP          0x00000040 // do not dump file
    117 #define EXT4_INODE_FLAG_NOATIME         0x00000080 // do not update atime
    118 /* Compression flags */
    119 #define EXT4_INODE_FLAG_DIRTY           0x00000100
    120 #define EXT4_INODE_FLAG_COMPRBLK        0x00000200 // One or more compressed clusters
    121 #define EXT4_INODE_FLAG_NOCOMPR         0x00000400 // Don't compress
    122 #define EXT4_INODE_FLAG_ECOMPR          0x00000800 // Compression error
    123 /* End compression flags --- maybe not all used */
    124 #define EXT4_INODE_FLAG_INDEX           0x00001000 // hash-indexed directory
    125 #define EXT4_INODE_FLAG_IMAGIC          0x00002000 // AFS directory */
    126 #define EXT4_INODE_FLAG_JOURNAL_DATA    0x00004000 // File data should be journaled
    127 #define EXT4_INODE_FLAG_NOTAIL          0x00008000 // File tail should not be merged
    128 #define EXT4_INODE_FLAG_DIRSYNC         0x00010000 // Dirsync behaviour (directories only)
    129 #define EXT4_INODE_FLAG_TOPDIR          0x00020000 // Top of directory hierarchies
    130 #define EXT4_INODE_FLAG_HUGE_FILE       0x00040000 // Set to each huge file
    131 #define EXT4_INODE_FLAG_EXTENTS         0x00080000 // Inode uses extents
    132 #define EXT4_INODE_FLAG_EA_INODE        0x00200000 // Inode used for large EA
    133 #define EXT4_INODE_FLAG_EOFBLOCKS       0x00400000 // Blocks allocated beyond EOF
    134 #define EXT4_INODE_FLAG_RESERVED        0x80000000 // reserved for ext4 lib
    135 
    136 #define EXT4_INODE_ROOT_INDEX   2
    137 
    138 typedef struct ext4_inode_ref {
    139         block_t *block; // Reference to a block containing this inode
    140         ext4_inode_t *inode;
    141         uint32_t index; // Index number of this inode
    142         bool dirty;
    143 } ext4_inode_ref_t;
    144 
     38#include "libext4_types.h"
    14539
    14640extern uint32_t ext4_inode_get_mode(ext4_superblock_t *, ext4_inode_t *);
  • uspace/lib/ext4/libext4_superblock.h

    ra872fc09 rb53a733  
    3737#include <sys/types.h>
    3838
    39 /*
    40  * Structure of the super block
    41  */
    42 typedef struct ext4_superblock {
    43         uint32_t inodes_count; // Inodes count
    44         uint32_t blocks_count_lo; // Blocks count
    45         uint32_t reserved_blocks_count_lo; // Reserved blocks count
    46         uint32_t free_blocks_count_lo; // Free blocks count
    47         uint32_t free_inodes_count; // Free inodes count
    48         uint32_t first_data_block; // First Data Block
    49         uint32_t log_block_size; // Block size
    50         uint32_t obso_log_frag_size; // Obsoleted fragment size
    51         uint32_t blocks_per_group; // Number of blocks per group
    52         uint32_t obso_frags_per_group; // Obsoleted fragments per group
    53         uint32_t inodes_per_group; // Number of inodes per group
    54         uint32_t mount_time; // Mount time
    55         uint32_t write_time; // Write time
    56         uint16_t mount_count; // Mount count
    57         uint16_t max_mount_count; // Maximal mount count
    58         uint16_t magic; // Magic signature
    59         uint16_t state; // File system state
    60         uint16_t errors; // Behaviour when detecting errors
    61         uint16_t minor_rev_level; // Minor revision level
    62         uint32_t last_check_time; // Time of last check
    63         uint32_t check_interval; // Maximum time between checks
    64         uint32_t creator_os; // Creator OS
    65         uint32_t rev_level; // Revision level
    66         uint16_t def_resuid; // Default uid for reserved blocks
    67         uint16_t def_resgid; // Default gid for reserved blocks
    68 
    69         // Fields for EXT4_DYNAMIC_REV superblocks only.
    70         uint32_t first_inode; // First non-reserved inode
    71         uint16_t inode_size; // Size of inode structure
    72         uint16_t block_group_number; // Block group number of this superblock
    73         uint32_t features_compatible; // Compatible feature set
    74         uint32_t features_incompatible; // Incompatible feature set
    75         uint32_t features_read_only; // Readonly-compatible feature set
    76         uint8_t uuid[16]; // 128-bit uuid for volume
    77         char volume_name[16]; // Volume name
    78         char last_mounted[64]; // Directory where last mounted
    79         uint32_t algorithm_usage_bitmap; // For compression
    80 
    81         /*
    82          * Performance hints. Directory preallocation should only
    83          * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
    84          */
    85         uint8_t s_prealloc_blocks; // Number of blocks to try to preallocate
    86         uint8_t s_prealloc_dir_blocks; // Number to preallocate for dirs
    87         uint16_t s_reserved_gdt_blocks; // Per group desc for online growth
    88 
    89         /*
    90          * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
    91          */
    92         uint8_t journal_uuid[16]; // UUID of journal superblock
    93         uint32_t journal_inode_number; // Inode number of journal file
    94         uint32_t journal_dev; // Device number of journal file
    95         uint32_t last_orphan; // Head of list of inodes to delete
    96         uint32_t hash_seed[4]; // HTREE hash seed
    97         uint8_t default_hash_version; // Default hash version to use
    98         uint8_t journal_backup_type;
    99         uint16_t desc_size; // Size of group descriptor
    100         uint32_t default_mount_opts; // Default mount options
    101         uint32_t first_meta_bg; // First metablock block group
    102         uint32_t mkfs_time; // When the filesystem was created
    103         uint32_t journal_blocks[17]; // Backup of the journal inode
    104 
    105         /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
    106         uint32_t blocks_count_hi; // Blocks count
    107         uint32_t reserved_blocks_count_hi; // Reserved blocks count
    108         uint32_t free_blocks_count_hi; // Free blocks count
    109         uint16_t min_extra_isize; // All inodes have at least # bytes
    110         uint16_t want_extra_isize; // New inodes should reserve # bytes
    111         uint32_t flags; // Miscellaneous flags
    112         uint16_t raid_stride; // RAID stride
    113         uint16_t mmp_interval; // # seconds to wait in MMP checking
    114         uint64_t mmp_block; // Block for multi-mount protection
    115         uint32_t raid_stripe_width; // blocks on all data disks (N*stride)
    116         uint8_t log_groups_per_flex; // FLEX_BG group size
    117         uint8_t reserved_char_pad;
    118         uint16_t reserved_pad;
    119         uint64_t kbytes_written; // Number of lifetime kilobytes written
    120         uint32_t snapshot_inum; // Inode number of active snapshot
    121         uint32_t snapshot_id; // Sequential ID of active snapshot
    122         uint64_t snapshot_r_blocks_count; /* reserved blocks for active snapshot's future use */
    123         uint32_t snapshot_list; // inode number of the head of the on-disk snapshot list
    124         uint32_t error_count; // number of fs errors
    125         uint32_t first_error_time; // First time an error happened
    126         uint32_t first_error_ino; // Inode involved in first error
    127         uint64_t first_error_block; // block involved of first error
    128         uint8_t first_error_func[32]; // Function where the error happened
    129         uint32_t first_error_line; // Line number where error happened
    130         uint32_t last_error_time; // Most recent time of an error
    131         uint32_t last_error_ino; // Inode involved in last error
    132         uint32_t last_error_line; // Line number where error happened
    133         uint64_t last_error_block;     // Block involved of last error
    134         uint8_t last_error_func[32];  // Function where the error happened
    135         uint8_t mount_opts[64];
    136         uint32_t padding[112]; // Padding to the end of the block
    137 } __attribute__((packed)) ext4_superblock_t;
    138 
    139 #define EXT4_SUPERBLOCK_MAGIC           0xEF53
    140 #define EXT4_SUPERBLOCK_SIZE            1024
    141 #define EXT4_SUPERBLOCK_OFFSET          1024
    142 
    143 #define EXT4_SUPERBLOCK_OS_LINUX        0
    144 #define EXT4_SUPERBLOCK_OS_HURD         1
    145 
    146 /*
    147  * Misc. filesystem flags
    148  */
    149 #define EXT4_SUPERBLOCK_FLAGS_SIGNED_HASH       0x0001  /* Signed dirhash in use */
    150 #define EXT4_SUPERBLOCK_FLAGS_UNSIGNED_HASH     0x0002  /* Unsigned dirhash in use */
    151 #define EXT4_SUPERBLOCK_FLAGS_TEST_FILESYS      0x0004  /* to test development code */
    152 
    153 /* Compatible features */
    154 #define EXT4_FEATURE_COMPAT_DIR_PREALLOC        0x0001
    155 #define EXT4_FEATURE_COMPAT_IMAGIC_INODES       0x0002
    156 #define EXT4_FEATURE_COMPAT_HAS_JOURNAL         0x0004
    157 #define EXT4_FEATURE_COMPAT_EXT_ATTR            0x0008
    158 #define EXT4_FEATURE_COMPAT_RESIZE_INODE        0x0010
    159 #define EXT4_FEATURE_COMPAT_DIR_INDEX           0x0020
    160 
    161 /* Read-only compatible features */
    162 #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER     0x0001
    163 #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE       0x0002
    164 #define EXT4_FEATURE_RO_COMPAT_BTREE_DIR        0x0004
    165 #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE        0x0008
    166 #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM         0x0010
    167 #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK        0x0020
    168 #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE      0x0040
    169 
    170 /* Incompatible features */
    171 #define EXT4_FEATURE_INCOMPAT_COMPRESSION       0x0001
    172 #define EXT4_FEATURE_INCOMPAT_FILETYPE          0x0002
    173 #define EXT4_FEATURE_INCOMPAT_RECOVER           0x0004 /* Needs recovery */
    174 #define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV       0x0008 /* Journal device */
    175 #define EXT4_FEATURE_INCOMPAT_META_BG           0x0010
    176 #define EXT4_FEATURE_INCOMPAT_EXTENTS           0x0040 /* extents support */
    177 #define EXT4_FEATURE_INCOMPAT_64BIT             0x0080
    178 #define EXT4_FEATURE_INCOMPAT_MMP               0x0100
    179 #define EXT4_FEATURE_INCOMPAT_FLEX_BG           0x0200
    180 #define EXT4_FEATURE_INCOMPAT_EA_INODE          0x0400 /* EA in inode */
    181 #define EXT4_FEATURE_INCOMPAT_DIRDATA           0x1000 /* data in dirent */
    182 
    183 // TODO MODIFY features corresponding with implementation
    184 #define EXT4_FEATURE_COMPAT_SUPP                (EXT4_FEATURE_COMPAT_DIR_INDEX)
    185 
    186 #define EXT4_FEATURE_INCOMPAT_SUPP      (EXT4_FEATURE_INCOMPAT_FILETYPE| \
    187                                          EXT4_FEATURE_INCOMPAT_EXTENTS| \
    188                                          EXT4_FEATURE_INCOMPAT_64BIT)
    189 
    190 #define EXT4_FEATURE_RO_COMPAT_SUPP     (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER | \
    191                                                                                  EXT4_FEATURE_RO_COMPAT_DIR_NLINK)
    192 
    193 
     39#include "libext4_types.h"
    19440
    19541extern uint32_t ext4_superblock_get_inodes_count(ext4_superblock_t *);
Note: See TracChangeset for help on using the changeset viewer.