X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=include%2Fext4_types.h;h=c9cdd344df5df2cc5ac2fab344c1bb79bd883336;hb=b1a34c56f4556f256fc16096190e77b69a715197;hp=d927cd8c74016ce5d4b4317dc8bd2ea28d8fb6a1;hpb=c8978f9dba53333004f3f20e5acc57df8867dc16;p=lwext4.git diff --git a/include/ext4_types.h b/include/ext4_types.h index d927cd8..c9cdd34 100644 --- a/include/ext4_types.h +++ b/include/ext4_types.h @@ -582,146 +582,7 @@ struct ext4_dir_entry_tail { #define EXT4_JOURNAL_INO 8 #define EXT4_GOOD_OLD_FIRST_INO 11 - -#define EXT4_EXT_UNWRITTEN_MASK (1L << 15) - -#define EXT4_EXT_MAX_LEN_WRITTEN (1L << 15) -#define EXT4_EXT_MAX_LEN_UNWRITTEN \ - (EXT4_EXT_MAX_LEN_WRITTEN - 1) - -#define EXT4_EXT_GET_LEN(ex) to_le16((ex)->block_count) -#define EXT4_EXT_GET_LEN_UNWRITTEN(ex) \ - (EXT4_EXT_GET_LEN(ex) &= ~(EXT4_EXT_UNWRITTEN_MASK)) -#define EXT4_EXT_SET_LEN(ex, count) \ - ((ex)->block_count = to_le16(count)) - -#define EXT4_EXT_IS_UNWRITTEN(ex) \ - (EXT4_EXT_GET_LEN(ex) > EXT4_EXT_MAX_LEN_WRITTEN) -#define EXT4_EXT_SET_UNWRITTEN(ex) \ - ((ex)->block_count |= to_le16(EXT4_EXT_UNWRITTEN_MASK)) -#define EXT4_EXT_SET_WRITTEN(ex) \ - ((ex)->block_count &= ~(to_le16(EXT4_EXT_UNWRITTEN_MASK))) - -#pragma pack(push, 1) - -/* - * This is the extent tail on-disk structure. - * All other extent structures are 12 bytes long. It turns out that - * block_size % 12 >= 4 for at least all powers of 2 greater than 512, which - * covers all valid ext4 block sizes. Therefore, this tail structure can be - * crammed into the end of the block without having to rebalance the tree. - */ -struct ext4_extent_tail -{ - uint32_t et_checksum; /* crc32c(uuid+inum+extent_block) */ -}; - -/* - * This is the extent on-disk structure. - * It's used at the bottom of the tree. - */ -struct ext4_extent { - uint32_t first_block; /* First logical block extent covers */ - uint16_t block_count; /* Number of blocks covered by extent */ - uint16_t start_hi; /* High 16 bits of physical block */ - uint32_t start_lo; /* Low 32 bits of physical block */ -}; - -/* - * This is index on-disk structure. - * It's used at all the levels except the bottom. - */ -struct ext4_extent_index { - uint32_t first_block; /* Index covers logical blocks from 'block' */ - - /** - * Pointer to the physical block of the next - * level. leaf or next index could be there - * high 16 bits of physical block - */ - uint32_t leaf_lo; - uint16_t leaf_hi; - uint16_t padding; -}; - -/* - * Each block (leaves and indexes), even inode-stored has header. - */ -struct ext4_extent_header { - uint16_t magic; - uint16_t entries_count; /* Number of valid entries */ - uint16_t max_entries_count; /* Capacity of store in entries */ - uint16_t depth; /* Has tree real underlying blocks? */ - uint32_t generation; /* generation of the tree */ -}; - -#pragma pack(pop) - - -#define EXT4_EXTENT_MAGIC 0xF30A - -#define EXT4_EXTENT_FIRST(header) \ - ((struct ext4_extent *)(((char *)(header)) + \ - sizeof(struct ext4_extent_header))) - -#define EXT4_EXTENT_FIRST_INDEX(header) \ - ((struct ext4_extent_index *)(((char *)(header)) + \ - sizeof(struct ext4_extent_header))) - -/* - * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an - * initialized extent. This is 2^15 and not (2^16 - 1), since we use the - * MSB of ee_len field in the extent datastructure to signify if this - * particular extent is an initialized extent or an uninitialized (i.e. - * preallocated). - * EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an - * uninitialized extent. - * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an - * uninitialized one. In other words, if MSB of ee_len is set, it is an - * uninitialized extent with only one special scenario when ee_len = 0x8000. - * In this case we can not have an uninitialized extent of zero length and - * thus we make it as a special case of initialized extent with 0x8000 length. - * This way we get better extent-to-group alignment for initialized extents. - * Hence, the maximum number of blocks we can have in an *initialized* - * extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767). - */ -#define EXT_INIT_MAX_LEN (1L << 15) -#define EXT_UNWRITTEN_MAX_LEN (EXT_INIT_MAX_LEN - 1) - -#define EXT_EXTENT_SIZE sizeof(struct ext4_extent) -#define EXT_INDEX_SIZE sizeof(struct ext4_extent_idx) - -#define EXT_FIRST_EXTENT(__hdr__) \ - ((struct ext4_extent *)(((char *)(__hdr__)) + \ - sizeof(struct ext4_extent_header))) -#define EXT_FIRST_INDEX(__hdr__) \ - ((struct ext4_extent_index *)(((char *)(__hdr__)) + \ - sizeof(struct ext4_extent_header))) -#define EXT_HAS_FREE_INDEX(__path__) \ - (to_le16((__path__)->header->entries_count) < \ - to_le16((__path__)->header->max_entries_count)) -#define EXT_LAST_EXTENT(__hdr__) \ - (EXT_FIRST_EXTENT((__hdr__)) + to_le16((__hdr__)->entries_count) - 1) -#define EXT_LAST_INDEX(__hdr__) \ - (EXT_FIRST_INDEX((__hdr__)) + to_le16((__hdr__)->entries_count) - 1) -#define EXT_MAX_EXTENT(__hdr__) \ - (EXT_FIRST_EXTENT((__hdr__)) + to_le16((__hdr__)->max_entries_count) - 1) -#define EXT_MAX_INDEX(__hdr__) \ - (EXT_FIRST_INDEX((__hdr__)) + to_le16((__hdr__)->max_entries_count) - 1) - -#define EXT4_EXTENT_TAIL_OFFSET(hdr) \ - (sizeof(struct ext4_extent_header) + \ - (sizeof(struct ext4_extent) * to_le16((hdr)->max_entries_count))) - -/* - * ext4_ext_next_allocated_block: - * returns allocated block in subsequent extent or EXT_MAX_BLOCKS. - * NOTE: it considers block number from index entry as - * allocated block. Thus, index entries have to be consistent - * with leaves. - */ #define EXT_MAX_BLOCKS (ext4_lblk_t) (-1) - #define IN_RANGE(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1) @@ -737,53 +598,6 @@ struct ext4_extent_header { #define EXT2_HTREE_EOF 0x7FFFFFFFUL - -/* Extended Attribute(EA) */ - -/* Magic value in attribute blocks */ -#define EXT4_XATTR_MAGIC 0xEA020000 - -/* Maximum number of references to one attribute block */ -#define EXT4_XATTR_REFCOUNT_MAX 1024 - -/* Name indexes */ -#define EXT4_XATTR_INDEX_USER 1 -#define EXT4_XATTR_INDEX_POSIX_ACL_ACCESS 2 -#define EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT 3 -#define EXT4_XATTR_INDEX_TRUSTED 4 -#define EXT4_XATTR_INDEX_LUSTRE 5 -#define EXT4_XATTR_INDEX_SECURITY 6 -#define EXT4_XATTR_INDEX_SYSTEM 7 -#define EXT4_XATTR_INDEX_RICHACL 8 -#define EXT4_XATTR_INDEX_ENCRYPTION 9 - -#pragma pack(push, 1) - -struct ext4_xattr_header { - uint32_t h_magic; /* magic number for identification */ - uint32_t h_refcount; /* reference count */ - uint32_t h_blocks; /* number of disk blocks used */ - uint32_t h_hash; /* hash value of all attributes */ - uint32_t h_checksum; /* crc32c(uuid+id+xattrblock) */ - /* id = inum if refcount=1, blknum otherwise */ - uint32_t h_reserved[3]; /* zero right now */ -}; - -struct ext4_xattr_ibody_header { - uint32_t h_magic; /* magic number for identification */ -}; - -struct ext4_xattr_entry { - uint8_t e_name_len; /* length of name */ - uint8_t e_name_index; /* attribute name index */ - uint16_t e_value_offs; /* offset in disk block of value */ - uint32_t e_value_block; /* disk block attribute is stored on (n/i) */ - uint32_t e_value_size; /* size of attribute value */ - uint32_t e_hash; /* hash value of name and value */ -}; - -#pragma pack(pop) - #define EXT4_GOOD_OLD_INODE_SIZE 128 /*****************************************************************************/