summaryrefslogtreecommitdiff
path: root/udevd.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-11-12 06:18:28 +0100
committerGreg KH <gregkh@suse.de>2005-04-26 22:24:30 -0700
commit13f24d596c5638443ffc7bc48c10a66758335c74 (patch)
treedb4de22cc3a09aa5a553f9ba2aa8e471b365f5b9 /udevd.c
parentc6478ec1e128f0a92c2123ed110a651b88d43569 (diff)
[PATCH] remove udev_lib dependency from udevsend, which makes it smaller
Diffstat (limited to 'udevd.c')
-rw-r--r--udevd.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/udevd.c b/udevd.c
index 12fbe1725f..43f3f0324b 100644
--- a/udevd.c
+++ b/udevd.c
@@ -43,6 +43,9 @@
#include "udevd.h"
#include "logging.h"
+/* global variables*/
+static int udevsendsock;
+
static int pipefds[2];
static unsigned long long expected_seqnum = 0;
static volatile int sigchilds_waiting;
@@ -127,6 +130,7 @@ static void udev_run(struct hotplug_msg *msg)
switch (pid) {
case 0:
/* child */
+ close(udevsendsock);
execle(udev_bin, "udev", msg->subsystem, NULL, msg->envp);
dbg("exec of child failed");
_exit(1);
@@ -397,7 +401,7 @@ static void user_sighandler(void)
int main(int argc, char *argv[], char *envp[])
{
- int ssock, maxsockplus;
+ int maxsockplus;
struct sockaddr_un saddr;
socklen_t addrlen;
int retval, fd;
@@ -476,28 +480,21 @@ int main(int argc, char *argv[], char *envp[])
strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
- ssock = socket(AF_LOCAL, SOCK_DGRAM, 0);
- if (ssock == -1) {
+ udevsendsock = socket(AF_LOCAL, SOCK_DGRAM, 0);
+ if (udevsendsock == -1) {
dbg("error getting socket, exit");
exit(1);
}
- set_cloexec_flag(ssock, 1);
-
/* the bind takes care of ensuring only one copy running */
- retval = bind(ssock, (struct sockaddr *) &saddr, addrlen);
+ retval = bind(udevsendsock, (struct sockaddr *) &saddr, addrlen);
if (retval < 0) {
dbg("bind failed, exit");
goto exit;
}
- retval = fcntl(ssock, F_SETFD, FD_CLOEXEC);
- if (retval < 0) {
- dbg("error fcntl on ssock: %s", strerror(errno));
- exit(1);
- }
/* enable receiving of the sender credentials */
- setsockopt(ssock, SOL_SOCKET, SO_PASSCRED, &feature_on, sizeof(feature_on));
+ setsockopt(udevsendsock, SOL_SOCKET, SO_PASSCRED, &feature_on, sizeof(feature_on));
/* possible override of udev binary, used for testing */
udev_bin = getenv("UDEV_BIN");
@@ -507,9 +504,9 @@ int main(int argc, char *argv[], char *envp[])
udev_bin = UDEV_BIN;
FD_ZERO(&readfds);
- FD_SET(ssock, &readfds);
+ FD_SET(udevsendsock, &readfds);
FD_SET(pipefds[0], &readfds);
- maxsockplus = ssock+1;
+ maxsockplus = udevsendsock+1;
while (1) {
fd_set workreadfds = readfds;
retval = select(maxsockplus, &workreadfds, NULL, NULL, NULL);
@@ -520,8 +517,8 @@ int main(int argc, char *argv[], char *envp[])
continue;
}
- if (FD_ISSET(ssock, &workreadfds))
- handle_udevsend_msg(ssock);
+ if (FD_ISSET(udevsendsock, &workreadfds))
+ handle_udevsend_msg(udevsendsock);
if (FD_ISSET(pipefds[0], &workreadfds))
user_sighandler();
@@ -548,7 +545,7 @@ int main(int argc, char *argv[], char *envp[])
}
}
exit:
- close(ssock);
+ close(udevsendsock);
logging_close();
return 1;
}