[eb91db7] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Frantisek Princ
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup libext4
|
---|
| 30 | * @{
|
---|
[9875711] | 31 | */
|
---|
[eb91db7] | 32 |
|
---|
| 33 | #ifndef LIBEXT4_LIBEXT4_SUPERBLOCK_H_
|
---|
| 34 | #define LIBEXT4_LIBEXT4_SUPERBLOCK_H_
|
---|
| 35 |
|
---|
[01ab41b] | 36 | #include <libblock.h>
|
---|
[9875711] | 37 | #include <sys/types.h>
|
---|
| 38 |
|
---|
| 39 | /*
|
---|
| 40 | * Structure of the super block
|
---|
| 41 | */
|
---|
| 42 | typedef struct ext4_superblock {
|
---|
[9c0c0e1] | 43 | uint32_t inodes_count; // Inodes count
|
---|
[3712434] | 44 | uint32_t blocks_count_lo; // Blocks count
|
---|
| 45 | uint32_t reserved_blocks_count_lo; // Reserved blocks count
|
---|
[9c0c0e1] | 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
|
---|
[3712434] | 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
|
---|
[3711e7e] | 53 | uint32_t inodes_per_group; // Number of inodes per group
|
---|
[3712434] | 54 | uint32_t mount_time; // Mount time
|
---|
| 55 | uint32_t write_time; // Write time
|
---|
[9c0c0e1] | 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
|
---|
[3712434] | 62 | uint32_t last_check_time; // Time of last check
|
---|
| 63 | uint32_t check_interval; // Maximum time between checks
|
---|
[9c0c0e1] | 64 | uint32_t creator_os; // Creator OS
|
---|
| 65 | uint32_t rev_level; // Revision level
|
---|
[3712434] | 66 | uint16_t def_resuid; // Default uid for reserved blocks
|
---|
| 67 | uint16_t def_resgid; // Default gid for reserved blocks
|
---|
[9875711] | 68 |
|
---|
| 69 | // Fields for EXT4_DYNAMIC_REV superblocks only.
|
---|
[3712434] | 70 | uint32_t first_inode; // First non-reserved inode
|
---|
[3711e7e] | 71 | uint16_t inode_size; // Size of inode structure
|
---|
[3712434] | 72 | uint16_t block_group_number; // Block group number of this superblock
|
---|
[9c0c0e1] | 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
|
---|
[3712434] | 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
|
---|
[9875711] | 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 | */
|
---|
[3712434] | 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
|
---|
[9875711] | 104 |
|
---|
| 105 | /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
|
---|
[3712434] | 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
|
---|
[7bc4508] | 111 | uint32_t flags; // Miscellaneous flags
|
---|
[3712434] | 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
|
---|
[9875711] | 137 | } __attribute__((packed)) ext4_superblock_t;
|
---|
| 138 |
|
---|
[01ab41b] | 139 | #define EXT4_SUPERBLOCK_MAGIC 0xEF53
|
---|
| 140 | #define EXT4_SUPERBLOCK_SIZE 1024
|
---|
| 141 | #define EXT4_SUPERBLOCK_OFFSET 1024
|
---|
| 142 |
|
---|
[9b9d37bb] | 143 | #define EXT4_SUPERBLOCK_OS_LINUX 0
|
---|
| 144 | #define EXT4_SUPERBLOCK_OS_HURD 1
|
---|
| 145 |
|
---|
[7bc4508] | 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 |
|
---|
[c25e39b] | 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
|
---|
[cd00f93] | 184 | #define EXT4_FEATURE_COMPAT_SUPP (EXT4_FEATURE_COMPAT_DIR_INDEX)
|
---|
[c25e39b] | 185 |
|
---|
| 186 | #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
|
---|
| 187 | EXT4_FEATURE_INCOMPAT_EXTENTS| \
|
---|
[cd00f93] | 188 | EXT4_FEATURE_INCOMPAT_64BIT)
|
---|
| 189 |
|
---|
| 190 | #define EXT4_FEATURE_RO_COMPAT_SUPP ()
|
---|
[c25e39b] | 191 |
|
---|
| 192 |
|
---|
[7bc4508] | 193 |
|
---|
[3712434] | 194 | extern uint32_t ext4_superblock_get_inodes_count(ext4_superblock_t *);
|
---|
[fe27eb4] | 195 | extern void ext4_superblock_set_inodes_count(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 196 | extern uint64_t ext4_superblock_get_blocks_count(ext4_superblock_t *);
|
---|
[fe27eb4] | 197 | extern void ext4_superblock_set_blocks_count(ext4_superblock_t *, uint64_t);
|
---|
[3712434] | 198 | extern uint64_t ext4_superblock_get_reserved_blocks_count(ext4_superblock_t *);
|
---|
[fe27eb4] | 199 | extern void ext4_superblock_set_reserved_blocks_count(ext4_superblock_t *, uint64_t);
|
---|
[3712434] | 200 | extern uint64_t ext4_superblock_get_free_blocks_count(ext4_superblock_t *);
|
---|
[ae3d4f8] | 201 | extern void ext4_superblock_set_free_blocks_count(ext4_superblock_t *, uint64_t);
|
---|
[3712434] | 202 | extern uint32_t ext4_superblock_get_free_inodes_count(ext4_superblock_t *);
|
---|
[fe27eb4] | 203 | extern void ext4_superblock_set_free_inodes_count(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 204 | extern uint32_t ext4_superblock_get_first_data_block(ext4_superblock_t *);
|
---|
[fe27eb4] | 205 | extern void ext4_superblock_set_first_data_block(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 206 | extern uint32_t ext4_superblock_get_log_block_size(ext4_superblock_t *);
|
---|
[fe27eb4] | 207 | extern void ext4_superblock_set_log_block_size(ext4_superblock_t *, uint32_t);
|
---|
[01ab41b] | 208 | extern uint32_t ext4_superblock_get_block_size(ext4_superblock_t *);
|
---|
[fe27eb4] | 209 | extern void ext4_superblock_set_block_size(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 210 | extern uint32_t ext4_superblock_get_blocks_per_group(ext4_superblock_t *);
|
---|
[fe27eb4] | 211 | extern void ext4_superblock_set_blocks_per_group(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 212 | extern uint32_t ext4_superblock_get_inodes_per_group(ext4_superblock_t *);
|
---|
[fe27eb4] | 213 | extern void ext4_superblock_set_inodes_per_group(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 214 | extern uint32_t ext4_superblock_get_mount_time(ext4_superblock_t *);
|
---|
[fe27eb4] | 215 | extern void ext4_superblock_set_mount_time(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 216 | extern uint32_t ext4_superblock_get_write_time(ext4_superblock_t *);
|
---|
[fe27eb4] | 217 | extern void ext4_superblock_set_write_time(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 218 | extern uint16_t ext4_superblock_get_mount_count(ext4_superblock_t *);
|
---|
[fe27eb4] | 219 | extern void ext4_superblock_set_mount_count(ext4_superblock_t *, uint16_t);
|
---|
[3712434] | 220 | extern uint16_t ext4_superblock_get_max_mount_count(ext4_superblock_t *);
|
---|
[fe27eb4] | 221 | extern void ext4_superblock_set_max_mount_count(ext4_superblock_t *, uint16_t);
|
---|
[3712434] | 222 | extern uint16_t ext4_superblock_get_magic(ext4_superblock_t *);
|
---|
| 223 | extern uint16_t ext4_superblock_get_state(ext4_superblock_t *);
|
---|
[fe27eb4] | 224 | extern void ext4_superblock_set_state(ext4_superblock_t *, uint16_t);
|
---|
[3712434] | 225 | extern uint16_t ext4_superblock_get_errors(ext4_superblock_t *);
|
---|
[fe27eb4] | 226 | extern void ext4_superblock_set_errors(ext4_superblock_t *, uint16_t);
|
---|
[3712434] | 227 | extern uint16_t ext4_superblock_get_minor_rev_level(ext4_superblock_t *);
|
---|
[fe27eb4] | 228 | extern void ext4_superblock_set_minor_rev_level(ext4_superblock_t *, uint16_t);
|
---|
[3712434] | 229 | extern uint32_t ext4_superblock_get_last_check_time(ext4_superblock_t *);
|
---|
[fe27eb4] | 230 | extern void ext4_superblock_set_last_check_time(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 231 | extern uint32_t ext4_superblock_get_check_interval(ext4_superblock_t *);
|
---|
[fe27eb4] | 232 | extern void ext4_superblock_set_check_interval(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 233 | extern uint32_t ext4_superblock_get_creator_os(ext4_superblock_t *);
|
---|
[fe27eb4] | 234 | extern void ext4_superblock_set_creator_os(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 235 | extern uint32_t ext4_superblock_get_rev_level(ext4_superblock_t *);
|
---|
[fe27eb4] | 236 | extern void ext4_superblock_set_rev_level(ext4_superblock_t *, uint32_t);
|
---|
| 237 | extern uint16_t ext4_superblock_get_def_resuid(ext4_superblock_t *);
|
---|
| 238 | extern void ext4_superblock_set_def_resuid(ext4_superblock_t *, uint16_t);
|
---|
| 239 | extern uint16_t ext4_superblock_get_def_resgid(ext4_superblock_t *);
|
---|
| 240 | extern void ext4_superblock_set_def_resgid(ext4_superblock_t *, uint16_t);
|
---|
[3712434] | 241 | extern uint32_t ext4_superblock_get_first_inode(ext4_superblock_t *);
|
---|
[fe27eb4] | 242 | extern void ext4_superblock_set_first_inode(ext4_superblock_t *, uint32_t);
|
---|
[3712434] | 243 | extern uint16_t ext4_superblock_get_inode_size(ext4_superblock_t *);
|
---|
[fe27eb4] | 244 | extern void ext4_superblock_set_inode_size(ext4_superblock_t *, uint16_t);
|
---|
[3712434] | 245 | extern uint16_t ext4_superblock_get_block_group_number(ext4_superblock_t *);
|
---|
[fe27eb4] | 246 | extern void ext4_superblock_set_block_group_number(ext4_superblock_t *, uint16_t);
|
---|
[9c0c0e1] | 247 | extern uint32_t ext4_superblock_get_features_compatible(ext4_superblock_t *);
|
---|
[fe27eb4] | 248 | extern void ext4_superblock_set_features_compatible(ext4_superblock_t *, uint32_t);
|
---|
[9c0c0e1] | 249 | extern uint32_t ext4_superblock_get_features_incompatible(ext4_superblock_t *);
|
---|
[fe27eb4] | 250 | extern void ext4_superblock_set_features_incompatible(ext4_superblock_t *, uint32_t);
|
---|
[9c0c0e1] | 251 | extern uint32_t ext4_superblock_get_features_read_only(ext4_superblock_t *);
|
---|
[fe27eb4] | 252 | extern void ext4_superblock_set_features_read_only(ext4_superblock_t *, uint32_t);
|
---|
[01ab41b] | 253 |
|
---|
[3712434] | 254 | /*
|
---|
| 255 | uint8_t s_uuid[16]; // 128-bit uuid for volume
|
---|
| 256 | char volume_name[16]; // Volume name
|
---|
| 257 | char last_mounted[64]; // Directory where last mounted
|
---|
| 258 | uint32_t s_algorithm_usage_bitmap; // For compression
|
---|
| 259 | uint8_t s_prealloc_blocks; // Number of blocks to try to preallocate
|
---|
| 260 | uint8_t s_prealloc_dir_blocks; // Number to preallocate for dirs
|
---|
| 261 | uint16_t s_reserved_gdt_blocks; // Per group desc for online growth
|
---|
| 262 | uint8_t s_journal_uuid[16]; // UUID of journal superblock
|
---|
| 263 | uint32_t s_journal_inum; // Inode number of journal file
|
---|
| 264 | uint32_t s_journal_dev; // Device number of journal file
|
---|
[7bc4508] | 265 | */
|
---|
[ebcaff4] | 266 | extern uint32_t ext4_superblock_get_last_orphan(ext4_superblock_t *);
|
---|
| 267 | extern void ext4_superblock_set_last_orphan(ext4_superblock_t *, uint32_t);
|
---|
[7bc4508] | 268 | extern uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *);
|
---|
| 269 | /*
|
---|
[3712434] | 270 | uint8_t s_def_hash_version; // Default hash version to use
|
---|
| 271 | uint8_t s_jnl_backup_type;
|
---|
[c25e39b] | 272 | */
|
---|
| 273 |
|
---|
| 274 | extern uint16_t ext4_superblock_get_desc_size(ext4_superblock_t *);
|
---|
[fe27eb4] | 275 | extern void ext4_superblock_set_desc_size(ext4_superblock_t *, uint16_t);
|
---|
[c25e39b] | 276 |
|
---|
| 277 | /*
|
---|
[3712434] | 278 | uint32_t s_default_mount_opts; // Default mount options
|
---|
| 279 | uint32_t s_first_meta_bg; // First metablock block group
|
---|
| 280 | uint32_t s_mkfs_time; // When the filesystem was created
|
---|
| 281 | uint32_t s_jnl_blocks[17]; // Backup of the journal inode
|
---|
| 282 | uint16_t s_min_extra_isize; // All inodes have at least # bytes
|
---|
| 283 | uint16_t s_want_extra_isize; // New inodes should reserve # bytes
|
---|
[7bc4508] | 284 | */
|
---|
| 285 | extern uint32_t ext4_superblock_get_flags(ext4_superblock_t *);
|
---|
[fe27eb4] | 286 | extern void ext4_superblock_set_flags(ext4_superblock_t *, uint32_t);
|
---|
[7bc4508] | 287 | /*
|
---|
[3712434] | 288 | uint16_t s_raid_stride; // RAID stride
|
---|
| 289 | uint16_t s_mmp_interval; // # seconds to wait in MMP checking
|
---|
| 290 | uint64_t s_mmp_block; // Block for multi-mount protection
|
---|
| 291 | uint32_t s_raid_stripe_width; // blocks on all data disks (N*stride)
|
---|
| 292 | uint8_t s_log_groups_per_flex; // FLEX_BG group size
|
---|
| 293 | uint8_t s_reserved_char_pad;
|
---|
| 294 | uint16_t s_reserved_pad;
|
---|
| 295 | uint64_t s_kbytes_written; // Number of lifetime kilobytes written
|
---|
| 296 | uint32_t s_snapshot_inum; // Inode number of active snapshot
|
---|
| 297 | uint32_t s_snapshot_id; // Sequential ID of active snapshot
|
---|
| 298 | uint64_t s_snapshot_r_blocks_count; // reserved blocks for active snapshot's future use
|
---|
| 299 | uint32_t s_snapshot_list; // inode number of the head of the on-disk snapshot list
|
---|
| 300 | uint32_t s_error_count; // number of fs errors
|
---|
| 301 | uint32_t s_first_error_time; // First time an error happened
|
---|
| 302 | uint32_t s_first_error_ino; // Inode involved in first error
|
---|
| 303 | uint64_t s_first_error_block; // block involved of first error
|
---|
| 304 | uint8_t s_first_error_func[32]; // Function where the error happened
|
---|
| 305 | uint32_t s_first_error_line; // Line number where error happened
|
---|
| 306 | uint32_t s_last_error_time; // Most recent time of an error
|
---|
| 307 | uint32_t s_last_error_ino; // Inode involved in last error
|
---|
| 308 | uint32_t s_last_error_line; // Line number where error happened
|
---|
| 309 | uint64_t s_last_error_block; // block involved of last error
|
---|
| 310 | uint8_t s_last_error_func[32]; // function where the error happened
|
---|
| 311 | uint8_t s_mount_opts[64];
|
---|
| 312 | */
|
---|
| 313 |
|
---|
| 314 | /* More complex superblock functions */
|
---|
[7bc4508] | 315 | extern bool ext4_superblock_has_flag(ext4_superblock_t *, uint32_t);
|
---|
[c25e39b] | 316 | extern bool ext4_superblock_has_feature_compatible(ext4_superblock_t *, uint32_t);
|
---|
| 317 | extern bool ext4_superblock_has_feature_incompatible(ext4_superblock_t *, uint32_t);
|
---|
| 318 | extern bool ext4_superblock_has_feature_read_only(ext4_superblock_t *, uint32_t);
|
---|
[01ab41b] | 319 | extern int ext4_superblock_read_direct(service_id_t, ext4_superblock_t **);
|
---|
[ae3d4f8] | 320 | extern int ext4_superblock_write_direct(service_id_t, ext4_superblock_t *);
|
---|
[01ab41b] | 321 | extern int ext4_superblock_check_sanity(ext4_superblock_t *);
|
---|
[eb91db7] | 322 |
|
---|
[b12ca16] | 323 | extern uint32_t ext4_superblock_get_block_group_count(ext4_superblock_t *);
|
---|
| 324 | extern uint32_t ext4_superblock_get_blocks_in_group(ext4_superblock_t *, uint32_t);
|
---|
| 325 | extern uint32_t ext4_superblock_get_inodes_in_group(ext4_superblock_t *, uint32_t);
|
---|
| 326 |
|
---|
[eb91db7] | 327 | #endif
|
---|
| 328 |
|
---|
| 329 | /**
|
---|
| 330 | * @}
|
---|
| 331 | */
|
---|