+static int import_uevent_var(const char *devpath)
+{
+ char path[PATH_SIZE];
+ static char value[4096]; /* must stay, used with putenv */
+ ssize_t size;
+ int fd;
+ char *key;
+ char *next;
+ int rc = -1;
+
+ /* read uevent file */
+ strlcpy(path, sysfs_path, sizeof(path));
+ strlcat(path, devpath, sizeof(path));
+ strlcat(path, "/uevent", sizeof(path));
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ goto out;
+ size = read(fd, value, sizeof(value));
+ close(fd);
+ if (size < 0)
+ goto out;
+ value[size] = '\0';
+
+ /* import keys into environment */
+ key = value;
+ while (key[0] != '\0') {
+ next = strchr(key, '\n');
+ if (next == NULL)
+ goto out;
+ next[0] = '\0';
+ info("import into environment: '%s'", key);
+ putenv(key);
+ key = &next[1];
+ }
+ rc = 0;
+out:
+ return rc;
+}
+