]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: remove trailing backslashes from mount point
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 12 Apr 2011 11:29:08 +0000 (14:29 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 18 Apr 2011 14:44:45 +0000 (17:44 +0300)
The test is not working if the user specified mount point with a trailing
back-slash at the end. Note, this had not worked before my changes as well.
Fix this.

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

index 910f22a60924b0856da436364e9abbeef0aadfdd..546077c0f95d777085289d6e21e3a18a3f3d2af3 100644 (file)
@@ -63,6 +63,7 @@ static struct {
  *                ENOSPC error
  * can_mmap: file-system supports share writable 'mmap()' operation
  * fstype: file-system type (e.g., "ubifs")
+ * mount_point: tested file-system mount point path
  */
 static struct {
        int max_name_len;
@@ -71,6 +72,7 @@ static struct {
        unsigned int nospc_size_ok:1;
        unsigned int can_mmap:1;
        const char *fstype;
+       const char *mount_point;
 } fsinfo = {
        .nospc_size_ok = 1,
        .can_mmap = 1,
@@ -265,7 +267,7 @@ static uint64_t get_free_space(void)
 {
        struct statvfs st;
 
-       CHECK(statvfs(args.mount_point, &st) != -1);
+       CHECK(statvfs(fsinfo.mount_point, &st) != -1);
        return (uint64_t)st.f_bavail * (uint64_t)st.f_frsize;
 }
 
@@ -275,7 +277,7 @@ static char *dir_path(struct dir_info *parent, const char *name)
        char *path;
 
        if (!parent)
-               return cat_paths(args.mount_point, name);
+               return cat_paths(fsinfo.mount_point, name);
        parent_path = dir_path(parent->parent, parent->name);
        path = cat_paths(parent_path, name);
        free(parent_path);
@@ -2033,9 +2035,16 @@ static void get_tested_fs_info(void)
        const char *mp;
         FILE *f;
        uint64_t z;
+       char *p;
 
-       CHECK(statfs(args.mount_point, &fs_info) == 0);
+       /* Remove trailing '/' symbols from the mount point */
+       p = dup_string(args.mount_point);
+       fsinfo.mount_point = p;
+       p += strlen(p);
+       while (*--p == '/');
+       *(p + 1) = '\0';
 
+       CHECK(statfs(fsinfo.mount_point, &fs_info) == 0);
        fsinfo.max_name_len = fs_info.f_namelen;
 
        mp = "/proc/mounts";
@@ -2053,7 +2062,7 @@ static void get_tested_fs_info(void)
                        CHECK(0);
                }
 
-               if (!strcmp(mntent->mnt_dir, args.mount_point))
+               if (!strcmp(mntent->mnt_dir, fsinfo.mount_point))
                        break;
         }
         fclose(f);
@@ -2164,7 +2173,7 @@ int main(int argc, char *argv[])
        get_tested_fs_info();
 
        /* Temporary hack - will be fixed a bit later */
-       tests_file_system_mount_dir = (void *)args.mount_point;
+       tests_file_system_mount_dir = (void *)fsinfo.mount_point;
        tests_file_system_type = (void *)fsinfo.fstype;
 
        /* Do the actual test */