Changes to update Tomato RAF.
[tomato.git] / release / src / router / busybox / e2fsprogs / old_e2fsprogs / ext2fs / io_manager.c
blobb47038602aeff7da9c18e9ef8e45385a4dfb33ab
1 /* vi: set sw=4 ts=4: */
2 /*
3 * io_manager.c --- the I/O manager abstraction
4 */
6 #include <stdio.h>
7 #include <string.h>
8 #if HAVE_UNISTD_H
9 #include <unistd.h>
10 #endif
11 #include <fcntl.h>
12 #include <time.h>
13 #if HAVE_SYS_STAT_H
14 #include <sys/stat.h>
15 #endif
16 #if HAVE_SYS_TYPES_H
17 #include <sys/types.h>
18 #endif
20 #include "ext2_fs.h"
21 #include "ext2fs.h"
23 errcode_t io_channel_set_options(io_channel channel, const char *opts)
25 errcode_t retval = 0;
26 char *next, *ptr, *options, *arg;
28 EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
30 if (!opts)
31 return 0;
33 if (!channel->manager->set_option)
34 return EXT2_ET_INVALID_ARGUMENT;
36 options = malloc(strlen(opts)+1);
37 if (!options)
38 return EXT2_ET_NO_MEMORY;
39 strcpy(options, opts);
40 ptr = options;
42 while (ptr && *ptr) {
43 next = strchr(ptr, '&');
44 if (next)
45 *next++ = 0;
47 arg = strchr(ptr, '=');
48 if (arg)
49 *arg++ = 0;
51 retval = (channel->manager->set_option)(channel, ptr, arg);
52 if (retval)
53 break;
54 ptr = next;
56 free(options);
57 return retval;
60 errcode_t io_channel_write_byte(io_channel channel, unsigned long offset,
61 int count, const void *data)
63 EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
65 if (channel->manager->write_byte)
66 return channel->manager->write_byte(channel, offset,
67 count, data);
69 return EXT2_ET_UNIMPLEMENTED;