summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--e2fsck/unix.c9
-rw-r--r--misc/e2image.c11
-rw-r--r--misc/e2initrd_helper.c11
-rw-r--r--misc/mke2fs.c18
-rw-r--r--misc/tune2fs.c29
-rw-r--r--resize/main.c7
6 files changed, 52 insertions, 33 deletions
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 07549b92..94938a4d 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -951,11 +951,12 @@ int main (int argc, char *argv[])
ctx->superblock = ctx->use_superblock;
restart:
#ifdef CONFIG_TESTIO_DEBUG
- io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
-#else
- io_ptr = unix_io_manager;
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+ } else
#endif
+ io_ptr = unix_io_manager;
flags = EXT2_FLAG_NOFREE_ON_ERROR;
if ((ctx->options & E2F_OPT_READONLY) == 0)
flags |= EXT2_FLAG_RW;
diff --git a/misc/e2image.c b/misc/e2image.c
index 9659d496..dd2a1caa 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -23,7 +23,9 @@ extern int optind;
#endif
#include <pwd.h>
#include <stdio.h>
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
+#endif
#include <string.h>
#include <time.h>
#include <unistd.h>
@@ -561,11 +563,12 @@ static void install_image(char *device, char *image_fn, int raw_flag)
}
#ifdef CONFIG_TESTIO_DEBUG
- io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
-#else
- io_ptr = unix_io_manager;
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+ } else
#endif
+ io_ptr = unix_io_manager;
retval = ext2fs_open (image_fn, open_flag, 0, 0,
io_ptr, &fs);
diff --git a/misc/e2initrd_helper.c b/misc/e2initrd_helper.c
index df09aa1d..ca019084 100644
--- a/misc/e2initrd_helper.c
+++ b/misc/e2initrd_helper.c
@@ -11,7 +11,9 @@
#include <stdio.h>
#include <unistd.h>
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
+#endif
#include <ctype.h>
#include <string.h>
#include <time.h>
@@ -370,11 +372,12 @@ int main (int argc, char ** argv)
PRS(argc, argv);
#ifdef CONFIG_TESTIO_DEBUG
- io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
-#else
- io_ptr = unix_io_manager;
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+ } else
#endif
+ io_ptr = unix_io_manager;
retval = ext2fs_open (device_name, open_flag, 0, 0, io_ptr, &fs);
if (retval)
exit(1);
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 1dd7e8aa..3d830fc5 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1359,11 +1359,12 @@ static void PRS(int argc, char *argv[])
io_manager io_ptr;
#ifdef CONFIG_TESTIO_DEBUG
- io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
-#else
- io_ptr = unix_io_manager;
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+ } else
#endif
+ io_ptr = unix_io_manager;
retval = ext2fs_open(journal_device,
EXT2_FLAG_JOURNAL_DEV_OK, 0,
0, io_ptr, &jfs);
@@ -1839,11 +1840,12 @@ int main (int argc, char *argv[])
PRS(argc, argv);
#ifdef CONFIG_TESTIO_DEBUG
- io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
-#else
- io_ptr = unix_io_manager;
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+ } else
#endif
+ io_ptr = unix_io_manager;
if (should_do_undo(device_name)) {
retval = mke2fs_setup_tdb(device_name, &io_ptr);
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 5d4cfc04..a130c14b 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -37,7 +37,9 @@ extern int optind;
#endif
#include <pwd.h>
#include <stdio.h>
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
+#endif
#include <string.h>
#include <time.h>
#include <unistd.h>
@@ -172,11 +174,12 @@ static void remove_journal_device(ext2_filsys fs)
}
#ifdef CONFIG_TESTIO_DEBUG
- io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
-#else
- io_ptr = unix_io_manager;
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+ } else
#endif
+ io_ptr = unix_io_manager;
retval = ext2fs_open(journal_path, EXT2_FLAG_RW|
EXT2_FLAG_JOURNAL_DEV_OK, 0,
fs->blocksize, io_ptr, &jfs);
@@ -473,11 +476,12 @@ static void add_journal(ext2_filsys fs)
check_plausibility(journal_device);
check_mount(journal_device, 0, _("journal"));
#ifdef CONFIG_TESTIO_DEBUG
- io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
-#else
- io_ptr = unix_io_manager;
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+ } else
#endif
+ io_ptr = unix_io_manager;
retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
EXT2_FLAG_JOURNAL_DEV_OK, 0,
fs->blocksize, io_ptr, &jfs);
@@ -1436,11 +1440,12 @@ int main (int argc, char ** argv)
parse_tune2fs_options(argc, argv);
#ifdef CONFIG_TESTIO_DEBUG
- io_ptr = test_io_manager;
- test_io_backing_manager = unix_io_manager;
-#else
- io_ptr = unix_io_manager;
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_DEBUG")) {
+ io_ptr = test_io_manager;
+ test_io_backing_manager = unix_io_manager;
+ } else
#endif
+ io_ptr = unix_io_manager;
retry_open:
retval = ext2fs_open2(device_name, io_options, open_flag,
diff --git a/resize/main.c b/resize/main.c
index aeac24bc..d6ecd8b3 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -22,6 +22,9 @@ extern char *optarg;
extern int optind;
#endif
#include <unistd.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -290,10 +293,12 @@ int main (int argc, char ** argv)
fd = -1;
}
- if (flags & RESIZE_DEBUG_IO) {
+#ifdef CONFIG_TESTIO_DEBUG
+ if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
io_ptr = test_io_manager;
test_io_backing_manager = unix_io_manager;
} else
+#endif
io_ptr = unix_io_manager;
if (!(mount_flags & EXT2_MF_MOUNTED))