]> err.no Git - systemd/commitdiff
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 53499d8871ff49985b3c06518222e2d51305dc9b..fe1c6da4f9391ee4c0459081b1a5a87bb3ea9ec6 100755 (executable)
@@ -1568,6 +1568,34 @@ EOF
                exp_name        => "00:e0:00:fb:04:e1",
                rules           => <<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
        },
 );
index e2877abe70be961b112c84beac4390b64985815a..0dcbf156ea14d9708b4b53b5d9cd60b4b956e0ff 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);