chiark / gitweb /
enable skipping of "naming-only" rules
[elogind.git] / udev / udev-rules.c
index 796d2c157fa6eccbf20c21ac3acd3bcdccd90956..9861a88a52b3a6a7f5fbe91bb4b4d073d6cc5253 100644 (file)
@@ -451,15 +451,10 @@ static int add_string(struct udev_rules *rules, const char *str)
        unsigned int off;
        struct trie_node *parent;
 
-       len = strlen(str);
-
-       /* offset 0 is always '\0' */
-       if (len == 0)
-               return 0;
-
        /* walk trie, start from last character of str to find matching tails */
-       node_idx = 0;
+       len = strlen(str);
        key = str[len-1];
+       node_idx = 0;
        for (depth = 0; depth <= len; depth++) {
                struct trie_node *node;
                unsigned int child_idx;
@@ -1140,6 +1135,7 @@ static int add_rule(struct udev_rules *rules, char *line,
        char *linepos;
        char *attr;
        int physdev = 0;
+       int waitfor = 0;
        struct rule_tmp rule_tmp;
 
        memset(&rule_tmp, 0x00, sizeof(struct rule_tmp));
@@ -1400,6 +1396,7 @@ static int add_rule(struct udev_rules *rules, char *line,
                if (strcasecmp(key, "WAIT_FOR") == 0 || strcasecmp(key, "WAIT_FOR_SYSFS") == 0) {
                        rule_add_key(&rule_tmp, TK_M_WAITFOR, 0, value, NULL);
                        valid = 1;
+                       waitfor = 1;
                        continue;
                }
 
@@ -1549,11 +1546,11 @@ static int add_rule(struct udev_rules *rules, char *line,
                err(rules->udev, "unknown key '%s' in %s:%u\n", key, filename, lineno);
        }
 
-       if (physdev)
-               err(rules->udev, "PHYSDEV* values are deprecated and not available on recent kernels, \n"
-                   "please fix it in %s:%u", filename, lineno);
+       if (physdev && !waitfor)
+               err(rules->udev, "PHYSDEV* values are deprecated and not available on recent kernels, "
+                   "please fix it in %s:%u\n", filename, lineno);
 
-       /* skip line if not any valid key was found */
+       /* skip line if no valid key was found */
        if (!valid)
                goto invalid;
 
@@ -1723,7 +1720,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
        if (rules->trie_nodes == NULL)
                return NULL;
        rules->trie_nodes_max = PREALLOC_TRIE;
-       /* offset 0 is the trie root */
+       /* offset 0 is the trie root, with an empty string */
        memset(rules->trie_nodes, 0x00, sizeof(struct trie_node));
        rules->trie_nodes_cur = 1;
 
@@ -2022,7 +2019,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                        rule = cur;
                        /* possibly skip rules which want to set NAME, SYMLINK, OWNER, GROUP, MODE */
                        if (!can_set_name && rule->rule.flags)
-                               ;//goto nomatch;
+                               goto nomatch;
                        esc = ESCAPE_UNSET;
                        break;
                case TK_M_ACTION: