1997-04-26 17:21:57 +04:00
|
|
|
/*
|
|
|
|
* io.h --- the I/O manager abstraction
|
2008-08-28 07:07:54 +04:00
|
|
|
*
|
1997-04-29 20:17:09 +04:00
|
|
|
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
2010-05-18 05:31:56 +04:00
|
|
|
* This file may be redistributed under the terms of the GNU Library
|
|
|
|
* General Public License, version 2.
|
1997-04-29 20:17:09 +04:00
|
|
|
* %End-Header%
|
1997-04-26 17:21:57 +04:00
|
|
|
*/
|
|
|
|
|
1998-02-17 01:00:37 +03:00
|
|
|
#ifndef _EXT2FS_EXT2_IO_H
|
|
|
|
#define _EXT2FS_EXT2_IO_H
|
|
|
|
|
1997-04-26 17:34:30 +04:00
|
|
|
/*
|
|
|
|
* ext2_loff_t is defined here since unix_io.c needs it.
|
|
|
|
*/
|
|
|
|
#if defined(__GNUC__) || defined(HAS_LONG_LONG)
|
|
|
|
typedef long long ext2_loff_t;
|
|
|
|
#else
|
|
|
|
typedef long ext2_loff_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* llseek.c */
|
ChangeLog, .del-io.h~72680822, irel_ma.c, llseek.c, rw_bitmaps.c:
io.h: Change the prototype of ext2fs_llseek() to use int's instead of
unsigned int's.
llseek.c: Change to allow PIC and !HAVE_LLSEEK. Add a prototype to
make life easer for GNU Libc 2.
rw_bitmaps.c: On the PowerPC, the big-endian variant of the ext2
filesystem has its bitmaps stored as 32-bit words with bit 0 as the
LSB of each word. Thus a bitmap with only bit 0 set would be, as a
string of bytes, 00 00 00 01 00 ... To cope with this, we
byte-reverse each word of a bitmap if we have a big-endian filesystem,
that is, if we are *not* byte-swapping other word-sized numbers.
ChangeLog, expect.1, image.gz:
f_badinode: Modify test to check for "bad" character and block devices
(i.e., ones which contain garbage block entries)
1997-08-14 21:20:42 +04:00
|
|
|
ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
|
1997-04-26 17:34:30 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
typedef struct struct_io_manager *io_manager;
|
|
|
|
typedef struct struct_io_channel *io_channel;
|
2007-08-04 04:07:09 +04:00
|
|
|
typedef struct struct_io_stats *io_stats;
|
1997-04-26 17:21:57 +04:00
|
|
|
|
2000-10-18 23:22:24 +04:00
|
|
|
#define CHANNEL_FLAGS_WRITETHROUGH 0x01
|
2010-11-18 06:38:37 +03:00
|
|
|
#define CHANNEL_FLAGS_DISCARD_ZEROES 0x02
|
2011-09-16 07:44:59 +04:00
|
|
|
#define CHANNEL_FLAGS_BLOCK_DEVICE 0x04
|
2010-11-18 06:38:37 +03:00
|
|
|
|
|
|
|
#define io_channel_discard_zeroes_data(i) (i->flags & CHANNEL_FLAGS_DISCARD_ZEROES)
|
2000-10-18 23:22:24 +04:00
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
struct struct_io_channel {
|
Many files:
dosio.c: New file to do DOS/BIOS disk accesses.
namei.c (open_namei): Make pathlen be of type size_t.
llseek.c: Always #include stdlib.h since it's need to define
size_t.
io.h: Use errcode_t for magic numbers.
icount.c (get_icount_el), dupfs.c (ext2fs_dup_handle), dblist.c
(dir_block_cmp): Use size_t where appropriate.
read_bb.c (ext2fs_read_bb_inode), cmp_bitmaps.c
(ext2fs_compare_inode_bitmap): Use blk_t, ino_t and size_t
where appropriate.
closefs.c (ext2fs_flush): Use dgrp_t instead of int where
appropriate.
openfs.c (ext2fs_open), check_desc.c (ext2fs_check_desc): Use blk_t
instead of int where appropriate.
rw_bitmaps.c (read_bitmaps), irel_ma.c, inode.c (ext2fs_write_inode),
initialize.c (ext2fs_initialize): brel_ma.c: Fix to make be
16-bit safe.
link.c (ext2fs_link), unlink.c (ext2fs_unlink), lookup.c (lookup_proc),
ismounted.c (ext2fs_check_if_mounted), block.c (xlate_func):
Add #pragma argsused for Turbo C.
1997-08-12 00:29:22 +04:00
|
|
|
errcode_t magic;
|
1997-04-26 17:21:57 +04:00
|
|
|
io_manager manager;
|
|
|
|
char *name;
|
|
|
|
int block_size;
|
|
|
|
errcode_t (*read_error)(io_channel channel,
|
|
|
|
unsigned long block,
|
|
|
|
int count,
|
|
|
|
void *data,
|
|
|
|
size_t size,
|
|
|
|
int actual_bytes_read,
|
|
|
|
errcode_t error);
|
|
|
|
errcode_t (*write_error)(io_channel channel,
|
|
|
|
unsigned long block,
|
|
|
|
int count,
|
|
|
|
const void *data,
|
|
|
|
size_t size,
|
|
|
|
int actual_bytes_written,
|
|
|
|
errcode_t error);
|
1997-04-30 01:26:48 +04:00
|
|
|
int refcount;
|
2000-10-18 23:22:24 +04:00
|
|
|
int flags;
|
2008-08-28 05:46:26 +04:00
|
|
|
long reserved[14];
|
1997-04-26 17:21:57 +04:00
|
|
|
void *private_data;
|
1997-08-24 06:57:55 +04:00
|
|
|
void *app_data;
|
1997-04-26 17:21:57 +04:00
|
|
|
};
|
|
|
|
|
2007-08-04 04:07:09 +04:00
|
|
|
struct struct_io_stats {
|
|
|
|
int num_fields;
|
|
|
|
int reserved;
|
|
|
|
unsigned long long bytes_read;
|
|
|
|
unsigned long long bytes_written;
|
|
|
|
};
|
|
|
|
|
1997-04-26 17:21:57 +04:00
|
|
|
struct struct_io_manager {
|
Many files:
dosio.c: New file to do DOS/BIOS disk accesses.
namei.c (open_namei): Make pathlen be of type size_t.
llseek.c: Always #include stdlib.h since it's need to define
size_t.
io.h: Use errcode_t for magic numbers.
icount.c (get_icount_el), dupfs.c (ext2fs_dup_handle), dblist.c
(dir_block_cmp): Use size_t where appropriate.
read_bb.c (ext2fs_read_bb_inode), cmp_bitmaps.c
(ext2fs_compare_inode_bitmap): Use blk_t, ino_t and size_t
where appropriate.
closefs.c (ext2fs_flush): Use dgrp_t instead of int where
appropriate.
openfs.c (ext2fs_open), check_desc.c (ext2fs_check_desc): Use blk_t
instead of int where appropriate.
rw_bitmaps.c (read_bitmaps), irel_ma.c, inode.c (ext2fs_write_inode),
initialize.c (ext2fs_initialize): brel_ma.c: Fix to make be
16-bit safe.
link.c (ext2fs_link), unlink.c (ext2fs_unlink), lookup.c (lookup_proc),
ismounted.c (ext2fs_check_if_mounted), block.c (xlate_func):
Add #pragma argsused for Turbo C.
1997-08-12 00:29:22 +04:00
|
|
|
errcode_t magic;
|
1997-04-26 17:21:57 +04:00
|
|
|
const char *name;
|
|
|
|
errcode_t (*open)(const char *name, int flags, io_channel *channel);
|
|
|
|
errcode_t (*close)(io_channel channel);
|
|
|
|
errcode_t (*set_blksize)(io_channel channel, int blksize);
|
|
|
|
errcode_t (*read_blk)(io_channel channel, unsigned long block,
|
|
|
|
int count, void *data);
|
|
|
|
errcode_t (*write_blk)(io_channel channel, unsigned long block,
|
|
|
|
int count, const void *data);
|
|
|
|
errcode_t (*flush)(io_channel channel);
|
2000-10-27 00:24:43 +04:00
|
|
|
errcode_t (*write_byte)(io_channel channel, unsigned long offset,
|
|
|
|
int count, const void *data);
|
2008-08-28 07:07:54 +04:00
|
|
|
errcode_t (*set_option)(io_channel channel, const char *option,
|
2004-11-30 22:07:11 +03:00
|
|
|
const char *arg);
|
2007-08-04 04:07:09 +04:00
|
|
|
errcode_t (*get_stats)(io_channel channel, io_stats *io_stats);
|
2008-03-03 19:41:18 +03:00
|
|
|
errcode_t (*read_blk64)(io_channel channel, unsigned long long block,
|
|
|
|
int count, void *data);
|
|
|
|
errcode_t (*write_blk64)(io_channel channel, unsigned long long block,
|
|
|
|
int count, const void *data);
|
2010-11-18 06:38:36 +03:00
|
|
|
errcode_t (*discard)(io_channel channel, unsigned long long block,
|
|
|
|
unsigned long long count);
|
2008-08-28 05:46:26 +04:00
|
|
|
long reserved[16];
|
1997-04-26 17:21:57 +04:00
|
|
|
};
|
|
|
|
|
2006-03-19 02:57:44 +03:00
|
|
|
#define IO_FLAG_RW 0x0001
|
|
|
|
#define IO_FLAG_EXCLUSIVE 0x0002
|
2010-09-24 18:02:25 +04:00
|
|
|
#define IO_FLAG_DIRECT_IO 0x0004
|
1997-04-26 17:21:57 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Convenience functions....
|
|
|
|
*/
|
|
|
|
#define io_channel_close(c) ((c)->manager->close((c)))
|
|
|
|
#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
|
|
|
|
#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
|
|
|
|
#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
|
|
|
|
#define io_channel_flush(c) ((c)->manager->flush((c)))
|
1997-04-30 01:26:48 +04:00
|
|
|
#define io_channel_bumpcount(c) ((c)->refcount++)
|
2008-08-28 07:07:54 +04:00
|
|
|
|
2004-11-30 22:07:11 +03:00
|
|
|
/* io_manager.c */
|
2008-08-28 07:07:54 +04:00
|
|
|
extern errcode_t io_channel_set_options(io_channel channel,
|
2004-11-30 22:07:11 +03:00
|
|
|
const char *options);
|
2008-08-28 07:07:54 +04:00
|
|
|
extern errcode_t io_channel_write_byte(io_channel channel,
|
2004-11-30 22:07:11 +03:00
|
|
|
unsigned long offset,
|
|
|
|
int count, const void *data);
|
2008-08-28 05:46:26 +04:00
|
|
|
extern errcode_t io_channel_read_blk64(io_channel channel,
|
|
|
|
unsigned long long block,
|
|
|
|
int count, void *data);
|
|
|
|
extern errcode_t io_channel_write_blk64(io_channel channel,
|
|
|
|
unsigned long long block,
|
|
|
|
int count, const void *data);
|
2011-02-28 04:09:54 +03:00
|
|
|
extern errcode_t io_channel_discard(io_channel channel,
|
|
|
|
unsigned long long block,
|
|
|
|
unsigned long long count);
|
2004-11-30 22:07:11 +03:00
|
|
|
|
1997-04-29 20:17:09 +04:00
|
|
|
/* unix_io.c */
|
1997-04-26 17:21:57 +04:00
|
|
|
extern io_manager unix_io_manager;
|
|
|
|
|
2007-08-13 14:26:21 +04:00
|
|
|
/* undo_io.c */
|
|
|
|
extern io_manager undo_io_manager;
|
|
|
|
extern errcode_t set_undo_io_backing_manager(io_manager manager);
|
|
|
|
extern errcode_t set_undo_io_backup_file(char *file_name);
|
|
|
|
|
1997-04-29 20:17:09 +04:00
|
|
|
/* test_io.c */
|
|
|
|
extern io_manager test_io_manager, test_io_backing_manager;
|
|
|
|
extern void (*test_io_cb_read_blk)
|
|
|
|
(unsigned long block, int count, errcode_t err);
|
|
|
|
extern void (*test_io_cb_write_blk)
|
|
|
|
(unsigned long block, int count, errcode_t err);
|
2009-08-05 08:27:10 +04:00
|
|
|
extern void (*test_io_cb_read_blk64)
|
|
|
|
(unsigned long long block, int count, errcode_t err);
|
|
|
|
extern void (*test_io_cb_write_blk64)
|
|
|
|
(unsigned long long block, int count, errcode_t err);
|
1997-04-29 20:17:09 +04:00
|
|
|
extern void (*test_io_cb_set_blksize)
|
|
|
|
(int blksize, errcode_t err);
|
1998-02-17 01:00:37 +03:00
|
|
|
|
|
|
|
#endif /* _EXT2FS_EXT2_IO_H */
|
2008-08-28 07:07:54 +04:00
|
|
|
|