diff options
author | Thibaut VARÈNE <hacks@slashdirt.org> | 2017-10-28 14:48:08 +0200 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2017-11-08 23:18:22 +0100 |
commit | 74f891752b617a9f17f675f341160458c055b301 (patch) | |
tree | b9d53df5e1c5159df17bb2360590285eab970099 /target/linux | |
parent | 050fb3b55cde4348f4ed12ab98f451c4c56a695b (diff) | |
download | mtk-20170518-74f891752b617a9f17f675f341160458c055b301.zip mtk-20170518-74f891752b617a9f17f675f341160458c055b301.tar.gz mtk-20170518-74f891752b617a9f17f675f341160458c055b301.tar.bz2 |
generic: make mtdsplit-tplink.c honor rootfs offset
The splitter ignored the rootfs offset from the header, probably
because until c1e6e61 it was invalid.
This patch fixes the splitter to use the now correct header data.
Regarding target/linux/ar71xx/files/drivers/mtd/tplinkpart.c,
this particular splitter "falls back" to the correct rootfs offset
reading and as such it doesn't need to be updated, although it will
report a kernel partition length that can be larger than the actual
length as it assumes that partition fills the entire segment up to
the rootfs partition.
Tested-by: Mathias Kresin <dev@kresin.me>
Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Tested-by: Daniel Engberg <daniel.engberg.lists@pyret.net>
Tested-by: Henryk Heisig <hyniu@o2.pl>
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
Diffstat (limited to 'target/linux')
-rw-r--r-- | target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c index 3a50250..c346aa8 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c @@ -106,6 +106,7 @@ static int mtdsplit_parse_tplink(struct mtd_info *master, return -EINVAL; kernel_size = sizeof(hdr) + be32_to_cpu(hdr.v1.kernel_len); + rootfs_offset = be32_to_cpu(hdr.v1.rootfs_ofs); break; case 2: case 3: @@ -113,6 +114,7 @@ static int mtdsplit_parse_tplink(struct mtd_info *master, return -EINVAL; kernel_size = sizeof(hdr) + be32_to_cpu(hdr.v2.kernel_len); + rootfs_offset = be32_to_cpu(hdr.v2.rootfs_ofs); break; default: return -EINVAL; @@ -121,11 +123,9 @@ static int mtdsplit_parse_tplink(struct mtd_info *master, if (kernel_size > master->size) return -EINVAL; - /* Find the rootfs after the kernel. */ - err = mtd_check_rootfs_magic(master, kernel_size, NULL); - if (!err) { - rootfs_offset = kernel_size; - } else { + /* Find the rootfs */ + err = mtd_check_rootfs_magic(master, rootfs_offset, NULL); + if (err) { /* * The size in the header might cover the rootfs as well. * Start the search from an arbitrary offset. @@ -142,7 +142,7 @@ static int mtdsplit_parse_tplink(struct mtd_info *master, parts[0].name = KERNEL_PART_NAME; parts[0].offset = 0; - parts[0].size = rootfs_offset; + parts[0].size = kernel_size; parts[1].name = ROOTFS_PART_NAME; parts[1].offset = rootfs_offset; |