#define EXT2_CHECK_MAGIC(struct, code) \
if ((struct)->magic != (code)) return (code)
-
+
struct test_private_data {
int magic;
io_channel real;
static errcode_t test_flush(io_channel channel);
static errcode_t test_write_byte(io_channel channel, unsigned long offset,
int count, const void *buf);
-static errcode_t test_set_option(io_channel channel, const char *option,
+static errcode_t test_set_option(io_channel channel, const char *option,
const char *arg);
static errcode_t test_get_stats(io_channel channel, io_stats *stats);
data->flags = 0;
if ((value = safe_getenv("TEST_IO_FLAGS")) != NULL)
data->flags = strtoul(value, NULL, 0);
-
+
data->block = 0;
if ((value = safe_getenv("TEST_IO_BLOCK")) != NULL)
data->block = strtoul(value, NULL, 0);
data->write_abort_count = 0;
if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL)
data->write_abort_count = strtoul(value, NULL, 0);
-
+
*channel = io;
return 0;
if (--channel->refcount > 0)
return 0;
-
+
if (data->real)
retval = io_channel_close(data->real);
if (data->outfile && data->outfile != stderr)
fclose(data->outfile);
-
+
ext2fs_free_mem(&channel->private_data);
if (channel->name)
ext2fs_free_mem(&channel->name);
test_dump_block(channel, data, block, buf);
if (--data->read_abort_count == 0)
test_abort(channel, block);
- }
+ }
return retval;
}
test_dump_block(channel, data, block, buf);
if (--data->read_abort_count == 0)
test_abort(channel, block);
- }
+ }
return retval;
}
{
struct test_private_data *data;
errcode_t retval = 0;
-
+
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
data = (struct test_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
if (data->real)
retval = io_channel_flush(data->real);
-
+
if (data->flags & TEST_FLAG_FLUSH)
fprintf(data->outfile, "Test_io: flush() returned %s\n",
retval ? error_message(retval) : "OK");
-
+
return retval;
}
-static errcode_t test_set_option(io_channel channel, const char *option,
+static errcode_t test_set_option(io_channel channel, const char *option,
const char *arg)
{
struct test_private_data *data;
if (data->flags & TEST_FLAG_SET_OPTION)
- fprintf(data->outfile, "Test_io: set_option(%s, %s) ",
+ fprintf(data->outfile, "Test_io: set_option(%s, %s) ",
option, arg);
if (data->real && data->real->manager->set_option) {
- retval = (data->real->manager->set_option)(data->real,
+ retval = (data->real->manager->set_option)(data->real,
option, arg);
if (data->flags & TEST_FLAG_SET_OPTION)
fprintf(data->outfile, "returned %s\n",