You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/01/14 09:29:32 UTC
(nuttx) branch master updated: fs: partition: fs_mbr: fix for MBR block count calculation.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f01e395b1c fs: partition: fs_mbr: fix for MBR block count calculation.
f01e395b1c is described below
commit f01e395b1ca05e0ba9d11de84c78fc4a1e577e4c
Author: Takeyoshi Kikuchi <ki...@centurysys.co.jp>
AuthorDate: Sat Jan 13 19:44:27 2024 +0900
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 <ki...@centurysys.co.jp>
---
fs/partition/fs_mbr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/partition/fs_mbr.c b/fs/partition/fs_mbr.c
index 672c9d76da..d8eccf45f9 100644
--- a/fs/partition/fs_mbr.c
+++ b/fs/partition/fs_mbr.c
@@ -36,7 +36,7 @@
****************************************************************************/
#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