block: avoid ubi{,block} duplicates
authorDaniel Golle <daniel@makrotopia.org>
Wed, 20 Jul 2016 22:58:08 +0000 (00:58 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 20 Jul 2016 23:38:37 +0000 (01:38 +0200)
Skip ubi?_? device if ubiblock?_? is present.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
block.c

diff --git a/block.c b/block.c
index 4d823e6bec562685c4b8770fab694f94271aa9dc..6c025fdce4963eb6169a37517637d9ee6873dde4 100644 (file)
--- a/block.c
+++ b/block.c
@@ -464,6 +464,16 @@ static int config_load(char *cfg)
 static struct blkid_struct_probe* _probe_path(char *path)
 {
        struct blkid_struct_probe *pr;
+       char tmppath[64];
+
+       /* skip ubi device if ubiblock device is present */
+       if (path[5] == 'u' && path[6] == 'b' && path[7] == 'i' &&
+           path[8] >= '0' && path[8] <= '9' ) {
+               snprintf(tmppath, sizeof(tmppath), "/dev/ubiblock%s", path + 8);
+               list_for_each_entry(pr, &devices, list)
+                       if (!strcasecmp(pr->dev, tmppath))
+                               return NULL;
+       }
 
        pr = malloc(sizeof(*pr));