[PATCH] filetype: move is_dos_exe into header
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Dec 15 00:38:28 PST 2025
The MZ magic can occur together with other magic signatures as well,
e.g. in x86 bzImages or in EFI-stubbed ARM/RISC-V kernel images.
Move the check into a header to allow it to be used e.g. from boot entry
providers.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/filetype.c | 5 -----
include/filetype.h | 6 ++++++
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/common/filetype.c b/common/filetype.c
index 3e3e18dae0b3..196591698768 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -288,11 +288,6 @@ enum filetype file_detect_partition_table(const void *_buf, size_t bufsize)
return filetype_unknown;
}
-static bool is_dos_exe(const u8 *buf8)
-{
- return buf8[0] == 'M' && buf8[1] == 'Z';
-}
-
#define CH_TOC_section_name 0x14
enum filetype file_detect_compression_type(const void *_buf, size_t bufsize)
diff --git a/include/filetype.h b/include/filetype.h
index 440eb95bfb0c..283b8fee4c70 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -143,6 +143,12 @@ static inline int is_barebox_head(const char *head)
return is_barebox_arm_head(head) || is_barebox_mips_head(head);
}
+static inline bool is_dos_exe(const void *buf)
+{
+ const u8 *buf8 = buf;
+ return buf8[0] == 'M' && buf8[1] == 'Z';
+}
+
static inline bool is_arm64_linux_bootimage(const void *header)
{
return le32_to_cpup(header + 56) == 0x644d5241;
--
2.47.3
More information about the barebox
mailing list