Whamcloud - gitweb
Only use the test_io manager if the right environment variables are set
authorTheodore Ts'o <tytso@mit.edu>
Mon, 1 Sep 2008 15:17:29 +0000 (11:17 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 1 Sep 2008 15:36:53 +0000 (11:36 -0400)
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" <tytso@mit.edu>
e2fsck/unix.c
misc/e2image.c
misc/e2initrd_helper.c
misc/mke2fs.c
misc/tune2fs.c
resize/main.c

index 07549b9..94938a4 100644 (file)
@@ -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;
index 9659d49..dd2a1ca 100644 (file)
@@ -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);
index df09aa1..ca01908 100644 (file)
@@ -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);
index 1dd7e8a..3d830fc 100644 (file)
@@ -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);
index 5d4cfc0..a130c14 100644 (file)
@@ -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,
index aeac24b..d6ecd8b 100644 (file)
@@ -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))