[libmultipath] Use strmatch to load config file
authorHannes Reinecke <hare@suse.de>
Thu, 9 Nov 2006 09:48:00 +0000 (10:48 +0100)
committerHannes Reinecke <hare@suse.de>
Thu, 9 Nov 2006 09:48:00 +0000 (10:48 +0100)
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 <hare@suse.de>
libmultipath/config.c

index a87e97e..b414db9 100644 (file)
 #include "blacklist.h"
 #include "defaults.h"
 
+static struct hwentry *
+find_hwe_strmatch (vector hwtable, char * vendor, char * product, char * revision)
+{
+       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;
+
+               if (hwe->revision && revision && strcmp(hwe->revision, revision))
+                       continue;
+
+               ret = hwe;
+               break;
+       }
+       return ret;
+}
+
 struct hwentry *
 find_hwe (vector hwtable, char * vendor, char * product)
 {
@@ -222,7 +244,7 @@ store_hwe (vector hwtable, struct hwentry * dhwe)
 {
        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()))