X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=e2fsck%2Fehandler.c;h=71ca301ca5fe8777d51ce1e2bbcc58484e05bdbd;hb=17f2fbf7371f2f1a1d35af986af24cfc57e3e8a0;hp=7bae4abd9ad348994ed47cdd5885bdd22657b330;hpb=efc6f628e15de95bcd13e4f0ee223cb42115d520;p=tools%2Fe2fsprogs.git diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c index 7bae4ab..71ca301 100644 --- a/e2fsck/ehandler.c +++ b/e2fsck/ehandler.c @@ -6,6 +6,7 @@ * under the terms of the GNU Public License. */ +#include "config.h" #include #include #include @@ -33,7 +34,8 @@ static errcode_t e2fsck_handle_read_error(io_channel channel, e2fsck_t ctx; ctx = (e2fsck_t) fs->priv_data; - + if (ctx->flags & E2F_FLAG_EXITING) + return 0; /* * If more than one block was read, try reading each block * separately. We could use the actual bytes read to figure @@ -42,7 +44,7 @@ static errcode_t e2fsck_handle_read_error(io_channel channel, if (count > 1) { p = (char *) data; for (i=0; i < count; i++, p += channel->block_size, block++) { - error = io_channel_read_blk(channel, block, + error = io_channel_read_blk64(channel, block, 1, p); if (error) return error; @@ -56,9 +58,14 @@ static errcode_t e2fsck_handle_read_error(io_channel channel, printf(_("Error reading block %lu (%s). "), block, error_message(error)); preenhalt(ctx); + + /* Don't rewrite a block past the end of the FS. */ + if (block >= ext2fs_blocks_count(fs->super)) + return 0; + if (ask(ctx, _("Ignore error"), 1)) { if (ask(ctx, _("Force rewrite"), 1)) - io_channel_write_blk(channel, block, 1, data); + io_channel_write_blk64(channel, block, count, data); return 0; } @@ -79,6 +86,8 @@ static errcode_t e2fsck_handle_write_error(io_channel channel, e2fsck_t ctx; ctx = (e2fsck_t) fs->priv_data; + if (ctx->flags & E2F_FLAG_EXITING) + return 0; /* * If more than one block was written, try writing each block @@ -88,7 +97,7 @@ static errcode_t e2fsck_handle_write_error(io_channel channel, if (count > 1) { p = (const char *) data; for (i=0; i < count; i++, p += channel->block_size, block++) { - error = io_channel_write_blk(channel, block, + error = io_channel_write_blk64(channel, block, 1, p); if (error) return error;