test_io.c revision 583d1f83284ddfe126d97e6db0020739a1609b5a
119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * test_io.c --- This is the Test I/O interface. 319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * 419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * Copyright (C) 1996 Theodore Ts'o. 519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * 619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * %Begin-Header% 719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * This file may be redistributed under the terms of the GNU Public 819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * License. 919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * %End-Header% 1019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 1119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 1219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <stdio.h> 1319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <string.h> 144cbe8af4b0d0c72fb28bb500c1bd8a46b00fdde3Theodore Ts'o#if HAVE_UNISTD_H 1519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <unistd.h> 164cbe8af4b0d0c72fb28bb500c1bd8a46b00fdde3Theodore Ts'o#endif 1719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <fcntl.h> 1819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <time.h> 191d2ff46ae7533ffd038534b189f272d2a4122e4eTheodore Ts'o#if HAVE_SYS_STAT_H 2019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <sys/stat.h> 211d2ff46ae7533ffd038534b189f272d2a4122e4eTheodore Ts'o#endif 221d2ff46ae7533ffd038534b189f272d2a4122e4eTheodore Ts'o#if HAVE_SYS_TYPES_H 2319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#include <sys/types.h> 241d2ff46ae7533ffd038534b189f272d2a4122e4eTheodore Ts'o#endif 25762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#ifdef HAVE_SYS_PRCTL_H 26762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#include <sys/prctl.h> 27762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#else 28762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#define PR_GET_DUMPABLE 3 29762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#endif 30762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#if (!defined(HAVE_PRCTL) && defined(linux)) 31762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#include <sys/syscall.h> 32762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#endif 3319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 34b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o#include "ext2_fs.h" 357b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o#include "ext2fs.h" 3619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 3719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 3819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * For checking structure magic numbers... 3919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 4019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 4119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_CHECK_MAGIC(struct, code) \ 4219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if ((struct)->magic != (code)) return (code) 4319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 4419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostruct test_private_data { 4519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int magic; 4619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o io_channel real; 472a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o int flags; 482a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o FILE *outfile; 492a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o unsigned long block; 50a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o int read_abort_count, write_abort_count; 5119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o void (*read_blk)(unsigned long block, int count, errcode_t err); 5219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o void (*write_blk)(unsigned long block, int count, errcode_t err); 5319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o void (*set_blksize)(int blksize, errcode_t err); 54c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o void (*write_byte)(unsigned long block, int count, errcode_t err); 5519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o}; 5619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 5719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_open(const char *name, int flags, io_channel *channel); 5819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_close(io_channel channel); 5919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_set_blksize(io_channel channel, int blksize); 6019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_read_blk(io_channel channel, unsigned long block, 6119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int count, void *data); 6219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_write_blk(io_channel channel, unsigned long block, 6319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int count, const void *data); 6419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_flush(io_channel channel); 6531dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'ostatic errcode_t test_write_byte(io_channel channel, unsigned long offset, 6631dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o int count, const void *buf); 672e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'ostatic errcode_t test_set_option(io_channel channel, const char *option, 682e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o const char *arg); 6919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 7019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic struct struct_io_manager struct_test_manager = { 7119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_ET_MAGIC_IO_MANAGER, 7219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o "Test I/O Manager", 7319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o test_open, 7419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o test_close, 7519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o test_set_blksize, 7619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o test_read_blk, 7719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o test_write_blk, 7831dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o test_flush, 792e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o test_write_byte, 802e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o test_set_option 8119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o}; 8219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 8319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oio_manager test_io_manager = &struct_test_manager; 8419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 8519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 8619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * These global variable can be set by the test program as 8719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * necessary *before* calling test_open 8819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 8919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oio_manager test_io_backing_manager = 0; 9019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ovoid (*test_io_cb_read_blk) 9119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o (unsigned long block, int count, errcode_t err) = 0; 9219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ovoid (*test_io_cb_write_blk) 9319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o (unsigned long block, int count, errcode_t err) = 0; 9419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ovoid (*test_io_cb_set_blksize) 9519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o (int blksize, errcode_t err) = 0; 96c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'ovoid (*test_io_cb_write_byte) 97c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o (unsigned long block, int count, errcode_t err) = 0; 9819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 992a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o/* 1002a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o * Test flags 1012a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o */ 1022a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o#define TEST_FLAG_READ 0x01 1032a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o#define TEST_FLAG_WRITE 0x02 1042a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o#define TEST_FLAG_SET_BLKSIZE 0x04 1052a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o#define TEST_FLAG_FLUSH 0x08 106a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o#define TEST_FLAG_DUMP 0x10 1072e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o#define TEST_FLAG_SET_OPTION 0x20 1082a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o 1092a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'ostatic void test_dump_block(io_channel channel, 1102a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o struct test_private_data *data, 11148e6e81362f264aee4f3945c14928efaf71a06c9Theodore Ts'o unsigned long block, const void *buf) 1122a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o{ 1132a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o const unsigned char *cp; 1142a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o FILE *f = data->outfile; 1152a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o int i; 1162a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o unsigned long cksum = 0; 1172a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o 1182a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o for (i=0, cp = buf; i < channel->block_size; i++, cp++) { 1192a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o cksum += *cp; 1202a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o } 12148e6e81362f264aee4f3945c14928efaf71a06c9Theodore Ts'o fprintf(f, "Contents of block %lu, checksum %08lu: \n", block, cksum); 1222a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o for (i=0, cp = buf; i < channel->block_size; i++, cp++) { 1232a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o if ((i % 16) == 0) 1242a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o fprintf(f, "%04x: ", i); 1252a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o fprintf(f, "%02x%c", *cp, ((i % 16) == 15) ? '\n' : ' '); 1262a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o } 1272a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o} 1282a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o 129a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'ostatic void test_abort(io_channel channel, unsigned long block) 130a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o{ 131a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o struct test_private_data *data; 132a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o FILE *f; 133a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o 134a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o data = (struct test_private_data *) channel->private_data; 135a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o f = data->outfile; 136a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o test_flush(channel); 137a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o 138a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o fprintf(f, "Aborting due to I/O to block %lu\n", block); 139a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o fflush(f); 140a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o abort(); 141a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o} 142a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o 143762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'ostatic char *safe_getenv(const char *arg) 144762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o{ 14509f3eba28a4d3c050a548eab571b73352b131021Theodore Ts'o if ((getuid() != geteuid()) || (getgid() != getegid())) 146762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o return NULL; 147762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#if HAVE_PRCTL 148583d1f83284ddfe126d97e6db0020739a1609b5aTheodore Ts'o if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0) 149762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o return NULL; 150762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#else 151762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#if (defined(linux) && defined(SYS_prctl)) 152583d1f83284ddfe126d97e6db0020739a1609b5aTheodore Ts'o if (syscall(SYS_prctl, PR_GET_DUMPABLE, 0, 0, 0, 0) == 0) 153762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o return NULL; 154762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#endif 155762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#endif 156762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o 157762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#ifdef HAVE___SECURE_GETENV 1583af0a45628c0984d298a885f8381498cdf866221Theodore Ts'o return __secure_getenv(arg); 159762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#else 1603af0a45628c0984d298a885f8381498cdf866221Theodore Ts'o return getenv(arg); 161762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o#endif 162762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o} 163762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o 16419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_open(const char *name, int flags, io_channel *channel) 16519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o{ 16619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o io_channel io = NULL; 16719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o struct test_private_data *data = NULL; 16819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o errcode_t retval; 169a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o char *value; 17019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 17119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (name == 0) 17219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o return EXT2_ET_BAD_DEVICE_NAME; 173c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io); 1747b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o if (retval) 1757b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o return retval; 17619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o memset(io, 0, sizeof(struct struct_io_channel)); 17719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o io->magic = EXT2_ET_MAGIC_IO_CHANNEL; 178c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o retval = ext2fs_get_mem(sizeof(struct test_private_data), &data); 1797b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o if (retval) { 1801f0b6c1f895d189fea6999d0c07a7fee936a4baaTheodore Ts'o retval = EXT2_ET_NO_MEMORY; 18119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o goto cleanup; 18219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o } 18319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o io->manager = test_io_manager; 184c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o retval = ext2fs_get_mem(strlen(name)+1, &io->name); 1857b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o if (retval) 18619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o goto cleanup; 1877b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o 18819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o strcpy(io->name, name); 18919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o io->private_data = data; 19019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o io->block_size = 1024; 19119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o io->read_error = 0; 19219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o io->write_error = 0; 193a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o io->refcount = 1; 19419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 19519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o memset(data, 0, sizeof(struct test_private_data)); 19619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data->magic = EXT2_ET_MAGIC_TEST_IO_CHANNEL; 19719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (test_io_backing_manager) { 19819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o retval = test_io_backing_manager->open(name, flags, 19919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o &data->real); 20019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (retval) 20119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o goto cleanup; 20219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o } else 20319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data->real = 0; 20419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data->read_blk = test_io_cb_read_blk; 20519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data->write_blk = test_io_cb_write_blk; 20619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data->set_blksize = test_io_cb_set_blksize; 207c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o data->write_byte = test_io_cb_write_byte; 2082a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o 2092a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o data->outfile = NULL; 210762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o if ((value = safe_getenv("TEST_IO_LOGFILE")) != NULL) 211a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o data->outfile = fopen(value, "w"); 2122a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o if (!data->outfile) 2132a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o data->outfile = stderr; 2142a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o 2152a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o data->flags = 0; 216762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o if ((value = safe_getenv("TEST_IO_FLAGS")) != NULL) 217a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o data->flags = strtoul(value, NULL, 0); 2182a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o 2192a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o data->block = 0; 220762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o if ((value = safe_getenv("TEST_IO_BLOCK")) != NULL) 221a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o data->block = strtoul(value, NULL, 0); 222a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o 223a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o data->read_abort_count = 0; 224762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o if ((value = safe_getenv("TEST_IO_READ_ABORT")) != NULL) 225a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o data->read_abort_count = strtoul(value, NULL, 0); 226a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o 227a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o data->write_abort_count = 0; 228762c7c65103615d976beeb4c8e2d1d9a79c87d86Theodore Ts'o if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL) 229a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o data->write_abort_count = strtoul(value, NULL, 0); 23019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 23119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o *channel = io; 23219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o return 0; 23319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 23419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ocleanup: 23519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (io) 236c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o ext2fs_free_mem(&io); 23719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (data) 238c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o ext2fs_free_mem(&data); 23919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o return retval; 24019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o} 24119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 24219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_close(io_channel channel) 24319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o{ 24419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o struct test_private_data *data; 24519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o errcode_t retval = 0; 24619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 24719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); 24819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data = (struct test_private_data *) channel->private_data; 24919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); 25019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 251a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o if (--channel->refcount > 0) 252a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o return 0; 253a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o 25419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (data->real) 25519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o retval = io_channel_close(data->real); 2562a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o 257c62dbdb9ec3244c8b324d8dbeb9ee14baac361f5Theodore Ts'o if (data->outfile && data->outfile != stderr) 2582a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o fclose(data->outfile); 25919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 260c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o ext2fs_free_mem(&channel->private_data); 26119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (channel->name) 262c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o ext2fs_free_mem(&channel->name); 263c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o ext2fs_free_mem(&channel); 26419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o return retval; 26519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o} 26619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 26719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_set_blksize(io_channel channel, int blksize) 26819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o{ 26919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o struct test_private_data *data; 27019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o errcode_t retval = 0; 27119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 27219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); 27319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data = (struct test_private_data *) channel->private_data; 27419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); 27519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 27619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (data->real) 27719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o retval = io_channel_set_blksize(data->real, blksize); 27819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (data->set_blksize) 27919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data->set_blksize(blksize, retval); 2802a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o if (data->flags & TEST_FLAG_SET_BLKSIZE) 2812a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o fprintf(data->outfile, 2822a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o "Test_io: set_blksize(%d) returned %s\n", 2832a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o blksize, retval ? error_message(retval) : "OK"); 2842a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o channel->block_size = blksize; 28519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o return retval; 28619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o} 28719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 28819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 28919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_read_blk(io_channel channel, unsigned long block, 29019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int count, void *buf) 29119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o{ 29219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o struct test_private_data *data; 29319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o errcode_t retval = 0; 29419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 29519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); 29619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data = (struct test_private_data *) channel->private_data; 29719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); 29819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 29919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (data->real) 30019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o retval = io_channel_read_blk(data->real, block, count, buf); 30119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (data->read_blk) 30219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data->read_blk(block, count, retval); 3032a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o if (data->flags & TEST_FLAG_READ) 3042a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o fprintf(data->outfile, 3052a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o "Test_io: read_blk(%lu, %d) returned %s\n", 3062a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o block, count, retval ? error_message(retval) : "OK"); 307a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o if (data->block && data->block == block) { 308a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o if (data->flags & TEST_FLAG_DUMP) 309a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o test_dump_block(channel, data, block, buf); 310a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o if (--data->read_abort_count == 0) 311a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o test_abort(channel, block); 312a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o } 31319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o return retval; 31419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o} 31519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 31619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_write_blk(io_channel channel, unsigned long block, 31719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int count, const void *buf) 31819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o{ 31919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o struct test_private_data *data; 32019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o errcode_t retval = 0; 32119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 32219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); 32319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data = (struct test_private_data *) channel->private_data; 32419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); 32519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 32619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (data->real) 32719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o retval = io_channel_write_blk(data->real, block, count, buf); 328f20d0d57f73f7eb7fc801b85921cff4a3d90e385Theodore Ts'o if (data->write_blk) 329f20d0d57f73f7eb7fc801b85921cff4a3d90e385Theodore Ts'o data->write_blk(block, count, retval); 3302a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o if (data->flags & TEST_FLAG_WRITE) 3312a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o fprintf(data->outfile, 3322a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o "Test_io: write_blk(%lu, %d) returned %s\n", 3332a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o block, count, retval ? error_message(retval) : "OK"); 334a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o if (data->block && data->block == block) { 335a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o if (data->flags & TEST_FLAG_DUMP) 336a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o test_dump_block(channel, data, block, buf); 337a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o if (--data->write_abort_count == 0) 338a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o test_abort(channel, block); 339a002e7e200308eb010f55f19b673a53775a7cccdTheodore Ts'o } 34019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o return retval; 34119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o} 34219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 343c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'ostatic errcode_t test_write_byte(io_channel channel, unsigned long offset, 344c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o int count, const void *buf) 345c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o{ 346c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o struct test_private_data *data; 347c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o errcode_t retval = 0; 348c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o 349c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); 350c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o data = (struct test_private_data *) channel->private_data; 351c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); 352c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o 353c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o if (data->real && data->real->manager->write_byte) 354c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o retval = io_channel_write_byte(data->real, offset, count, buf); 355c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o if (data->write_byte) 356c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o data->write_byte(offset, count, retval); 3572a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o if (data->flags & TEST_FLAG_WRITE) 3582a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o fprintf(data->outfile, 3592a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o "Test_io: write_byte(%lu, %d) returned %s\n", 3602a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o offset, count, retval ? error_message(retval) : "OK"); 361c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o return retval; 362c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o} 363c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o 36419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 36519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * Flush data buffers to disk. 36619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 36719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostatic errcode_t test_flush(io_channel channel) 36819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o{ 36919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o struct test_private_data *data; 3709abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o errcode_t retval = 0; 37119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 37219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); 37319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o data = (struct test_private_data *) channel->private_data; 37419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); 37519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 37619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o if (data->real) 3779abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o retval = io_channel_flush(data->real); 3789abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o 3792a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o if (data->flags & TEST_FLAG_FLUSH) 3802a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o fprintf(data->outfile, "Test_io: flush() returned %s\n", 3812a29f1354f793557fa1829c9e85e74586e2907dbTheodore Ts'o retval ? error_message(retval) : "OK"); 3829abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o 3839abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o return retval; 38419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o} 38519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 3862e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'ostatic errcode_t test_set_option(io_channel channel, const char *option, 3872e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o const char *arg) 3882e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o{ 3892e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o struct test_private_data *data; 3902e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o errcode_t retval = 0; 3912e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o 3922e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); 3932e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o data = (struct test_private_data *) channel->private_data; 3942e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); 3952e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o 3962e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o 3972e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o if (data->flags & TEST_FLAG_SET_OPTION) 3982e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o fprintf(data->outfile, "Test_io: set_option(%s, %s) ", 3992e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o option, arg); 4002e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o if (data->real && data->real->manager->set_option) { 4012e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o retval = (data->real->manager->set_option)(data->real, 4022e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o option, arg); 4032e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o if (data->flags & TEST_FLAG_SET_OPTION) 4042e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o fprintf(data->outfile, "returned %s\n", 4052e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o retval ? error_message(retval) : "OK"); 4062e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o } else { 4072e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o if (data->flags & TEST_FLAG_SET_OPTION) 4082e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o fprintf(data->outfile, "not implemented\n"); 4092e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o } 4102e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o return retval; 4112e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o} 412