CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Introduced udev with patches to remove accept4() call until glibc update
[ports/cubox-arm.git] / udev / pre-accept4-kernel.patch
CommitLineData
70126a0c
RM
1diff -urN a/src/udev-ctrl.c b/src/udev-ctrl.c
2--- a/src/udev-ctrl.c 2011-10-09 17:10:32.000000000 -0600
3+++ b/src/udev-ctrl.c 2011-10-25 15:11:09.000000000 -0600
4@@ -15,6 +15,7 @@
5 #include <stddef.h>
6 #include <string.h>
7 #include <unistd.h>
8+#include <fcntl.h>
9 #include <sys/types.h>
10 #include <sys/poll.h>
11 #include <sys/socket.h>
12@@ -182,6 +183,7 @@
13 struct ucred ucred;
14 socklen_t slen;
15 const int on = 1;
16+ int flgs;
17
18 conn = calloc(1, sizeof(struct udev_ctrl_connection));
19 if (conn == NULL)
20@@ -189,13 +191,19 @@
21 conn->refcount = 1;
22 conn->uctrl = uctrl;
23
24- conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
25+ //conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
26+ conn->sock = accept(uctrl->sock, NULL, NULL);
27 if (conn->sock < 0) {
28 if (errno != EINTR)
29 err(uctrl->udev, "unable to receive ctrl connection: %m\n");
30 goto err;
31 }
32
33+ // Since we don't have accept4
34+ flgs = fcntl(conn->sock, F_GETFL, NULL);
35+ if(flgs >= 0) fcntl(conn->sock, F_SETFL, flgs | O_NONBLOCK);
36+ fcntl(conn->sock, F_SETFD, FD_CLOEXEC);
37+
38 /* check peer credential of connection */
39 slen = sizeof(ucred);
40 if (getsockopt(conn->sock, SOL_SOCKET, SO_PEERCRED, &ucred, &slen) < 0) {
41