]> err.no Git - systemd/commitdiff
device: ignore a couple of 'API' devices
authorLennart Poettering <lennart@poettering.net>
Sat, 10 Apr 2010 15:45:14 +0000 (17:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 10 Apr 2010 16:00:34 +0000 (18:00 +0200)
device.c
device.h

index 500cd23e2718c7e46ac3b3555330665ebc1f26c0..39375a4258282110a5878b49147809fc9dbdc639 100644 (file)
--- a/device.c
+++ b/device.c
@@ -137,6 +137,28 @@ static int device_find_escape_name(Manager *m, const char *dn, Unit **_u) {
         return 0;
 }
 
+static bool devnode_is_api(const char *node) {
+        unsigned i;
+
+        static const char * const table[] = {
+                "/dev/null",
+                "/dev/zero",
+                "/dev/urandom",
+                "/dev/random",
+                "/dev/port",
+                "/dev/oldmem",
+                "/dev/full",
+                "/dev/kmsg",
+                "/dev/mem"
+        };
+
+        for (i = 0; i < ELEMENTSOF(table); i++)
+                if (streq(table[i], node))
+                        return true;
+
+        return false;
+}
+
 static int device_process_new_device(Manager *m, struct udev_device *dev, bool update_state) {
         const char *dn, *names, *wants, *sysfs, *expose, *model;
         Unit *u = NULL;
@@ -168,7 +190,7 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
                 if (!b)
                         return 0;
         } else
-                if (!dn && !names && !wants)
+                if ((!dn || devnode_is_api(dn)) && !names && !wants)
                         return 0;
 
         /* Ok, seems kinda interesting. Now, let's see if this one
index 30b8915c16f16f22cfbf7c02bd7402d30d563d21..b9ca22d1983c8696bcfc7a5d7e1abbdb9208f927 100644 (file)
--- a/device.h
+++ b/device.h
@@ -31,7 +31,8 @@ typedef struct Device Device;
 typedef enum DeviceState {
         DEVICE_DEAD,
         DEVICE_AVAILABLE,
-        _DEVICE_STATE_MAX
+        _DEVICE_STATE_MAX,
+        _DEVICE_STATE_INVALID = -1
 } DeviceState;
 
 struct Device {
@@ -39,7 +40,6 @@ struct Device {
 
         DeviceState state;
 
-        /* A single device can be created by multiple sysfs objects */
         char *sysfs;
 };