mirror of
https://github.com/FUjr/gl-infra-builder.git
synced 2025-12-16 17:15:08 +00:00
parent
76c72f2f7c
commit
49672cca57
@ -1,41 +1,20 @@
|
|||||||
From a335de65a396f71e35797bf9b7ea76016f91edb2 Mon Sep 17 00:00:00 2001
|
From cb7839fee0d6191efd0f8f6351b5128a202f1b26 Mon Sep 17 00:00:00 2001
|
||||||
From: Hongjian Zhang <hongjian.zhang@gl-inet.com>
|
From: Hongjian Zhang <hongjian.zhang@gl-inet.com>
|
||||||
Date: Mon, 13 Feb 2023 16:45:22 +0800
|
Date: Mon, 13 Feb 2023 16:45:22 +0800
|
||||||
Subject: [PATCH] Kernel: support Shortcut-fe
|
Subject: [PATCH] Kernel: support software acceleration
|
||||||
|
|
||||||
---
|
---
|
||||||
target/linux/generic/config-5.4 | 2 +
|
|
||||||
...k-events-support-multiple-registrant.patch | 313 ++++++++++++++++++
|
...k-events-support-multiple-registrant.patch | 313 ++++++++++++++++++
|
||||||
...-linux-kernel-to-support-shortcut-fe.patch | 282 ++++++++++++++++
|
...-linux-kernel-to-support-shortcut-fe.patch | 282 ++++++++++++++++
|
||||||
3 files changed, 597 insertions(+)
|
2 files changed, 595 insertions(+)
|
||||||
create mode 100644 target/linux/generic/hack-5.4/952-net-conntrack-events-support-multiple-registrant.patch
|
create mode 100644 target/linux/mediatek/patches-5.4/952-net-conntrack-events-support-multiple-registrant.patch
|
||||||
create mode 100644 target/linux/generic/hack-5.4/953-net-patch-linux-kernel-to-support-shortcut-fe.patch
|
create mode 100644 target/linux/mediatek/patches-5.4/953-net-patch-linux-kernel-to-support-shortcut-fe.patch
|
||||||
|
|
||||||
diff --git a/target/linux/generic/config-5.4 b/target/linux/generic/config-5.4
|
diff --git a/target/linux/mediatek/patches-5.4/952-net-conntrack-events-support-multiple-registrant.patch b/target/linux/mediatek/patches-5.4/952-net-conntrack-events-support-multiple-registrant.patch
|
||||||
index 63213a8e1f..11d5cd2b0c 100644
|
|
||||||
--- a/target/linux/generic/config-5.4
|
|
||||||
+++ b/target/linux/generic/config-5.4
|
|
||||||
@@ -654,6 +654,7 @@ CONFIG_BPF_JIT=y
|
|
||||||
# CONFIG_BPF_JIT_ALWAYS_ON is not set
|
|
||||||
# CONFIG_BPF_UNPRIV_DEFAULT_OFF is not set
|
|
||||||
# CONFIG_BPF_STREAM_PARSER is not set
|
|
||||||
+# CONFIG_SHORTCUT_FE is not set
|
|
||||||
CONFIG_BPF_SYSCALL=y
|
|
||||||
# CONFIG_BPQETHER is not set
|
|
||||||
CONFIG_BQL=y
|
|
||||||
@@ -3696,6 +3697,7 @@ CONFIG_NFS_V3=y
|
|
||||||
# CONFIG_NF_CONNTRACK_AMANDA is not set
|
|
||||||
# CONFIG_NF_CONNTRACK_BRIDGE is not set
|
|
||||||
# CONFIG_NF_CONNTRACK_EVENTS is not set
|
|
||||||
+# CONFIG_NF_CONNTRACK_CHAIN_EVENTS is not set
|
|
||||||
# CONFIG_NF_CONNTRACK_FTP is not set
|
|
||||||
# CONFIG_NF_CONNTRACK_H323 is not set
|
|
||||||
# CONFIG_NF_CONNTRACK_IPV4 is not set
|
|
||||||
diff --git a/target/linux/generic/hack-5.4/952-net-conntrack-events-support-multiple-registrant.patch b/target/linux/generic/hack-5.4/952-net-conntrack-events-support-multiple-registrant.patch
|
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000..c763449594
|
index 0000000000..c763449594
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/target/linux/generic/hack-5.4/952-net-conntrack-events-support-multiple-registrant.patch
|
+++ b/target/linux/mediatek/patches-5.4/952-net-conntrack-events-support-multiple-registrant.patch
|
||||||
@@ -0,0 +1,313 @@
|
@@ -0,0 +1,313 @@
|
||||||
+From 42824d4b753f84ccf885eca602c5037338b546c8 Mon Sep 17 00:00:00 2001
|
+From 42824d4b753f84ccf885eca602c5037338b546c8 Mon Sep 17 00:00:00 2001
|
||||||
+From: Zhi Chen <zhichen@codeaurora.org>
|
+From: Zhi Chen <zhichen@codeaurora.org>
|
||||||
@ -350,11 +329,11 @@ index 0000000000..c763449594
|
|||||||
+
|
+
|
||||||
+ static struct nf_exp_event_notifier ctnl_notifier_exp = {
|
+ static struct nf_exp_event_notifier ctnl_notifier_exp = {
|
||||||
+ .fcn = ctnetlink_expect_event,
|
+ .fcn = ctnetlink_expect_event,
|
||||||
diff --git a/target/linux/generic/hack-5.4/953-net-patch-linux-kernel-to-support-shortcut-fe.patch b/target/linux/generic/hack-5.4/953-net-patch-linux-kernel-to-support-shortcut-fe.patch
|
diff --git a/target/linux/mediatek/patches-5.4/953-net-patch-linux-kernel-to-support-shortcut-fe.patch b/target/linux/mediatek/patches-5.4/953-net-patch-linux-kernel-to-support-shortcut-fe.patch
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000..3f29c65344
|
index 0000000000..3f29c65344
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/target/linux/generic/hack-5.4/953-net-patch-linux-kernel-to-support-shortcut-fe.patch
|
+++ b/target/linux/mediatek/patches-5.4/953-net-patch-linux-kernel-to-support-shortcut-fe.patch
|
||||||
@@ -0,0 +1,282 @@
|
@@ -0,0 +1,282 @@
|
||||||
+Index: b/include/linux/if_bridge.h
|
+Index: b/include/linux/if_bridge.h
|
||||||
+===================================================================
|
+===================================================================
|
||||||
@ -639,5 +618,5 @@ index 0000000000..3f29c65344
|
|||||||
+ void nf_conntrack_unregister_notifier(struct net *net,
|
+ void nf_conntrack_unregister_notifier(struct net *net,
|
||||||
+ struct nf_ct_event_notifier *new)
|
+ struct nf_ct_event_notifier *new)
|
||||||
--
|
--
|
||||||
2.34.1
|
2.17.1
|
||||||
|
|
||||||
@ -1,159 +0,0 @@
|
|||||||
From f37449982969777ab1bc6268fd174bd10a2c7464 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jianhui Zhao <jianhui.zhao@gl-inet.com>
|
|
||||||
Date: Tue, 16 May 2023 18:18:31 +0800
|
|
||||||
Subject: [PATCH] kernel: block2mtd support partline
|
|
||||||
|
|
||||||
Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
|
|
||||||
---
|
|
||||||
.../9999-block2mtd-support-partline.patch | 139 ++++++++++++++++++
|
|
||||||
1 file changed, 139 insertions(+)
|
|
||||||
create mode 100644 target/linux/generic/hack-5.4/9999-block2mtd-support-partline.patch
|
|
||||||
|
|
||||||
diff --git a/target/linux/generic/hack-5.4/9999-block2mtd-support-partline.patch b/target/linux/generic/hack-5.4/9999-block2mtd-support-partline.patch
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..2e4c2555da
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/target/linux/generic/hack-5.4/9999-block2mtd-support-partline.patch
|
|
||||||
@@ -0,0 +1,139 @@
|
|
||||||
+Index: linux-5.4.188/drivers/mtd/devices/block2mtd.c
|
|
||||||
+===================================================================
|
|
||||||
+--- linux-5.4.188.orig/drivers/mtd/devices/block2mtd.c
|
|
||||||
++++ linux-5.4.188/drivers/mtd/devices/block2mtd.c
|
|
||||||
+@@ -26,11 +26,14 @@
|
|
||||||
+ #include <linux/list.h>
|
|
||||||
+ #include <linux/init.h>
|
|
||||||
+ #include <linux/mtd/mtd.h>
|
|
||||||
++#include <linux/mtd/partitions.h>
|
|
||||||
+ #include <linux/mutex.h>
|
|
||||||
+ #include <linux/mount.h>
|
|
||||||
+ #include <linux/slab.h>
|
|
||||||
+ #include <linux/major.h>
|
|
||||||
+
|
|
||||||
++static const char * const block2mtd_probe_types[] = { "ofpart","cmdlinepart", NULL };
|
|
||||||
++
|
|
||||||
+ /* Info for the block device */
|
|
||||||
+ struct block2mtd_dev {
|
|
||||||
+ struct list_head list;
|
|
||||||
+@@ -183,10 +186,9 @@ static int block2mtd_write(struct mtd_in
|
|
||||||
+ mutex_unlock(&dev->write_mutex);
|
|
||||||
+ if (err > 0)
|
|
||||||
+ err = 0;
|
|
||||||
++ sync_blockdev(dev->blkdev);
|
|
||||||
+ return err;
|
|
||||||
+ }
|
|
||||||
+-
|
|
||||||
+-
|
|
||||||
+ /* sync the device - wait until the write queue is empty */
|
|
||||||
+ static void block2mtd_sync(struct mtd_info *mtd)
|
|
||||||
+ {
|
|
||||||
+@@ -214,12 +216,13 @@ static void block2mtd_free_device(struct
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ static struct block2mtd_dev *add_device(char *devname, int erase_size,
|
|
||||||
+- int timeout)
|
|
||||||
++ const char *mtdname, int timeout)
|
|
||||||
+ {
|
|
||||||
+ #ifndef MODULE
|
|
||||||
+ int i;
|
|
||||||
+ #endif
|
|
||||||
+ const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
|
|
||||||
++ struct mtd_part_parser_data ppdata;
|
|
||||||
+ struct block_device *bdev;
|
|
||||||
+ struct block2mtd_dev *dev;
|
|
||||||
+ char *name;
|
|
||||||
+@@ -278,10 +281,13 @@ static struct block2mtd_dev *add_device(
|
|
||||||
+
|
|
||||||
+ /* Setup the MTD structure */
|
|
||||||
+ /* make the name contain the block device in */
|
|
||||||
+- name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
|
|
||||||
++ if (!mtdname)
|
|
||||||
++ mtdname = devname;
|
|
||||||
++ name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL);
|
|
||||||
+ if (!name)
|
|
||||||
+ goto err_destroy_mutex;
|
|
||||||
+
|
|
||||||
++ strcpy(name, mtdname);
|
|
||||||
+ dev->mtd.name = name;
|
|
||||||
+
|
|
||||||
+ dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
|
|
||||||
+@@ -292,12 +298,14 @@ static struct block2mtd_dev *add_device(
|
|
||||||
+ dev->mtd.flags = MTD_CAP_RAM;
|
|
||||||
+ dev->mtd._erase = block2mtd_erase;
|
|
||||||
+ dev->mtd._write = block2mtd_write;
|
|
||||||
++ dev->mtd._panic_write = block2mtd_write;
|
|
||||||
+ dev->mtd._sync = block2mtd_sync;
|
|
||||||
+ dev->mtd._read = block2mtd_read;
|
|
||||||
+ dev->mtd.priv = dev;
|
|
||||||
+ dev->mtd.owner = THIS_MODULE;
|
|
||||||
+
|
|
||||||
+- if (mtd_device_register(&dev->mtd, NULL, 0)) {
|
|
||||||
++ memset(&ppdata, '\0', sizeof(ppdata));
|
|
||||||
++ if (mtd_device_parse_register(&dev->mtd, block2mtd_probe_types, &ppdata, NULL, 0)) {
|
|
||||||
+ /* Device didn't get added, so free the entry */
|
|
||||||
+ goto err_destroy_mutex;
|
|
||||||
+ }
|
|
||||||
+@@ -305,7 +313,7 @@ static struct block2mtd_dev *add_device(
|
|
||||||
+ list_add(&dev->list, &blkmtd_device_list);
|
|
||||||
+ pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n",
|
|
||||||
+ dev->mtd.index,
|
|
||||||
+- dev->mtd.name + strlen("block2mtd: "),
|
|
||||||
++ dev->mtd.name,
|
|
||||||
+ dev->mtd.erasesize >> 10, dev->mtd.erasesize);
|
|
||||||
+ return dev;
|
|
||||||
+
|
|
||||||
+@@ -381,7 +389,7 @@ static int block2mtd_setup2(const char *
|
|
||||||
+ /* 80 for device, 12 for erase size, 80 for name, 8 for timeout */
|
|
||||||
+ char buf[80 + 12 + 80 + 8];
|
|
||||||
+ char *str = buf;
|
|
||||||
+- char *token[2];
|
|
||||||
++ char *token[4];
|
|
||||||
+ char *name;
|
|
||||||
+ size_t erase_size = PAGE_SIZE;
|
|
||||||
+ unsigned long timeout = MTD_DEFAULT_TIMEOUT;
|
|
||||||
+@@ -395,7 +403,7 @@ static int block2mtd_setup2(const char *
|
|
||||||
+ strcpy(str, val);
|
|
||||||
+ kill_final_newline(str);
|
|
||||||
+
|
|
||||||
+- for (i = 0; i < 2; i++)
|
|
||||||
++ for (i = 0; i < 4; i++)
|
|
||||||
+ token[i] = strsep(&str, ",");
|
|
||||||
+
|
|
||||||
+ if (str) {
|
|
||||||
+@@ -421,8 +429,13 @@ static int block2mtd_setup2(const char *
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
++ if (token[2] && (strlen(token[2]) + 1 > 80))
|
|
||||||
++ pr_err("mtd device name too long\n");
|
|
||||||
++
|
|
||||||
++ if (token[3] && kstrtoul(token[3], 0, &timeout))
|
|
||||||
++ pr_err("invalid timeout\n");
|
|
||||||
+
|
|
||||||
+- add_device(name, erase_size, timeout);
|
|
||||||
++ add_device(name, erase_size, token[2], timeout);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+@@ -454,9 +467,8 @@ static int block2mtd_setup(const char *v
|
|
||||||
+ #endif
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+-
|
|
||||||
+ module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
|
|
||||||
+-MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
|
|
||||||
++MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>[,<timeout>]]]\"");
|
|
||||||
+
|
|
||||||
+ static int __init block2mtd_init(void)
|
|
||||||
+ {
|
|
||||||
+@@ -484,7 +496,7 @@ static void block2mtd_exit(void)
|
|
||||||
+ mutex_destroy(&dev->write_mutex);
|
|
||||||
+ pr_info("mtd%d: [%s] removed\n",
|
|
||||||
+ dev->mtd.index,
|
|
||||||
+- dev->mtd.name + strlen("block2mtd: "));
|
|
||||||
++ dev->mtd.name);
|
|
||||||
+ list_del(&dev->list);
|
|
||||||
+ block2mtd_free_device(dev);
|
|
||||||
+ }
|
|
||||||
--
|
|
||||||
2.34.1
|
|
||||||
|
|
||||||
@ -1,206 +0,0 @@
|
|||||||
From a5fb2fb2faa520dabb8b3515918f725678d3ed80 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jianhui Zhao <jianhui.zhao@gl-inet.com>
|
|
||||||
Date: Tue, 16 May 2023 18:19:30 +0800
|
|
||||||
Subject: [PATCH] kernel: block: support partition split
|
|
||||||
|
|
||||||
Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
|
|
||||||
---
|
|
||||||
.../9999-support-partition-split.patch | 186 ++++++++++++++++++
|
|
||||||
1 file changed, 186 insertions(+)
|
|
||||||
create mode 100644 target/linux/generic/hack-5.4/9999-support-partition-split.patch
|
|
||||||
|
|
||||||
diff --git a/target/linux/generic/hack-5.4/9999-support-partition-split.patch b/target/linux/generic/hack-5.4/9999-support-partition-split.patch
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000..8e0026c216
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/target/linux/generic/hack-5.4/9999-support-partition-split.patch
|
|
||||||
@@ -0,0 +1,186 @@
|
|
||||||
+Index: linux-5.4.188/block/Kconfig
|
|
||||||
+===================================================================
|
|
||||||
+--- linux-5.4.188.orig/block/Kconfig
|
|
||||||
++++ linux-5.4.188/block/Kconfig
|
|
||||||
+@@ -105,6 +105,9 @@ config BLK_DEV_THROTTLING_LOW
|
|
||||||
+
|
|
||||||
+ Note, this is an experimental interface and could be changed someday.
|
|
||||||
+
|
|
||||||
++config PARTITION_SPLIT
|
|
||||||
++ bool "Openwrt Block device partition rootfs split"
|
|
||||||
++
|
|
||||||
+ config BLK_CMDLINE_PARSER
|
|
||||||
+ bool "Block device command line partition parser"
|
|
||||||
+ ---help---
|
|
||||||
+Index: linux-5.4.188/block/Makefile
|
|
||||||
+===================================================================
|
|
||||||
+--- linux-5.4.188.orig/block/Makefile
|
|
||||||
++++ linux-5.4.188/block/Makefile
|
|
||||||
+@@ -36,3 +36,4 @@ obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-deb
|
|
||||||
+ obj-$(CONFIG_BLK_DEBUG_FS_ZONED)+= blk-mq-debugfs-zoned.o
|
|
||||||
+ obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o
|
|
||||||
+ obj-$(CONFIG_BLK_PM) += blk-pm.o
|
|
||||||
++obj-$(CONFIG_PARTITION_SPLIT) += partition-split.o
|
|
||||||
+Index: linux-5.4.188/block/partition-generic.c
|
|
||||||
+===================================================================
|
|
||||||
+--- linux-5.4.188.orig/block/partition-generic.c
|
|
||||||
++++ linux-5.4.188/block/partition-generic.c
|
|
||||||
+@@ -21,6 +21,10 @@
|
|
||||||
+
|
|
||||||
+ #include "partitions/check.h"
|
|
||||||
+
|
|
||||||
++#ifdef CONFIG_PARTITION_SPLIT
|
|
||||||
++#include "partition-split.h"
|
|
||||||
++#endif
|
|
||||||
++
|
|
||||||
+ #ifdef CONFIG_BLK_DEV_MD
|
|
||||||
+ extern void md_autodetect_dev(dev_t dev);
|
|
||||||
+ #endif
|
|
||||||
+@@ -569,6 +573,9 @@ rescan:
|
|
||||||
+ highest = p;
|
|
||||||
+
|
|
||||||
+ disk_expand_part_tbl(disk, highest);
|
|
||||||
++#ifdef CONFIG_PARTITION_SPLIT
|
|
||||||
++ partition_split(bdev, state);
|
|
||||||
++#endif
|
|
||||||
+
|
|
||||||
+ /* add partitions */
|
|
||||||
+ for (p = 1; p < state->limit; p++) {
|
|
||||||
+Index: linux-5.4.188/block/partition-split.c
|
|
||||||
+===================================================================
|
|
||||||
+--- /dev/null
|
|
||||||
++++ linux-5.4.188/block/partition-split.c
|
|
||||||
+@@ -0,0 +1,111 @@
|
|
||||||
++#include <linux/blkdev.h>
|
|
||||||
++#include <linux/magic.h>
|
|
||||||
++#include <linux/module.h>
|
|
||||||
++#include "partitions/check.h"
|
|
||||||
++#include "partition-split.h"
|
|
||||||
++
|
|
||||||
++void print_sblock_value(char *buf)
|
|
||||||
++{
|
|
||||||
++ int i, j;
|
|
||||||
++ for (i = 0; i < sizeof(struct squashfs_sblock);) {
|
|
||||||
++ for (j = 0; j < 16; j++) {
|
|
||||||
++ printk("%02x ", buf[i]);
|
|
||||||
++ i++;
|
|
||||||
++ }
|
|
||||||
++ printk("\n");
|
|
||||||
++ }
|
|
||||||
++}
|
|
||||||
++
|
|
||||||
++unsigned char *fs_read_super_block(struct block_device *bdev, sector_t from, Sector *sector)
|
|
||||||
++{
|
|
||||||
++ if (from >= get_capacity(bdev->bd_disk)) {
|
|
||||||
++ return NULL;
|
|
||||||
++ }
|
|
||||||
++ return read_dev_sector(bdev, from, sector);
|
|
||||||
++}
|
|
||||||
++
|
|
||||||
++
|
|
||||||
++int get_squashfs_len(struct block_device *bdev, sector_t from, size_t *squashfs_len)
|
|
||||||
++{
|
|
||||||
++ struct squashfs_sblock sb;
|
|
||||||
++ unsigned char *buf;
|
|
||||||
++ Sector sector;
|
|
||||||
++ size_t retlen;
|
|
||||||
++
|
|
||||||
++ buf = fs_read_super_block(bdev, from, §or);
|
|
||||||
++ if (!buf) {
|
|
||||||
++ printk("failed to get super\n");
|
|
||||||
++ return -EIO;
|
|
||||||
++ }
|
|
||||||
++ memcpy((void *)&sb, buf, sizeof(sb));
|
|
||||||
++ put_dev_sector(sector);
|
|
||||||
++
|
|
||||||
++ if (le32_to_cpu(sb.s_magic) != SQUASHFS_MAGIC) {
|
|
||||||
++ printk("no squashfs found in\n");
|
|
||||||
++ //print_sblock_value((char *)&sb);
|
|
||||||
++ return -EINVAL;
|
|
||||||
++ }
|
|
||||||
++
|
|
||||||
++ retlen = le64_to_cpu(sb.bytes_used);
|
|
||||||
++ if (retlen <= 0) {
|
|
||||||
++ printk("squashfs is empty in \n");
|
|
||||||
++ return -ENODEV;
|
|
||||||
++ }
|
|
||||||
++
|
|
||||||
++ *squashfs_len = retlen;
|
|
||||||
++ return 0;
|
|
||||||
++}
|
|
||||||
++
|
|
||||||
++static int find_part_by_lable(struct parsed_partitions *state, const char *lable)
|
|
||||||
++{
|
|
||||||
++ int p;
|
|
||||||
++ /* add partitions */
|
|
||||||
++ for (p = 1; p < state->limit; p++) {
|
|
||||||
++ if (!strcmp(state->parts[p].info.volname, lable))
|
|
||||||
++ return p;
|
|
||||||
++ }
|
|
||||||
++ return 0;
|
|
||||||
++}
|
|
||||||
++
|
|
||||||
++int partition_split(struct block_device *bdev, struct parsed_partitions *state)
|
|
||||||
++{
|
|
||||||
++ int p, insert;
|
|
||||||
++ size_t sqfs_size;
|
|
||||||
++ sector_t new_size, new_from;
|
|
||||||
++ struct partition_meta_info *info;
|
|
||||||
++ char tmp[sizeof(info->volname) + 4];
|
|
||||||
++
|
|
||||||
++ p = find_part_by_lable(state, ROOTFS_PART);
|
|
||||||
++ if (p == 0)
|
|
||||||
++ return 0;
|
|
||||||
++ if (get_squashfs_len(bdev, state->parts[p].from, &sqfs_size))
|
|
||||||
++ return 0;
|
|
||||||
++
|
|
||||||
++ sqfs_size = (sqfs_size + (ALING_SQFS - 1)) & ~(ALING_SQFS - 1); //squashfs 64k对齐
|
|
||||||
++
|
|
||||||
++ //计算新分区大小和起始位置
|
|
||||||
++
|
|
||||||
++ new_size = state->parts[p].size - (sqfs_size >> 9);
|
|
||||||
++ new_from = state->parts[p].from + (sqfs_size >> 9);
|
|
||||||
++
|
|
||||||
++ for (insert = 1; insert < state->limit; insert++) {
|
|
||||||
++ if (!state->parts[insert].size)
|
|
||||||
++ break;
|
|
||||||
++ }
|
|
||||||
++
|
|
||||||
++ if (insert >= state->limit)
|
|
||||||
++ return 0;
|
|
||||||
++
|
|
||||||
++ //追加一个新分区并设置相关信息
|
|
||||||
++ put_partition(state, insert, new_from, new_size);
|
|
||||||
++
|
|
||||||
++ info = &state->parts[insert].info;
|
|
||||||
++
|
|
||||||
++ strncpy(info->volname, ROOTFS_PART_DATA, strlen(ROOTFS_PART_DATA) + 1);
|
|
||||||
++ snprintf(tmp, sizeof(tmp), "(%s)", info->volname);
|
|
||||||
++ strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
|
||||||
++
|
|
||||||
++ state->parts[insert].has_info = true;
|
|
||||||
++ return 0;
|
|
||||||
++
|
|
||||||
++}
|
|
||||||
+Index: linux-5.4.188/block/partition-split.h
|
|
||||||
+===================================================================
|
|
||||||
+--- /dev/null
|
|
||||||
++++ linux-5.4.188/block/partition-split.h
|
|
||||||
+@@ -0,0 +1,17 @@
|
|
||||||
++#ifndef __PARTITION_SPLIT_H
|
|
||||||
++#define __PARTITION_SPLIT_H
|
|
||||||
++
|
|
||||||
++#define ROOTFS_PART "rootfs"
|
|
||||||
++#define ROOTFS_PART_DATA "rootfs_data"
|
|
||||||
++
|
|
||||||
++#define ALING_SQFS 0X10000
|
|
||||||
++
|
|
||||||
++struct squashfs_sblock {
|
|
||||||
++ __le32 s_magic;
|
|
||||||
++ __le32 pad0[9];
|
|
||||||
++ __le64 bytes_used;
|
|
||||||
++};
|
|
||||||
++
|
|
||||||
++extern int partition_split(struct block_device *bdev, struct parsed_partitions *state);
|
|
||||||
++
|
|
||||||
++#endif
|
|
||||||
--
|
|
||||||
2.34.1
|
|
||||||
|
|
||||||
@ -1,17 +1,21 @@
|
|||||||
From 4145af6cc999a793345e48d98336a38ec6700d49 Mon Sep 17 00:00:00 2001
|
From d6957948ef99f0d6c28bce715013557f433f07e2 Mon Sep 17 00:00:00 2001
|
||||||
From: Luo Chongjun <luochongjun@gl-inet.com>
|
From: Luo Chongjun <luochongjun@gl-inet.com>
|
||||||
Date: Thu, 19 Jan 2023 10:37:12 +0800
|
Date: Thu, 19 Jan 2023 10:37:12 +0800
|
||||||
Subject: [PATCH] support MT2500 target
|
Subject: [PATCH] support MT2500 target
|
||||||
|
|
||||||
---
|
---
|
||||||
.../boot/dts/mediatek/mt7981-gl-mt2500.dts | 184 ++++++++++++++++++
|
.../boot/dts/mediatek/mt7981-gl-mt2500.dts | 184 +++++++++++++++++
|
||||||
target/linux/mediatek/mt7981/config-5.4 | 5 +-
|
target/linux/mediatek/mt7981/config-5.4 | 7 +-
|
||||||
2 files changed, 187 insertions(+), 2 deletions(-)
|
.../9999-block2mtd-support-partline.patch | 139 +++++++++++++
|
||||||
|
.../9999-support-partition-split.patch | 186 ++++++++++++++++++
|
||||||
|
4 files changed, 514 insertions(+), 2 deletions(-)
|
||||||
create mode 100755 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
|
create mode 100755 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
|
||||||
|
create mode 100644 target/linux/mediatek/patches-5.4/9999-block2mtd-support-partline.patch
|
||||||
|
create mode 100644 target/linux/mediatek/patches-5.4/9999-support-partition-split.patch
|
||||||
|
|
||||||
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
|
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
|
||||||
new file mode 100755
|
new file mode 100755
|
||||||
index 0000000000..1537bc2b74
|
index 0000000000..2b673e74cc
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
|
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
|
||||||
@@ -0,0 +1,184 @@
|
@@ -0,0 +1,184 @@
|
||||||
@ -200,7 +204,7 @@ index 0000000000..1537bc2b74
|
|||||||
+ status = "okay";
|
+ status = "okay";
|
||||||
+};
|
+};
|
||||||
diff --git a/target/linux/mediatek/mt7981/config-5.4 b/target/linux/mediatek/mt7981/config-5.4
|
diff --git a/target/linux/mediatek/mt7981/config-5.4 b/target/linux/mediatek/mt7981/config-5.4
|
||||||
index 219c62fca8..7ee7a7609c 100644
|
index 219c62fca8..d79d4ff221 100644
|
||||||
--- a/target/linux/mediatek/mt7981/config-5.4
|
--- a/target/linux/mediatek/mt7981/config-5.4
|
||||||
+++ b/target/linux/mediatek/mt7981/config-5.4
|
+++ b/target/linux/mediatek/mt7981/config-5.4
|
||||||
@@ -264,6 +264,8 @@ CONFIG_MMC_MTK=y
|
@@ -264,6 +264,8 @@ CONFIG_MMC_MTK=y
|
||||||
@ -220,7 +224,7 @@ index 219c62fca8..7ee7a7609c 100644
|
|||||||
CONFIG_PCI=y
|
CONFIG_PCI=y
|
||||||
# CONFIG_PCIE_MEDIATEK is not set
|
# CONFIG_PCIE_MEDIATEK is not set
|
||||||
CONFIG_PCIE_MEDIATEK_GEN3=y
|
CONFIG_PCIE_MEDIATEK_GEN3=y
|
||||||
@@ -467,7 +470,5 @@ CONFIG_XPS=y
|
@@ -467,7 +470,7 @@ CONFIG_XPS=y
|
||||||
CONFIG_ZLIB_DEFLATE=y
|
CONFIG_ZLIB_DEFLATE=y
|
||||||
CONFIG_ZLIB_INFLATE=y
|
CONFIG_ZLIB_INFLATE=y
|
||||||
CONFIG_ZONE_DMA32=y
|
CONFIG_ZONE_DMA32=y
|
||||||
@ -228,6 +232,345 @@ index 219c62fca8..7ee7a7609c 100644
|
|||||||
-CONFIG_MTK_EFUSE=y
|
-CONFIG_MTK_EFUSE=y
|
||||||
# CONFIG_MTD_SPI_NAND_W25N01KV is not set
|
# CONFIG_MTD_SPI_NAND_W25N01KV is not set
|
||||||
# CONFIG_MAXLINEAR_GPHY is not set
|
# CONFIG_MAXLINEAR_GPHY is not set
|
||||||
|
+# CONFIG_SHORTCUT_FE is not set
|
||||||
|
+# CONFIG_NF_CONNTRACK_CHAIN_EVENTS is not set
|
||||||
|
diff --git a/target/linux/mediatek/patches-5.4/9999-block2mtd-support-partline.patch b/target/linux/mediatek/patches-5.4/9999-block2mtd-support-partline.patch
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..2e4c2555da
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/target/linux/mediatek/patches-5.4/9999-block2mtd-support-partline.patch
|
||||||
|
@@ -0,0 +1,139 @@
|
||||||
|
+Index: linux-5.4.188/drivers/mtd/devices/block2mtd.c
|
||||||
|
+===================================================================
|
||||||
|
+--- linux-5.4.188.orig/drivers/mtd/devices/block2mtd.c
|
||||||
|
++++ linux-5.4.188/drivers/mtd/devices/block2mtd.c
|
||||||
|
+@@ -26,11 +26,14 @@
|
||||||
|
+ #include <linux/list.h>
|
||||||
|
+ #include <linux/init.h>
|
||||||
|
+ #include <linux/mtd/mtd.h>
|
||||||
|
++#include <linux/mtd/partitions.h>
|
||||||
|
+ #include <linux/mutex.h>
|
||||||
|
+ #include <linux/mount.h>
|
||||||
|
+ #include <linux/slab.h>
|
||||||
|
+ #include <linux/major.h>
|
||||||
|
+
|
||||||
|
++static const char * const block2mtd_probe_types[] = { "ofpart","cmdlinepart", NULL };
|
||||||
|
++
|
||||||
|
+ /* Info for the block device */
|
||||||
|
+ struct block2mtd_dev {
|
||||||
|
+ struct list_head list;
|
||||||
|
+@@ -183,10 +186,9 @@ static int block2mtd_write(struct mtd_in
|
||||||
|
+ mutex_unlock(&dev->write_mutex);
|
||||||
|
+ if (err > 0)
|
||||||
|
+ err = 0;
|
||||||
|
++ sync_blockdev(dev->blkdev);
|
||||||
|
+ return err;
|
||||||
|
+ }
|
||||||
|
+-
|
||||||
|
+-
|
||||||
|
+ /* sync the device - wait until the write queue is empty */
|
||||||
|
+ static void block2mtd_sync(struct mtd_info *mtd)
|
||||||
|
+ {
|
||||||
|
+@@ -214,12 +216,13 @@ static void block2mtd_free_device(struct
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ static struct block2mtd_dev *add_device(char *devname, int erase_size,
|
||||||
|
+- int timeout)
|
||||||
|
++ const char *mtdname, int timeout)
|
||||||
|
+ {
|
||||||
|
+ #ifndef MODULE
|
||||||
|
+ int i;
|
||||||
|
+ #endif
|
||||||
|
+ const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
|
||||||
|
++ struct mtd_part_parser_data ppdata;
|
||||||
|
+ struct block_device *bdev;
|
||||||
|
+ struct block2mtd_dev *dev;
|
||||||
|
+ char *name;
|
||||||
|
+@@ -278,10 +281,13 @@ static struct block2mtd_dev *add_device(
|
||||||
|
+
|
||||||
|
+ /* Setup the MTD structure */
|
||||||
|
+ /* make the name contain the block device in */
|
||||||
|
+- name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
|
||||||
|
++ if (!mtdname)
|
||||||
|
++ mtdname = devname;
|
||||||
|
++ name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL);
|
||||||
|
+ if (!name)
|
||||||
|
+ goto err_destroy_mutex;
|
||||||
|
+
|
||||||
|
++ strcpy(name, mtdname);
|
||||||
|
+ dev->mtd.name = name;
|
||||||
|
+
|
||||||
|
+ dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
|
||||||
|
+@@ -292,12 +298,14 @@ static struct block2mtd_dev *add_device(
|
||||||
|
+ dev->mtd.flags = MTD_CAP_RAM;
|
||||||
|
+ dev->mtd._erase = block2mtd_erase;
|
||||||
|
+ dev->mtd._write = block2mtd_write;
|
||||||
|
++ dev->mtd._panic_write = block2mtd_write;
|
||||||
|
+ dev->mtd._sync = block2mtd_sync;
|
||||||
|
+ dev->mtd._read = block2mtd_read;
|
||||||
|
+ dev->mtd.priv = dev;
|
||||||
|
+ dev->mtd.owner = THIS_MODULE;
|
||||||
|
+
|
||||||
|
+- if (mtd_device_register(&dev->mtd, NULL, 0)) {
|
||||||
|
++ memset(&ppdata, '\0', sizeof(ppdata));
|
||||||
|
++ if (mtd_device_parse_register(&dev->mtd, block2mtd_probe_types, &ppdata, NULL, 0)) {
|
||||||
|
+ /* Device didn't get added, so free the entry */
|
||||||
|
+ goto err_destroy_mutex;
|
||||||
|
+ }
|
||||||
|
+@@ -305,7 +313,7 @@ static struct block2mtd_dev *add_device(
|
||||||
|
+ list_add(&dev->list, &blkmtd_device_list);
|
||||||
|
+ pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n",
|
||||||
|
+ dev->mtd.index,
|
||||||
|
+- dev->mtd.name + strlen("block2mtd: "),
|
||||||
|
++ dev->mtd.name,
|
||||||
|
+ dev->mtd.erasesize >> 10, dev->mtd.erasesize);
|
||||||
|
+ return dev;
|
||||||
|
+
|
||||||
|
+@@ -381,7 +389,7 @@ static int block2mtd_setup2(const char *
|
||||||
|
+ /* 80 for device, 12 for erase size, 80 for name, 8 for timeout */
|
||||||
|
+ char buf[80 + 12 + 80 + 8];
|
||||||
|
+ char *str = buf;
|
||||||
|
+- char *token[2];
|
||||||
|
++ char *token[4];
|
||||||
|
+ char *name;
|
||||||
|
+ size_t erase_size = PAGE_SIZE;
|
||||||
|
+ unsigned long timeout = MTD_DEFAULT_TIMEOUT;
|
||||||
|
+@@ -395,7 +403,7 @@ static int block2mtd_setup2(const char *
|
||||||
|
+ strcpy(str, val);
|
||||||
|
+ kill_final_newline(str);
|
||||||
|
+
|
||||||
|
+- for (i = 0; i < 2; i++)
|
||||||
|
++ for (i = 0; i < 4; i++)
|
||||||
|
+ token[i] = strsep(&str, ",");
|
||||||
|
+
|
||||||
|
+ if (str) {
|
||||||
|
+@@ -421,8 +429,13 @@ static int block2mtd_setup2(const char *
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
++ if (token[2] && (strlen(token[2]) + 1 > 80))
|
||||||
|
++ pr_err("mtd device name too long\n");
|
||||||
|
++
|
||||||
|
++ if (token[3] && kstrtoul(token[3], 0, &timeout))
|
||||||
|
++ pr_err("invalid timeout\n");
|
||||||
|
+
|
||||||
|
+- add_device(name, erase_size, timeout);
|
||||||
|
++ add_device(name, erase_size, token[2], timeout);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+@@ -454,9 +467,8 @@ static int block2mtd_setup(const char *v
|
||||||
|
+ #endif
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+-
|
||||||
|
+ module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
|
||||||
|
+-MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
|
||||||
|
++MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>[,<timeout>]]]\"");
|
||||||
|
+
|
||||||
|
+ static int __init block2mtd_init(void)
|
||||||
|
+ {
|
||||||
|
+@@ -484,7 +496,7 @@ static void block2mtd_exit(void)
|
||||||
|
+ mutex_destroy(&dev->write_mutex);
|
||||||
|
+ pr_info("mtd%d: [%s] removed\n",
|
||||||
|
+ dev->mtd.index,
|
||||||
|
+- dev->mtd.name + strlen("block2mtd: "));
|
||||||
|
++ dev->mtd.name);
|
||||||
|
+ list_del(&dev->list);
|
||||||
|
+ block2mtd_free_device(dev);
|
||||||
|
+ }
|
||||||
|
diff --git a/target/linux/mediatek/patches-5.4/9999-support-partition-split.patch b/target/linux/mediatek/patches-5.4/9999-support-partition-split.patch
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..8e0026c216
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/target/linux/mediatek/patches-5.4/9999-support-partition-split.patch
|
||||||
|
@@ -0,0 +1,186 @@
|
||||||
|
+Index: linux-5.4.188/block/Kconfig
|
||||||
|
+===================================================================
|
||||||
|
+--- linux-5.4.188.orig/block/Kconfig
|
||||||
|
++++ linux-5.4.188/block/Kconfig
|
||||||
|
+@@ -105,6 +105,9 @@ config BLK_DEV_THROTTLING_LOW
|
||||||
|
+
|
||||||
|
+ Note, this is an experimental interface and could be changed someday.
|
||||||
|
+
|
||||||
|
++config PARTITION_SPLIT
|
||||||
|
++ bool "Openwrt Block device partition rootfs split"
|
||||||
|
++
|
||||||
|
+ config BLK_CMDLINE_PARSER
|
||||||
|
+ bool "Block device command line partition parser"
|
||||||
|
+ ---help---
|
||||||
|
+Index: linux-5.4.188/block/Makefile
|
||||||
|
+===================================================================
|
||||||
|
+--- linux-5.4.188.orig/block/Makefile
|
||||||
|
++++ linux-5.4.188/block/Makefile
|
||||||
|
+@@ -36,3 +36,4 @@ obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-deb
|
||||||
|
+ obj-$(CONFIG_BLK_DEBUG_FS_ZONED)+= blk-mq-debugfs-zoned.o
|
||||||
|
+ obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o
|
||||||
|
+ obj-$(CONFIG_BLK_PM) += blk-pm.o
|
||||||
|
++obj-$(CONFIG_PARTITION_SPLIT) += partition-split.o
|
||||||
|
+Index: linux-5.4.188/block/partition-generic.c
|
||||||
|
+===================================================================
|
||||||
|
+--- linux-5.4.188.orig/block/partition-generic.c
|
||||||
|
++++ linux-5.4.188/block/partition-generic.c
|
||||||
|
+@@ -21,6 +21,10 @@
|
||||||
|
+
|
||||||
|
+ #include "partitions/check.h"
|
||||||
|
+
|
||||||
|
++#ifdef CONFIG_PARTITION_SPLIT
|
||||||
|
++#include "partition-split.h"
|
||||||
|
++#endif
|
||||||
|
++
|
||||||
|
+ #ifdef CONFIG_BLK_DEV_MD
|
||||||
|
+ extern void md_autodetect_dev(dev_t dev);
|
||||||
|
+ #endif
|
||||||
|
+@@ -569,6 +573,9 @@ rescan:
|
||||||
|
+ highest = p;
|
||||||
|
+
|
||||||
|
+ disk_expand_part_tbl(disk, highest);
|
||||||
|
++#ifdef CONFIG_PARTITION_SPLIT
|
||||||
|
++ partition_split(bdev, state);
|
||||||
|
++#endif
|
||||||
|
+
|
||||||
|
+ /* add partitions */
|
||||||
|
+ for (p = 1; p < state->limit; p++) {
|
||||||
|
+Index: linux-5.4.188/block/partition-split.c
|
||||||
|
+===================================================================
|
||||||
|
+--- /dev/null
|
||||||
|
++++ linux-5.4.188/block/partition-split.c
|
||||||
|
+@@ -0,0 +1,111 @@
|
||||||
|
++#include <linux/blkdev.h>
|
||||||
|
++#include <linux/magic.h>
|
||||||
|
++#include <linux/module.h>
|
||||||
|
++#include "partitions/check.h"
|
||||||
|
++#include "partition-split.h"
|
||||||
|
++
|
||||||
|
++void print_sblock_value(char *buf)
|
||||||
|
++{
|
||||||
|
++ int i, j;
|
||||||
|
++ for (i = 0; i < sizeof(struct squashfs_sblock);) {
|
||||||
|
++ for (j = 0; j < 16; j++) {
|
||||||
|
++ printk("%02x ", buf[i]);
|
||||||
|
++ i++;
|
||||||
|
++ }
|
||||||
|
++ printk("\n");
|
||||||
|
++ }
|
||||||
|
++}
|
||||||
|
++
|
||||||
|
++unsigned char *fs_read_super_block(struct block_device *bdev, sector_t from, Sector *sector)
|
||||||
|
++{
|
||||||
|
++ if (from >= get_capacity(bdev->bd_disk)) {
|
||||||
|
++ return NULL;
|
||||||
|
++ }
|
||||||
|
++ return read_dev_sector(bdev, from, sector);
|
||||||
|
++}
|
||||||
|
++
|
||||||
|
++
|
||||||
|
++int get_squashfs_len(struct block_device *bdev, sector_t from, size_t *squashfs_len)
|
||||||
|
++{
|
||||||
|
++ struct squashfs_sblock sb;
|
||||||
|
++ unsigned char *buf;
|
||||||
|
++ Sector sector;
|
||||||
|
++ size_t retlen;
|
||||||
|
++
|
||||||
|
++ buf = fs_read_super_block(bdev, from, §or);
|
||||||
|
++ if (!buf) {
|
||||||
|
++ printk("failed to get super\n");
|
||||||
|
++ return -EIO;
|
||||||
|
++ }
|
||||||
|
++ memcpy((void *)&sb, buf, sizeof(sb));
|
||||||
|
++ put_dev_sector(sector);
|
||||||
|
++
|
||||||
|
++ if (le32_to_cpu(sb.s_magic) != SQUASHFS_MAGIC) {
|
||||||
|
++ printk("no squashfs found in\n");
|
||||||
|
++ //print_sblock_value((char *)&sb);
|
||||||
|
++ return -EINVAL;
|
||||||
|
++ }
|
||||||
|
++
|
||||||
|
++ retlen = le64_to_cpu(sb.bytes_used);
|
||||||
|
++ if (retlen <= 0) {
|
||||||
|
++ printk("squashfs is empty in \n");
|
||||||
|
++ return -ENODEV;
|
||||||
|
++ }
|
||||||
|
++
|
||||||
|
++ *squashfs_len = retlen;
|
||||||
|
++ return 0;
|
||||||
|
++}
|
||||||
|
++
|
||||||
|
++static int find_part_by_lable(struct parsed_partitions *state, const char *lable)
|
||||||
|
++{
|
||||||
|
++ int p;
|
||||||
|
++ /* add partitions */
|
||||||
|
++ for (p = 1; p < state->limit; p++) {
|
||||||
|
++ if (!strcmp(state->parts[p].info.volname, lable))
|
||||||
|
++ return p;
|
||||||
|
++ }
|
||||||
|
++ return 0;
|
||||||
|
++}
|
||||||
|
++
|
||||||
|
++int partition_split(struct block_device *bdev, struct parsed_partitions *state)
|
||||||
|
++{
|
||||||
|
++ int p, insert;
|
||||||
|
++ size_t sqfs_size;
|
||||||
|
++ sector_t new_size, new_from;
|
||||||
|
++ struct partition_meta_info *info;
|
||||||
|
++ char tmp[sizeof(info->volname) + 4];
|
||||||
|
++
|
||||||
|
++ p = find_part_by_lable(state, ROOTFS_PART);
|
||||||
|
++ if (p == 0)
|
||||||
|
++ return 0;
|
||||||
|
++ if (get_squashfs_len(bdev, state->parts[p].from, &sqfs_size))
|
||||||
|
++ return 0;
|
||||||
|
++
|
||||||
|
++ sqfs_size = (sqfs_size + (ALING_SQFS - 1)) & ~(ALING_SQFS - 1); //squashfs 64k对齐
|
||||||
|
++
|
||||||
|
++ //计算新分区大小和起始位置
|
||||||
|
++
|
||||||
|
++ new_size = state->parts[p].size - (sqfs_size >> 9);
|
||||||
|
++ new_from = state->parts[p].from + (sqfs_size >> 9);
|
||||||
|
++
|
||||||
|
++ for (insert = 1; insert < state->limit; insert++) {
|
||||||
|
++ if (!state->parts[insert].size)
|
||||||
|
++ break;
|
||||||
|
++ }
|
||||||
|
++
|
||||||
|
++ if (insert >= state->limit)
|
||||||
|
++ return 0;
|
||||||
|
++
|
||||||
|
++ //追加一个新分区并设置相关信息
|
||||||
|
++ put_partition(state, insert, new_from, new_size);
|
||||||
|
++
|
||||||
|
++ info = &state->parts[insert].info;
|
||||||
|
++
|
||||||
|
++ strncpy(info->volname, ROOTFS_PART_DATA, strlen(ROOTFS_PART_DATA) + 1);
|
||||||
|
++ snprintf(tmp, sizeof(tmp), "(%s)", info->volname);
|
||||||
|
++ strlcat(state->pp_buf, tmp, PAGE_SIZE);
|
||||||
|
++
|
||||||
|
++ state->parts[insert].has_info = true;
|
||||||
|
++ return 0;
|
||||||
|
++
|
||||||
|
++}
|
||||||
|
+Index: linux-5.4.188/block/partition-split.h
|
||||||
|
+===================================================================
|
||||||
|
+--- /dev/null
|
||||||
|
++++ linux-5.4.188/block/partition-split.h
|
||||||
|
+@@ -0,0 +1,17 @@
|
||||||
|
++#ifndef __PARTITION_SPLIT_H
|
||||||
|
++#define __PARTITION_SPLIT_H
|
||||||
|
++
|
||||||
|
++#define ROOTFS_PART "rootfs"
|
||||||
|
++#define ROOTFS_PART_DATA "rootfs_data"
|
||||||
|
++
|
||||||
|
++#define ALING_SQFS 0X10000
|
||||||
|
++
|
||||||
|
++struct squashfs_sblock {
|
||||||
|
++ __le32 s_magic;
|
||||||
|
++ __le32 pad0[9];
|
||||||
|
++ __le64 bytes_used;
|
||||||
|
++};
|
||||||
|
++
|
||||||
|
++extern int partition_split(struct block_device *bdev, struct parsed_partitions *state);
|
||||||
|
++
|
||||||
|
++#endif
|
||||||
--
|
--
|
||||||
2.34.1
|
2.25.1
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user