fs: partition: fs_mbr: fix for MBR block count calculation.

When the MBR partition size exceeds 2 GiB, a 32-bit wrap-around occurs,
causing an error in the block count calculation.

* wrong
 brw-rw-rw- 5150605312 mmcblk0
 brw-rw-rw-  629145600 mmcblk0p1
 brw-rw-rw-  225443840 mmcblk0p2 <--

* fixed
 brw-rw-rw- 5150605312 mmcblk0
 brw-rw-rw-  629145600 mmcblk0p1
 brw-rw-rw- 4520411136 mmcblk0p2 <--

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
This commit is contained in:
Takeyoshi Kikuchi 2024-01-13 19:44:27 +09:00 committed by Xiang Xiao
parent 78e8c0dea5
commit f01e395b1c
1 changed files with 1 additions and 1 deletions

View File

@ -36,7 +36,7 @@
****************************************************************************/ ****************************************************************************/
#define MBR_SIZE 512 #define MBR_SIZE 512
#define MBR_LBA_TO_BLOCK(lba, blk) ((le32toh(lba) * 512 + (blk) - 1) / (blk)) #define MBR_LBA_TO_BLOCK(lba, blk) (((blkcnt_t)le32toh(lba) * 512 + (blk) - 1) / (blk))
/**************************************************************************** /****************************************************************************
* Private Types * Private Types