init: Allow wildcards in property triggers by using * for property value
For example, the following trigger will fire when the sys.foo property
is set to any value:
on property:sys.foo=*
write /data/foo hello
It is also possible to refer to the property within the trigger actions:
on property:sys.foo=*
write /data/foo $sys.foo
Change-Id: If78d20a532f77e17aa5703d53be581ad6736cbcf
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/init/init_parser.c b/init/init_parser.c
index e8e65ac..e88c5a0 100644
--- a/init/init_parser.c
+++ b/init/init_parser.c
@@ -347,7 +347,8 @@
if (!strncmp(name, test, name_length) &&
test[name_length] == '=' &&
- !strcmp(test + name_length + 1, value)) {
+ (!strcmp(test + name_length + 1, value) ||
+ !strcmp(test + name_length + 1, "*"))) {
action_add_queue_tail(act);
}
}
@@ -377,7 +378,8 @@
/* does the property exist, and match the trigger value? */
value = property_get(prop_name);
- if (value && !strcmp(equals + 1, value)) {
+ if (value && (!strcmp(equals + 1, value) ||
+ !strcmp(equals + 1, "*"))) {
action_add_queue_tail(act);
}
}