Whamcloud - gitweb
e2fsck: check the error return from the forced rewrite write
authorTheodore Ts'o <tytso@mit.edu>
Wed, 1 May 2024 04:24:52 +0000 (00:24 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 1 May 2024 04:24:52 +0000 (00:24 -0400)
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>
e2fsck/ehandler.c

index 71ca301..14e9549 100644 (file)
@@ -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;
        }