aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ext2fs/test_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext2fs/test_io.c')
-rw-r--r--lib/ext2fs/test_io.c47
1 files changed, 7 insertions, 40 deletions
diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c
index d79c6d58..8d887a86 100644
--- a/lib/ext2fs/test_io.c
+++ b/lib/ext2fs/test_io.c
@@ -9,12 +9,6 @@
* %End-Header%
*/
-#if HAVE_SECURE_GETENV
-#define _GNU_SOURCE
-#endif
-#if HAVE_SECURE_GETENV
-#define _GNU_SOURCE
-#endif
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
@@ -79,8 +73,7 @@ static errcode_t test_write_byte(io_channel channel, unsigned long offset,
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);
-static errcode_t test_discard(io_channel channel, unsigned long long block,
- unsigned long long count);
+
static struct struct_io_manager struct_test_manager = {
EXT2_ET_MAGIC_IO_MANAGER,
@@ -96,7 +89,6 @@ static struct struct_io_manager struct_test_manager = {
test_get_stats,
test_read_blk64,
test_write_blk64,
- test_discard,
};
io_manager test_io_manager = &struct_test_manager;
@@ -128,7 +120,6 @@ void (*test_io_cb_write_byte)
#define TEST_FLAG_FLUSH 0x08
#define TEST_FLAG_DUMP 0x10
#define TEST_FLAG_SET_OPTION 0x20
-#define TEST_FLAG_DISCARD 0x40
static void test_dump_block(io_channel channel,
struct test_private_data *data,
@@ -178,9 +169,7 @@ static char *safe_getenv(const char *arg)
#endif
#endif
-#if defined(HAVE_SECURE_GETENV)
- return secure_getenv(arg);
-#elif defined(HAVE___SECURE_GETENV)
+#ifdef HAVE___SECURE_GETENV
return __secure_getenv(arg);
#else
return getenv(arg);
@@ -198,12 +187,14 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
return EXT2_ET_BAD_DEVICE_NAME;
retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
if (retval)
- goto cleanup;
+ return retval;
memset(io, 0, sizeof(struct struct_io_channel));
io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
retval = ext2fs_get_mem(sizeof(struct test_private_data), &data);
- if (retval)
+ if (retval) {
+ retval = EXT2_ET_NO_MEMORY;
goto cleanup;
+ }
io->manager = test_io_manager;
retval = ext2fs_get_mem(strlen(name)+1, &io->name);
if (retval)
@@ -254,9 +245,6 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL)
data->write_abort_count = strtoul(value, NULL, 0);
- if (data->real)
- io->align = data->real->align;
-
*channel = io;
return 0;
@@ -302,10 +290,8 @@ static errcode_t test_set_blksize(io_channel channel, int blksize)
data = (struct test_private_data *) channel->private_data;
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
- if (data->real) {
+ if (data->real)
retval = io_channel_set_blksize(data->real, blksize);
- channel->align = data->real->align;
- }
if (data->set_blksize)
data->set_blksize(blksize, retval);
if (data->flags & TEST_FLAG_SET_BLKSIZE)
@@ -509,22 +495,3 @@ static errcode_t test_get_stats(io_channel channel, io_stats *stats)
}
return retval;
}
-
-static errcode_t test_discard(io_channel channel, unsigned long long block,
- unsigned long long count)
-{
- 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_discard(data->real, block, count);
- if (data->flags & TEST_FLAG_DISCARD)
- fprintf(data->outfile,
- "Test_io: discard(%llu, %llu) returned %s\n",
- block, count, retval ? error_message(retval) : "OK");
- return retval;
-}