mtdsplit_squashfs always splits into rootfs and rootfs_data. Wit this
patch is not possible to give the new partition a different name.

Example:
partition@140000 {
        reg = <0x140000 0x1ea0000>;
        compatible = "openwrt,uimage", "denx,uimage", "openwrt,squashfs";
        label = "firmware";
        openwrt,offset = <380>;
        openwrt,data-partition-name = "ubi";
};
This splits at first the uImage into kernel and rootfs, after that
rootfs is splitted into rootfs (only squash) and the new ubi partition.

Signed-off-by: André Valentin <[email protected]>
---
 .../drivers/mtd/mtdsplit/mtdsplit_squashfs.c     | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c
index f6353da65b..9fdc425844 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c
@@ -18,6 +18,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/byteorder/generic.h>
+#include <linux/of.h>
 
 #include "mtdsplit.h"
 
@@ -26,10 +27,12 @@ mtdsplit_parse_squashfs(struct mtd_info *master,
                        const struct mtd_partition **pparts,
                        struct mtd_part_parser_data *data)
 {
+       struct device_node *np;
        struct mtd_partition *part;
        struct mtd_info *parent_mtd;
        size_t part_offset;
        size_t squashfs_len;
+       const char *part_name = NULL;
        int err;
 
        err = mtd_get_squashfs_len(master, 0, &squashfs_len);
@@ -46,7 +49,18 @@ mtdsplit_parse_squashfs(struct mtd_info *master,
                return -ENOMEM;
        }
 
-       part->name = ROOTFS_SPLIT_NAME;
+       np = mtd_get_of_node(parent_mtd);
+       if (np && of_device_is_compatible(np, "openwrt,squashfs")) {
+               err = of_property_read_string(np, 
"openwrt,data-partition-name", &part_name);
+               if (err)
+                       pr_debug("failed to retrieve 
openwrt,data-partition-name.\n");
+       }
+
+       if (part_name == NULL) {
+               part->name = ROOTFS_SPLIT_NAME;
+       } else {
+               part->name = part_name;
+       }
        part->offset = mtd_roundup_to_eb(part_offset + squashfs_len,
                                         parent_mtd) - part_offset;
        part->size = mtd_rounddown_to_eb(master->size - part->offset, master);
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to