aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2024-05-01 00:24:52 -0400
committerTheodore Ts'o <tytso@mit.edu>2024-05-01 00:24:52 -0400
commit96732f6833fd5292eff82bd7e31401784d0468f3 (patch)
tree9ce8ff4ccc5cb8eac705b6590502f29108773581
parent5f3a677bfccfa34c1387336b306ab5805acf95ae (diff)
downloade2fsprogs-96732f6833fd5292eff82bd7e31401784d0468f3.tar.gz
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 <tytso@mit.edu>
-rw-r--r--e2fsck/ehandler.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c
index 71ca301ca..14e954912 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;
}