* Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
*
* %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
* %End-Header%
*/
#include "ext2_fs.h"
#include "ext2fs.h"
+#ifdef __GNUC__
+#define ATTR(x) __attribute__(x)
+#else
+#define ATTR(x)
+#endif
+
/*
* For checking structure magic numbers...
*/
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 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_write_blk,
undo_flush,
undo_write_byte,
- undo_set_option
+ undo_set_option,
+ undo_get_stats,
+ undo_read_blk64,
+ undo_write_blk64,
};
io_manager undo_io_manager = &struct_undo_manager;
static char *tdb_file;
static int actual_size;
+static unsigned char mtime_key[] = "filesystem MTIME";
+static unsigned char blksize_key[] = "filesystem BLKSIZE";
+static unsigned char uuid_key[] = "filesystem UUID";
+
errcode_t set_undo_io_backing_manager(io_manager manager)
{
/*
block_size = channel->block_size;
io_channel_set_blksize(channel, SUPERBLOCK_OFFSET);
- retval = io_channel_read_blk(channel, 1, -SUPERBLOCK_SIZE, &super);
+ retval = io_channel_read_blk64(channel, 1, -SUPERBLOCK_SIZE, &super);
if (retval)
goto err_out;
/* Write to tdb file in the file system byte order */
- tdb_key.dptr = "filesystem MTIME";
- tdb_key.dsize = sizeof("filesystem MTIME");
+ tdb_key.dptr = mtime_key;
+ tdb_key.dsize = sizeof(mtime_key);
tdb_data.dptr = (unsigned char *) &(super.s_mtime);
tdb_data.dsize = sizeof(super.s_mtime);
goto err_out;
}
- tdb_key.dptr = "filesystem UUID";
- tdb_key.dsize = sizeof("filesystem UUID");
+ tdb_key.dptr = uuid_key;
+ tdb_key.dsize = sizeof(uuid_key);
tdb_data.dptr = (unsigned char *)&(super.s_uuid);
tdb_data.dsize = sizeof(super.s_uuid);
errcode_t retval;
TDB_DATA tdb_key, tdb_data;
- tdb_key.dptr = "filesystem BLKSIZE";
- tdb_key.dsize = sizeof("filesystem BLKSIZE");
+ tdb_key.dptr = blksize_key;
+ tdb_key.dsize = sizeof(blksize_key);
tdb_data.dptr = (unsigned char *)&(block_size);
tdb_data.dsize = sizeof(block_size);
}
static errcode_t undo_write_tdb(io_channel channel,
- unsigned long block, int count)
+ unsigned long long block, int count)
{
- int size, i, sz;
- unsigned long block_num, backing_blk_num;
+ int size, sz;
+ unsigned long long block_num, backing_blk_num;
errcode_t retval = 0;
ext2_loff_t offset;
struct undo_private_data *data;
TDB_DATA tdb_key, tdb_data;
- char *read_ptr;
- unsigned long end_block;
+ unsigned char *read_ptr;
+ unsigned long long end_block;
data = (struct undo_private_data *) channel->private_data;
sz = count / channel->block_size;
else
sz = -count;
- retval = io_channel_read_blk(data->real, backing_blk_num,
+ retval = io_channel_read_blk64(data->real, backing_blk_num,
sz, read_ptr);
if (retval) {
if (retval != EXT2_ET_SHORT_READ) {
tdb_data.dptr = read_ptr +
((offset - data->offset) % channel->block_size);
#ifdef DEBUG
- printf("Printing with key %ld data %x and size %d\n",
+ printf("Printing with key %lld data %x and size %d\n",
block_num,
tdb_data.dptr,
tdb_data.dsize);
return retval;
}
-static errcode_t undo_io_read_error(io_channel channel,
- unsigned long block, int count, void *data,
- size_t size, int actual, errcode_t error)
+static errcode_t undo_io_read_error(io_channel channel ATTR((unused)),
+ unsigned long block ATTR((unused)),
+ int count ATTR((unused)),
+ void *data ATTR((unused)),
+ size_t size ATTR((unused)),
+ int actual,
+ errcode_t error ATTR((unused)))
{
actual_size = actual;
return error;
io_channel io = NULL;
struct undo_private_data *data = NULL;
errcode_t retval;
- int open_flags;
- struct stat st;
if (name == 0)
return EXT2_ET_BAD_DEVICE_NAME;
static errcode_t undo_set_blksize(io_channel channel, int blksize)
{
struct undo_private_data *data;
- errcode_t retval;
+ errcode_t retval = 0;
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
data = (struct undo_private_data *) channel->private_data;
return retval;
}
-static errcode_t undo_read_blk(io_channel channel, unsigned long block,
+static errcode_t undo_read_blk64(io_channel channel, unsigned long long block,
int count, void *buf)
{
- errcode_t retval;
+ errcode_t retval = 0;
struct undo_private_data *data;
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
if (data->real)
- retval = io_channel_read_blk(data->real, block, count, buf);
+ retval = io_channel_read_blk64(data->real, block, count, buf);
return retval;
}
-static errcode_t undo_write_blk(io_channel channel, unsigned long block,
+static errcode_t undo_read_blk(io_channel channel, unsigned long block,
+ int count, void *buf)
+{
+ return undo_read_blk64(channel, block, count, buf);
+}
+
+static errcode_t undo_write_blk64(io_channel channel, unsigned long long block,
int count, const void *buf)
{
struct undo_private_data *data;
if (retval)
return retval;
if (data->real)
- retval = io_channel_write_blk(data->real, block, count, buf);
+ retval = io_channel_write_blk64(data->real, block, count, buf);
return retval;
}
+static errcode_t undo_write_blk(io_channel channel, unsigned long block,
+ int count, const void *buf)
+{
+ return undo_write_blk64(channel, block, count, buf);
+}
+
static errcode_t undo_write_byte(io_channel channel, unsigned long offset,
int size, const void *buf)
{
struct undo_private_data *data;
errcode_t retval = 0;
- ssize_t actual;
ext2_loff_t location;
unsigned long blk_num, count;;
}
return retval;
}
+
+static errcode_t undo_get_stats(io_channel channel, io_stats *stats)
+{
+ errcode_t retval = 0;
+ struct undo_private_data *data;
+
+ EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
+ data = (struct undo_private_data *) channel->private_data;
+ EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
+
+ if (data->real)
+ retval = (data->real->manager->get_stats)(data->real, stats);
+
+ return retval;
+}