* io_manager.c --- the I/O manager abstraction
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
return (channel->manager->write_blk)(channel, (unsigned long) block,
count, data);
}
+
+errcode_t io_channel_discard(io_channel channel, unsigned long long block,
+ unsigned long long count)
+{
+ EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
+
+ if (channel->manager->discard)
+ return (channel->manager->discard)(channel, block, count);
+
+ return EXT2_ET_UNIMPLEMENTED;
+}
+
+errcode_t io_channel_alloc_buf(io_channel io, int count, void *ptr)
+{
+ size_t size;
+
+ if (count == 0)
+ size = io->block_size;
+ else if (count > 0)
+ size = io->block_size * count;
+ else
+ size = -count;
+
+ if (io->align)
+ return ext2fs_get_memalign(size, io->align, ptr);
+ else
+ return ext2fs_get_mem(size, ptr);
+}