match full mtd partition names
[project/fstools.git] / libfstools / mtd.c
index a0005d7..b9daabc 100644 (file)
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <mtd/mtd-user.h>
 
-#include "../fs-state.h"
+#include "libfstools.h"
 
 #include "volume.h"
 
@@ -130,7 +130,9 @@ static char* mtd_find_index(char *name)
                return index;
 
        while (!index && fgets(line, sizeof(line), fp)) {
-               if (strstr(line, name)) {
+               char *ret;
+
+               if ((ret = strstr(line, name)) && (ret[strlen(name)] == '"')) {
                        char *eol = strstr(line, ":");
 
                        if (!eol)
@@ -170,6 +172,11 @@ static int mtd_volume_find(struct volume *v, char *name)
        snprintf(buffer, sizeof(buffer), "/dev/mtd%s", idx);
        p->chr = strdup(buffer);
 
+       if (mtd_volume_load(v)) {
+               fprintf(stderr, "reading %s failed\n", v->name);
+               return -1;
+       }
+
        return 0;
 }
 
@@ -192,7 +199,7 @@ static int mtd_volume_identify(struct volume *v)
                return -1;
        }
 
-       if (deadc0de == 0x4f575254)
+       if (deadc0de == __be32_to_cpu(0x4f575254))
                return FS_SNAPSHOT;
 
        deadc0de = __be32_to_cpu(deadc0de);