*/
#include "config.h"
-#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
#define TEST_FLAG_DUMP 0x10
#define TEST_FLAG_SET_OPTION 0x20
#define TEST_FLAG_DISCARD 0x40
+#define TEST_FLAG_READAHEAD 0x80
static void test_dump_block(io_channel channel,
struct test_private_data *data,
return retval;
}
+static errcode_t test_cache_readahead(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_cache_readahead(data->real, block, count);
+ if (data->flags & TEST_FLAG_READAHEAD)
+ fprintf(data->outfile,
+ "Test_io: readahead(%llu, %llu) returned %s\n",
+ block, count, retval ? error_message(retval) : "OK");
+ return retval;
+}
+
static struct struct_io_manager struct_test_manager = {
- EXT2_ET_MAGIC_IO_MANAGER,
- "Test I/O Manager",
- test_open,
- test_close,
- test_set_blksize,
- test_read_blk,
- test_write_blk,
- test_flush,
- test_write_byte,
- test_set_option,
- test_get_stats,
- test_read_blk64,
- test_write_blk64,
- test_discard,
+ .magic = EXT2_ET_MAGIC_IO_MANAGER,
+ .name = "Test I/O Manager",
+ .open = test_open,
+ .close = test_close,
+ .set_blksize = test_set_blksize,
+ .read_blk = test_read_blk,
+ .write_blk = test_write_blk,
+ .flush = test_flush,
+ .write_byte = test_write_byte,
+ .set_option = test_set_option,
+ .get_stats = test_get_stats,
+ .read_blk64 = test_read_blk64,
+ .write_blk64 = test_write_blk64,
+ .discard = test_discard,
+ .cache_readahead = test_cache_readahead,
};
io_manager test_io_manager = &struct_test_manager;