diff options
author | Mike Frysinger | 2005-05-09 22:10:42 +0000 |
---|---|---|
committer | Mike Frysinger | 2005-05-09 22:10:42 +0000 |
commit | 1fd98e039d146dcff02a5350f509cabca65fd29c (patch) | |
tree | 1564707d41a6271bb44cf3fa5b88b9cc70fedd35 /e2fsprogs/ext2fs/io_manager.c | |
parent | b32011943a0764872ca1ea17f13b53176ace8e69 (diff) | |
download | busybox-1fd98e039d146dcff02a5350f509cabca65fd29c.zip busybox-1fd98e039d146dcff02a5350f509cabca65fd29c.tar.gz |
import ext2fs lib to prep for new e2fsprogs
Diffstat (limited to 'e2fsprogs/ext2fs/io_manager.c')
-rw-r--r-- | e2fsprogs/ext2fs/io_manager.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/e2fsprogs/ext2fs/io_manager.c b/e2fsprogs/ext2fs/io_manager.c new file mode 100644 index 0000000..e50d7e4 --- /dev/null +++ b/e2fsprogs/ext2fs/io_manager.c @@ -0,0 +1,69 @@ +/* + * io_manager.c --- the I/O manager abstraction + */ + +#include <stdio.h> +#include <string.h> +#if HAVE_UNISTD_H +#include <unistd.h> +#endif +#include <fcntl.h> +#include <time.h> +#if HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#if HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#include "ext2_fs.h" +#include "ext2fs.h" + +errcode_t io_channel_set_options(io_channel channel, const char *opts) +{ + errcode_t retval = 0; + char *next, *ptr, *options, *arg; + + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); + + if (!opts) + return 0; + + if (!channel->manager->set_option) + return EXT2_ET_INVALID_ARGUMENT; + + options = malloc(strlen(opts)+1); + if (!options) + return EXT2_ET_NO_MEMORY; + strcpy(options, opts); + ptr = options; + + while (ptr && *ptr) { + next = strchr(ptr, '&'); + if (next) + *next++ = 0; + + arg = strchr(ptr, '='); + if (arg) + *arg++ = 0; + + retval = (channel->manager->set_option)(channel, ptr, arg); + if (retval) + break; + ptr = next; + } + free(options); + return retval; +} + +errcode_t io_channel_write_byte(io_channel channel, unsigned long offset, + int count, const void *data) +{ + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); + + if (channel->manager->write_byte) + return channel->manager->write_byte(channel, offset, + count, data); + + return EXT2_ET_UNIMPLEMENTED; +} |