2 * ehandler.c --- handle bad block errors which come up during the
3 * course of an e2fsck session.
5 * Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
6 * under the terms of the GNU Public License.
18 #include <sys/resource.h>
20 static const char *operation;
22 static errcode_t e2fsck_handle_read_error(io_channel channel,
32 ext2_filsys fs = (ext2_filsys) channel->app_data;
35 ctx = (e2fsck_t) fs->priv_data;
38 * If more than one block was read, try reading each block
39 * separately. We could use the actual bytes read to figure
40 * out where to start, but we don't bother.
44 for (i=0; i < count; i++, p += channel->block_size, block++) {
45 error = io_channel_read_blk(channel, block,
53 printf("Error reading block %lu (%s) while %s. ", block,
54 error_message(error), operation);
56 printf("Error reading block %lu (%s). ", block,
57 error_message(error));
59 if (ask(ctx, "Ignore error", 1))
65 static errcode_t e2fsck_handle_write_error(io_channel channel,
75 ext2_filsys fs = (ext2_filsys) channel->app_data;
78 ctx = (e2fsck_t) fs->priv_data;
81 * If more than one block was written, try writing each block
82 * separately. We could use the actual bytes read to figure
83 * out where to start, but we don't bother.
86 p = (const char *) data;
87 for (i=0; i < count; i++, p += channel->block_size, block++) {
88 error = io_channel_write_blk(channel, block,
97 printf("Error writing block %lu (%s) while %s. ", block,
98 error_message(error), operation);
100 printf("Error writing block %lu (%s). ", block,
101 error_message(error));
103 if (ask(ctx, "Ignore error", 1))
109 const char *ehandler_operation(const char *op)
111 const char *ret = operation;
117 void ehandler_init(io_channel channel)
119 channel->read_error = e2fsck_handle_read_error;
120 channel->write_error = e2fsck_handle_write_error;