[PATCH 1/4] filetype: Add detection for barebox environment

Sascha Hauer s.hauer at pengutronix.de
Thu Feb 20 08:49:26 EST 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 8cdf827..0b5da30 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -23,6 +23,7 @@
 #include <fs.h>
 #include <malloc.h>
 #include <errno.h>
+#include <envfs.h>
 
 struct filetype_str {
 	const char *name;	/* human readable filetype */
@@ -51,6 +52,7 @@ static const struct filetype_str filetype_str[] = {
 	[filetype_ext] = { "ext filesystem", "ext" },
 	[filetype_gpt] = { "GUID Partition Table", "gpt" },
 	[filetype_bpk] = { "Binary PacKage", "bpk" },
+	[filetype_barebox_env] = { "barebox environment file", "bbenv" },
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -188,6 +190,8 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 
 	if (strncmp(buf8, "#!/bin/sh", 9) == 0)
 		return filetype_sh;
+	if (buf[0] == ENVFS_32(ENVFS_MAGIC))
+		return filetype_barebox_env;
 
 	if (bufsize < 32)
 		return filetype_unknown;
diff --git a/include/filetype.h b/include/filetype.h
index ffefe1c..c20a4f9 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -29,6 +29,7 @@ enum filetype {
 	filetype_gpt,
 	filetype_ubifs,
 	filetype_bpk,
+	filetype_barebox_env,
 	filetype_max,
 };
 
-- 
1.8.5.3




More information about the barebox mailing list