mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] filetype: move is_dos_exe into header
Date: Mon, 15 Dec 2025 09:38:28 +0100	[thread overview]
Message-ID: <20251215083829.2386659-1-a.fatoum@pengutronix.de> (raw)

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@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




             reply	other threads:[~2025-12-15  8:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15  8:38 Ahmad Fatoum [this message]
2025-12-15  9:10 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251215083829.2386659-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox