PKGBUILDs/core/udev-oxnas/pre-accept4-kernel.patch

41 lines
1.2 KiB
Diff
Raw Normal View History

2011-10-25 21:18:24 +00:00
diff -urN a/udev/udev-ctrl.c b/udev/udev-ctrl.c
--- a/udev/udev-ctrl.c 2011-10-09 17:10:32.000000000 -0600
+++ b/udev/udev-ctrl.c 2011-10-25 15:11:09.000000000 -0600
2011-07-05 23:34:18 +00:00
@@ -15,6 +15,7 @@
#include <stddef.h>
#include <string.h>
#include <unistd.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/socket.h>
2011-10-25 21:18:24 +00:00
@@ -182,6 +183,7 @@
2011-07-05 23:34:18 +00:00
struct ucred ucred;
socklen_t slen;
const int on = 1;
+ int flgs;
conn = calloc(1, sizeof(struct udev_ctrl_connection));
if (conn == NULL)
2011-10-25 21:18:24 +00:00
@@ -189,13 +191,19 @@
2011-07-05 23:34:18 +00:00
conn->refcount = 1;
conn->uctrl = uctrl;
- conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
+// conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
+ conn->sock = accept(uctrl->sock, NULL, NULL);
if (conn->sock < 0) {
if (errno != EINTR)
err(uctrl->udev, "unable to receive ctrl connection: %m\n");
goto err;
}
+// Since we don't have accept4
+ flgs = fcntl(conn->sock, F_GETFL, NULL);
+ if(flgs >= 0) fcntl(conn->sock, F_SETFL, flgs | O_NONBLOCK);
+ fcntl(conn->sock, F_SETFD, FD_CLOEXEC);
+
/* check peer credential of connection */
slen = sizeof(ucred);
if (getsockopt(conn->sock, SOL_SOCKET, SO_PEERCRED, &ucred, &slen) < 0) {