diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-04-08 00:53:21 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-04-08 00:53:21 +0200 |
commit | 7f275a9f1d3854cae637280048c57cca64ce89fe (patch) | |
tree | 34a618c535e2175d5597f89c27f22df1636f20bc /device.c | |
parent | fd18e1f4bf40481570ec20f1261b111d15f6c923 (diff) |
udev: introduce SYSTEMD_EXPOSE as binary udev property for hiding/showing devices in the systemd list
Diffstat (limited to 'device.c')
-rw-r--r-- | device.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -112,7 +112,7 @@ static int device_add_escaped_name(Unit *u, const char *dn, bool make_id) { } static int device_process_new_device(Manager *m, struct udev_device *dev, bool update_state) { - const char *dn, *names, *wants, *sysfs; + const char *dn, *names, *wants, *sysfs, *expose; Unit *u = NULL; int r; char *e, *w, *state; @@ -122,20 +122,32 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u assert(m); + if (!(sysfs = udev_device_get_syspath(dev))) + return -ENOMEM; + /* Check whether this entry is even relevant for us. */ dn = udev_device_get_devnode(dev); + expose = udev_device_get_property_value(dev, "SYSTEMD_EXPOSE"); names = udev_device_get_property_value(dev, "SYSTEMD_NAMES"); wants = udev_device_get_property_value(dev, "SYSTEMD_WANTS"); - if (!dn && !names && !wants) - return 0; + if (expose) { + int b; + + if ((b = parse_boolean(expose)) < 0) { + log_error("Failed to parse SYSTEMD_EXPOSE udev property for device %s: %s", sysfs, expose); + return 0; + } + + if (!b) + return 0; + } else + if (!dn && !names && !wants) + return 0; /* Ok, seems kinda interesting. Now, let's see if this one * already exists. */ - if (!(sysfs = udev_device_get_syspath(dev))) - return -ENOMEM; - assert(sysfs[0] == '/'); if (!(e = unit_name_escape_path(sysfs+1, ".device"))) return -ENOMEM; |