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, '|');
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;
}
info("writing '%s' to sysfs file '%s'", value, attr);
f = fopen(attr, "w");
if (f != NULL) {
- if (fprintf(f, "%s", value) <= 0)
- err("error writing ATTR{%s}: %s", attr, strerror(errno));
+ if (!udev->test_run)
+ if (fprintf(f, "%s", value) <= 0)
+ err("error writing ATTR{%s}: %s", attr, strerror(errno));
fclose(f);
} else
err("error opening ATTR{%s} for writing: %s", attr, strerror(errno));
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);
}