]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: handle errors in remount_tested_fs
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 14 Apr 2011 10:32:06 +0000 (13:32 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 22 Apr 2011 11:29:51 +0000 (14:29 +0300)
Teach 'remount_tested_fs()' return error code when it fails
to mount the file-system.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/fs-tests/integrity/integck.c

index d138a7da9655bbe3a250ddbd3714a11e5f5c74c8..5b1adc14246bd7b11fede2af520ad41faa6ea9ec 100644 (file)
@@ -2076,7 +2076,7 @@ static void update_test_data(void)
  * Re-mount the test file-system. This function randomly select how to
  * re-mount.
  */
-void remount_tested_fs(void)
+static int remount_tested_fs(void)
 {
        char *wd_save;
        int ret;
@@ -2105,13 +2105,15 @@ void remount_tested_fs(void)
                flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT;
                ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype,
                            flags, fsinfo.mount_opts);
-               CHECK(ret == 0);
+               if (ret)
+                       return -1;
 
                flags = fsinfo.mount_flags | MS_REMOUNT;
                flags &= ~((unsigned long)MS_RDONLY);
                ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype,
                            flags, fsinfo.mount_opts);
-               CHECK(ret == 0);
+               if (ret)
+                       return -1;
        }
 
        if (um) {
@@ -2119,7 +2121,8 @@ void remount_tested_fs(void)
                        flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT;
                        ret = mount(fsinfo.fsdev, fsinfo.mount_point,
                                    fsinfo.fstype, flags, fsinfo.mount_opts);
-                       CHECK(ret == 0);
+                       if (ret)
+                               return -1;
                }
 
                CHECK(umount(fsinfo.mount_point) != -1);
@@ -2128,18 +2131,21 @@ void remount_tested_fs(void)
                        ret = mount(fsinfo.fsdev, fsinfo.mount_point,
                                    fsinfo.fstype, fsinfo.mount_flags,
                                    fsinfo.mount_opts);
-                       CHECK(ret == 0);
+                       if (ret)
+                               return -1;
                } else {
                        ret = mount(fsinfo.fsdev, fsinfo.mount_point,
                                    fsinfo.fstype, fsinfo.mount_flags | MS_RDONLY,
                                    fsinfo.mount_opts);
-                       CHECK(ret == 0);
+                       if (ret)
+                               return -1;
 
                        flags = fsinfo.mount_flags | MS_REMOUNT;
                        flags &= ~((unsigned long)MS_RDONLY);
                        ret = mount(fsinfo.fsdev, fsinfo.mount_point,
                                    fsinfo.fstype, flags, fsinfo.mount_opts);
-                       CHECK(ret == 0);
+                       if (ret)
+                               return -1;
                }
        }
 
@@ -2147,18 +2153,21 @@ void remount_tested_fs(void)
                flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT;
                ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype,
                            flags, fsinfo.mount_opts);
-               CHECK(ret == 0);
+               if (ret)
+                       return -1;
 
                flags = fsinfo.mount_flags | MS_REMOUNT;
                flags &= ~((unsigned long)MS_RDONLY);
                ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype,
                            flags, fsinfo.mount_opts);
-               CHECK(ret == 0);
+               if (ret)
+                       return -1;
        }
 
        /* Restore the previous working directory */
        CHECK(chdir(wd_save) == 0);
        free(wd_save);
+       return 0;
 }
 
 /*
@@ -2188,7 +2197,9 @@ static int integck(void)
 
        if (fsinfo.is_rootfs) {
                close_open_files();
-               remount_tested_fs();
+               ret = remount_tested_fs();
+               if (ret)
+                       return -1;
        }
 
        /* Check everything */
@@ -2201,7 +2212,9 @@ static int integck(void)
 
                if (!fsinfo.is_rootfs) {
                        close_open_files();
-                       remount_tested_fs();
+                       ret = remount_tested_fs();
+                       if (ret)
+                               return -1;
                }
 
                /* Check everything */