summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-11-01 19:12:20 +0100
committerKay Sievers <kay.sievers@vrfy.org>2008-11-01 19:12:20 +0100
commit00f98bd2b3cc8205ec70e2b1a6fc2132dba3d9ba (patch)
tree0ea47351debc9e114dab46292bc2d404cd41fb15
parent0ef254d5800c0c0dabfaf943886a47731784a955 (diff)
skip entire rule containing device naming keys, if no device can be named
If rules set NAME, SYMLINK, OWNER, GROUP, MODE, events without a device node and remove events will skip the entire rule. The old parser did the same.
-rw-r--r--TODO1
-rw-r--r--udev/udev-rules.c19
-rw-r--r--udev/udevd.c1
3 files changed, 18 insertions, 3 deletions
diff --git a/TODO b/TODO
index a8d3fc0515..ac0618ec16 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,5 @@
+ o drop pnp shell script, acpi will take care of loading pnp modules
o add DVB variables to kernel (patch sent), and drop shell script rule
o DEVTYPE for disks is set by the kernel, they will be removed from
the default rules
diff --git a/udev/udev-rules.c b/udev/udev-rules.c
index b5fe2f468b..d1c02e9204 100644
--- a/udev/udev-rules.c
+++ b/udev/udev-rules.c
@@ -877,11 +877,12 @@ static void dump_token(struct udev_rules *rules, struct token *token)
const char *tk_ptr = (char *)token;
unsigned int off = tk_ptr - tks_ptr;
- dbg(rules->udev, "* RULE %s:%u, off: %u(%u), next: %u, label: '%s'\n",
+ dbg(rules->udev, "* RULE %s:%u, off: %u(%u), next: %u, label: '%s', flags: 0x%02x\n",
&rules->buf[token->rule.filename_off], token->rule.filename_line,
off / (unsigned int) sizeof(struct token), off,
token->rule.next_rule,
- &rules->buf[token->rule.label_off]);
+ &rules->buf[token->rule.label_off],
+ token->rule.flags);
break;
}
case TK_M_ACTION:
@@ -1316,6 +1317,7 @@ static int add_rule(struct udev_rules *rules, char *line,
}
}
}
+ rule_tmp.rule.rule.flags = 1;
continue;
}
@@ -1324,6 +1326,7 @@ static int add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_M_DEVLINK, op, value, NULL);
else
rule_add_key(&rule_tmp, TK_A_DEVLINK, op, value, NULL);
+ rule_tmp.rule.rule.flags = 1;
valid = 1;
continue;
}
@@ -1341,6 +1344,7 @@ static int add_rule(struct udev_rules *rules, char *line,
} else {
rule_add_key(&rule_tmp, TK_A_OWNER, op, value, NULL);
}
+ rule_tmp.rule.rule.flags = 1;
valid = 1;
continue;
}
@@ -1358,6 +1362,7 @@ static int add_rule(struct udev_rules *rules, char *line,
} else {
rule_add_key(&rule_tmp, TK_A_GROUP, op, value, NULL);
}
+ rule_tmp.rule.rule.flags = 1;
valid = 1;
continue;
}
@@ -1371,6 +1376,7 @@ static int add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_A_MODE_ID, op, NULL, &mode);
else
rule_add_key(&rule_tmp, TK_A_MODE, op, value, NULL);
+ rule_tmp.rule.rule.flags = 1;
valid = 1;
continue;
}
@@ -1856,10 +1862,16 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
struct token *cur;
struct token *rule;
enum escape_type esc = ESCAPE_UNSET;
+ int can_set_name;
if (rules->tokens == NULL)
return -1;
+ can_set_name = ((strcmp(udev_device_get_action(event->dev), "add") == 0 ||
+ strcmp(udev_device_get_action(event->dev), "change") == 0) &&
+ (major(udev_device_get_devnum(event->dev)) > 0 ||
+ strcmp(udev_device_get_subsystem(event->dev), "net") == 0));
+
/* loop through token list, match, run actions or forward to next rule */
cur = &rules->tokens[0];
rule = cur;
@@ -1871,6 +1883,9 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
case TK_RULE:
/* current rule */
rule = cur;
+ /* possibly skip rules which want to set NAME, SYMLINK, OWNER, GROUP, MODE */
+ if (!can_set_name && rule->rule.flags)
+ ;//goto nomatch;
esc = ESCAPE_UNSET;
break;
case TK_M_ACTION:
diff --git a/udev/udevd.c b/udev/udevd.c
index 9096f9505b..405a1ed907 100644
--- a/udev/udevd.c
+++ b/udev/udevd.c
@@ -430,7 +430,6 @@ static void event_queue_manager(struct udev *udev)
continue;
}
- /* do dendencies, start event */
event_fork(loop_event);
dbg(udev, "moved seq %llu to running list\n", udev_device_get_seqnum(loop_event->dev));
}