Skip to content

Commit

Permalink
filetype: Add fastboot sparse format detection
Browse files Browse the repository at this point in the history
Signed-off-by: Sascha Hauer <[email protected]>
  • Loading branch information
saschahauer committed Jan 17, 2018
1 parent 13f649a commit c5ebb4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/filetype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions include/filetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum filetype {
filetype_mxs_bootstream,
filetype_socfpga_xload,
filetype_kwbimage_v1,
filetype_android_sparse,
filetype_max,
};

Expand Down

0 comments on commit c5ebb4d

Please sign in to comment.