diff options
Diffstat (limited to 'e2fsprogs/ext2fs/test_io.c')
-rw-r--r-- | e2fsprogs/ext2fs/test_io.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/e2fsprogs/ext2fs/test_io.c b/e2fsprogs/ext2fs/test_io.c index 6a3b248e9..d4b36532f 100644 --- a/e2fsprogs/ext2fs/test_io.c +++ b/e2fsprogs/ext2fs/test_io.c | |||
@@ -32,7 +32,7 @@ | |||
32 | 32 | ||
33 | #define EXT2_CHECK_MAGIC(struct, code) \ | 33 | #define EXT2_CHECK_MAGIC(struct, code) \ |
34 | if ((struct)->magic != (code)) return (code) | 34 | if ((struct)->magic != (code)) return (code) |
35 | 35 | ||
36 | struct test_private_data { | 36 | struct test_private_data { |
37 | int magic; | 37 | int magic; |
38 | io_channel real; | 38 | io_channel real; |
@@ -56,7 +56,7 @@ static errcode_t test_write_blk(io_channel channel, unsigned long block, | |||
56 | static errcode_t test_flush(io_channel channel); | 56 | static errcode_t test_flush(io_channel channel); |
57 | static errcode_t test_write_byte(io_channel channel, unsigned long offset, | 57 | static errcode_t test_write_byte(io_channel channel, unsigned long offset, |
58 | int count, const void *buf); | 58 | int count, const void *buf); |
59 | static errcode_t test_set_option(io_channel channel, const char *option, | 59 | static errcode_t test_set_option(io_channel channel, const char *option, |
60 | const char *arg); | 60 | const char *arg); |
61 | 61 | ||
62 | static struct struct_io_manager struct_test_manager = { | 62 | static struct struct_io_manager struct_test_manager = { |
@@ -172,10 +172,10 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) | |||
172 | goto cleanup; | 172 | goto cleanup; |
173 | } else | 173 | } else |
174 | data->real = 0; | 174 | data->real = 0; |
175 | data->read_blk = test_io_cb_read_blk; | 175 | data->read_blk = test_io_cb_read_blk; |
176 | data->write_blk = test_io_cb_write_blk; | 176 | data->write_blk = test_io_cb_write_blk; |
177 | data->set_blksize = test_io_cb_set_blksize; | 177 | data->set_blksize = test_io_cb_set_blksize; |
178 | data->write_byte = test_io_cb_write_byte; | 178 | data->write_byte = test_io_cb_write_byte; |
179 | 179 | ||
180 | data->outfile = NULL; | 180 | data->outfile = NULL; |
181 | if ((value = getenv("TEST_IO_LOGFILE")) != NULL) | 181 | if ((value = getenv("TEST_IO_LOGFILE")) != NULL) |
@@ -186,7 +186,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) | |||
186 | data->flags = 0; | 186 | data->flags = 0; |
187 | if ((value = getenv("TEST_IO_FLAGS")) != NULL) | 187 | if ((value = getenv("TEST_IO_FLAGS")) != NULL) |
188 | data->flags = strtoul(value, NULL, 0); | 188 | data->flags = strtoul(value, NULL, 0); |
189 | 189 | ||
190 | data->block = 0; | 190 | data->block = 0; |
191 | if ((value = getenv("TEST_IO_BLOCK")) != NULL) | 191 | if ((value = getenv("TEST_IO_BLOCK")) != NULL) |
192 | data->block = strtoul(value, NULL, 0); | 192 | data->block = strtoul(value, NULL, 0); |
@@ -198,7 +198,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) | |||
198 | data->write_abort_count = 0; | 198 | data->write_abort_count = 0; |
199 | if ((value = getenv("TEST_IO_WRITE_ABORT")) != NULL) | 199 | if ((value = getenv("TEST_IO_WRITE_ABORT")) != NULL) |
200 | data->write_abort_count = strtoul(value, NULL, 0); | 200 | data->write_abort_count = strtoul(value, NULL, 0); |
201 | 201 | ||
202 | *channel = io; | 202 | *channel = io; |
203 | return 0; | 203 | return 0; |
204 | 204 | ||
@@ -221,13 +221,13 @@ static errcode_t test_close(io_channel channel) | |||
221 | 221 | ||
222 | if (--channel->refcount > 0) | 222 | if (--channel->refcount > 0) |
223 | return 0; | 223 | return 0; |
224 | 224 | ||
225 | if (data->real) | 225 | if (data->real) |
226 | retval = io_channel_close(data->real); | 226 | retval = io_channel_close(data->real); |
227 | 227 | ||
228 | if (data->outfile && data->outfile != stderr) | 228 | if (data->outfile && data->outfile != stderr) |
229 | fclose(data->outfile); | 229 | fclose(data->outfile); |
230 | 230 | ||
231 | ext2fs_free_mem(&channel->private_data); | 231 | ext2fs_free_mem(&channel->private_data); |
232 | if (channel->name) | 232 | if (channel->name) |
233 | ext2fs_free_mem(&channel->name); | 233 | ext2fs_free_mem(&channel->name); |
@@ -280,7 +280,7 @@ static errcode_t test_read_blk(io_channel channel, unsigned long block, | |||
280 | test_dump_block(channel, data, block, buf); | 280 | test_dump_block(channel, data, block, buf); |
281 | if (--data->read_abort_count == 0) | 281 | if (--data->read_abort_count == 0) |
282 | test_abort(channel, block); | 282 | test_abort(channel, block); |
283 | } | 283 | } |
284 | return retval; | 284 | return retval; |
285 | } | 285 | } |
286 | 286 | ||
@@ -339,22 +339,22 @@ static errcode_t test_flush(io_channel channel) | |||
339 | { | 339 | { |
340 | struct test_private_data *data; | 340 | struct test_private_data *data; |
341 | errcode_t retval = 0; | 341 | errcode_t retval = 0; |
342 | 342 | ||
343 | EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); | 343 | EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); |
344 | data = (struct test_private_data *) channel->private_data; | 344 | data = (struct test_private_data *) channel->private_data; |
345 | EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); | 345 | EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); |
346 | 346 | ||
347 | if (data->real) | 347 | if (data->real) |
348 | retval = io_channel_flush(data->real); | 348 | retval = io_channel_flush(data->real); |
349 | 349 | ||
350 | if (data->flags & TEST_FLAG_FLUSH) | 350 | if (data->flags & TEST_FLAG_FLUSH) |
351 | fprintf(data->outfile, "Test_io: flush() returned %s\n", | 351 | fprintf(data->outfile, "Test_io: flush() returned %s\n", |
352 | retval ? error_message(retval) : "OK"); | 352 | retval ? error_message(retval) : "OK"); |
353 | 353 | ||
354 | return retval; | 354 | return retval; |
355 | } | 355 | } |
356 | 356 | ||
357 | static errcode_t test_set_option(io_channel channel, const char *option, | 357 | static errcode_t test_set_option(io_channel channel, const char *option, |
358 | const char *arg) | 358 | const char *arg) |
359 | { | 359 | { |
360 | struct test_private_data *data; | 360 | struct test_private_data *data; |
@@ -366,10 +366,10 @@ static errcode_t test_set_option(io_channel channel, const char *option, | |||
366 | 366 | ||
367 | 367 | ||
368 | if (data->flags & TEST_FLAG_SET_OPTION) | 368 | if (data->flags & TEST_FLAG_SET_OPTION) |
369 | fprintf(data->outfile, "Test_io: set_option(%s, %s) ", | 369 | fprintf(data->outfile, "Test_io: set_option(%s, %s) ", |
370 | option, arg); | 370 | option, arg); |
371 | if (data->real && data->real->manager->set_option) { | 371 | if (data->real && data->real->manager->set_option) { |
372 | retval = (data->real->manager->set_option)(data->real, | 372 | retval = (data->real->manager->set_option)(data->real, |
373 | option, arg); | 373 | option, arg); |
374 | if (data->flags & TEST_FLAG_SET_OPTION) | 374 | if (data->flags & TEST_FLAG_SET_OPTION) |
375 | fprintf(data->outfile, "returned %s\n", | 375 | fprintf(data->outfile, "returned %s\n", |