History

Fix issues with big-endian system

branzhu committed 9 years ago

Commit 02eb0501 parent 9c59c0b3 files · +9 −8Browse files

Unified · Split

3 files
  1. include/ext4_types.h +7 −6
  2. src/ext4_fs.c +1 −1
  3. src/ext4_mkfs.c +1 −1
include/ext4_types.h+7−6
@@ -698,19 +698,20 @@ struct ext4_extent_header { · 697 unmodified lines
698698 ((struct ext4_extent_index *)(((char *)(__hdr__)) + \
699699 sizeof(struct ext4_extent_header)))
700700 #define EXT_HAS_FREE_INDEX(__path__) \
701− ((__path__)->header->entries_count < (__path__)->header->max_entries_count)
701+ (to_le16((__path__)->header->entries_count) < \
702+ to_le16((__path__)->header->max_entries_count))
702703 #define EXT_LAST_EXTENT(__hdr__) \
703− (EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->entries_count - 1)
704+ (EXT_FIRST_EXTENT((__hdr__)) + to_le16((__hdr__)->entries_count) - 1)
704705 #define EXT_LAST_INDEX(__hdr__) \
705− (EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->entries_count - 1)
706+ (EXT_FIRST_INDEX((__hdr__)) + to_le16((__hdr__)->entries_count) - 1)
706707 #define EXT_MAX_EXTENT(__hdr__) \
707− (EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->max_entries_count - 1)
708+ (EXT_FIRST_EXTENT((__hdr__)) + to_le16((__hdr__)->max_entries_count) - 1)
708709 #define EXT_MAX_INDEX(__hdr__) \
709− (EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->max_entries_count - 1)
710+ (EXT_FIRST_INDEX((__hdr__)) + to_le16((__hdr__)->max_entries_count) - 1)
710711
711712 #define EXT4_EXTENT_TAIL_OFFSET(hdr) \
712713 (sizeof(struct ext4_extent_header) + \
713− (sizeof(struct ext4_extent) * (hdr)->max_entries_count))
714+ (sizeof(struct ext4_extent) * to_le16((hdr)->max_entries_count)))
714715
715716 /*
716717 * ext4_ext_next_allocated_block:
src/ext4_fs.c+1−1
@@ -431,7 +431,7 @@ static int ext4_fs_init_inode_table(struct ext4_block_group_ref *bg_ref) · 430 unmodified lines
431431 struct ext4_sblock *sb = &bg_ref->fs->sb;
432432 struct ext4_bgroup *bg = bg_ref->block_group;
433433
434− uint32_t inode_size = ext4_get32(sb, inode_size);
434+ uint32_t inode_size = ext4_get16(sb, inode_size);
435435 uint32_t block_size = ext4_sb_get_block_size(sb);
436436 uint32_t inodes_per_block = block_size / inode_size;
437437 uint32_t inodes_in_group = ext4_inodes_in_group_cnt(sb, bg_ref->index);
src/ext4_mkfs.c+1−1
@@ -388,7 +388,7 @@ static int write_bgroups(struct ext4_blockdev *bd, struct fs_aux_info *aux_info, · 387 unmodified lines
388388 bg_free_blk);
389389
390390 ext4_bg_set_free_inodes_count(bg_desc,
391− aux_info->sb, aux_info->sb->inodes_per_group);
391+ aux_info->sb, to_le32(aux_info->sb->inodes_per_group));
392392
393393 ext4_bg_set_used_dirs_count(bg_desc, aux_info->sb, 0);
394394

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t