From: Theodore Ts'o Date: Mon, 1 Sep 2008 15:17:29 +0000 (-0400) Subject: Only use the test_io manager if the right environment variables are set X-Git-Tag: v1.41.1~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f38cf3cb34addaa53d1f855d7607b151082a4229;p=thirdparty%2Fe2fsprogs.git Only use the test_io manager if the right environment variables are set In order to make it possible for the test_io manager to be compiled in by default, make all of the programs that might try to use it to only do so if the environment variables TEST_IO_FLAGS and TEST_IO_DEBUG are set. Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 07549b92a..94938a4d9 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 9659d4962..dd2a1caab 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -23,7 +23,9 @@ extern int optind; #endif #include #include +#ifdef HAVE_STDLIB_H #include +#endif #include #include #include @@ -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 df09aa1dd..ca0190843 100644 --- a/misc/e2initrd_helper.c +++ b/misc/e2initrd_helper.c @@ -11,7 +11,9 @@ #include #include +#ifdef HAVE_STDLIB_H #include +#endif #include #include #include @@ -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 1dd7e8aa4..3d830fc50 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 5d4cfc040..a130c14b6 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -37,7 +37,9 @@ extern int optind; #endif #include #include +#ifdef HAVE_STDLIB_H #include +#endif #include #include #include @@ -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 aeac24bc2..d6ecd8b3a 100644 --- a/resize/main.c +++ b/resize/main.c @@ -22,6 +22,9 @@ extern char *optarg; extern int optind; #endif #include +#ifdef HAVE_STDLIB_H +#include +#endif #include #include #include @@ -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))