-#include "udev_rules.h"
-
-static int import_uevent_var(struct udev *udev, const char *devpath)
-{
- char path[UTIL_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 */
- util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
- util_strlcat(path, devpath, sizeof(path));
- util_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(udev, "import into environment: '%s'\n", key);
- putenv(key);
- key = &next[1];
- }
- rc = 0;
-out:
- return rc;
-}