[PATCH 12/21] filetype: Add DOS EXE file detection support

Sascha Hauer s.hauer at pengutronix.de
Tue Jul 8 01:50:08 PDT 2014


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/filetype.c  | 4 ++++
 include/filetype.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index 508a2b5..a1640ff 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -53,6 +53,7 @@ static const struct filetype_str filetype_str[] = {
 	[filetype_gpt] = { "GUID Partition Table", "gpt" },
 	[filetype_bpk] = { "Binary PacKage", "bpk" },
 	[filetype_barebox_env] = { "barebox environment file", "bbenv" },
+	[filetype_dos] = { "MS-DOS executable", "dos" },
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -231,6 +232,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 	if (bufsize < 64)
 		return filetype_unknown;
 
+	if (buf8[0] == 'M' && buf8[1] == 'Z')
+		return filetype_dos;
+
 	if (is_barebox_arm_head(_buf))
 		return filetype_arm_barebox;
 	if (buf[9] == 0x016f2818 || buf[9] == 0x18286f01)
diff --git a/include/filetype.h b/include/filetype.h
index c20a4f9..db2db35 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -30,6 +30,7 @@ enum filetype {
 	filetype_ubifs,
 	filetype_bpk,
 	filetype_barebox_env,
+	filetype_dos,
 	filetype_max,
 };
 
-- 
2.0.0




More information about the barebox mailing list