1/*- 2 * modified for EXT2FS support in Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 *
| 1/*- 2 * modified for EXT2FS support in Lites 1.1 3 * 4 * Aug 1995, Godmar Back (gback@cs.utah.edu) 5 * University of Utah, Department of Computer Science 6 *
|
7 * $FreeBSD: head/sys/fs/ext2fs/ext2fs.h 251562 2013-06-09 01:38:51Z pfg $
| 7 * $FreeBSD: head/sys/fs/ext2fs/ext2fs.h 251809 2013-06-16 16:10:45Z pfg $
|
8 */ 9/*- 10 * Copyright (c) 2009 Aditya Sarawgi 11 * All rights reserved. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * 35 */ 36 37#ifndef _FS_EXT2FS_EXT2FS_H_ 38#define _FS_EXT2FS_EXT2FS_H_ 39 40#include <sys/types.h> 41 42/* 43 * Maximal count of links to a file 44 */ 45#define EXT2_LINK_MAX 32000 46 47/*
| 8 */ 9/*- 10 * Copyright (c) 2009 Aditya Sarawgi 11 * All rights reserved. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * 35 */ 36 37#ifndef _FS_EXT2FS_EXT2FS_H_ 38#define _FS_EXT2FS_EXT2FS_H_ 39 40#include <sys/types.h> 41 42/* 43 * Maximal count of links to a file 44 */ 45#define EXT2_LINK_MAX 32000 46 47/*
|
48 * A summary of contiguous blocks of various sizes is maintained 49 * in each cylinder group. Normally this is set by the initial 50 * value of fs_maxcontig. 51 * 52 * XXX:FS_MAXCONTIG is set to 16 to conserve space. Here we set 53 * EXT2_MAXCONTIG to 32 for better performance. 54 */ 55#define EXT2_MAXCONTIG 32 56 57/* 58 * Constants relative to the data blocks 59 */ 60#define EXT2_NDIR_BLOCKS 12 61#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS 62#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) 63#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) 64#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) 65#define EXT2_MAXSYMLINKLEN (EXT2_N_BLOCKS * sizeof(uint32_t)) 66 67/*
| |
68 * The path name on which the file system is mounted is maintained 69 * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in 70 * the super block for this name. 71 */ 72#define MAXMNTLEN 512 73 74/* 75 * Super block for an ext2fs file system. 76 */ 77struct ext2fs { 78 uint32_t e2fs_icount; /* Inode count */ 79 uint32_t e2fs_bcount; /* blocks count */ 80 uint32_t e2fs_rbcount; /* reserved blocks count */ 81 uint32_t e2fs_fbcount; /* free blocks count */ 82 uint32_t e2fs_ficount; /* free inodes count */ 83 uint32_t e2fs_first_dblock; /* first data block */ 84 uint32_t e2fs_log_bsize; /* block size = 1024*(2^e2fs_log_bsize) */ 85 uint32_t e2fs_log_fsize; /* fragment size */ 86 uint32_t e2fs_bpg; /* blocks per group */ 87 uint32_t e2fs_fpg; /* frags per group */ 88 uint32_t e2fs_ipg; /* inodes per group */ 89 uint32_t e2fs_mtime; /* mount time */ 90 uint32_t e2fs_wtime; /* write time */ 91 uint16_t e2fs_mnt_count; /* mount count */ 92 uint16_t e2fs_max_mnt_count; /* max mount count */ 93 uint16_t e2fs_magic; /* magic number */ 94 uint16_t e2fs_state; /* file system state */ 95 uint16_t e2fs_beh; /* behavior on errors */ 96 uint16_t e2fs_minrev; /* minor revision level */ 97 uint32_t e2fs_lastfsck; /* time of last fsck */ 98 uint32_t e2fs_fsckintv; /* max time between fscks */ 99 uint32_t e2fs_creator; /* creator OS */ 100 uint32_t e2fs_rev; /* revision level */ 101 uint16_t e2fs_ruid; /* default uid for reserved blocks */ 102 uint16_t e2fs_rgid; /* default gid for reserved blocks */ 103 /* EXT2_DYNAMIC_REV superblocks */ 104 uint32_t e2fs_first_ino; /* first non-reserved inode */ 105 uint16_t e2fs_inode_size; /* size of inode structure */ 106 uint16_t e2fs_block_group_nr; /* block grp number of this sblk*/ 107 uint32_t e2fs_features_compat; /* compatible feature set */ 108 uint32_t e2fs_features_incompat; /* incompatible feature set */ 109 uint32_t e2fs_features_rocompat; /* RO-compatible feature set */ 110 uint8_t e2fs_uuid[16]; /* 128-bit uuid for volume */ 111 char e2fs_vname[16]; /* volume name */ 112 char e2fs_fsmnt[64]; /* name mounted on */ 113 uint32_t e2fs_algo; /* For compression */ 114 uint8_t e2fs_prealloc; /* # of blocks for old prealloc */ 115 uint8_t e2fs_dir_prealloc; /* # of blocks for old prealloc dirs */ 116 uint16_t e2fs_reserved_ngdb; /* # of reserved gd blocks for resize */ 117 char e3fs_journal_uuid[16]; /* uuid of journal superblock */ 118 uint32_t e3fs_journal_inum; /* inode number of journal file */ 119 uint32_t e3fs_journal_dev; /* device number of journal file */ 120 uint32_t e3fs_last_orphan; /* start of list of inodes to delete */ 121 uint32_t e3fs_hash_seed[4]; /* HTREE hash seed */ 122 char e3fs_def_hash_version; /* Default hash version to use */ 123 char e3fs_reserved_char_pad; 124 uint32_t e3fs_default_mount_opts; 125 uint32_t e3fs_first_meta_bg; /* First metablock block group */ 126 uint32_t e3fs_mkfs_time; /* when the fs was created */ 127 uint32_t e3fs_jnl_blks[17]; /* backup of the journal inode */ 128 uint32_t e4fs_bcount_hi; /* block count */ 129 uint32_t e4fs_rbcount_hi; /* reserved blocks count */ 130 uint32_t e4fs_fbcount_hi; /* free blocks count */ 131 uint16_t e4fs_min_extra_isize;/* all inodes have at least some bytes */ 132 uint16_t e4fs_want_extra_isize; /* inodes must reserve some bytes */ 133 uint32_t e4fs_flags; /* miscellaneous flags */ 134 uint16_t e4fs_raid_stride; /* RAID stride */ 135 uint16_t e4fs_mmpintv; /* number of seconds to wait in MMP checking */ 136 uint64_t e4fs_mmpblk; /* block for multi-mount protection */ 137 uint32_t e4fs_raid_stripe_wid;/* blocks on all data disks (N * stride) */ 138 uint8_t e4fs_log_gpf; /* FLEX_BG group size */ 139 uint8_t e4fs_char_pad2; 140 uint16_t e4fs_pad; 141 uint32_t reserved2[162]; /* Padding to the end of the block */ 142}; 143 144 145/* 146 * In-Memory Superblock 147 */ 148 149struct m_ext2fs { 150 struct ext2fs * e2fs; 151 char e2fs_fsmnt[MAXMNTLEN];/* name mounted on */ 152 char e2fs_ronly; /* mounted read-only flag */ 153 char e2fs_fmod; /* super block modified flag */ 154 uint32_t e2fs_bsize; /* Block size */ 155 uint32_t e2fs_bshift; /* calc of logical block no */ 156 uint32_t e2fs_bpg; /* Number of blocks per group */ 157 int64_t e2fs_qbmask; /* = s_blocksize -1 */ 158 uint32_t e2fs_fsbtodb; /* Shift to get disk block */ 159 uint32_t e2fs_ipg; /* Number of inodes per group */ 160 uint32_t e2fs_ipb; /* Number of inodes per block */ 161 uint32_t e2fs_itpg; /* Number of inode table per group */ 162 uint32_t e2fs_fsize; /* Size of fragments per block */ 163 uint32_t e2fs_fpb; /* Number of fragments per block */ 164 uint32_t e2fs_fpg; /* Number of fragments per group */ 165 uint32_t e2fs_gdbcount; /* Number of group descriptors */ 166 uint32_t e2fs_gcount; /* Number of groups */ 167 uint32_t e2fs_isize; /* Size of inode */ 168 uint32_t e2fs_total_dir; /* Total number of directories */ 169 uint8_t *e2fs_contigdirs; /* (u) # of contig. allocated dirs */ 170 char e2fs_wasvalid; /* valid at mount time */ 171 off_t e2fs_maxfilesize; 172 struct ext2_gd *e2fs_gd; /* Group Descriptors */ 173 int32_t e2fs_contigsumsize; /* size of cluster summary array */ 174 int32_t *e2fs_maxcluster; /* max cluster in each cyl group */ 175 struct csum *e2fs_clustersum; /* cluster summary in each cyl group */ 176}; 177
| 48 * The path name on which the file system is mounted is maintained 49 * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in 50 * the super block for this name. 51 */ 52#define MAXMNTLEN 512 53 54/* 55 * Super block for an ext2fs file system. 56 */ 57struct ext2fs { 58 uint32_t e2fs_icount; /* Inode count */ 59 uint32_t e2fs_bcount; /* blocks count */ 60 uint32_t e2fs_rbcount; /* reserved blocks count */ 61 uint32_t e2fs_fbcount; /* free blocks count */ 62 uint32_t e2fs_ficount; /* free inodes count */ 63 uint32_t e2fs_first_dblock; /* first data block */ 64 uint32_t e2fs_log_bsize; /* block size = 1024*(2^e2fs_log_bsize) */ 65 uint32_t e2fs_log_fsize; /* fragment size */ 66 uint32_t e2fs_bpg; /* blocks per group */ 67 uint32_t e2fs_fpg; /* frags per group */ 68 uint32_t e2fs_ipg; /* inodes per group */ 69 uint32_t e2fs_mtime; /* mount time */ 70 uint32_t e2fs_wtime; /* write time */ 71 uint16_t e2fs_mnt_count; /* mount count */ 72 uint16_t e2fs_max_mnt_count; /* max mount count */ 73 uint16_t e2fs_magic; /* magic number */ 74 uint16_t e2fs_state; /* file system state */ 75 uint16_t e2fs_beh; /* behavior on errors */ 76 uint16_t e2fs_minrev; /* minor revision level */ 77 uint32_t e2fs_lastfsck; /* time of last fsck */ 78 uint32_t e2fs_fsckintv; /* max time between fscks */ 79 uint32_t e2fs_creator; /* creator OS */ 80 uint32_t e2fs_rev; /* revision level */ 81 uint16_t e2fs_ruid; /* default uid for reserved blocks */ 82 uint16_t e2fs_rgid; /* default gid for reserved blocks */ 83 /* EXT2_DYNAMIC_REV superblocks */ 84 uint32_t e2fs_first_ino; /* first non-reserved inode */ 85 uint16_t e2fs_inode_size; /* size of inode structure */ 86 uint16_t e2fs_block_group_nr; /* block grp number of this sblk*/ 87 uint32_t e2fs_features_compat; /* compatible feature set */ 88 uint32_t e2fs_features_incompat; /* incompatible feature set */ 89 uint32_t e2fs_features_rocompat; /* RO-compatible feature set */ 90 uint8_t e2fs_uuid[16]; /* 128-bit uuid for volume */ 91 char e2fs_vname[16]; /* volume name */ 92 char e2fs_fsmnt[64]; /* name mounted on */ 93 uint32_t e2fs_algo; /* For compression */ 94 uint8_t e2fs_prealloc; /* # of blocks for old prealloc */ 95 uint8_t e2fs_dir_prealloc; /* # of blocks for old prealloc dirs */ 96 uint16_t e2fs_reserved_ngdb; /* # of reserved gd blocks for resize */ 97 char e3fs_journal_uuid[16]; /* uuid of journal superblock */ 98 uint32_t e3fs_journal_inum; /* inode number of journal file */ 99 uint32_t e3fs_journal_dev; /* device number of journal file */ 100 uint32_t e3fs_last_orphan; /* start of list of inodes to delete */ 101 uint32_t e3fs_hash_seed[4]; /* HTREE hash seed */ 102 char e3fs_def_hash_version; /* Default hash version to use */ 103 char e3fs_reserved_char_pad; 104 uint32_t e3fs_default_mount_opts; 105 uint32_t e3fs_first_meta_bg; /* First metablock block group */ 106 uint32_t e3fs_mkfs_time; /* when the fs was created */ 107 uint32_t e3fs_jnl_blks[17]; /* backup of the journal inode */ 108 uint32_t e4fs_bcount_hi; /* block count */ 109 uint32_t e4fs_rbcount_hi; /* reserved blocks count */ 110 uint32_t e4fs_fbcount_hi; /* free blocks count */ 111 uint16_t e4fs_min_extra_isize;/* all inodes have at least some bytes */ 112 uint16_t e4fs_want_extra_isize; /* inodes must reserve some bytes */ 113 uint32_t e4fs_flags; /* miscellaneous flags */ 114 uint16_t e4fs_raid_stride; /* RAID stride */ 115 uint16_t e4fs_mmpintv; /* number of seconds to wait in MMP checking */ 116 uint64_t e4fs_mmpblk; /* block for multi-mount protection */ 117 uint32_t e4fs_raid_stripe_wid;/* blocks on all data disks (N * stride) */ 118 uint8_t e4fs_log_gpf; /* FLEX_BG group size */ 119 uint8_t e4fs_char_pad2; 120 uint16_t e4fs_pad; 121 uint32_t reserved2[162]; /* Padding to the end of the block */ 122}; 123 124 125/* 126 * In-Memory Superblock 127 */ 128 129struct m_ext2fs { 130 struct ext2fs * e2fs; 131 char e2fs_fsmnt[MAXMNTLEN];/* name mounted on */ 132 char e2fs_ronly; /* mounted read-only flag */ 133 char e2fs_fmod; /* super block modified flag */ 134 uint32_t e2fs_bsize; /* Block size */ 135 uint32_t e2fs_bshift; /* calc of logical block no */ 136 uint32_t e2fs_bpg; /* Number of blocks per group */ 137 int64_t e2fs_qbmask; /* = s_blocksize -1 */ 138 uint32_t e2fs_fsbtodb; /* Shift to get disk block */ 139 uint32_t e2fs_ipg; /* Number of inodes per group */ 140 uint32_t e2fs_ipb; /* Number of inodes per block */ 141 uint32_t e2fs_itpg; /* Number of inode table per group */ 142 uint32_t e2fs_fsize; /* Size of fragments per block */ 143 uint32_t e2fs_fpb; /* Number of fragments per block */ 144 uint32_t e2fs_fpg; /* Number of fragments per group */ 145 uint32_t e2fs_gdbcount; /* Number of group descriptors */ 146 uint32_t e2fs_gcount; /* Number of groups */ 147 uint32_t e2fs_isize; /* Size of inode */ 148 uint32_t e2fs_total_dir; /* Total number of directories */ 149 uint8_t *e2fs_contigdirs; /* (u) # of contig. allocated dirs */ 150 char e2fs_wasvalid; /* valid at mount time */ 151 off_t e2fs_maxfilesize; 152 struct ext2_gd *e2fs_gd; /* Group Descriptors */ 153 int32_t e2fs_contigsumsize; /* size of cluster summary array */ 154 int32_t *e2fs_maxcluster; /* max cluster in each cyl group */ 155 struct csum *e2fs_clustersum; /* cluster summary in each cyl group */ 156}; 157
|
178/* 179 * The second extended file system version 180 */ 181#define E2FS_DATE "95/08/09" 182#define E2FS_VERSION "0.5b"
| 158/* cluster summary information */
|
183
| 159
|
| 160struct csum { 161 int8_t cs_init; /* cluster summary has been initialized */ 162 int32_t *cs_sum; /* cluster summary array */ 163}; 164
|
184/* 185 * The second extended file system magic number 186 */ 187#define E2FS_MAGIC 0xEF53 188 189/* 190 * Revision levels 191 */ 192#define E2FS_REV0 0 /* The good old (original) format */ 193#define E2FS_REV1 1 /* V2 format w/ dynamic inode sizes */ 194
| 165/* 166 * The second extended file system magic number 167 */ 168#define E2FS_MAGIC 0xEF53 169 170/* 171 * Revision levels 172 */ 173#define E2FS_REV0 0 /* The good old (original) format */ 174#define E2FS_REV1 1 /* V2 format w/ dynamic inode sizes */ 175
|
195#define E2FS_CURRENT_REV E2FS_REV0 196#define E2FS_MAX_SUPP_REV E2FS_REV1 197
| |
198#define E2FS_REV0_INODE_SIZE 128 199 200/* 201 * compatible/incompatible features 202 */ 203#define EXT2F_COMPAT_PREALLOC 0x0001 204#define EXT2F_COMPAT_HASJOURNAL 0x0004 205#define EXT2F_COMPAT_RESIZE 0x0010 206#define EXT2F_COMPAT_DIRHASHINDEX 0x0020 207 208#define EXT2F_ROCOMPAT_SPARSESUPER 0x0001 209#define EXT2F_ROCOMPAT_LARGEFILE 0x0002 210#define EXT2F_ROCOMPAT_BTREE_DIR 0x0004 211#define EXT2F_ROCOMPAT_HUGE_FILE 0x0008 212#define EXT2F_ROCOMPAT_GDT_CSUM 0x0010 213#define EXT2F_ROCOMPAT_DIR_NLINK 0x0020 214#define EXT2F_ROCOMPAT_EXTRA_ISIZE 0x0040 215 216#define EXT2F_INCOMPAT_COMP 0x0001 217#define EXT2F_INCOMPAT_FTYPE 0x0002 218#define EXT2F_INCOMPAT_META_BG 0x0010 219#define EXT2F_INCOMPAT_EXTENTS 0x0040 220#define EXT2F_INCOMPAT_64BIT 0x0080 221#define EXT2F_INCOMPAT_MMP 0x0100 222#define EXT2F_INCOMPAT_FLEX_BG 0x0200 223 224/* 225 * Features supported in this implementation 226 * 227 * We support the following REV1 features: 228 * - EXT2F_ROCOMPAT_SPARSESUPER 229 * - EXT2F_ROCOMPAT_LARGEFILE 230 * - EXT2F_INCOMPAT_FTYPE 231 */ 232#define EXT2F_COMPAT_SUPP 0x0000 233#define EXT2F_ROCOMPAT_SUPP (EXT2F_ROCOMPAT_SPARSESUPER | \ 234 EXT2F_ROCOMPAT_LARGEFILE | \ 235 EXT2F_ROCOMPAT_EXTRA_ISIZE) 236#define EXT2F_INCOMPAT_SUPP EXT2F_INCOMPAT_FTYPE 237 238/* Assume that user mode programs are passing in an ext2fs superblock, not 239 * a kernel struct super_block. This will allow us to call the feature-test 240 * macros from user land. */ 241#define EXT2_SB(sb) (sb) 242 243/* 244 * Feature set definitions 245 */ 246#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ 247 ( EXT2_SB(sb)->e2fs->e2fs_features_compat & htole32(mask) ) 248#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ 249 ( EXT2_SB(sb)->e2fs->e2fs_features_rocompat & htole32(mask) ) 250#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ 251 ( EXT2_SB(sb)->e2fs->e2fs_features_incompat & htole32(mask) ) 252 253/*
| 176#define E2FS_REV0_INODE_SIZE 128 177 178/* 179 * compatible/incompatible features 180 */ 181#define EXT2F_COMPAT_PREALLOC 0x0001 182#define EXT2F_COMPAT_HASJOURNAL 0x0004 183#define EXT2F_COMPAT_RESIZE 0x0010 184#define EXT2F_COMPAT_DIRHASHINDEX 0x0020 185 186#define EXT2F_ROCOMPAT_SPARSESUPER 0x0001 187#define EXT2F_ROCOMPAT_LARGEFILE 0x0002 188#define EXT2F_ROCOMPAT_BTREE_DIR 0x0004 189#define EXT2F_ROCOMPAT_HUGE_FILE 0x0008 190#define EXT2F_ROCOMPAT_GDT_CSUM 0x0010 191#define EXT2F_ROCOMPAT_DIR_NLINK 0x0020 192#define EXT2F_ROCOMPAT_EXTRA_ISIZE 0x0040 193 194#define EXT2F_INCOMPAT_COMP 0x0001 195#define EXT2F_INCOMPAT_FTYPE 0x0002 196#define EXT2F_INCOMPAT_META_BG 0x0010 197#define EXT2F_INCOMPAT_EXTENTS 0x0040 198#define EXT2F_INCOMPAT_64BIT 0x0080 199#define EXT2F_INCOMPAT_MMP 0x0100 200#define EXT2F_INCOMPAT_FLEX_BG 0x0200 201 202/* 203 * Features supported in this implementation 204 * 205 * We support the following REV1 features: 206 * - EXT2F_ROCOMPAT_SPARSESUPER 207 * - EXT2F_ROCOMPAT_LARGEFILE 208 * - EXT2F_INCOMPAT_FTYPE 209 */ 210#define EXT2F_COMPAT_SUPP 0x0000 211#define EXT2F_ROCOMPAT_SUPP (EXT2F_ROCOMPAT_SPARSESUPER | \ 212 EXT2F_ROCOMPAT_LARGEFILE | \ 213 EXT2F_ROCOMPAT_EXTRA_ISIZE) 214#define EXT2F_INCOMPAT_SUPP EXT2F_INCOMPAT_FTYPE 215 216/* Assume that user mode programs are passing in an ext2fs superblock, not 217 * a kernel struct super_block. This will allow us to call the feature-test 218 * macros from user land. */ 219#define EXT2_SB(sb) (sb) 220 221/* 222 * Feature set definitions 223 */ 224#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ 225 ( EXT2_SB(sb)->e2fs->e2fs_features_compat & htole32(mask) ) 226#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ 227 ( EXT2_SB(sb)->e2fs->e2fs_features_rocompat & htole32(mask) ) 228#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ 229 ( EXT2_SB(sb)->e2fs->e2fs_features_incompat & htole32(mask) ) 230 231/*
|
254 * Definitions of behavior on errors 255 */ 256#define E2FS_BEH_CONTINUE 1 /* continue operation */ 257#define E2FS_BEH_READONLY 2 /* remount fs read only */ 258#define E2FS_BEH_PANIC 3 /* cause panic */ 259#define E2FS_BEH_DEFAULT E2FS_BEH_CONTINUE 260 261/* 262 * OS identification 263 */ 264#define E2FS_OS_LINUX 0 265#define E2FS_OS_HURD 1 266#define E2FS_OS_MASIX 2 267#define E2FS_OS_FREEBSD 3 268#define E2FS_OS_LITES 4 269 270/*
| |
271 * File clean flags 272 */ 273#define E2FS_ISCLEAN 0x0001 /* Unmounted cleanly */ 274#define E2FS_ERRORS 0x0002 /* Errors detected */ 275 276/* ext2 file system block group descriptor */ 277 278struct ext2_gd { 279 uint32_t ext2bgd_b_bitmap; /* blocks bitmap block */ 280 uint32_t ext2bgd_i_bitmap; /* inodes bitmap block */ 281 uint32_t ext2bgd_i_tables; /* inodes table block */ 282 uint16_t ext2bgd_nbfree; /* number of free blocks */ 283 uint16_t ext2bgd_nifree; /* number of free inodes */ 284 uint16_t ext2bgd_ndirs; /* number of directories */ 285 uint16_t ext2bgd_flags; /* block group flags */ 286 uint32_t ext2bgd_x_bitmap; /* snapshot exclusion bitmap loc. */ 287 uint16_t ext2bgd_b_bmap_csum; /* block bitmap checksum */ 288 uint16_t ext2bgd_i_bmap_csum; /* inode bitmap checksum */ 289 uint16_t ext2bgd_i_unused; /* unused inode count */ 290 uint16_t ext2bgd_csum; /* group descriptor checksum */ 291}; 292
| 232 * File clean flags 233 */ 234#define E2FS_ISCLEAN 0x0001 /* Unmounted cleanly */ 235#define E2FS_ERRORS 0x0002 /* Errors detected */ 236 237/* ext2 file system block group descriptor */ 238 239struct ext2_gd { 240 uint32_t ext2bgd_b_bitmap; /* blocks bitmap block */ 241 uint32_t ext2bgd_i_bitmap; /* inodes bitmap block */ 242 uint32_t ext2bgd_i_tables; /* inodes table block */ 243 uint16_t ext2bgd_nbfree; /* number of free blocks */ 244 uint16_t ext2bgd_nifree; /* number of free inodes */ 245 uint16_t ext2bgd_ndirs; /* number of directories */ 246 uint16_t ext2bgd_flags; /* block group flags */ 247 uint32_t ext2bgd_x_bitmap; /* snapshot exclusion bitmap loc. */ 248 uint16_t ext2bgd_b_bmap_csum; /* block bitmap checksum */ 249 uint16_t ext2bgd_i_bmap_csum; /* inode bitmap checksum */ 250 uint16_t ext2bgd_i_unused; /* unused inode count */ 251 uint16_t ext2bgd_csum; /* group descriptor checksum */ 252}; 253
|
293/* cluster summary information */
| |
294
| 254
|
295struct csum { 296 int8_t cs_init; /* cluster summary has been initialized */ 297 int32_t *cs_sum; /* cluster summary array */ 298}; 299
| |
300/* EXT2FS metadatas are stored in little-endian byte order. These macros 301 * helps reading these metadatas 302 */ 303 304#define e2fs_cgload(old, new, size) memcpy((new), (old), (size)); 305#define e2fs_cgsave(old, new, size) memcpy((new), (old), (size)); 306 307/* 308 * Macro-instructions used to manage several block sizes 309 */ 310#define EXT2_MAX_BLOCK_SIZE 4096 311#define EXT2_MIN_BLOCK_LOG_SIZE 10 312#define EXT2_BLOCK_SIZE(s) ((s)->e2fs_bsize) 313#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t)) 314#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->e2fs_isize) 315 316/* 317 * Macro-instructions used to manage fragments 318 */ 319#define EXT2_MIN_FRAG_SIZE 1024 320#define EXT2_MAX_FRAG_SIZE 4096 321#define EXT2_MIN_FRAG_LOG_SIZE 10 322#define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->e2fs_fsize) 323#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->e2fs_fpb) 324 325/* 326 * Macro-instructions used to manage group descriptors 327 */ 328#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->e2fs_bpg) 329 330#endif /* !_FS_EXT2FS_EXT2FS_H_ */
| 255/* EXT2FS metadatas are stored in little-endian byte order. These macros 256 * helps reading these metadatas 257 */ 258 259#define e2fs_cgload(old, new, size) memcpy((new), (old), (size)); 260#define e2fs_cgsave(old, new, size) memcpy((new), (old), (size)); 261 262/* 263 * Macro-instructions used to manage several block sizes 264 */ 265#define EXT2_MAX_BLOCK_SIZE 4096 266#define EXT2_MIN_BLOCK_LOG_SIZE 10 267#define EXT2_BLOCK_SIZE(s) ((s)->e2fs_bsize) 268#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t)) 269#define EXT2_INODE_SIZE(s) (EXT2_SB(s)->e2fs_isize) 270 271/* 272 * Macro-instructions used to manage fragments 273 */ 274#define EXT2_MIN_FRAG_SIZE 1024 275#define EXT2_MAX_FRAG_SIZE 4096 276#define EXT2_MIN_FRAG_LOG_SIZE 10 277#define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->e2fs_fsize) 278#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->e2fs_fpb) 279 280/* 281 * Macro-instructions used to manage group descriptors 282 */ 283#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->e2fs_bpg) 284 285#endif /* !_FS_EXT2FS_EXT2FS_H_ */
|