chiark / gitweb /
rules: add i2o driver rule
[elogind.git] / udev_rules.c
index e2877abe70be961b112c84beac4390b64985815a..35db958c8df4959fbb68664b1aed7afb0124a3aa 100644 (file)
@@ -475,10 +475,12 @@ static int pass_env_to_socket(const char *sockname, const char *devpath, const c
 
        bufpos = snprintf(buf, sizeof(buf)-1, "%s@%s", action, devpath);
        bufpos++;
-       for (i = 0; environ[i] != NULL && bufpos < sizeof(buf); i++) {
+       for (i = 0; environ[i] != NULL && bufpos < (sizeof(buf)-1); i++) {
                bufpos += strlcpy(&buf[bufpos], environ[i], sizeof(buf) - bufpos-1);
                bufpos++;
        }
+       if (bufpos > sizeof(buf))
+               bufpos = sizeof(buf);
 
        count = sendto(sock, &buf, bufpos, 0, (struct sockaddr *)&saddr, addrlen);
        if (count < 0)
@@ -1003,6 +1005,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);