mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
store ENV{key}="value" exported keys in the database
Just like the IMPORT values are stored in the udev database the exported keys are stored in the udev database. The database is also imported on a remove event before the rules are matched. So it is possible to do: ACTION=="add", KERNEL=="sda", ENV{MY_DEVICE}="1234", RUN+="/bin/logger add $devpath" ACTION=="remove", ENV{MY_DEVICE}=="1234", RUN+="/bin/logger remove $devpath" Signed-off-by: Kay Sievers <kay.sievers@suse.de>
This commit is contained in:
parent
c4ef16f92c
commit
8f847bb845
12
udev_event.c
12
udev_event.c
@ -91,15 +91,21 @@ int udev_process_event(struct udev_rules *rules, struct udevice *udev)
|
||||
}
|
||||
sysfs_close_class_device(class_dev);
|
||||
} else if (strcmp(udev->action, "remove") == 0) {
|
||||
struct name_entry *name_loop;
|
||||
|
||||
/* get data from db, remove db-entry, delete node */
|
||||
dbg("node remove");
|
||||
retval = udev_remove_device(udev);
|
||||
|
||||
/* restore stored persistent data */
|
||||
list_for_each_entry(name_loop, &udev->env_list, node)
|
||||
putenv(name_loop->name);
|
||||
|
||||
udev_rules_get_run(rules, udev, NULL, NULL);
|
||||
if (udev->ignore_device) {
|
||||
dbg("device event will be ignored");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* get name from db, remove db-entry, delete node */
|
||||
retval = udev_remove_device(udev);
|
||||
}
|
||||
|
||||
/* export name of device node or netif */
|
||||
|
@ -859,6 +859,7 @@ try_parent:
|
||||
const char *key_name = key_pair_name(rule, pair);
|
||||
const char *value = key_val(rule, &pair->key);
|
||||
|
||||
name_list_key_add(&udev->env_list, key_name, value);
|
||||
setenv(key_name, value, 1);
|
||||
dbg("export ENV '%s=%s'", key_name, value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user