summaryrefslogtreecommitdiffstats
path: root/common/filetype.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-12-02 11:22:44 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-12-03 11:23:25 +0100
commitd2dc3640ef3d058a921270ae64e06f9889d80684 (patch)
tree3d59d1dafa6f8dd5fba3bef0d2b99b3f5fb15a44 /common/filetype.c
parent5e742637623af0b1ea365b4c8ffda566a0ee3a2b (diff)
downloadbarebox-d2dc3640ef3d058a921270ae64e06f9889d80684.tar.gz
add ext fs detection support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/filetype.c')
-rw-r--r--common/filetype.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/filetype.c b/common/filetype.c
index c1bd11d..748e364 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -47,6 +47,7 @@ static const struct filetype_str filetype_str[] = {
[filetype_mbr] = { "MBR sector", "mbr" },
[filetype_bmp] = { "BMP image", "bmp" },
[filetype_png] = { "PNG image", "png" },
+ [filetype_ext] = { "ext filesystem", "ext" },
};
const char *file_type_to_string(enum filetype f)
@@ -110,6 +111,7 @@ enum filetype file_detect_type(void *_buf, size_t bufsize)
u32 *buf = _buf;
u64 *buf64 = _buf;
u8 *buf8 = _buf;
+ u16 *buf16 = _buf;
enum filetype type;
if (bufsize < 9)
@@ -161,6 +163,12 @@ enum filetype file_detect_type(void *_buf, size_t bufsize)
if (type != filetype_unknown)
return type;
+ if (bufsize < 1536)
+ return filetype_unknown;
+
+ if (buf16[512 + 28] == le16_to_cpu(0xef53))
+ return filetype_ext;
+
return filetype_unknown;
}