[PATCH 04/11] config/udev: Add verbose info when fetching udev properties

Dan Nicholson dbn.lists at gmail.com
Thu May 20 07:09:06 PDT 2010


Give the user a chance to see why their input devices are being ignored,
even if they have to start the server with -logverbose.

Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
---
 config/udev.c |   39 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/config/udev.c b/config/udev.c
index 201506a..0f5cf11 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -37,6 +37,17 @@
 
 #define UDEV_XKB_PROP_KEY "xkb"
 
+#define LOG_PROPERTY(path, prop, val)                                   \
+    LogMessageVerb(X_INFO, 10,                                          \
+                   "config/udev: getting property %s on %s "            \
+                   "returned \"%s\"\n",                                 \
+                   (prop), (path), (val) ? (val) : "(null)")
+#define LOG_SYSATTR(path, attr, val)                                    \
+    LogMessageVerb(X_INFO, 10,                                          \
+                   "config/udev: getting attribute %s on %s "           \
+                   "returned \"%s\"\n",                                 \
+                   (attr), (path), (val) ? (val) : "(null)")
+
 static struct udev_monitor *udev_monitor;
 
 static void
@@ -45,6 +56,7 @@ device_added(struct udev_device *udev_device)
     const char *path, *name = NULL;
     char *config_info = NULL;
     const char *syspath;
+    const char *tags_prop;
     const char *key, *value, *tmp;
     char **tags = NULL;
     InputOption *options = NULL, *tmpo;
@@ -61,8 +73,13 @@ device_added(struct udev_device *udev_device)
     if (!path || !syspath)
         return;
 
-    if (!udev_device_get_property_value(udev_device, "ID_INPUT"))
+    if (!udev_device_get_property_value(udev_device, "ID_INPUT")) {
+        LogMessageVerb(X_INFO, 10,
+                       "config/udev: ignoring device %s without "
+                       "property ID_INPUT set\n",
+                       path);
         return;
+    }
 
     options = calloc(sizeof(*options), 1);
     if (!options)
@@ -75,9 +92,14 @@ device_added(struct udev_device *udev_device)
 
     parent = udev_device_get_parent(udev_device);
     if (parent) {
+        const char *ppath = udev_device_get_devnode(parent);
+
         name = udev_device_get_sysattr_value(parent, "name");
-        if (!name)
+        LOG_SYSATTR(ppath, "name", name);
+        if (!name) {
             name = udev_device_get_property_value(parent, "NAME");
+            LOG_PROPERTY(ppath, "NAME", name);
+        }
     }
     if (!name)
         name = "(unnamed)";
@@ -88,7 +110,10 @@ device_added(struct udev_device *udev_device)
     add_option(&options, "path", path);
     add_option(&options, "device", path);
     attrs.device = path;
-    tags = xstrtokenize(udev_device_get_property_value(udev_device, "ID_INPUT.tags"), ",");
+
+    tags_prop = udev_device_get_property_value(udev_device, "ID_INPUT.tags");
+    LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
+    tags = xstrtokenize(tags_prop, ",");
     attrs.tags = (const char * const *)tags;
 
     config_info = Xprintf("udev:%s", syspath);
@@ -109,6 +134,7 @@ device_added(struct udev_device *udev_device)
         value = udev_list_entry_get_value(entry);
         if (!strncasecmp(key, UDEV_XKB_PROP_KEY,
                                 sizeof(UDEV_XKB_PROP_KEY) - 1)) {
+            LOG_PROPERTY(path, key, value);
             tmp = key + sizeof(UDEV_XKB_PROP_KEY) - 1;
             if (!strcasecmp(tmp, "rules"))
                 add_option(&options, "xkb_rules", value);
@@ -121,18 +147,25 @@ device_added(struct udev_device *udev_device)
             else if (!strcasecmp(tmp, "options"))
                 add_option(&options, "xkb_options", value);
         } else if (!strcmp(key, "ID_VENDOR")) {
+            LOG_PROPERTY(path, key, value);
             attrs.vendor = value;
         } else if (!strcmp(key, "ID_INPUT_KEY")) {
+            LOG_PROPERTY(path, key, value);
             attrs.flags |= ATTR_KEYBOARD;
         } else if (!strcmp(key, "ID_INPUT_MOUSE")) {
+            LOG_PROPERTY(path, key, value);
             attrs.flags |= ATTR_POINTER;
         } else if (!strcmp(key, "ID_INPUT_JOYSTICK")) {
+            LOG_PROPERTY(path, key, value);
             attrs.flags |= ATTR_JOYSTICK;
         } else if (!strcmp(key, "ID_INPUT_TABLET")) {
+            LOG_PROPERTY(path, key, value);
             attrs.flags |= ATTR_TABLET;
         } else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) {
+            LOG_PROPERTY(path, key, value);
             attrs.flags |= ATTR_TOUCHPAD;
         } else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
+            LOG_PROPERTY(path, key, value);
             attrs.flags |= ATTR_TOUCHSCREEN;
         }
     }
-- 
1.6.6.1



More information about the xorg-devel mailing list