mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-04-25 14:50:10 +03:00
[PATCH] compile udevd with klibc
On Mon, Feb 09, 2004 at 05:41:15AM +0100, Kay Sievers wrote: > It seems that today was just another udev-sunday for me :) > > Here is a working patch to compile udevd with klibc. > > It's sweet the static binary takes 6 kbytes and it runs > with only 80 kbytes virtual memory. > > I changed a few peaces and added a siginterrupt.c file to klibc. > We may check with hpa to get the changes upstream? So here is the next try :) hpa, for good reason, didn't like my changes to klibc. He will dump signal() completely from klibc instead, so here we switch to sigaction() and keep udevd working with klibc.
This commit is contained in:
parent
c5118442a1
commit
f8911dbb04
4
Makefile
4
Makefile
@ -157,7 +157,6 @@ ifeq ($(strip $(USE_KLIBC)),true)
|
|||||||
-I$(LINUX_INCLUDE_DIR)
|
-I$(LINUX_INCLUDE_DIR)
|
||||||
LIB_OBJS =
|
LIB_OBJS =
|
||||||
LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
|
LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
|
||||||
UDEVD =
|
|
||||||
else
|
else
|
||||||
WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
|
WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
|
||||||
CRT0 =
|
CRT0 =
|
||||||
@ -165,12 +164,11 @@ else
|
|||||||
CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
|
CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
|
||||||
LIB_OBJS = -lc
|
LIB_OBJS = -lc
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
UDEVD = $(DAEMON)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -I$(PWD)/libsysfs
|
CFLAGS += -I$(PWD)/libsysfs
|
||||||
|
|
||||||
all: $(ROOT) $(SENDER) $(UDEVD) $(HELPER)
|
all: $(ROOT) $(SENDER) $(DAEMON) $(HELPER)
|
||||||
@extras="$(EXTRAS)" ; for target in $$extras ; do \
|
@extras="$(EXTRAS)" ; for target in $$extras ; do \
|
||||||
echo $$target ; \
|
echo $$target ; \
|
||||||
$(MAKE) prefix=$(prefix) \
|
$(MAKE) prefix=$(prefix) \
|
||||||
|
10
udev.c
10
udev.c
@ -47,14 +47,12 @@ int log_ok(void)
|
|||||||
|
|
||||||
static void sig_handler(int signum)
|
static void sig_handler(int signum)
|
||||||
{
|
{
|
||||||
dbg("caught signal %d", signum);
|
|
||||||
switch (signum) {
|
switch (signum) {
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
sysbus_disconnect();
|
sysbus_disconnect();
|
||||||
udevdb_exit();
|
udevdb_exit();
|
||||||
exit(20 + signum);
|
exit(20 + signum);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
dbg("unhandled signal");
|
dbg("unhandled signal");
|
||||||
}
|
}
|
||||||
@ -100,6 +98,7 @@ static int udev_hotplug(int argc, char **argv)
|
|||||||
char *subsystem;
|
char *subsystem;
|
||||||
int retval = -EINVAL;
|
int retval = -EINVAL;
|
||||||
int i;
|
int i;
|
||||||
|
struct sigaction act;
|
||||||
|
|
||||||
action = get_action();
|
action = get_action();
|
||||||
if (!action) {
|
if (!action) {
|
||||||
@ -146,8 +145,11 @@ static int udev_hotplug(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set up a default signal handler for now */
|
/* set up a default signal handler for now */
|
||||||
signal(SIGINT, sig_handler);
|
act.sa_handler = sig_handler;
|
||||||
signal(SIGTERM, sig_handler);
|
sigemptyset (&act.sa_mask);
|
||||||
|
act.sa_flags = SA_RESTART;
|
||||||
|
sigaction(SIGINT, &act, NULL);
|
||||||
|
sigaction(SIGTERM, &act, NULL);
|
||||||
|
|
||||||
/* initialize the naming deamon */
|
/* initialize the naming deamon */
|
||||||
namedev_init();
|
namedev_init();
|
||||||
|
28
udevd.c
28
udevd.c
@ -114,14 +114,18 @@ static void msg_queue_insert(struct hotplug_msg *msg)
|
|||||||
static void udev_run(struct hotplug_msg *msg)
|
static void udev_run(struct hotplug_msg *msg)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
setenv("ACTION", msg->action, 1);
|
char action[32];
|
||||||
setenv("DEVPATH", msg->devpath, 1);
|
char devpath[256];
|
||||||
|
char *env[] = { action, devpath, NULL };
|
||||||
|
|
||||||
|
snprintf(action, sizeof(action), "ACTION=%s", msg->action);
|
||||||
|
snprintf(devpath, sizeof(devpath), "DEVPATH=%s", msg->devpath);
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
switch (pid) {
|
switch (pid) {
|
||||||
case 0:
|
case 0:
|
||||||
/* child */
|
/* child */
|
||||||
execl(UDEV_BIN, "udev", msg->subsystem, NULL);
|
execle(UDEV_BIN, "udev", msg->subsystem, NULL, env);
|
||||||
dbg("exec of child failed");
|
dbg("exec of child failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
@ -285,17 +289,21 @@ int main(int argc, char *argv[])
|
|||||||
struct sockaddr_un saddr;
|
struct sockaddr_un saddr;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
int retval;
|
int retval;
|
||||||
|
struct sigaction act;
|
||||||
|
|
||||||
init_logging("udevd");
|
init_logging("udevd");
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
/* set signal handler */
|
||||||
signal(SIGTERM, sig_handler);
|
act.sa_handler = sig_handler;
|
||||||
signal(SIGALRM, sig_handler);
|
sigemptyset (&act.sa_mask);
|
||||||
signal(SIGCHLD, sig_handler);
|
act.sa_flags = SA_RESTART;
|
||||||
|
sigaction(SIGINT, &act, NULL);
|
||||||
|
sigaction(SIGTERM, &act, NULL);
|
||||||
|
|
||||||
/* we want these two to interrupt system calls */
|
/* we want these two to interrupt system calls */
|
||||||
siginterrupt(SIGALRM, 1);
|
act.sa_flags = 0;
|
||||||
siginterrupt(SIGCHLD, 1);
|
sigaction(SIGALRM, &act, NULL);
|
||||||
|
sigaction(SIGCHLD, &act, NULL);
|
||||||
|
|
||||||
memset(&saddr, 0x00, sizeof(saddr));
|
memset(&saddr, 0x00, sizeof(saddr));
|
||||||
saddr.sun_family = AF_LOCAL;
|
saddr.sun_family = AF_LOCAL;
|
||||||
@ -310,7 +318,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* the bind takes care of ensuring only one copy running */
|
/* the bind takes care of ensuring only one copy running */
|
||||||
retval = bind(ssock, &saddr, addrlen);
|
retval = bind(ssock, (struct sockaddr *) &saddr, addrlen);
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
dbg("bind failed\n");
|
dbg("bind failed\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -179,7 +179,7 @@ int main(int argc, char* argv[])
|
|||||||
/* If we can't send, try to start daemon and resend message */
|
/* If we can't send, try to start daemon and resend message */
|
||||||
loop = UDEVSEND_CONNECT_RETRY;
|
loop = UDEVSEND_CONNECT_RETRY;
|
||||||
while (loop--) {
|
while (loop--) {
|
||||||
retval = sendto(sock, &message, size, 0, (struct sockaddr*)&saddr, addrlen);
|
retval = sendto(sock, &message, size, 0, (struct sockaddr *)&saddr, addrlen);
|
||||||
if (retval != -1) {
|
if (retval != -1) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
goto close_and_exit;
|
goto close_and_exit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user