chiark / gitweb /
accept relative path for TEST
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 16 Aug 2007 10:45:31 +0000 (12:45 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Thu, 16 Aug 2007 10:45:31 +0000 (12:45 +0200)
test/udev-test.pl
udev_rules.c

index 53499d8..fe1c6da 100755 (executable)
@@ -1570,6 +1570,34 @@ EOF
 KERNEL=="sda", NAME="\$attr{[net/eth0]address}"
 EOF
        },
+       {
+               desc            => "TEST absolute path",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "there",
+               rules           => <<EOF
+TEST=="/etc/hosts", NAME="there"
+NAME="notthere"
+EOF
+       },
+       {
+               desc            => "TEST subsys/kernel lookup",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "yes",
+               rules           => <<EOF
+KERNEL=="sda", TEST=="[net/eth0]", NAME="yes"
+EOF
+       },
+       {
+               desc            => "TEST relative path",
+               subsys          => "block",
+               devpath         => "/block/sda",
+               exp_name        => "relative",
+               rules           => <<EOF
+KERNEL=="sda", TEST=="size", NAME="relative"
+EOF
+       },
 );
 
 # set env
index e2877ab..0dcbf15 100644 (file)
@@ -1003,6 +1003,14 @@ static int match_rule(struct udevice *udev, struct udev_rule *rule)
                                strlcat(filename, "/", sizeof(filename));
                                strlcat(filename, attr, sizeof(filename));
                        }
+               } else if (filename[0] != '/') {
+                       char tmp[PATH_SIZE];
+
+                       strlcpy(tmp, sysfs_path, sizeof(tmp));
+                       strlcat(tmp, udev->dev->devpath, sizeof(tmp));
+                       strlcat(tmp, "/", sizeof(tmp));
+                       strlcat(tmp, filename, sizeof(tmp));
+                       strlcpy(filename, tmp, sizeof(filename));
                }
 
                match = (stat(filename, &statbuf) == 0);