From 96732f6833fd5292eff82bd7e31401784d0468f3 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 May 2024 00:24:52 -0400 Subject: [PATCH] e2fsck: check the error return from the forced rewrite write If read of a block fails, we offer the user the opportunity to force a rewrite to that sector to force the storage device to remap the LBA to its spare block pool. Check that write so if it fails, we can let the user know. Addresses-Coverity-bug: 1432422 Signed-off-by: Theodore Ts'o --- e2fsck/ehandler.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c index 71ca301..14e9549 100644 --- a/e2fsck/ehandler.c +++ b/e2fsck/ehandler.c @@ -31,6 +31,7 @@ static errcode_t e2fsck_handle_read_error(io_channel channel, int i; char *p; ext2_filsys fs = (ext2_filsys) channel->app_data; + errcode_t retval; e2fsck_t ctx; ctx = (e2fsck_t) fs->priv_data; @@ -64,8 +65,13 @@ static errcode_t e2fsck_handle_read_error(io_channel channel, return 0; if (ask(ctx, _("Ignore error"), 1)) { - if (ask(ctx, _("Force rewrite"), 1)) - io_channel_write_blk64(channel, block, count, data); + if (ask(ctx, _("Force rewrite"), 1)) { + retval = io_channel_write_blk64(channel, block, + count, data); + if (retval) + printf(_("Error rewriting block %lu (%s)\n"), + block, error_message(retval)); + } return 0; } -- 1.8.3.1