summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-01-09 16:00:59 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-01-17 11:04:44 +0100
commitc5ebb4d5b4a8612c8c16ae4545e2ffa4aeb6c7b1 (patch)
tree63fc5c69c359074cd6a8365ed6afa5c3b8a81856
parent13f649a4f960b6ded4735ba99d59dee49e3e77cc (diff)
downloadbarebox-c5ebb4d5b4a8612c8c16ae4545e2ffa4aeb6c7b1.tar.gz
barebox-c5ebb4d5b4a8612c8c16ae4545e2ffa4aeb6c7b1.tar.xz
filetype: Add fastboot sparse format detection
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/filetype.c5
-rw-r--r--include/filetype.h1
2 files changed, 6 insertions, 0 deletions
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,
};