[PATCH 1/2] filetype: fix MBR detection
Sascha Hauer
s.hauer at pengutronix.de
Mon Mar 24 03:24:41 PDT 2025
is_fat_or_mbr() doesn't detect MBRs anymore because we return
filetype_unknown when it's not a FAT filesystem. Instead we may only
return early when it's explicitly a FAT filesystem, but continue
in the function in case it's not to properly detect a MBR.
Fixes: b25680a9c9 ("filetype: add file_detect_fs_type()")
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/filetype.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/common/filetype.c b/common/filetype.c
index ce868223d5..80e6ceb845 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -243,9 +243,12 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec)
if (bootsec)
*bootsec = 0;
- if (file_detect_fs_fat(sector, 512) != filetype_fat)
+ if (get_unaligned_le16(§or[BS_55AA]) != 0xAA55)
return filetype_unknown;
+ if (file_detect_fs_fat(sector, 512) == filetype_fat)
+ return filetype_fat;
+
if (bootsec)
/*
* This must be an MBR, so return the starting sector of the
--
2.39.5
More information about the barebox
mailing list