From: Lennart Poettering Date: Wed, 7 Apr 2010 22:53:21 +0000 (+0200) Subject: udev: introduce SYSTEMD_EXPOSE as binary udev property for hiding/showing devices... X-Git-Tag: 0.git+20100605+dfd8ee-1~210 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f275a9f1d3854cae637280048c57cca64ce89fe;p=systemd udev: introduce SYSTEMD_EXPOSE as binary udev property for hiding/showing devices in the systemd list --- diff --git a/device.c b/device.c index 5739af9e..25661e05 100644 --- a/device.c +++ b/device.c @@ -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;