From c0e7c5d0fdc7acf4c0fb42fc109a8942bf117a43 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sun, 19 Oct 2025 00:00:00 +0200 Subject: [PATCH] patches: carry forward IPQ807x UBI force detach (0050) Adds UBI force detach patch for IPQ807x to handle problematic UBI volumes. Renumbered from patches/0071. Signed-off-by: John Crispin --- ...0-ipq807x-add-ubi-force-detach-patch.patch | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) rename patches/0071-ipq807x-add-ubi-force-detach-patch.patch => patches-24.10/0050-ipq807x-add-ubi-force-detach-patch.patch (85%) diff --git a/patches/0071-ipq807x-add-ubi-force-detach-patch.patch b/patches-24.10/0050-ipq807x-add-ubi-force-detach-patch.patch similarity index 85% rename from patches/0071-ipq807x-add-ubi-force-detach-patch.patch rename to patches-24.10/0050-ipq807x-add-ubi-force-detach-patch.patch index ed9453453..dc7c87313 100644 --- a/patches/0071-ipq807x-add-ubi-force-detach-patch.patch +++ b/patches-24.10/0050-ipq807x-add-ubi-force-detach-patch.patch @@ -1,20 +1,22 @@ -From 3dd22aa711f2f8c8e968d21cbac85beb713760af Mon Sep 17 00:00:00 2001 +From 708107bebf50e8c15f65eac6d939a677893be040 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sun, 16 Jul 2023 17:21:04 +0200 -Subject: [PATCH 41/43] ipq807x: add ubi force detach patch +Subject: [PATCH 50/55] ipq807x: add ubi force detach patch + +Adds force detach option to ubidetach utility, allowing UBI volumes to be detached even when busy during system upgrade. Signed-off-by: John Crispin --- - .../patches/131-add_ubi_force_detach.patch | 185 ++++++++++++++++++ - 1 file changed, 185 insertions(+) + .../patches/131-add_ubi_force_detach.patch | 196 ++++++++++++++++++ + 1 file changed, 196 insertions(+) create mode 100644 package/utils/mtd-utils/patches/131-add_ubi_force_detach.patch diff --git a/package/utils/mtd-utils/patches/131-add_ubi_force_detach.patch b/package/utils/mtd-utils/patches/131-add_ubi_force_detach.patch new file mode 100644 -index 0000000000..f3cd6a6b28 +index 0000000000..03cc8663a2 --- /dev/null +++ b/package/utils/mtd-utils/patches/131-add_ubi_force_detach.patch -@@ -0,0 +1,185 @@ +@@ -0,0 +1,196 @@ +--- a/include/mtd/ubi-user.h ++++ b/include/mtd/ubi-user.h +@@ -176,6 +176,7 @@ @@ -27,7 +29,7 @@ index 0000000000..f3cd6a6b28 + +--- a/include/libubi.h ++++ b/include/libubi.h -+@@ -48,6 +48,7 @@ typedef void * libubi_t; ++@@ -51,6 +51,7 @@ typedef void * libubi_t; + * number) + * @mtd_num: MTD device number to attach (used if @mtd_dev_node is %NULL) + * @mtd_dev_node: path to MTD device node to attach @@ -35,7 +37,7 @@ index 0000000000..f3cd6a6b28 + * @vid_hdr_offset: VID header offset (%0 means default offset and this is what + * most of the users want) + * @max_beb_per1024: Maximum expected bad eraseblocks per 1024 eraseblocks -+@@ -240,29 +241,33 @@ int ubi_attach(libubi_t desc, const char ++@@ -249,29 +250,33 @@ int ubi_attach(libubi_t desc, const char + * corresponding UBI device is removed. Returns zero in case of success and %-1 + * in case of failure. + */ @@ -74,7 +76,7 @@ index 0000000000..f3cd6a6b28 + * ubi_mkvol - create an UBI volume. +--- a/lib/libubi.c ++++ b/lib/libubi.c -+@@ -808,7 +808,7 @@ int ubi_attach(libubi_t desc, const char ++@@ -807,7 +807,7 @@ int ubi_attach(libubi_t desc, const char + return ret; + } + @@ -83,7 +85,7 @@ index 0000000000..f3cd6a6b28 + { + int ret, ubi_dev; + -+@@ -818,10 +818,11 @@ int ubi_detach_mtd(libubi_t desc, const ++@@ -817,10 +817,11 @@ int ubi_detach_mtd(libubi_t desc, const + return ret; + } + @@ -97,7 +99,7 @@ index 0000000000..f3cd6a6b28 + { + int mtd_num; + -+@@ -834,10 +835,10 @@ int ubi_detach(libubi_t desc, const char ++@@ -833,10 +834,10 @@ int ubi_detach(libubi_t desc, const char + if (mtd_num == -1) + return -1; + @@ -109,8 +111,8 @@ index 0000000000..f3cd6a6b28 ++int ubi_remove_dev(libubi_t desc, const char *node, int ubi_dev, int force) + { + int fd, ret; -+ -+@@ -847,6 +848,10 @@ int ubi_remove_dev(libubi_t desc, const ++ (void)desc; ++@@ -845,6 +846,10 @@ int ubi_remove_dev(libubi_t desc, const + if (fd == -1) + return sys_errmsg("cannot open \"%s\"", node); + ret = ioctl(fd, UBI_IOCDET, &ubi_dev); @@ -200,6 +202,17 @@ index 0000000000..f3cd6a6b28 + if (err) { + sys_errmsg("cannot detach mtd%d", args.mtdn); + goto out_libubi; ++--- a/tests/fs-tests/integrity/integck.c +++++ b/tests/fs-tests/integrity/integck.c ++@@ -2596,7 +2596,7 @@ static int reattach(void) ++ return sys_errmsg("cannot open libubi"); ++ } ++ ++- err = ubi_detach_mtd(libubi, "/dev/ubi_ctrl", args.mtdn); +++ err = ubi_detach_mtd(libubi, "/dev/ubi_ctrl", args.mtdn, false); ++ if (err) { ++ sys_errmsg("cannot detach mtd%d", args.mtdn); ++ goto out; -- 2.34.1