summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbranzhu <branzhu@outlook.com>2017-03-24 00:51:51 -0400
committerbranzhu <branzhu@outlook.com>2017-03-24 00:51:51 -0400
commit02eb05014ff09bbadca174a2924ff2bdbc69b97e (patch)
tree606e39d4dbe56dbf785c4008a02e8386b8c85896
parent9c59c0b576a924d6acda7c4b745b668f5e958f5c (diff)
Fix issues with big-endian system
-rw-r--r--include/ext4_types.h13
-rw-r--r--src/ext4_fs.c2
-rw-r--r--src/ext4_mkfs.c2
3 files changed, 9 insertions, 8 deletions
diff --git a/include/ext4_types.h b/include/ext4_types.h
index 2d9e49c..80e9a0f 100644
--- a/include/ext4_types.h
+++ b/include/ext4_types.h
@@ -698,19 +698,20 @@ struct ext4_extent_header {
((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:
diff --git a/src/ext4_fs.c b/src/ext4_fs.c
index 5cc317a..0e0ae15 100644
--- a/src/ext4_fs.c
+++ b/src/ext4_fs.c
@@ -431,7 +431,7 @@ static int ext4_fs_init_inode_table(struct ext4_block_group_ref *bg_ref)
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);
diff --git a/src/ext4_mkfs.c b/src/ext4_mkfs.c
index 81867d6..cd27c68 100644
--- a/src/ext4_mkfs.c
+++ b/src/ext4_mkfs.c
@@ -388,7 +388,7 @@ static int write_bgroups(struct ext4_blockdev *bd, struct fs_aux_info *aux_info,
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);