[PATCH 4/7] filetype: Add fastboot sparse format detection

Sascha Hauer s.hauer at pengutronix.de
Wed Jan 10 23:50:09 PST 2018


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

diff --git a/common/filetype.c b/common/filetype.c
index 323da026af..f9c034ff2a 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <envfs.h>
 #include <disks.h>
+#include <image-sparse.h>
 
 struct filetype_str {
 	const char *name;	/* human readable filetype */
@@ -64,6 +65,7 @@ static const struct filetype_str filetype_str[] = {
 	[filetype_mxs_bootstream] = { "Freescale MXS bootstream", "mxsbs" },
 	[filetype_socfpga_xload] = { "SoCFPGA prebootloader image", "socfpga-xload" },
 	[filetype_kwbimage_v1] = { "MVEBU kwbimage (v1)", "kwb" },
+	[filetype_android_sparse] = { "Android sparse image", "sparse" },
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -301,6 +303,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 	    (buf8[0x1e] == 0 || buf8[0x1e] == 1))
 		return filetype_kwbimage_v1;
 
+	if (is_sparse_image(_buf))
+		return filetype_android_sparse;
+
 	if (bufsize < 64)
 		return filetype_unknown;
 
diff --git a/include/filetype.h b/include/filetype.h
index c84905d782..b98dcb5014 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -39,6 +39,7 @@ enum filetype {
 	filetype_mxs_bootstream,
 	filetype_socfpga_xload,
 	filetype_kwbimage_v1,
+	filetype_android_sparse,
 	filetype_max,
 };
 
-- 
2.11.0




More information about the barebox mailing list