cosmetic udev glitches

Dan Nicholson dbn.lists at gmail.com
Tue Mar 2 16:47:09 PST 2010


On Wed, Mar 03, 2010 at 10:40:16AM +1000, Peter Hutterer wrote:
> On Tue, Mar 02, 2010 at 04:29:41PM -0800, Dan Nicholson wrote:
> > On Tue, Mar 2, 2010 at 4:16 PM, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> > > On Tue, Mar 02, 2010 at 02:47:22PM -0800, Dan Nicholson wrote:
> > >> Can you try the patch below that uses the name attribute instead of the
> > >> value from the uevent? I ran it through a little test app, but not in X.
> > >>
> > >> From c01a4e6dce7196a60b5247dde78054b27e004494 Mon Sep 17 00:00:00 2001
> > >> From: Dan Nicholson <dbn.lists at gmail.com>
> > >> Date: Tue, 2 Mar 2010 14:42:22 -0800
> > >> Subject: [PATCH] config/udev: Get product name from attribute instead of uevent
> > >>
> > >> The input device product name in the kernel uevent has embedded quotes
> > >> that aren't expected here. Use the sysfs name attribute instead, which
> > >> does not suffer this problem.
> > >>
> > >> Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>
> > >> ---
> > >>  config/udev.c |    2 +-
> > >>  1 files changed, 1 insertions(+), 1 deletions(-)
> > >>
> > >> diff --git a/config/udev.c b/config/udev.c
> > >> index 69257e9..54306ef 100644
> > >> --- a/config/udev.c
> > >> +++ b/config/udev.c
> > >> @@ -74,7 +74,7 @@ device_added(struct udev_device *udev_device)
> > >>
> > >>      parent = udev_device_get_parent(udev_device);
> > >>      if (parent)
> > >> -        name = udev_device_get_property_value(parent, "NAME");
> > >> +        name = udev_device_get_sysattr_value(parent, "name");
> > >>      if (!name)
> > >>          name = "(unnamed)";
> > >>      else
> > >> --
> > >> 1.6.6.1
> > >
> > > Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
> > >
> > > tested too.
> > 
> > Is this on rawhide with udev-151? When I tried it against the udev on
> > f12, it was replacing the spaces in the name with underscores. I can't
> > figure out why, but when I ran it against a vanilla udev 145 or git,
> > it worked fine.
> 
> This was on F12 (X server from git) and I don't see the underscore issue you
> mentioned. Updates-testing from yesterday.
> Not quite sure where that comes from tbh.

Never mind. I don't know what I doing, but it's working now. Here's my
little test app for reference. You have to pass it the sysfs device path.

--
Dan

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE 1
#include <libudev.h>

int main(int argc, char *argv[])
{
    struct udev *udev;
    struct udev_device *device, *parent;
    const char *path, *name;

    if (argc < 2) {
        fprintf(stderr, "No device path specified\n");
        exit(EXIT_FAILURE);
    }
    path = argv[1];

    udev = udev_new();
    device = udev_device_new_from_syspath(udev, path);
    if (!device) {
        fprintf(stderr, "Device not found from path \"%s\"\n", path);
        exit(EXIT_FAILURE);
    }
    parent = udev_device_get_parent(device);
    if (!parent)
        parent = device;
    name = udev_device_get_sysattr_value(parent, "name");
    printf("%s: \"%s\"\n", path, name);

    udev_device_unref(device);
    udev_unref(udev);

    return 0;
}



More information about the xorg mailing list