aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files
diff options
context:
space:
mode:
authorGeorge Hopkins <george-hopkins@null.net>2017-10-28 14:01:10 +0200
committerJohn Crispin <john@phrozen.org>2018-02-13 11:16:49 +0100
commit5c7a58764e55d34317db2cfedb7206c634b4d7f6 (patch)
tree56dae418ab0be486f97cfa9938253d4e0d324b31 /target/linux/generic/files
parent6e7357097f665096af3e099d17898371e56f1df5 (diff)
downloadupstream-5c7a58764e55d34317db2cfedb7206c634b4d7f6.tar.gz
upstream-5c7a58764e55d34317db2cfedb7206c634b4d7f6.tar.bz2
upstream-5c7a58764e55d34317db2cfedb7206c634b4d7f6.zip
kernel: mtdsplit: split by WRG header
Support splitting WRG images, which can be found in older D-Link devices. Signed-off-by: George Hopkins <george-hopkins@null.net>
Diffstat (limited to 'target/linux/generic/files')
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c
index c0e897777d..16ebd51345 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_wrgg.c
@@ -22,6 +22,7 @@
#define WRGG_NR_PARTS 2
#define WRGG_MIN_ROOTFS_OFFS 0x80000 /* 512KiB */
#define WRGG03_MAGIC 0x20080321
+#define WRG_MAGIC 0x20040220
struct wrgg03_header {
char signature[32];
@@ -38,6 +39,16 @@ struct wrgg03_header {
char digest[16];
} __attribute__ ((packed));
+struct wrg_header {
+ char signature[32];
+ uint32_t magic1;
+ uint32_t magic2;
+ uint32_t size;
+ uint32_t offset;
+ char devname[32];
+ char digest[16];
+} __attribute__ ((packed));
+
static int mtdsplit_parse_wrgg(struct mtd_info *master,
const struct mtd_partition **pparts,
@@ -59,10 +70,14 @@ static int mtdsplit_parse_wrgg(struct mtd_info *master,
return -EIO;
/* sanity checks */
- if (le32_to_cpu(hdr.magic1) != WRGG03_MAGIC)
+ if (le32_to_cpu(hdr.magic1) == WRGG03_MAGIC) {
+ kernel_ent_size = hdr_len + be32_to_cpu(hdr.size);
+ } else if (le32_to_cpu(hdr.magic1) == WRG_MAGIC) {
+ kernel_ent_size = sizeof(struct wrg_header) + le32_to_cpu(
+ ((struct wrg_header*)&hdr)->size);
+ } else {
return -EINVAL;
-
- kernel_ent_size = hdr_len + be32_to_cpu(hdr.size);
+ }
if (kernel_ent_size > master->size)
return -EINVAL;