summaryrefslogtreecommitdiff
path: root/udev/udev-rules.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-02-25 11:18:15 +0100
committerKay Sievers <kay.sievers@vrfy.org>2009-02-25 11:18:15 +0100
commit46f194cbdecda5a8a0cb4d647b9c74b477a89133 (patch)
treec20c7613bfb5c85ee80d9e3ee7fc6f1bb69a6a80 /udev/udev-rules.c
parent3d3a0a709a38805259fe07240c3ca47a120dd5d6 (diff)
add "nowatch" to disable a default installed watch with a later rule
Diffstat (limited to 'udev/udev-rules.c')
-rw-r--r--udev/udev-rules.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/udev/udev-rules.c b/udev/udev-rules.c
index 3751cbb36d..905a1a0038 100644
--- a/udev/udev-rules.c
+++ b/udev/udev-rules.c
@@ -140,7 +140,7 @@ enum token_type {
TK_A_IGNORE_DEVICE,
TK_A_STRING_ESCAPE_NONE,
TK_A_STRING_ESCAPE_REPLACE,
- TK_A_INOTIFY_WATCH,
+ TK_A_INOTIFY_WATCH, /* int */
TK_A_NUM_FAKE_PART, /* int */
TK_A_DEVLINK_PRIO, /* int */
TK_A_OWNER, /* val */
@@ -183,7 +183,6 @@ struct token {
union {
unsigned int attr_off;
int ignore_error;
- int i;
unsigned int rule_goto;
mode_t mode;
uid_t uid;
@@ -191,6 +190,7 @@ struct token {
int num_fake_part;
int devlink_prio;
int event_timeout;
+ int watch;
};
} key;
};
@@ -354,7 +354,6 @@ static void dump_token(struct udev_rules *rules, struct token *token)
case TK_A_IGNORE_DEVICE:
case TK_A_STRING_ESCAPE_NONE:
case TK_A_STRING_ESCAPE_REPLACE:
- case TK_A_INOTIFY_WATCH:
case TK_A_LAST_RULE:
case TK_A_IGNORE_REMOVE:
dbg(rules->udev, "%s\n", token_str(type));
@@ -363,6 +362,9 @@ static void dump_token(struct udev_rules *rules, struct token *token)
dbg(rules->udev, "%s %s '%s'(%s) %#o\n",
token_str(type), operation_str(op), value, string_glob_str(glob), token->key.mode);
break;
+ case TK_A_INOTIFY_WATCH:
+ dbg(rules->udev, "%s %u\n", token_str(type), token->key.i);
+ break;
case TK_A_NUM_FAKE_PART:
dbg(rules->udev, "%s %u\n", token_str(type), token->key.num_fake_part);
break;
@@ -1023,7 +1025,6 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
case TK_A_IGNORE_DEVICE:
case TK_A_STRING_ESCAPE_NONE:
case TK_A_STRING_ESCAPE_REPLACE:
- case TK_A_INOTIFY_WATCH:
case TK_A_IGNORE_REMOVE:
case TK_A_LAST_RULE:
break;
@@ -1031,9 +1032,8 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
token->key.value_off = add_string(rule_tmp->rules, value);
token->key.ignore_error = *(int *)data;
break;
+ case TK_A_INOTIFY_WATCH:
case TK_A_NUM_FAKE_PART:
- token->key.num_fake_part = *(int *)data;
- break;
case TK_A_DEVLINK_PRIO:
token->key.devlink_prio = *(int *)data;
break;
@@ -1516,10 +1516,20 @@ static int add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_A_NUM_FAKE_PART, 0, NULL, &num);
dbg(rules->udev, "creation of partition nodes requested\n");
}
- pos = strstr(value, "watch");
+ pos = strstr(value, "nowatch");
if (pos != NULL) {
- rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, 0, NULL, NULL);
- dbg(rules->udev, "inotify watch of device requested\n");
+ const int off = 0;
+
+ rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, 0, NULL, &off);
+ dbg(rules->udev, "inotify watch of device disabled\n");
+ } else {
+ pos = strstr(value, "watch");
+ if (pos != NULL) {
+ const int on = 1;
+
+ rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, 0, NULL, &on);
+ dbg(rules->udev, "inotify watch of device requested\n");
+ }
}
continue;
}
@@ -2254,7 +2264,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
udev_device_set_num_fake_partitions(event->dev, cur->key.num_fake_part);
break;
case TK_A_INOTIFY_WATCH:
- event->inotify_watch = 1;
+ event->inotify_watch = cur->key.watch;
break;
case TK_A_DEVLINK_PRIO:
udev_device_set_devlink_priority(event->dev, cur->key.devlink_prio);