ubi: fix false positive in volume_find
[project/fstools.git] / libfstools / ubi.c
index 69f64061ee4f6d60d0d1d823f346b6afaed26514..3051720f65d8df6fc58848ff2422eae5d3c88d17 100644 (file)
@@ -93,7 +93,7 @@ test_open(char *filename)
 
 static int ubi_volume_init(struct volume *v)
 {
-       char voldir[40], voldev[32], *volname, *voltype;
+       char voldir[40], voldev[32], *volname;
        struct ubi_priv *p;
        unsigned int volsize;
 
@@ -138,7 +138,7 @@ static int ubi_volume_match(struct volume *v, char *name, int ubi_num, int volid
 
        volname = read_string_from_file(voldir, "name");
 
-       if (strncmp(name, volname, strlen(volname)))
+       if (strncmp(name, volname, strlen(volname) + 1))
                return -1;
 
        p = calloc(1, sizeof(struct ubi_priv));
@@ -180,6 +180,9 @@ static int ubi_volume_find(struct volume *v, char *name)
        unsigned int ubi_num;
        int ret = -1;
 
+       if (find_filesystem("ubifs"))
+               return ret;
+
        ubi_dir = opendir(ubi_dir_name);
        /* check for os ubi support */
        if (!ubi_dir)