mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2025-02-20 02:40:49 +00:00
mkfs: fix bug in endianness at f2fs_update_nat_root
This patch fixes a bug in the function "f2fs_update_nat_root", where the access to the array "nat_blk->entries" was done using an index without encapsulation of the "le32_to_cpu" macro. The bug happens when trying to format an SD card in a powerpc architecture, which natively runs at big-endian mode Signed-off-by: Oded Gabbay <ogabbay@advaoptical.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
fef98ebdf3
commit
b6ae58ed44
@ -810,18 +810,18 @@ static int f2fs_update_nat_root(void)
|
||||
}
|
||||
|
||||
/* update root */
|
||||
nat_blk->entries[super_block.root_ino].block_addr = cpu_to_le32(
|
||||
nat_blk->entries[le32_to_cpu(super_block.root_ino)].block_addr = cpu_to_le32(
|
||||
le32_to_cpu(super_block.main_blkaddr) +
|
||||
config.cur_seg[CURSEG_HOT_NODE] * config.blks_per_seg);
|
||||
nat_blk->entries[super_block.root_ino].ino = super_block.root_ino;
|
||||
nat_blk->entries[le32_to_cpu(super_block.root_ino)].ino = super_block.root_ino;
|
||||
|
||||
/* update node nat */
|
||||
nat_blk->entries[super_block.node_ino].block_addr = cpu_to_le32(1);
|
||||
nat_blk->entries[super_block.node_ino].ino = super_block.node_ino;
|
||||
nat_blk->entries[le32_to_cpu(super_block.node_ino)].block_addr = cpu_to_le32(1);
|
||||
nat_blk->entries[le32_to_cpu(super_block.node_ino)].ino = super_block.node_ino;
|
||||
|
||||
/* update meta nat */
|
||||
nat_blk->entries[super_block.meta_ino].block_addr = cpu_to_le32(1);
|
||||
nat_blk->entries[super_block.meta_ino].ino = super_block.meta_ino;
|
||||
nat_blk->entries[le32_to_cpu(super_block.meta_ino)].block_addr = cpu_to_le32(1);
|
||||
nat_blk->entries[le32_to_cpu(super_block.meta_ino)].ino = super_block.meta_ino;
|
||||
|
||||
blk_size_bytes = 1 << le32_to_cpu(super_block.log_blocksize);
|
||||
nat_seg_blk_offset = le32_to_cpu(super_block.nat_blkaddr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user