X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=libudev%2Flibudev-device.c;h=5811490a34599cbfdb4078938bda213a33c405fa;hp=3f441d099921da31a76382fa4a3351ec6c2764ee;hb=a7d29d15095a7977c02fa3a6bb1efe627dcdd2f4;hpb=bfd88b1d7b689ce86a2b04f62ac5a2b23b0aef84 diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c index 3f441d099..5811490a3 100644 --- a/libudev/libudev-device.c +++ b/libudev/libudev-device.c @@ -279,7 +279,7 @@ int udev_device_read_db(struct udev_device *udev_device) 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; @@ -339,7 +339,7 @@ int udev_device_read_uevent_file(struct udev_device *udev_device) 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; @@ -1164,7 +1164,7 @@ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const 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; @@ -1287,8 +1287,21 @@ void udev_device_cleanup_tags_list(struct udev_device *udev_device) 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); }