ref: 02eb05014ff09bbadca174a2924ff2bdbc69b97e
parent: 9c59c0b576a924d6acda7c4b745b668f5e958f5c
author: branzhu <[email protected]>
date: Thu Mar 23 20:51:51 EDT 2017
Fix issues with big-endian system
--- a/include/ext4_types.h
+++ b/include/ext4_types.h
@@ -698,19 +698,20 @@
((struct ext4_extent_index *)(((char *)(__hdr__)) + \
sizeof(struct ext4_extent_header)))
#define EXT_HAS_FREE_INDEX(__path__) \
- ((__path__)->header->entries_count < (__path__)->header->max_entries_count)
+ (to_le16((__path__)->header->entries_count) < \
+ to_le16((__path__)->header->max_entries_count))
#define EXT_LAST_EXTENT(__hdr__) \
- (EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->entries_count - 1)
+ (EXT_FIRST_EXTENT((__hdr__)) + to_le16((__hdr__)->entries_count) - 1)
#define EXT_LAST_INDEX(__hdr__) \
- (EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->entries_count - 1)
+ (EXT_FIRST_INDEX((__hdr__)) + to_le16((__hdr__)->entries_count) - 1)
#define EXT_MAX_EXTENT(__hdr__) \
- (EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->max_entries_count - 1)
+ (EXT_FIRST_EXTENT((__hdr__)) + to_le16((__hdr__)->max_entries_count) - 1)
#define EXT_MAX_INDEX(__hdr__) \
- (EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->max_entries_count - 1)
+ (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) * (hdr)->max_entries_count))
+ (sizeof(struct ext4_extent) * to_le16((hdr)->max_entries_count)))
/*
* ext4_ext_next_allocated_block:
--- a/src/ext4_fs.c
+++ b/src/ext4_fs.c
@@ -431,7 +431,7 @@
struct ext4_sblock *sb = &bg_ref->fs->sb;
struct ext4_bgroup *bg = bg_ref->block_group;
- uint32_t inode_size = ext4_get32(sb, inode_size);
+ uint32_t inode_size = ext4_get16(sb, inode_size);
uint32_t block_size = ext4_sb_get_block_size(sb);
uint32_t inodes_per_block = block_size / inode_size;
uint32_t inodes_in_group = ext4_inodes_in_group_cnt(sb, bg_ref->index);
--- a/src/ext4_mkfs.c
+++ b/src/ext4_mkfs.c
@@ -388,7 +388,7 @@
bg_free_blk);
ext4_bg_set_free_inodes_count(bg_desc,
- aux_info->sb, aux_info->sb->inodes_per_group);
+ aux_info->sb, to_le32(aux_info->sb->inodes_per_group));
ext4_bg_set_used_dirs_count(bg_desc, aux_info->sb, 0);