[PATCH] diskpart: reread partition table

2 views
Skip to first unread message

Stefano Babic

unread,
Feb 20, 2026, 10:58:54 AM (2 days ago) Feb 20
to swup...@googlegroups.com, Stefano Babic
There is a race condition because the handler just waits a couple of
seconds before exiting, and in some cases this is not enough for the
kernel to reread the table, so force to reread before exiting.

Signed-off-by: Stefano Babic <stefan...@swupdate.org>
---
handlers/diskpart_handler.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
index 9be67695..2f3aea41 100644
--- a/handlers/diskpart_handler.c
+++ b/handlers/diskpart_handler.c
@@ -1456,6 +1456,17 @@ static int diskpart(struct img_type *img,
ret = diskpart_write_table(cxt, createtable, oldtb, priv.nolock, priv.noinuse);

handler_exit:
+
+ /*
+ * Kernel rereads the partition table and add just a delay to be sure
+ * that SWUpdate does not try to access the partitions before the kernel is
+ * ready
+ */
+
+ if (!ret) {
+ ret = fdisk_reread_partition_table(cxt);
+ }
+
if (tb)
diskpart_unref_table(tb);
if (oldtb)
@@ -1468,12 +1479,6 @@ handler_release:
if (cxt)
diskpart_unref_context(cxt);

- /*
- * Kernel rereads the partition table and add just a delay to be sure
- * that SWUpdate does not try to access the partitions before the kernel is
- * ready
- */
-
sleep(2);

#ifdef CONFIG_DISKPART_FORMAT
--
2.43.0

Reply all
Reply to author
Forward
0 new messages