[libmultipath] Use strmatch to load config file Currently we're using regexec to load the initial hardware table. Unfortunately the hardware table has regex as defaults, so it's quite possible for two different regular expressions do match. But that's quite undesired as we just want a clean 1:1 copy here. So we're better using a string match for comparison. Signed-off-by: Hannes Reinecke --- libmultipath/config.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index a87e97e..2f07792 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -20,6 +20,25 @@ #include "config.h" #include "blacklist.h" #include "defaults.h" +static struct hwentry * +find_hwe_strmatch (vector hwtable, char * vendor, char * product) +{ + int i; + struct hwentry *hwe, *ret = NULL; + + vector_foreach_slot (hwtable, hwe, i) { + if (hwe->vendor && vendor && strcmp(hwe->vendor, vendor)) + continue; + + if (hwe->product && product && strcmp(hwe->product, product)) + continue; + + ret = hwe; + break; + } + return ret; +} + struct hwentry * find_hwe (vector hwtable, char * vendor, char * product) { @@ -222,7 +241,7 @@ store_hwe (vector hwtable, struct hwentr { struct hwentry * hwe; - if (dup_hwe(hwtable, dhwe->vendor, dhwe->product)) + if (find_hwe_strmatch(hwtable, dhwe->vendor, dhwe->product)) return 0; if (!(hwe = alloc_hwe())) -- 1.3.1