Util-Linux package development
 help / color / mirror / Atom feed
From: Tianyi Chen <hi@tychen.cc>
To: util-linux@vger.kernel.org
Cc: kzak@redhat.com
Subject: [PATCH 1/3] libfdisk: propagate errors from fdisk_reread_changes()
Date: Thu, 17 Sep 2026 01:05:12 +0800	[thread overview]
Message-ID: <20260916170514.2595842-2-hi@tychen.cc> (raw)
In-Reply-To: <20260916170514.2595842-1-hi@tychen.cc>

Failed BLKPG operations emit warnings but leave the return value at zero,
so callers cannot detect that the kernel partition layout was not fully
updated. Return -EIO if any operation fails, while still attempting the
remaining updates.

Also stop if reading the current partition layout fails instead of
proceeding with an incomplete table.

Assisted-by: LLM
Signed-off-by: Tianyi Chen <hi@tychen.cc>
---
 libfdisk/src/context.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 2c407029..f06667c6 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -985,7 +985,9 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org)
 	fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
 
 	/* the current layout */
-	fdisk_get_partitions(cxt, &tb);
+	rc = fdisk_get_partitions(cxt, &tb);
+	if (rc)
+		goto done;
 	/* maximal number of partitions */
 	nparts = max(fdisk_table_get_nents(tb), fdisk_table_get_nents(org));
 
@@ -1052,10 +1054,12 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org)
 			err++;
 		}
 	}
-	if (err)
+	if (err) {
 		fdisk_info(cxt,	_(
 			"The kernel still uses the old partitions. The new "
 			"table will be used at the next reboot. "));
+		rc = -EIO;
+	}
 done:
 	free(rem);
 	free(add);
-- 
2.55.0


  reply	other threads:[~2026-09-16 17:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 17:05 [PATCH 0/3] sfdisk: incremental kernel updates for -N and --append Tianyi Chen
2026-09-16 17:05 ` Tianyi Chen [this message]
2026-09-16 17:05 ` [PATCH 2/3] libfdisk: limit resized DOS extended partitions to two sectors Tianyi Chen
2026-09-16 17:05 ` [PATCH 3/3] sfdisk: update only changed partitions with -N and --append Tianyi Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260916170514.2595842-2-hi@tychen.cc \
    --to=hi@tychen.cc \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox