xref: /aosp_15_r20/external/e2fsprogs/lib/ext2fs/test_io.c (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker /*
2*6a54128fSAndroid Build Coastguard Worker  * test_io.c --- This is the Test I/O interface.
3*6a54128fSAndroid Build Coastguard Worker  *
4*6a54128fSAndroid Build Coastguard Worker  * Copyright (C) 1996 Theodore Ts'o.
5*6a54128fSAndroid Build Coastguard Worker  *
6*6a54128fSAndroid Build Coastguard Worker  * %Begin-Header%
7*6a54128fSAndroid Build Coastguard Worker  * This file may be redistributed under the terms of the GNU Library
8*6a54128fSAndroid Build Coastguard Worker  * General Public License, version 2.
9*6a54128fSAndroid Build Coastguard Worker  * %End-Header%
10*6a54128fSAndroid Build Coastguard Worker  */
11*6a54128fSAndroid Build Coastguard Worker 
12*6a54128fSAndroid Build Coastguard Worker #include "config.h"
13*6a54128fSAndroid Build Coastguard Worker #include <stdio.h>
14*6a54128fSAndroid Build Coastguard Worker #include <string.h>
15*6a54128fSAndroid Build Coastguard Worker #if HAVE_UNISTD_H
16*6a54128fSAndroid Build Coastguard Worker #include <unistd.h>
17*6a54128fSAndroid Build Coastguard Worker #endif
18*6a54128fSAndroid Build Coastguard Worker #include <fcntl.h>
19*6a54128fSAndroid Build Coastguard Worker #include <time.h>
20*6a54128fSAndroid Build Coastguard Worker #if HAVE_SYS_STAT_H
21*6a54128fSAndroid Build Coastguard Worker #include <sys/stat.h>
22*6a54128fSAndroid Build Coastguard Worker #endif
23*6a54128fSAndroid Build Coastguard Worker #if HAVE_SYS_TYPES_H
24*6a54128fSAndroid Build Coastguard Worker #include <sys/types.h>
25*6a54128fSAndroid Build Coastguard Worker #endif
26*6a54128fSAndroid Build Coastguard Worker #ifdef HAVE_SYS_PRCTL_H
27*6a54128fSAndroid Build Coastguard Worker #include <sys/prctl.h>
28*6a54128fSAndroid Build Coastguard Worker #else
29*6a54128fSAndroid Build Coastguard Worker #define PR_GET_DUMPABLE 3
30*6a54128fSAndroid Build Coastguard Worker #endif
31*6a54128fSAndroid Build Coastguard Worker #if (!defined(HAVE_PRCTL) && defined(linux))
32*6a54128fSAndroid Build Coastguard Worker #include <sys/syscall.h>
33*6a54128fSAndroid Build Coastguard Worker #endif
34*6a54128fSAndroid Build Coastguard Worker 
35*6a54128fSAndroid Build Coastguard Worker #include "ext2_fs.h"
36*6a54128fSAndroid Build Coastguard Worker #include "ext2fs.h"
37*6a54128fSAndroid Build Coastguard Worker 
38*6a54128fSAndroid Build Coastguard Worker /*
39*6a54128fSAndroid Build Coastguard Worker  * For checking structure magic numbers...
40*6a54128fSAndroid Build Coastguard Worker  */
41*6a54128fSAndroid Build Coastguard Worker 
42*6a54128fSAndroid Build Coastguard Worker #define EXT2_CHECK_MAGIC(struct, code) \
43*6a54128fSAndroid Build Coastguard Worker 	  if ((struct)->magic != (code)) return (code)
44*6a54128fSAndroid Build Coastguard Worker 
45*6a54128fSAndroid Build Coastguard Worker struct test_private_data {
46*6a54128fSAndroid Build Coastguard Worker 	int	magic;
47*6a54128fSAndroid Build Coastguard Worker 	io_channel real;
48*6a54128fSAndroid Build Coastguard Worker 	int flags;
49*6a54128fSAndroid Build Coastguard Worker 	FILE *outfile;
50*6a54128fSAndroid Build Coastguard Worker 	unsigned long block;
51*6a54128fSAndroid Build Coastguard Worker 	int read_abort_count, write_abort_count;
52*6a54128fSAndroid Build Coastguard Worker 	void (*read_blk)(unsigned long block, int count, errcode_t err);
53*6a54128fSAndroid Build Coastguard Worker 	void (*write_blk)(unsigned long block, int count, errcode_t err);
54*6a54128fSAndroid Build Coastguard Worker 	void (*set_blksize)(int blksize, errcode_t err);
55*6a54128fSAndroid Build Coastguard Worker 	void (*write_byte)(unsigned long block, int count, errcode_t err);
56*6a54128fSAndroid Build Coastguard Worker 	void (*read_blk64)(unsigned long long block, int count, errcode_t err);
57*6a54128fSAndroid Build Coastguard Worker 	void (*write_blk64)(unsigned long long block, int count, errcode_t err);
58*6a54128fSAndroid Build Coastguard Worker };
59*6a54128fSAndroid Build Coastguard Worker 
60*6a54128fSAndroid Build Coastguard Worker /*
61*6a54128fSAndroid Build Coastguard Worker  * These global variable can be set by the test program as
62*6a54128fSAndroid Build Coastguard Worker  * necessary *before* calling test_open
63*6a54128fSAndroid Build Coastguard Worker  */
64*6a54128fSAndroid Build Coastguard Worker io_manager test_io_backing_manager = 0;
65*6a54128fSAndroid Build Coastguard Worker void (*test_io_cb_read_blk)
66*6a54128fSAndroid Build Coastguard Worker 	(unsigned long block, int count, errcode_t err) = 0;
67*6a54128fSAndroid Build Coastguard Worker void (*test_io_cb_write_blk)
68*6a54128fSAndroid Build Coastguard Worker 	(unsigned long block, int count, errcode_t err) = 0;
69*6a54128fSAndroid Build Coastguard Worker void (*test_io_cb_read_blk64)
70*6a54128fSAndroid Build Coastguard Worker 	(unsigned long long block, int count, errcode_t err) = 0;
71*6a54128fSAndroid Build Coastguard Worker void (*test_io_cb_write_blk64)
72*6a54128fSAndroid Build Coastguard Worker 	(unsigned long long block, int count, errcode_t err) = 0;
73*6a54128fSAndroid Build Coastguard Worker void (*test_io_cb_set_blksize)
74*6a54128fSAndroid Build Coastguard Worker 	(int blksize, errcode_t err) = 0;
75*6a54128fSAndroid Build Coastguard Worker void (*test_io_cb_write_byte)
76*6a54128fSAndroid Build Coastguard Worker 	(unsigned long block, int count, errcode_t err) = 0;
77*6a54128fSAndroid Build Coastguard Worker 
78*6a54128fSAndroid Build Coastguard Worker /*
79*6a54128fSAndroid Build Coastguard Worker  * Test flags
80*6a54128fSAndroid Build Coastguard Worker  */
81*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_READ			0x01
82*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_WRITE			0x02
83*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_SET_BLKSIZE		0x04
84*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_FLUSH			0x08
85*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_DUMP			0x10
86*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_SET_OPTION		0x20
87*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_DISCARD		0x40
88*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_READAHEAD		0x80
89*6a54128fSAndroid Build Coastguard Worker #define TEST_FLAG_ZEROOUT		0x100
90*6a54128fSAndroid Build Coastguard Worker 
test_dump_block(io_channel channel,struct test_private_data * data,unsigned long block,const void * buf)91*6a54128fSAndroid Build Coastguard Worker static void test_dump_block(io_channel channel,
92*6a54128fSAndroid Build Coastguard Worker 			    struct test_private_data *data,
93*6a54128fSAndroid Build Coastguard Worker 			    unsigned long block, const void *buf)
94*6a54128fSAndroid Build Coastguard Worker {
95*6a54128fSAndroid Build Coastguard Worker 	const unsigned char *cp;
96*6a54128fSAndroid Build Coastguard Worker 	FILE *f = data->outfile;
97*6a54128fSAndroid Build Coastguard Worker 	int	i;
98*6a54128fSAndroid Build Coastguard Worker 	unsigned long	cksum = 0;
99*6a54128fSAndroid Build Coastguard Worker 
100*6a54128fSAndroid Build Coastguard Worker 	for (i=0, cp = buf; i < channel->block_size; i++, cp++) {
101*6a54128fSAndroid Build Coastguard Worker 		cksum += *cp;
102*6a54128fSAndroid Build Coastguard Worker 	}
103*6a54128fSAndroid Build Coastguard Worker 	fprintf(f, "Contents of block %lu, checksum %08lu: \n", block, cksum);
104*6a54128fSAndroid Build Coastguard Worker 	for (i=0, cp = buf; i < channel->block_size; i++, cp++) {
105*6a54128fSAndroid Build Coastguard Worker 		if ((i % 16) == 0)
106*6a54128fSAndroid Build Coastguard Worker 			fprintf(f, "%04x: ", i);
107*6a54128fSAndroid Build Coastguard Worker 		fprintf(f, "%02x%c", *cp, ((i % 16) == 15) ? '\n' : ' ');
108*6a54128fSAndroid Build Coastguard Worker 	}
109*6a54128fSAndroid Build Coastguard Worker }
110*6a54128fSAndroid Build Coastguard Worker 
111*6a54128fSAndroid Build Coastguard Worker /*
112*6a54128fSAndroid Build Coastguard Worker  * Flush data buffers to disk.
113*6a54128fSAndroid Build Coastguard Worker  */
test_flush(io_channel channel)114*6a54128fSAndroid Build Coastguard Worker static errcode_t test_flush(io_channel channel)
115*6a54128fSAndroid Build Coastguard Worker {
116*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data	*data;
117*6a54128fSAndroid Build Coastguard Worker 	errcode_t			retval = 0;
118*6a54128fSAndroid Build Coastguard Worker 
119*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
120*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *)channel->private_data;
121*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
122*6a54128fSAndroid Build Coastguard Worker 
123*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
124*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_flush(data->real);
125*6a54128fSAndroid Build Coastguard Worker 
126*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_FLUSH)
127*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile, "Test_io: flush() returned %s\n",
128*6a54128fSAndroid Build Coastguard Worker 			retval ? error_message(retval) : "OK");
129*6a54128fSAndroid Build Coastguard Worker 
130*6a54128fSAndroid Build Coastguard Worker 	return retval;
131*6a54128fSAndroid Build Coastguard Worker }
132*6a54128fSAndroid Build Coastguard Worker 
test_abort(io_channel channel,unsigned long block)133*6a54128fSAndroid Build Coastguard Worker static void test_abort(io_channel channel, unsigned long block)
134*6a54128fSAndroid Build Coastguard Worker {
135*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
136*6a54128fSAndroid Build Coastguard Worker 	FILE *f;
137*6a54128fSAndroid Build Coastguard Worker 
138*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
139*6a54128fSAndroid Build Coastguard Worker 	f = data->outfile;
140*6a54128fSAndroid Build Coastguard Worker 	test_flush(channel);
141*6a54128fSAndroid Build Coastguard Worker 
142*6a54128fSAndroid Build Coastguard Worker 	fprintf(f, "Aborting due to I/O to block %lu\n", block);
143*6a54128fSAndroid Build Coastguard Worker 	fflush(f);
144*6a54128fSAndroid Build Coastguard Worker 	abort();
145*6a54128fSAndroid Build Coastguard Worker }
146*6a54128fSAndroid Build Coastguard Worker 
safe_getenv(const char * arg)147*6a54128fSAndroid Build Coastguard Worker static char *safe_getenv(const char *arg)
148*6a54128fSAndroid Build Coastguard Worker {
149*6a54128fSAndroid Build Coastguard Worker #if !defined(_WIN32)
150*6a54128fSAndroid Build Coastguard Worker 	if ((getuid() != geteuid()) || (getgid() != getegid()))
151*6a54128fSAndroid Build Coastguard Worker 		return NULL;
152*6a54128fSAndroid Build Coastguard Worker #endif
153*6a54128fSAndroid Build Coastguard Worker #if HAVE_PRCTL
154*6a54128fSAndroid Build Coastguard Worker 	if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)
155*6a54128fSAndroid Build Coastguard Worker 		return NULL;
156*6a54128fSAndroid Build Coastguard Worker #else
157*6a54128fSAndroid Build Coastguard Worker #if (defined(linux) && defined(SYS_prctl))
158*6a54128fSAndroid Build Coastguard Worker 	if (syscall(SYS_prctl, PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)
159*6a54128fSAndroid Build Coastguard Worker 		return NULL;
160*6a54128fSAndroid Build Coastguard Worker #endif
161*6a54128fSAndroid Build Coastguard Worker #endif
162*6a54128fSAndroid Build Coastguard Worker 
163*6a54128fSAndroid Build Coastguard Worker #if defined(HAVE_SECURE_GETENV)
164*6a54128fSAndroid Build Coastguard Worker 	return secure_getenv(arg);
165*6a54128fSAndroid Build Coastguard Worker #elif defined(HAVE___SECURE_GETENV)
166*6a54128fSAndroid Build Coastguard Worker 	return __secure_getenv(arg);
167*6a54128fSAndroid Build Coastguard Worker #else
168*6a54128fSAndroid Build Coastguard Worker 	return getenv(arg);
169*6a54128fSAndroid Build Coastguard Worker #endif
170*6a54128fSAndroid Build Coastguard Worker }
171*6a54128fSAndroid Build Coastguard Worker 
test_open(const char * name,int flags,io_channel * channel)172*6a54128fSAndroid Build Coastguard Worker static errcode_t test_open(const char *name, int flags, io_channel *channel)
173*6a54128fSAndroid Build Coastguard Worker {
174*6a54128fSAndroid Build Coastguard Worker 	io_channel	io = NULL;
175*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data = NULL;
176*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval;
177*6a54128fSAndroid Build Coastguard Worker 	char		*value;
178*6a54128fSAndroid Build Coastguard Worker 
179*6a54128fSAndroid Build Coastguard Worker 	if (name == 0)
180*6a54128fSAndroid Build Coastguard Worker 		return EXT2_ET_BAD_DEVICE_NAME;
181*6a54128fSAndroid Build Coastguard Worker 	retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
182*6a54128fSAndroid Build Coastguard Worker 	if (retval)
183*6a54128fSAndroid Build Coastguard Worker 		goto cleanup;
184*6a54128fSAndroid Build Coastguard Worker 	memset(io, 0, sizeof(struct struct_io_channel));
185*6a54128fSAndroid Build Coastguard Worker 	io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
186*6a54128fSAndroid Build Coastguard Worker 	retval = ext2fs_get_mem(sizeof(struct test_private_data), &data);
187*6a54128fSAndroid Build Coastguard Worker 	if (retval)
188*6a54128fSAndroid Build Coastguard Worker 		goto cleanup;
189*6a54128fSAndroid Build Coastguard Worker 	io->manager = test_io_manager;
190*6a54128fSAndroid Build Coastguard Worker 	retval = ext2fs_get_mem(strlen(name)+1, &io->name);
191*6a54128fSAndroid Build Coastguard Worker 	if (retval)
192*6a54128fSAndroid Build Coastguard Worker 		goto cleanup;
193*6a54128fSAndroid Build Coastguard Worker 
194*6a54128fSAndroid Build Coastguard Worker 	strcpy(io->name, name);
195*6a54128fSAndroid Build Coastguard Worker 	io->private_data = data;
196*6a54128fSAndroid Build Coastguard Worker 	io->block_size = 1024;
197*6a54128fSAndroid Build Coastguard Worker 	io->read_error = 0;
198*6a54128fSAndroid Build Coastguard Worker 	io->write_error = 0;
199*6a54128fSAndroid Build Coastguard Worker 	io->refcount = 1;
200*6a54128fSAndroid Build Coastguard Worker 	io->flags = 0;
201*6a54128fSAndroid Build Coastguard Worker 
202*6a54128fSAndroid Build Coastguard Worker 	memset(data, 0, sizeof(struct test_private_data));
203*6a54128fSAndroid Build Coastguard Worker 	data->magic = EXT2_ET_MAGIC_TEST_IO_CHANNEL;
204*6a54128fSAndroid Build Coastguard Worker 	if (test_io_backing_manager) {
205*6a54128fSAndroid Build Coastguard Worker 		retval = test_io_backing_manager->open(name, flags,
206*6a54128fSAndroid Build Coastguard Worker 						       &data->real);
207*6a54128fSAndroid Build Coastguard Worker 		if (retval)
208*6a54128fSAndroid Build Coastguard Worker 			goto cleanup;
209*6a54128fSAndroid Build Coastguard Worker 	} else {
210*6a54128fSAndroid Build Coastguard Worker 		data->real = 0;
211*6a54128fSAndroid Build Coastguard Worker 	}
212*6a54128fSAndroid Build Coastguard Worker 	data->read_blk =	test_io_cb_read_blk;
213*6a54128fSAndroid Build Coastguard Worker 	data->write_blk =	test_io_cb_write_blk;
214*6a54128fSAndroid Build Coastguard Worker 	data->set_blksize =	test_io_cb_set_blksize;
215*6a54128fSAndroid Build Coastguard Worker 	data->write_byte =	test_io_cb_write_byte;
216*6a54128fSAndroid Build Coastguard Worker 	data->read_blk64 =	test_io_cb_read_blk64;
217*6a54128fSAndroid Build Coastguard Worker 	data->write_blk64 =	test_io_cb_write_blk64;
218*6a54128fSAndroid Build Coastguard Worker 
219*6a54128fSAndroid Build Coastguard Worker 	data->outfile = NULL;
220*6a54128fSAndroid Build Coastguard Worker 	if ((value = safe_getenv("TEST_IO_LOGFILE")) != NULL)
221*6a54128fSAndroid Build Coastguard Worker 		data->outfile = fopen(value, "w");
222*6a54128fSAndroid Build Coastguard Worker 	if (!data->outfile)
223*6a54128fSAndroid Build Coastguard Worker 		data->outfile = stderr;
224*6a54128fSAndroid Build Coastguard Worker 
225*6a54128fSAndroid Build Coastguard Worker 	data->flags = 0;
226*6a54128fSAndroid Build Coastguard Worker 	if ((value = safe_getenv("TEST_IO_FLAGS")) != NULL)
227*6a54128fSAndroid Build Coastguard Worker 		data->flags = strtoul(value, NULL, 0);
228*6a54128fSAndroid Build Coastguard Worker 
229*6a54128fSAndroid Build Coastguard Worker 	data->block = 0;
230*6a54128fSAndroid Build Coastguard Worker 	if ((value = safe_getenv("TEST_IO_BLOCK")) != NULL)
231*6a54128fSAndroid Build Coastguard Worker 		data->block = strtoul(value, NULL, 0);
232*6a54128fSAndroid Build Coastguard Worker 
233*6a54128fSAndroid Build Coastguard Worker 	data->read_abort_count = 0;
234*6a54128fSAndroid Build Coastguard Worker 	if ((value = safe_getenv("TEST_IO_READ_ABORT")) != NULL)
235*6a54128fSAndroid Build Coastguard Worker 		data->read_abort_count = strtoul(value, NULL, 0);
236*6a54128fSAndroid Build Coastguard Worker 
237*6a54128fSAndroid Build Coastguard Worker 	data->write_abort_count = 0;
238*6a54128fSAndroid Build Coastguard Worker 	if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL)
239*6a54128fSAndroid Build Coastguard Worker 		data->write_abort_count = strtoul(value, NULL, 0);
240*6a54128fSAndroid Build Coastguard Worker 
241*6a54128fSAndroid Build Coastguard Worker 	if (data->real) {
242*6a54128fSAndroid Build Coastguard Worker 		io->align = data->real->align;
243*6a54128fSAndroid Build Coastguard Worker 		if (data->real->flags & CHANNEL_FLAGS_THREADS)
244*6a54128fSAndroid Build Coastguard Worker 			io->flags |= CHANNEL_FLAGS_THREADS;
245*6a54128fSAndroid Build Coastguard Worker 	}
246*6a54128fSAndroid Build Coastguard Worker 
247*6a54128fSAndroid Build Coastguard Worker 	*channel = io;
248*6a54128fSAndroid Build Coastguard Worker 	return 0;
249*6a54128fSAndroid Build Coastguard Worker 
250*6a54128fSAndroid Build Coastguard Worker cleanup:
251*6a54128fSAndroid Build Coastguard Worker 	if (io && io->name)
252*6a54128fSAndroid Build Coastguard Worker 		ext2fs_free_mem(&io->name);
253*6a54128fSAndroid Build Coastguard Worker 	if (io)
254*6a54128fSAndroid Build Coastguard Worker 		ext2fs_free_mem(&io);
255*6a54128fSAndroid Build Coastguard Worker 	if (data)
256*6a54128fSAndroid Build Coastguard Worker 		ext2fs_free_mem(&data);
257*6a54128fSAndroid Build Coastguard Worker 	return retval;
258*6a54128fSAndroid Build Coastguard Worker }
259*6a54128fSAndroid Build Coastguard Worker 
test_close(io_channel channel)260*6a54128fSAndroid Build Coastguard Worker static errcode_t test_close(io_channel channel)
261*6a54128fSAndroid Build Coastguard Worker {
262*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
263*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
264*6a54128fSAndroid Build Coastguard Worker 
265*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
266*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
267*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
268*6a54128fSAndroid Build Coastguard Worker 
269*6a54128fSAndroid Build Coastguard Worker 	if (--channel->refcount > 0)
270*6a54128fSAndroid Build Coastguard Worker 		return 0;
271*6a54128fSAndroid Build Coastguard Worker 
272*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
273*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_close(data->real);
274*6a54128fSAndroid Build Coastguard Worker 
275*6a54128fSAndroid Build Coastguard Worker 	if (data->outfile && data->outfile != stderr)
276*6a54128fSAndroid Build Coastguard Worker 		fclose(data->outfile);
277*6a54128fSAndroid Build Coastguard Worker 
278*6a54128fSAndroid Build Coastguard Worker 	ext2fs_free_mem(&channel->private_data);
279*6a54128fSAndroid Build Coastguard Worker 	if (channel->name)
280*6a54128fSAndroid Build Coastguard Worker 		ext2fs_free_mem(&channel->name);
281*6a54128fSAndroid Build Coastguard Worker 	ext2fs_free_mem(&channel);
282*6a54128fSAndroid Build Coastguard Worker 	return retval;
283*6a54128fSAndroid Build Coastguard Worker }
284*6a54128fSAndroid Build Coastguard Worker 
test_set_blksize(io_channel channel,int blksize)285*6a54128fSAndroid Build Coastguard Worker static errcode_t test_set_blksize(io_channel channel, int blksize)
286*6a54128fSAndroid Build Coastguard Worker {
287*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
288*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
289*6a54128fSAndroid Build Coastguard Worker 
290*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
291*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
292*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
293*6a54128fSAndroid Build Coastguard Worker 
294*6a54128fSAndroid Build Coastguard Worker 	if (data->real) {
295*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_set_blksize(data->real, blksize);
296*6a54128fSAndroid Build Coastguard Worker 		channel->align = data->real->align;
297*6a54128fSAndroid Build Coastguard Worker 	}
298*6a54128fSAndroid Build Coastguard Worker 	if (data->set_blksize)
299*6a54128fSAndroid Build Coastguard Worker 		data->set_blksize(blksize, retval);
300*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_SET_BLKSIZE)
301*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
302*6a54128fSAndroid Build Coastguard Worker 			"Test_io: set_blksize(%d) returned %s\n",
303*6a54128fSAndroid Build Coastguard Worker 			blksize, retval ? error_message(retval) : "OK");
304*6a54128fSAndroid Build Coastguard Worker 	channel->block_size = blksize;
305*6a54128fSAndroid Build Coastguard Worker 	return retval;
306*6a54128fSAndroid Build Coastguard Worker }
307*6a54128fSAndroid Build Coastguard Worker 
308*6a54128fSAndroid Build Coastguard Worker 
test_read_blk(io_channel channel,unsigned long block,int count,void * buf)309*6a54128fSAndroid Build Coastguard Worker static errcode_t test_read_blk(io_channel channel, unsigned long block,
310*6a54128fSAndroid Build Coastguard Worker 			       int count, void *buf)
311*6a54128fSAndroid Build Coastguard Worker {
312*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
313*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
314*6a54128fSAndroid Build Coastguard Worker 
315*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
316*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
317*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
318*6a54128fSAndroid Build Coastguard Worker 
319*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
320*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_read_blk(data->real, block, count, buf);
321*6a54128fSAndroid Build Coastguard Worker 	if (data->read_blk)
322*6a54128fSAndroid Build Coastguard Worker 		data->read_blk(block, count, retval);
323*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_READ)
324*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
325*6a54128fSAndroid Build Coastguard Worker 			"Test_io: read_blk(%lu, %d) returned %s\n",
326*6a54128fSAndroid Build Coastguard Worker 			block, count, retval ? error_message(retval) : "OK");
327*6a54128fSAndroid Build Coastguard Worker 	if (data->block && data->block == block) {
328*6a54128fSAndroid Build Coastguard Worker 		if (data->flags & TEST_FLAG_DUMP)
329*6a54128fSAndroid Build Coastguard Worker 			test_dump_block(channel, data, block, buf);
330*6a54128fSAndroid Build Coastguard Worker 		if (--data->read_abort_count == 0)
331*6a54128fSAndroid Build Coastguard Worker 			test_abort(channel, block);
332*6a54128fSAndroid Build Coastguard Worker 	}
333*6a54128fSAndroid Build Coastguard Worker 	return retval;
334*6a54128fSAndroid Build Coastguard Worker }
335*6a54128fSAndroid Build Coastguard Worker 
test_write_blk(io_channel channel,unsigned long block,int count,const void * buf)336*6a54128fSAndroid Build Coastguard Worker static errcode_t test_write_blk(io_channel channel, unsigned long block,
337*6a54128fSAndroid Build Coastguard Worker 			       int count, const void *buf)
338*6a54128fSAndroid Build Coastguard Worker {
339*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
340*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
341*6a54128fSAndroid Build Coastguard Worker 
342*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
343*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
344*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
345*6a54128fSAndroid Build Coastguard Worker 
346*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
347*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_write_blk(data->real, block, count, buf);
348*6a54128fSAndroid Build Coastguard Worker 	if (data->write_blk)
349*6a54128fSAndroid Build Coastguard Worker 		data->write_blk(block, count, retval);
350*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_WRITE)
351*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
352*6a54128fSAndroid Build Coastguard Worker 			"Test_io: write_blk(%lu, %d) returned %s\n",
353*6a54128fSAndroid Build Coastguard Worker 			block, count, retval ? error_message(retval) : "OK");
354*6a54128fSAndroid Build Coastguard Worker 	if (data->block && data->block == block) {
355*6a54128fSAndroid Build Coastguard Worker 		if (data->flags & TEST_FLAG_DUMP)
356*6a54128fSAndroid Build Coastguard Worker 			test_dump_block(channel, data, block, buf);
357*6a54128fSAndroid Build Coastguard Worker 		if (--data->write_abort_count == 0)
358*6a54128fSAndroid Build Coastguard Worker 			test_abort(channel, block);
359*6a54128fSAndroid Build Coastguard Worker 	}
360*6a54128fSAndroid Build Coastguard Worker 	return retval;
361*6a54128fSAndroid Build Coastguard Worker }
362*6a54128fSAndroid Build Coastguard Worker 
test_read_blk64(io_channel channel,unsigned long long block,int count,void * buf)363*6a54128fSAndroid Build Coastguard Worker static errcode_t test_read_blk64(io_channel channel, unsigned long long block,
364*6a54128fSAndroid Build Coastguard Worker 			       int count, void *buf)
365*6a54128fSAndroid Build Coastguard Worker {
366*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
367*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
368*6a54128fSAndroid Build Coastguard Worker 
369*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
370*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
371*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
372*6a54128fSAndroid Build Coastguard Worker 
373*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
374*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_read_blk64(data->real, block, count, buf);
375*6a54128fSAndroid Build Coastguard Worker 	if (data->read_blk64)
376*6a54128fSAndroid Build Coastguard Worker 		data->read_blk64(block, count, retval);
377*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_READ)
378*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
379*6a54128fSAndroid Build Coastguard Worker 			"Test_io: read_blk64(%llu, %d) returned %s\n",
380*6a54128fSAndroid Build Coastguard Worker 			block, count, retval ? error_message(retval) : "OK");
381*6a54128fSAndroid Build Coastguard Worker 	if (data->block && data->block == block) {
382*6a54128fSAndroid Build Coastguard Worker 		if (data->flags & TEST_FLAG_DUMP)
383*6a54128fSAndroid Build Coastguard Worker 			test_dump_block(channel, data, block, buf);
384*6a54128fSAndroid Build Coastguard Worker 		if (--data->read_abort_count == 0)
385*6a54128fSAndroid Build Coastguard Worker 			test_abort(channel, block);
386*6a54128fSAndroid Build Coastguard Worker 	}
387*6a54128fSAndroid Build Coastguard Worker 	return retval;
388*6a54128fSAndroid Build Coastguard Worker }
389*6a54128fSAndroid Build Coastguard Worker 
test_write_blk64(io_channel channel,unsigned long long block,int count,const void * buf)390*6a54128fSAndroid Build Coastguard Worker static errcode_t test_write_blk64(io_channel channel, unsigned long long block,
391*6a54128fSAndroid Build Coastguard Worker 			       int count, const void *buf)
392*6a54128fSAndroid Build Coastguard Worker {
393*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
394*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
395*6a54128fSAndroid Build Coastguard Worker 
396*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
397*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
398*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
399*6a54128fSAndroid Build Coastguard Worker 
400*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
401*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_write_blk64(data->real, block, count, buf);
402*6a54128fSAndroid Build Coastguard Worker 	if (data->write_blk64)
403*6a54128fSAndroid Build Coastguard Worker 		data->write_blk64(block, count, retval);
404*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_WRITE)
405*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
406*6a54128fSAndroid Build Coastguard Worker 			"Test_io: write_blk64(%llu, %d) returned %s\n",
407*6a54128fSAndroid Build Coastguard Worker 			block, count, retval ? error_message(retval) : "OK");
408*6a54128fSAndroid Build Coastguard Worker 	if (data->block && data->block == block) {
409*6a54128fSAndroid Build Coastguard Worker 		if (data->flags & TEST_FLAG_DUMP)
410*6a54128fSAndroid Build Coastguard Worker 			test_dump_block(channel, data, block, buf);
411*6a54128fSAndroid Build Coastguard Worker 		if (--data->write_abort_count == 0)
412*6a54128fSAndroid Build Coastguard Worker 			test_abort(channel, block);
413*6a54128fSAndroid Build Coastguard Worker 	}
414*6a54128fSAndroid Build Coastguard Worker 	return retval;
415*6a54128fSAndroid Build Coastguard Worker }
416*6a54128fSAndroid Build Coastguard Worker 
test_write_byte(io_channel channel,unsigned long offset,int count,const void * buf)417*6a54128fSAndroid Build Coastguard Worker static errcode_t test_write_byte(io_channel channel, unsigned long offset,
418*6a54128fSAndroid Build Coastguard Worker 			       int count, const void *buf)
419*6a54128fSAndroid Build Coastguard Worker {
420*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
421*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
422*6a54128fSAndroid Build Coastguard Worker 
423*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
424*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
425*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
426*6a54128fSAndroid Build Coastguard Worker 
427*6a54128fSAndroid Build Coastguard Worker 	if (data->real && data->real->manager->write_byte)
428*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_write_byte(data->real, offset, count, buf);
429*6a54128fSAndroid Build Coastguard Worker 	if (data->write_byte)
430*6a54128fSAndroid Build Coastguard Worker 		data->write_byte(offset, count, retval);
431*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_WRITE)
432*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
433*6a54128fSAndroid Build Coastguard Worker 			"Test_io: write_byte(%lu, %d) returned %s\n",
434*6a54128fSAndroid Build Coastguard Worker 			offset, count, retval ? error_message(retval) : "OK");
435*6a54128fSAndroid Build Coastguard Worker 	return retval;
436*6a54128fSAndroid Build Coastguard Worker }
437*6a54128fSAndroid Build Coastguard Worker 
test_set_option(io_channel channel,const char * option,const char * arg)438*6a54128fSAndroid Build Coastguard Worker static errcode_t test_set_option(io_channel channel, const char *option,
439*6a54128fSAndroid Build Coastguard Worker 				 const char *arg)
440*6a54128fSAndroid Build Coastguard Worker {
441*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
442*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
443*6a54128fSAndroid Build Coastguard Worker 
444*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
445*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
446*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
447*6a54128fSAndroid Build Coastguard Worker 
448*6a54128fSAndroid Build Coastguard Worker 
449*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_SET_OPTION)
450*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile, "Test_io: set_option(%s, %s) ",
451*6a54128fSAndroid Build Coastguard Worker 			option, arg);
452*6a54128fSAndroid Build Coastguard Worker 	if (data->real && data->real->manager->set_option) {
453*6a54128fSAndroid Build Coastguard Worker 		retval = (data->real->manager->set_option)(data->real,
454*6a54128fSAndroid Build Coastguard Worker 							   option, arg);
455*6a54128fSAndroid Build Coastguard Worker 		if (data->flags & TEST_FLAG_SET_OPTION)
456*6a54128fSAndroid Build Coastguard Worker 			fprintf(data->outfile, "returned %s\n",
457*6a54128fSAndroid Build Coastguard Worker 				retval ? error_message(retval) : "OK");
458*6a54128fSAndroid Build Coastguard Worker 	} else {
459*6a54128fSAndroid Build Coastguard Worker 		if (data->flags & TEST_FLAG_SET_OPTION)
460*6a54128fSAndroid Build Coastguard Worker 			fprintf(data->outfile, "not implemented\n");
461*6a54128fSAndroid Build Coastguard Worker 	}
462*6a54128fSAndroid Build Coastguard Worker 	return retval;
463*6a54128fSAndroid Build Coastguard Worker }
464*6a54128fSAndroid Build Coastguard Worker 
test_get_stats(io_channel channel,io_stats * stats)465*6a54128fSAndroid Build Coastguard Worker static errcode_t test_get_stats(io_channel channel, io_stats *stats)
466*6a54128fSAndroid Build Coastguard Worker {
467*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
468*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
469*6a54128fSAndroid Build Coastguard Worker 
470*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
471*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
472*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
473*6a54128fSAndroid Build Coastguard Worker 
474*6a54128fSAndroid Build Coastguard Worker 	if (data->real && data->real->manager->get_stats) {
475*6a54128fSAndroid Build Coastguard Worker 		retval = (data->real->manager->get_stats)(data->real, stats);
476*6a54128fSAndroid Build Coastguard Worker 	}
477*6a54128fSAndroid Build Coastguard Worker 	return retval;
478*6a54128fSAndroid Build Coastguard Worker }
479*6a54128fSAndroid Build Coastguard Worker 
test_discard(io_channel channel,unsigned long long block,unsigned long long count)480*6a54128fSAndroid Build Coastguard Worker static errcode_t test_discard(io_channel channel, unsigned long long block,
481*6a54128fSAndroid Build Coastguard Worker 			      unsigned long long count)
482*6a54128fSAndroid Build Coastguard Worker {
483*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
484*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
485*6a54128fSAndroid Build Coastguard Worker 
486*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
487*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
488*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
489*6a54128fSAndroid Build Coastguard Worker 
490*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
491*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_discard(data->real, block, count);
492*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_DISCARD)
493*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
494*6a54128fSAndroid Build Coastguard Worker 			"Test_io: discard(%llu, %llu) returned %s\n",
495*6a54128fSAndroid Build Coastguard Worker 			block, count, retval ? error_message(retval) : "OK");
496*6a54128fSAndroid Build Coastguard Worker 	return retval;
497*6a54128fSAndroid Build Coastguard Worker }
498*6a54128fSAndroid Build Coastguard Worker 
test_cache_readahead(io_channel channel,unsigned long long block,unsigned long long count)499*6a54128fSAndroid Build Coastguard Worker static errcode_t test_cache_readahead(io_channel channel,
500*6a54128fSAndroid Build Coastguard Worker 				      unsigned long long block,
501*6a54128fSAndroid Build Coastguard Worker 				      unsigned long long count)
502*6a54128fSAndroid Build Coastguard Worker {
503*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
504*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
505*6a54128fSAndroid Build Coastguard Worker 
506*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
507*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
508*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
509*6a54128fSAndroid Build Coastguard Worker 
510*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
511*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_cache_readahead(data->real, block, count);
512*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_READAHEAD)
513*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
514*6a54128fSAndroid Build Coastguard Worker 			"Test_io: readahead(%llu, %llu) returned %s\n",
515*6a54128fSAndroid Build Coastguard Worker 			block, count, retval ? error_message(retval) : "OK");
516*6a54128fSAndroid Build Coastguard Worker 	return retval;
517*6a54128fSAndroid Build Coastguard Worker }
518*6a54128fSAndroid Build Coastguard Worker 
test_zeroout(io_channel channel,unsigned long long block,unsigned long long count)519*6a54128fSAndroid Build Coastguard Worker static errcode_t test_zeroout(io_channel channel, unsigned long long block,
520*6a54128fSAndroid Build Coastguard Worker 			      unsigned long long count)
521*6a54128fSAndroid Build Coastguard Worker {
522*6a54128fSAndroid Build Coastguard Worker 	struct test_private_data *data;
523*6a54128fSAndroid Build Coastguard Worker 	errcode_t	retval = 0;
524*6a54128fSAndroid Build Coastguard Worker 
525*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
526*6a54128fSAndroid Build Coastguard Worker 	data = (struct test_private_data *) channel->private_data;
527*6a54128fSAndroid Build Coastguard Worker 	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
528*6a54128fSAndroid Build Coastguard Worker 
529*6a54128fSAndroid Build Coastguard Worker 	if (data->real)
530*6a54128fSAndroid Build Coastguard Worker 		retval = io_channel_zeroout(data->real, block, count);
531*6a54128fSAndroid Build Coastguard Worker 	if (data->flags & TEST_FLAG_ZEROOUT)
532*6a54128fSAndroid Build Coastguard Worker 		fprintf(data->outfile,
533*6a54128fSAndroid Build Coastguard Worker 			"Test_io: zeroout(%llu, %llu) returned %s\n",
534*6a54128fSAndroid Build Coastguard Worker 			block, count, retval ? error_message(retval) : "OK");
535*6a54128fSAndroid Build Coastguard Worker 	return retval;
536*6a54128fSAndroid Build Coastguard Worker }
537*6a54128fSAndroid Build Coastguard Worker 
538*6a54128fSAndroid Build Coastguard Worker static struct struct_io_manager struct_test_manager = {
539*6a54128fSAndroid Build Coastguard Worker 	.magic		= EXT2_ET_MAGIC_IO_MANAGER,
540*6a54128fSAndroid Build Coastguard Worker 	.name		= "Test I/O Manager",
541*6a54128fSAndroid Build Coastguard Worker 	.open		= test_open,
542*6a54128fSAndroid Build Coastguard Worker 	.close		= test_close,
543*6a54128fSAndroid Build Coastguard Worker 	.set_blksize	= test_set_blksize,
544*6a54128fSAndroid Build Coastguard Worker 	.read_blk	= test_read_blk,
545*6a54128fSAndroid Build Coastguard Worker 	.write_blk	= test_write_blk,
546*6a54128fSAndroid Build Coastguard Worker 	.flush		= test_flush,
547*6a54128fSAndroid Build Coastguard Worker 	.write_byte	= test_write_byte,
548*6a54128fSAndroid Build Coastguard Worker 	.set_option	= test_set_option,
549*6a54128fSAndroid Build Coastguard Worker 	.get_stats	= test_get_stats,
550*6a54128fSAndroid Build Coastguard Worker 	.read_blk64	= test_read_blk64,
551*6a54128fSAndroid Build Coastguard Worker 	.write_blk64	= test_write_blk64,
552*6a54128fSAndroid Build Coastguard Worker 	.discard	= test_discard,
553*6a54128fSAndroid Build Coastguard Worker 	.cache_readahead	= test_cache_readahead,
554*6a54128fSAndroid Build Coastguard Worker 	.zeroout	= test_zeroout,
555*6a54128fSAndroid Build Coastguard Worker };
556*6a54128fSAndroid Build Coastguard Worker 
557*6a54128fSAndroid Build Coastguard Worker io_manager test_io_manager = &struct_test_manager;
558