From: Daniel Golle Date: Wed, 20 Jul 2016 22:58:08 +0000 (+0200) Subject: block: avoid ubi{,block} duplicates X-Git-Url: http://git.openwrt.org/?p=project%2Ffstools.git;a=commitdiff_plain;h=b98642a50b0cd11696eaad151638f8cf9d153c40 block: avoid ubi{,block} duplicates Skip ubi?_? device if ubiblock?_? is present. Signed-off-by: Daniel Golle --- diff --git a/block.c b/block.c index 4d823e6..6c025fd 100644 --- 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));