mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] filetype: fix MBR detection
@ 2025-03-24 10:24 Sascha Hauer
  2025-03-24 10:24 ` [PATCH 2/2] filetype: fix FILETYPE_STRING misspelling Sascha Hauer
  2025-03-25  7:16 ` [PATCH 1/2] filetype: fix MBR detection Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2025-03-24 10:24 UTC (permalink / raw)
  To: Barebox List

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@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(&sector[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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-25  7:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-24 10:24 [PATCH 1/2] filetype: fix MBR detection Sascha Hauer
2025-03-24 10:24 ` [PATCH 2/2] filetype: fix FILETYPE_STRING misspelling Sascha Hauer
2025-03-25  7:16 ` [PATCH 1/2] filetype: fix MBR detection Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox