1 /* vi: set sw=4 ts=4: */
3 * io.h --- the I/O manager abstraction
5 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
8 * This file may be redistributed under the terms of the GNU Public
13 #ifndef _EXT2FS_EXT2_IO_H
14 #define _EXT2FS_EXT2_IO_H
17 * ext2_loff_t is defined here since unix_io.c needs it.
19 #if defined(__GNUC__) || defined(HAS_LONG_LONG)
20 typedef long long ext2_loff_t;
22 typedef long ext2_loff_t;
26 /* ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int); */
28 # define ext2fs_llseek lseek64
30 # define ext2fs_llseek lseek
33 typedef struct struct_io_manager *io_manager;
34 typedef struct struct_io_channel *io_channel;
36 #define CHANNEL_FLAGS_WRITETHROUGH 0x01
38 struct struct_io_channel {
43 errcode_t (*read_error)(io_channel channel,
48 int actual_bytes_read,
50 errcode_t (*write_error)(io_channel channel,
55 int actual_bytes_written,
64 struct struct_io_manager {
67 errcode_t (*open)(const char *name, int flags, io_channel *channel);
68 errcode_t (*close)(io_channel channel);
69 errcode_t (*set_blksize)(io_channel channel, int blksize);
70 errcode_t (*read_blk)(io_channel channel, unsigned long block,
71 int count, void *data);
72 errcode_t (*write_blk)(io_channel channel, unsigned long block,
73 int count, const void *data);
74 errcode_t (*flush)(io_channel channel);
75 errcode_t (*write_byte)(io_channel channel, unsigned long offset,
76 int count, const void *data);
77 errcode_t (*set_option)(io_channel channel, const char *option,
85 * Convenience functions....
87 #define io_channel_close(c) ((c)->manager->close((c)))
88 #define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
89 #define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
90 #define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
91 #define io_channel_flush(c) ((c)->manager->flush((c)))
92 #define io_channel_bumpcount(c) ((c)->refcount++)
95 extern errcode_t io_channel_set_options(io_channel channel,
97 extern errcode_t io_channel_write_byte(io_channel channel,
99 int count, const void *data);
102 extern io_manager unix_io_manager;
105 extern io_manager test_io_manager, test_io_backing_manager;
106 extern void (*test_io_cb_read_blk)
107 (unsigned long block, int count, errcode_t err);
108 extern void (*test_io_cb_write_blk)
109 (unsigned long block, int count, errcode_t err);
110 extern void (*test_io_cb_set_blksize)
111 (int blksize, errcode_t err);
113 #endif /* _EXT2FS_EXT2_IO_H */