X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev_rules.c;h=6bd28ad4b7981a5ee136d38c6a80cd666b416fa6;hb=8127859217bcc4db6f42f8d549f157df93a44557;hp=5078f2d3d1668a6e4d80b9eb487c9c324234c0c7;hpb=d2c9a56e0e624ed448aed8ad18460deed63973e1;p=elogind.git diff --git a/udev_rules.c b/udev_rules.c index 5078f2d3d..6bd28ad4b 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -584,18 +584,18 @@ static char *key_pair_name(struct udev_rule *rule, struct key_pair *pair) static int match_key(const char *key_name, struct udev_rule *rule, struct key *key, const char *val) { - int match; char value[PATH_SIZE]; char *key_value; char *pos; + int match = 0; if (key->operation != KEY_OP_MATCH && key->operation != KEY_OP_NOMATCH) return 0; + /* look for a matching string, parts are separated by '|' */ strlcpy(value, rule->buf + key->val_off, sizeof(value)); key_value = value; - dbg("key %s value='%s'", key_name, key_value); while (key_value) { pos = strchr(key_value, '|'); @@ -603,19 +603,23 @@ static int match_key(const char *key_name, struct udev_rule *rule, struct key *k pos[0] = '\0'; pos++; } + dbg("match %s '%s' <-> '%s'", key_name, key_value, val); match = (fnmatch(key_value, val, 0) == 0); - if (match && (key->operation != KEY_OP_NOMATCH)) { - dbg("%s is true (matching value)", key_name); - return 0; - } - if (!match && (key->operation == KEY_OP_NOMATCH)) { - dbg("%s is true (non-matching value)", key_name); - return 0; - } + if (match) + break; + key_value = pos; } - dbg("%s is false", key_name); + + if (match && (key->operation == KEY_OP_MATCH)) { + dbg("%s is true (matching value)", key_name); + return 0; + } + if (!match && (key->operation == KEY_OP_NOMATCH)) { + dbg("%s is true (non-matching value)", key_name); + return 0; + } return -1; } @@ -910,7 +914,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev) udev->ignore_remove = 1; dbg("remove event should be ignored"); } - if (rule->link_priority) { + if (rule->link_priority != 0) { udev->link_priority = rule->link_priority; info("link_priority=%i", udev->link_priority); }