summaryrefslogtreecommitdiff
path: root/libudev
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-10-30 12:31:59 +0100
committerKay Sievers <kay.sievers@vrfy.org>2009-10-30 12:39:04 +0100
commit26347a4c5538008318188118872490128f43fcd3 (patch)
tree1bd46e51f23a581bc4ac0faa591a58487b015bda /libudev
parent82c6558e0109f66091e3a8e2c4ceef0372b0b331 (diff)
use CLOEXEC flags instead of fcntl()
Diffstat (limited to 'libudev')
-rw-r--r--libudev/docs/libudev-sections.txt1
-rw-r--r--libudev/libudev-monitor.c6
-rw-r--r--libudev/libudev-private.h1
-rw-r--r--libudev/libudev-util.c12
4 files changed, 3 insertions, 17 deletions
diff --git a/libudev/docs/libudev-sections.txt b/libudev/docs/libudev-sections.txt
index 4d70bca322..ff2dd363b1 100644
--- a/libudev/docs/libudev-sections.txt
+++ b/libudev/docs/libudev-sections.txt
@@ -83,6 +83,7 @@ udev_enumerate_add_nomatch_subsystem
udev_enumerate_add_match_sysattr
udev_enumerate_add_nomatch_sysattr
udev_enumerate_add_match_property
+udev_enumerate_add_match_sysname
udev_enumerate_add_syspath
udev_enumerate_scan_devices
udev_enumerate_scan_subsystems
diff --git a/libudev/libudev-monitor.c b/libudev/libudev-monitor.c
index ee855afac4..96c153fbd7 100644
--- a/libudev/libudev-monitor.c
+++ b/libudev/libudev-monitor.c
@@ -139,13 +139,12 @@ struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char
util_strscpy(&udev_monitor->sun.sun_path[1], sizeof(udev_monitor->sun.sun_path)-1, socket_path);
udev_monitor->addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(socket_path)+1;
}
- udev_monitor->sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
+ udev_monitor->sock = socket(AF_LOCAL, SOCK_DGRAM|SOCK_CLOEXEC, 0);
if (udev_monitor->sock == -1) {
err(udev, "error getting socket: %m\n");
free(udev_monitor);
return NULL;
}
- util_set_fd_cloexec(udev_monitor->sock);
dbg(udev, "monitor %p created with '%s'\n", udev_monitor, socket_path);
return udev_monitor;
@@ -197,13 +196,12 @@ struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char
if (udev_monitor == NULL)
return NULL;
- udev_monitor->sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
+ udev_monitor->sock = socket(PF_NETLINK, SOCK_DGRAM|SOCK_CLOEXEC, NETLINK_KOBJECT_UEVENT);
if (udev_monitor->sock == -1) {
err(udev, "error getting socket: %m\n");
free(udev_monitor);
return NULL;
}
- util_set_fd_cloexec(udev_monitor->sock);
udev_monitor->snl.nl_family = AF_NETLINK;
udev_monitor->snl.nl_groups = group;
diff --git a/libudev/libudev-private.h b/libudev/libudev-private.h
index 285b9d48c1..28110d191c 100644
--- a/libudev/libudev-private.h
+++ b/libudev/libudev-private.h
@@ -205,7 +205,6 @@ size_t util_strscpyl(char *dest, size_t size, const char *src, ...) __attribute_
int udev_util_replace_whitespace(const char *str, char *to, size_t len);
int udev_util_replace_chars(char *str, const char *white);
int udev_util_encode_string(const char *str, char *str_enc, size_t len);
-void util_set_fd_cloexec(int fd);
unsigned int util_string_hash32(const char *str);
/* libudev-util-private.c */
diff --git a/libudev/libudev-util.c b/libudev/libudev-util.c
index 9a656b5a98..c0209f9cc6 100644
--- a/libudev/libudev-util.c
+++ b/libudev/libudev-util.c
@@ -481,18 +481,6 @@ err:
return -1;
}
-void util_set_fd_cloexec(int fd)
-{
- int flags;
-
- flags = fcntl(fd, F_GETFD);
- if (flags < 0)
- flags = FD_CLOEXEC;
- else
- flags |= FD_CLOEXEC;
- fcntl(fd, F_SETFD, flags);
-}
-
unsigned int util_string_hash32(const char *str)
{
unsigned int hash = 0;