chiark / gitweb /
[PATCH] catch replace device by wildcard
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Wed, 3 Dec 2003 01:52:26 +0000 (17:52 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:13:05 +0000 (21:13 -0700)
  catch device name by wildcard to support a whole class of devices
  by just one config line like:
  REPLACE, KERNEL="tty*", NAME="vc/%n"

namedev.c
test/udev-test.pl

index 0abd4b8..ea64f34 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -860,8 +860,8 @@ static int do_replace(struct sysfs_class_device *class_dev, struct udevice *udev
                        continue;
 
                dbg_parse("compare name '%s' with '%s'",
-                         dev->kernel_name, dev->name);
-               if (strcmp(dev->kernel_name, class_dev->name) != 0)
+                         dev->kernel_name, class_dev->name);
+               if (strncmp_wildcard(class_dev->name, dev->kernel_name, NAME_SIZE) != 0)
                        continue;
 
                strfieldcpy(udev->name, dev->name);
index 3f48de8..8b967c3 100644 (file)
@@ -51,6 +51,15 @@ LABEL, BUS="scsi", vendor="IBM-ESXS", NAME="boot_disk%n"
 EOF
        },
        {
+               desc     => "catch device by wildcard",
+               subsys   => "tty",
+               devpath  => "class/tty/ttyUSB0",
+               expected => "visor/0" ,
+               conf     => <<EOF
+REPLACE, KERNEL="ttyUSB*", NAME="visor/%n"
+EOF
+       },
+       {
                desc     => "replace kernel name",
                subsys   => "tty",
                devpath  => "class/tty/ttyUSB0",