diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2011-04-13 22:33:01 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2011-04-13 22:33:01 +0200 |
commit | 9ead662791b5e59a95b6c5a9351d661cb61d76bb (patch) | |
tree | 392eb083d47cc9de102fed885c4d8477103bc89c /udev/udev-rules.c | |
parent | 09913ced8c6c081840c27a9f2ae4d430045a7c68 (diff) |
udevadm: info --cleanup-db
Most of the udev database from initramfs should be deleted before
starting udev in the real root. udevadm: info --cleanup-db deletes
all database entries in /run/udev. Events that processed IMPORT{db},
or mark devices explicitely as persistent, will be excluded.
Diffstat (limited to 'udev/udev-rules.c')
-rw-r--r-- | udev/udev-rules.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/udev/udev-rules.c b/udev/udev-rules.c index 221865c9dc..805f449f22 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -150,6 +150,7 @@ enum token_type { TK_A_STRING_ESCAPE_NONE, TK_A_STRING_ESCAPE_REPLACE, + TK_A_DB_PERSIST, TK_A_INOTIFY_WATCH, /* int */ TK_A_DEVLINK_PRIO, /* int */ TK_A_OWNER, /* val */ @@ -284,6 +285,7 @@ static const char *token_str(enum token_type type) [TK_A_STRING_ESCAPE_NONE] = "A STRING_ESCAPE_NONE", [TK_A_STRING_ESCAPE_REPLACE] = "A STRING_ESCAPE_REPLACE", + [TK_A_DB_PERSIST] = "A DB_PERSIST", [TK_A_INOTIFY_WATCH] = "A INOTIFY_WATCH", [TK_A_DEVLINK_PRIO] = "A DEVLINK_PRIO", [TK_A_OWNER] = "A OWNER", @@ -370,6 +372,7 @@ static void dump_token(struct udev_rules *rules, struct token *token) break; case TK_A_STRING_ESCAPE_NONE: case TK_A_STRING_ESCAPE_REPLACE: + case TK_A_DB_PERSIST: dbg(rules->udev, "%s\n", token_str(type)); break; case TK_M_TEST: @@ -1045,6 +1048,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type, break; case TK_A_STRING_ESCAPE_NONE: case TK_A_STRING_ESCAPE_REPLACE: + case TK_A_DB_PERSIST: break; case TK_A_RUN: token->key.value_off = add_string(rule_tmp->rules, value); @@ -1572,6 +1576,7 @@ static int add_rule(struct udev_rules *rules, char *line, rule_add_key(&rule_tmp, TK_A_DEVLINK_PRIO, op, NULL, &prio); dbg(rules->udev, "link priority=%i\n", prio); } + pos = strstr(value, "event_timeout="); if (pos != NULL) { int tout = atoi(&pos[strlen("event_timeout=")]); @@ -1579,6 +1584,7 @@ static int add_rule(struct udev_rules *rules, char *line, rule_add_key(&rule_tmp, TK_A_EVENT_TIMEOUT, op, NULL, &tout); dbg(rules->udev, "event timeout=%i\n", tout); } + pos = strstr(value, "string_escape="); if (pos != NULL) { pos = &pos[strlen("string_escape=")]; @@ -1587,6 +1593,11 @@ static int add_rule(struct udev_rules *rules, char *line, else if (strncmp(pos, "replace", strlen("replace")) == 0) rule_add_key(&rule_tmp, TK_A_STRING_ESCAPE_REPLACE, op, NULL, NULL); } + + pos = strstr(value, "db_persist="); + if (pos != NULL) + rule_add_key(&rule_tmp, TK_A_DB_PERSIST, op, NULL, NULL); + pos = strstr(value, "nowatch"); if (pos != NULL) { const int off = 0; @@ -1602,11 +1613,13 @@ static int add_rule(struct udev_rules *rules, char *line, dbg(rules->udev, "inotify watch of device requested\n"); } } + pos = strstr(value, "static_node="); if (pos != NULL) { rule_add_key(&rule_tmp, TK_A_STATIC_NODE, op, &pos[strlen("static_node=")], NULL); rule_tmp.rule.rule.has_static_node = true; } + continue; } err(rules->udev, "unknown key '%s' in %s:%u\n", key, filename, lineno); @@ -2332,6 +2345,9 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event const char *key = &rules->buf[cur->key.value_off]; const char *value; + /* implicitely mark database as persistent across initramfs transition */ + udev_device_set_db_persist(event->dev); + value = udev_device_get_property_value(event->dev_db, key); if (value != NULL) { struct udev_list_entry *entry; @@ -2407,6 +2423,9 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event case TK_A_STRING_ESCAPE_REPLACE: esc = ESCAPE_REPLACE; break; + case TK_A_DB_PERSIST: + udev_device_set_db_persist(event->dev); + break; case TK_A_INOTIFY_WATCH: if (event->inotify_watch_final) break; |