2 * io.h --- the I/O manager abstraction
4 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
13 * ext2_loff_t is defined here since unix_io.c needs it.
15 #if defined(__GNUC__) || defined(HAS_LONG_LONG)
16 typedef long long ext2_loff_t;
18 typedef long ext2_loff_t;
22 ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
24 typedef struct struct_io_manager *io_manager;
25 typedef struct struct_io_channel *io_channel;
27 struct struct_io_channel {
32 errcode_t (*read_error)(io_channel channel,
37 int actual_bytes_read,
39 errcode_t (*write_error)(io_channel channel,
44 int actual_bytes_written,
51 struct struct_io_manager {
54 errcode_t (*open)(const char *name, int flags, io_channel *channel);
55 errcode_t (*close)(io_channel channel);
56 errcode_t (*set_blksize)(io_channel channel, int blksize);
57 errcode_t (*read_blk)(io_channel channel, unsigned long block,
58 int count, void *data);
59 errcode_t (*write_blk)(io_channel channel, unsigned long block,
60 int count, const void *data);
61 errcode_t (*flush)(io_channel channel);
68 * Convenience functions....
70 #define io_channel_close(c) ((c)->manager->close((c)))
71 #define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
72 #define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
73 #define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
74 #define io_channel_flush(c) ((c)->manager->flush((c)))
75 #define io_channel_bumpcount(c) ((c)->refcount++)
78 extern io_manager unix_io_manager;
81 extern io_manager test_io_manager, test_io_backing_manager;
82 extern void (*test_io_cb_read_blk)
83 (unsigned long block, int count, errcode_t err);
84 extern void (*test_io_cb_write_blk)
85 (unsigned long block, int count, errcode_t err);
86 extern void (*test_io_cb_set_blksize)
87 (int blksize, errcode_t err);