void (*write_blk64)(unsigned long long block, int count, errcode_t err);
};
-static errcode_t test_open(const char *name, int flags, io_channel *channel);
-static errcode_t test_close(io_channel channel);
-static errcode_t test_set_blksize(io_channel channel, int blksize);
-static errcode_t test_read_blk(io_channel channel, unsigned long block,
- int count, void *data);
-static errcode_t test_write_blk(io_channel channel, unsigned long block,
- int count, const void *data);
-static errcode_t test_read_blk64(io_channel channel, unsigned long long block,
- int count, void *data);
-static errcode_t test_write_blk64(io_channel channel, unsigned long long block,
- int count, const void *data);
-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,
- 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,
- "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,
-};
-
-io_manager test_io_manager = &struct_test_manager;
-
/*
* These global variable can be set by the test program as
* necessary *before* calling test_open
}
}
+/*
+ * Flush data buffers to disk.
+ */
+static errcode_t test_flush(io_channel channel)
+{
+ 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 void test_abort(io_channel channel, unsigned long block)
{
struct test_private_data *data;
&data->real);
if (retval)
goto cleanup;
- } else
+ } else {
data->real = 0;
- data->read_blk = test_io_cb_read_blk;
- data->write_blk = test_io_cb_write_blk;
- data->set_blksize = test_io_cb_set_blksize;
- data->write_byte = test_io_cb_write_byte;
- data->read_blk64 = test_io_cb_read_blk64;
- data->write_blk64 = test_io_cb_write_blk64;
+ }
+ data->read_blk = test_io_cb_read_blk;
+ data->write_blk = test_io_cb_write_blk;
+ data->set_blksize = test_io_cb_set_blksize;
+ data->write_byte = test_io_cb_write_byte;
+ data->read_blk64 = test_io_cb_read_blk64;
+ data->write_blk64 = test_io_cb_write_blk64;
data->outfile = NULL;
if ((value = safe_getenv("TEST_IO_LOGFILE")) != NULL)
return retval;
}
-/*
- * Flush data buffers to disk.
- */
-static errcode_t test_flush(io_channel channel)
-{
- 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,
const char *arg)
{
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,
+};
+
+io_manager test_io_manager = &struct_test_manager;
ext2_loff_t offset;
};
-static errcode_t undo_open(const char *name, int flags, io_channel *channel);
-static errcode_t undo_close(io_channel channel);
-static errcode_t undo_set_blksize(io_channel channel, int blksize);
-static errcode_t undo_read_blk64(io_channel channel, unsigned long long block,
- int count, void *data);
-static errcode_t undo_write_blk64(io_channel channel, unsigned long long block,
- int count, const void *data);
-static errcode_t undo_read_blk(io_channel channel, unsigned long block,
- int count, void *data);
-static errcode_t undo_write_blk(io_channel channel, unsigned long block,
- int count, const void *data);
-static errcode_t undo_flush(io_channel channel);
-static errcode_t undo_write_byte(io_channel channel, unsigned long offset,
- int size, const void *data);
-static errcode_t undo_set_option(io_channel channel, const char *option,
- const char *arg);
-static errcode_t undo_get_stats(io_channel channel, io_stats *stats);
-
-static struct struct_io_manager struct_undo_manager = {
- EXT2_ET_MAGIC_IO_MANAGER,
- "Undo I/O Manager",
- undo_open,
- undo_close,
- undo_set_blksize,
- undo_read_blk,
- undo_write_blk,
- undo_flush,
- undo_write_byte,
- undo_set_option,
- undo_get_stats,
- undo_read_blk64,
- undo_write_blk64,
-};
-
-io_manager undo_io_manager = &struct_undo_manager;
-static io_manager undo_io_backing_manager ;
+static io_manager undo_io_backing_manager;
static char *tdb_file;
static int actual_size;
return retval;
}
+
+static struct struct_io_manager struct_undo_manager = {
+ EXT2_ET_MAGIC_IO_MANAGER,
+ "Undo I/O Manager",
+ undo_open,
+ undo_close,
+ undo_set_blksize,
+ undo_read_blk,
+ undo_write_blk,
+ undo_flush,
+ undo_write_byte,
+ undo_set_option,
+ undo_get_stats,
+ undo_read_blk64,
+ undo_write_blk64,
+};
+
+io_manager undo_io_manager = &struct_undo_manager;
/*
* unix_io.c --- This is the Unix (well, really POSIX) implementation
- * of the I/O manager.
+ * of the I/O manager.
*
* Implements a one-block write-through cache.
*
* Includes support for Windows NT support under Cygwin.
*
* Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- * 2002 by Theodore Ts'o.
+ * 2002 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Library
#define IS_ALIGNED(n, align) ((((unsigned long) n) & \
((unsigned long) ((align)-1))) == 0)
-static errcode_t unix_open(const char *name, int flags, io_channel *channel);
-static errcode_t unix_close(io_channel channel);
-static errcode_t unix_set_blksize(io_channel channel, int blksize);
-static errcode_t unix_read_blk(io_channel channel, unsigned long block,
- int count, void *data);
-static errcode_t unix_write_blk(io_channel channel, unsigned long block,
- int count, const void *data);
-static errcode_t unix_flush(io_channel channel);
-static errcode_t unix_write_byte(io_channel channel, unsigned long offset,
- int size, const void *data);
-static errcode_t unix_set_option(io_channel channel, const char *option,
- const char *arg);
-static errcode_t unix_get_stats(io_channel channel, io_stats *stats)
-;
-static void reuse_cache(io_channel channel, struct unix_private_data *data,
- struct unix_cache *cache, unsigned long long block);
-static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
- int count, void *data);
-static errcode_t unix_write_blk64(io_channel channel, unsigned long long block,
- int count, const void *data);
-static errcode_t unix_discard(io_channel channel, unsigned long long block,
- unsigned long long count);
-
-static struct struct_io_manager struct_unix_manager = {
- EXT2_ET_MAGIC_IO_MANAGER,
- "Unix I/O Manager",
- unix_open,
- unix_close,
- unix_set_blksize,
- unix_read_blk,
- unix_write_blk,
- unix_flush,
- unix_write_byte,
- unix_set_option,
- unix_get_stats,
- unix_read_blk64,
- unix_write_blk64,
- unix_discard,
-};
-
-io_manager unix_io_manager = &struct_unix_manager;
-
static errcode_t unix_get_stats(io_channel channel, io_stats *stats)
{
- errcode_t retval = 0;
+ errcode_t retval = 0;
struct unix_private_data *data;
int f_nocache = 0;
ext2fs_struct_stat st;
#ifdef __linux__
- struct utsname ut;
+ struct utsname ut;
#endif
if (name == 0)
unimplemented:
return EXT2_ET_UNIMPLEMENTED;
}
+
+static struct struct_io_manager struct_unix_manager = {
+ EXT2_ET_MAGIC_IO_MANAGER,
+ "Unix I/O Manager",
+ unix_open,
+ unix_close,
+ unix_set_blksize,
+ unix_read_blk,
+ unix_write_blk,
+ unix_flush,
+ unix_write_byte,
+ unix_set_option,
+ unix_get_stats,
+ unix_read_blk64,
+ unix_write_blk64,
+ unix_discard,
+};
+
+io_manager unix_io_manager = &struct_unix_manager;