summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2010-04-22 18:33:24 +0200
committerKay Sievers <kay.sievers@vrfy.org>2010-04-22 18:33:24 +0200
commit3f896a2abd76972eafe636cac4110608b6d3ff2f (patch)
tree00d76b4c9fdee5f3be2ef5cc95d19c424ddd856f /udev
parent28460195c2ae90892bf556aff2b80705a8f37795 (diff)
all to match against a given TAG==
Diffstat (limited to 'udev')
-rw-r--r--udev/udev-rules.c24
-rw-r--r--udev/udev.xml7
2 files changed, 30 insertions, 1 deletions
diff --git a/udev/udev-rules.c b/udev/udev-rules.c
index b5016d0bc3..5965723919 100644
--- a/udev/udev-rules.c
+++ b/udev/udev-rules.c
@@ -125,6 +125,7 @@ enum token_type {
TK_M_DEVLINK, /* val */
TK_M_NAME, /* val */
TK_M_ENV, /* val, attr */
+ TK_M_TAG, /* val */
TK_M_SUBSYSTEM, /* val */
TK_M_DRIVER, /* val */
TK_M_WAITFOR, /* val */
@@ -254,6 +255,7 @@ static const char *token_str(enum token_type type)
[TK_M_DEVLINK] = "M DEVLINK",
[TK_M_NAME] = "M NAME",
[TK_M_ENV] = "M ENV",
+ [TK_M_TAG] = "M TAG",
[TK_M_SUBSYSTEM] = "M SUBSYSTEM",
[TK_M_DRIVER] = "M DRIVER",
[TK_M_WAITFOR] = "M WAITFOR",
@@ -356,6 +358,7 @@ static void dump_token(struct udev_rules *rules, struct token *token)
dbg(rules->udev, "%s %s '%s' '%s'(%s)\n",
token_str(type), operation_str(op), attr, value, string_glob_str(glob));
break;
+ case TK_M_TAG:
case TK_A_TAG:
dbg(rules->udev, "%s %s '%s'\n", token_str(type), operation_str(op), value);
break;
@@ -1008,6 +1011,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
case TK_A_MODE:
case TK_A_NAME:
case TK_A_GOTO:
+ case TK_M_TAG:
case TK_A_TAG:
token->key.value_off = add_string(rule_tmp->rules, value);
break;
@@ -1357,7 +1361,10 @@ static int add_rule(struct udev_rules *rules, char *line,
}
if (strcmp(key, "TAG") == 0) {
- rule_add_key(&rule_tmp, TK_A_TAG, op, value, NULL);
+ if (op < OP_MATCH_MAX)
+ rule_add_key(&rule_tmp, TK_M_TAG, op, value, NULL);
+ else
+ rule_add_key(&rule_tmp, TK_A_TAG, op, value, NULL);
continue;
}
@@ -2104,6 +2111,21 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
goto nomatch;
break;
}
+ case TK_M_TAG:
+ {
+ struct udev_list_entry *list_entry;
+ bool match = false;
+
+ udev_list_entry_foreach(list_entry, udev_device_get_tags_list_entry(event->dev)) {
+ if (strcmp(&rules->buf[cur->key.value_off], udev_list_entry_get_name(list_entry)) == 0) {
+ match = true;
+ break;
+ }
+ }
+ if (!match && (cur->key.op != OP_NOMATCH))
+ goto nomatch;
+ break;
+ }
case TK_M_SUBSYSTEM:
if (match_key(rules, cur, udev_device_get_subsystem(event->dev)) != 0)
goto nomatch;
diff --git a/udev/udev.xml b/udev/udev.xml
index 842fd5d52a..d2277c93d0 100644
--- a/udev/udev.xml
+++ b/udev/udev.xml
@@ -238,6 +238,13 @@
</varlistentry>
<varlistentry>
+ <term><option>TAG</option></term>
+ <listitem>
+ <para>Match against a device tag.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>TEST{<replaceable>octal mode mask</replaceable>}</option></term>
<listitem>
<para>Test the existence of a file. An octal mode mask can be specified