]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: do not use tests_fs_is_rootfs
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 13 Apr 2011 12:06:18 +0000 (15:06 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 18 Apr 2011 14:44:45 +0000 (17:44 +0300)
Do not use the shared 'tests_fs_is_rootfs()' function - introduce
'fsinfo.is_rootfs' flag and utilize it instead. This is another step
forward the goal to make integck independent of the common code.

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

index 92571d170d29cfb63e52b5be08310a20ada9ed68..7a4bcdcc720150f0bf60c3aaa34d17785077382b 100644 (file)
@@ -65,6 +65,7 @@ static struct {
  * nospc_size_ok: file size is updated even if the write operation failed with
  *                ENOSPC error
  * can_mmap: file-system supports share writable 'mmap()' operation
+ * is_rootfs: the tested file-system the root file-system
  * fstype: file-system type (e.g., "ubifs")
  * mount_point: tested file-system mount point path
  * test_dir: the directory on the tested file-system where we test
@@ -75,6 +76,7 @@ static struct {
        unsigned int log10_initial_free;
        unsigned int nospc_size_ok:1;
        unsigned int can_mmap:1;
+       unsigned int is_rootfs:1;
        const char *fstype;
        const char *mount_point;
        const char *test_dir;
@@ -2026,7 +2028,7 @@ static int integck(void)
 
        create_test_data();
 
-       if (!tests_fs_is_rootfs()) {
+       if (fsinfo.is_rootfs) {
                close_open_files();
                tests_remount(); /* Requires root access */
        }
@@ -2039,7 +2041,7 @@ static int integck(void)
        for (rpt = 0; args.repeat_cnt == 0 || rpt < args.repeat_cnt; ++rpt) {
                update_test_data();
 
-               if (!tests_fs_is_rootfs()) {
+               if (!fsinfo.is_rootfs) {
                        close_open_files();
                        tests_remount(); /* Requires root access */
                }
@@ -2069,6 +2071,7 @@ static void get_tested_fs_info(void)
        uint64_t z;
        char *p;
        unsigned int pid;
+       struct stat st1, st2;
 
        /* Remove trailing '/' symbols from the mount point */
        p = dup_string(args.mount_point);
@@ -2127,6 +2130,11 @@ static void get_tested_fs_info(void)
 
        normsg("pid %u, testing \"%s\" at \"%s\"",
               pid, fsinfo.fstype, fsinfo.mount_point);
+
+       CHECK(stat(fsinfo.mount_point, &st1) == 0);
+       CHECK(stat("/", &st2) != -1);
+       if (st1.st_dev == st2.st_dev)
+               fsinfo.is_rootfs = 1;
 }
 
 static const char doc[] = PROGRAM_NAME " version " PROGRAM_VERSION