chiark / gitweb /
udev: introduce SYSTEMD_EXPOSE as binary udev property for hiding/showing devices...
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Apr 2010 22:53:21 +0000 (00:53 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Apr 2010 22:53:21 +0000 (00:53 +0200)
device.c

index 5739af9..25661e0 100644 (file)
--- 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;