From 0c5c48040ac0f4c97f73fb3ac5493cc2d84a963b Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 14 May 2010 14:52:18 +0200 Subject: [PATCH] libudev: add O_CLOEXEC --- Makefile.am | 2 +- libudev/libudev-device.c | 6 +++--- libudev/libudev-queue.c | 4 ++-- libudev/libudev.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8d13f193..09cb5601 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,7 +29,7 @@ CLEANFILES = # libudev # ------------------------------------------------------------------------------ LIBUDEV_CURRENT=8 -LIBUDEV_REVISION=0 +LIBUDEV_REVISION=1 LIBUDEV_AGE=8 SUBDIRS += libudev/docs diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c index 7e6b7f1c..5811490a 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; diff --git a/libudev/libudev-queue.c b/libudev/libudev-queue.c index 5a4a3dc0..f3cb5ab4 100644 --- a/libudev/libudev-queue.c +++ b/libudev/libudev-queue.c @@ -131,7 +131,7 @@ unsigned long long int udev_get_kernel_seqnum(struct udev *udev) ssize_t len; util_strscpyl(filename, sizeof(filename), udev_get_sys_path(udev), "/kernel/uevent_seqnum", NULL); - fd = open(filename, O_RDONLY); + fd = open(filename, O_RDONLY|O_CLOEXEC); if (fd < 0) return 0; len = read(fd, buf, sizeof(buf)); @@ -215,7 +215,7 @@ static FILE *open_queue_file(struct udev_queue *udev_queue, unsigned long long i FILE *queue_file; util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue->udev), "/.udev/queue.bin", NULL); - queue_file = fopen(filename, "r"); + queue_file = fopen(filename, "re"); if (queue_file == NULL) return NULL; diff --git a/libudev/libudev.c b/libudev/libudev.c index 0ae5a911..cd418709 100644 --- a/libudev/libudev.c +++ b/libudev/libudev.c @@ -146,7 +146,7 @@ struct udev *udev_new(void) } if (config_file == NULL) goto err; - f = fopen(config_file, "r"); + f = fopen(config_file, "re"); if (f != NULL) { char line[UTIL_LINE_SIZE]; int line_nr = 0; -- 2.39.5