Fix bug in endianness at f2fs_update_nat_root
PATCH 1/1 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 <[email protected]>
--- mkfs/f2fs_format.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
mkfs/f2fs_format.c +6 -6
@@ -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);
Signature · 9 lines
1.8.3.1 ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev