return 0;
}
- f = fopen(filename, "r");
+ f = fopen(filename, "re");
if (f == NULL) {
dbg(udev_device->udev, "error reading db file %s: %m\n", filename);
return -1;
}
+ udev_device->db_loaded = true;
+
while (fgets(line, sizeof(line), f)) {
ssize_t len;
const char *val;
fclose(f);
info(udev_device->udev, "device %p filled with db file data\n", udev_device);
- udev_device->db_loaded = true;
return 0;
}
return 0;
util_strscpyl(filename, sizeof(filename), udev_device->syspath, "/uevent", NULL);
- f = fopen(filename, "r");
+ f = fopen(filename, "re");
if (f == NULL)
return -1;
+ udev_device->uevent_loaded = true;
while (fgets(line, sizeof(line), f)) {
char *pos;
udev_device->devnum = makedev(maj, min);
fclose(f);
- udev_device->uevent_loaded = true;
return 0;
}
goto out;
/* read attribute value */
- fd = open(path, O_RDONLY);
+ fd = open(path, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
dbg(udev_device->udev, "attribute '%s' can not be opened\n", path);
goto out;
udev_list_cleanup_entries(udev_device->udev, &udev_device->tags_list);
}
+/**
+ * udev_device_get_tags_list_entry:
+ * @udev_device: udev device
+ *
+ * Retrieve the list of tags attached to the udev device. The next
+ * list entry can be retrieved with udev_list_entry_next(),
+ * which returns #NULL if no more entries exist. The tag string
+ * can be retrieved from the list entry by udev_list_get_name().
+ *
+ * Returns: the first entry of the tag list
+ **/
struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device)
{
+ if (udev_device == NULL)
+ return NULL;
return udev_list_get_entry(&udev_device->tags_list);
}