summaryrefslogtreecommitdiffstats
path: root/common/filetype.c
diff options
context:
space:
mode:
authorEnrico Jorns <ejo@pengutronix.de>2016-10-04 12:10:47 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-10-24 08:14:41 +0200
commit9bcbb51263b5f21981651cd146dec439def797e3 (patch)
tree7518508ceb13db3e29930d46aeb1c94183630a9f /common/filetype.c
parent6feed0b491d7f433abca608d4a1d872045187774 (diff)
downloadbarebox-9bcbb51263b5f21981651cd146dec439def797e3.tar.gz
Add filetype and detection for squashfs images
This adds `filetype_squashfs` to the list of known filetypes and adds a detection for squashfs files to file_detect_type(). This currently matches on the `hsqs` start sequence of an image file. Additionally, the newly introduced filetype is registered as the type of the squashfs_driver which allows, for example, to mount squashfs without the need to specify a type parameter. This changes enable booting a squashfs with the simple `boot` command pointing to the location (device) that holds the squashfs. Note that booting with blspec is limited as the current squashfs driver is not capable of handling symbolic links. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/filetype.c')
-rw-r--r--common/filetype.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/filetype.c b/common/filetype.c
index 4728f87..8d72933 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -40,6 +40,7 @@ static const struct filetype_str filetype_str[] = {
[filetype_uimage] = { "U-Boot uImage", "u-boot" },
[filetype_ubi] = { "UBI image", "ubi" },
[filetype_jffs2] = { "JFFS2 image", "jffs2" },
+ [filetype_squashfs] = { "Squashfs image", "squashfs" },
[filetype_gzip] = { "GZIP compressed", "gzip" },
[filetype_bzip2] = { "BZIP2 compressed", "bzip2" },
[filetype_oftree] = { "open firmware Device Tree flattened Binary", "dtb" },
@@ -278,6 +279,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
if (buf8[0] == 0xfd && buf8[1] == 0x37 && buf8[2] == 0x7a &&
buf8[3] == 0x58 && buf8[4] == 0x5a && buf8[5] == 0x00)
return filetype_xz_compressed;
+ if (buf8[0] == 'h' && buf8[1] == 's' && buf8[2] == 'q' &&
+ buf8[3] == 's')
+ return filetype_squashfs;
if (buf[0] == be32_to_cpu(0xd00dfeed))
return filetype_oftree;
if (strncmp(buf8, "ANDROID!", 8) == 0)