linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: [patch] compile udevd with klibc
Date: Mon, 09 Feb 2004 04:41:15 +0000	[thread overview]
Message-ID: <20040209044115.GA11755@vrfy.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

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?


thanks,
Kay

[-- Attachment #2: 03-udevd-klibc.patch --]
[-- Type: text/plain, Size: 4364 bytes --]

diff -Nru a/Makefile b/Makefile
--- a/Makefile	Mon Feb  9 05:06:07 2004
+++ b/Makefile	Mon Feb  9 05:06:07 2004
@@ -157,7 +157,6 @@
 		-I$(LINUX_INCLUDE_DIR)
 	LIB_OBJS =
 	LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
-	UDEVD =
 else
 	WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
 	CRT0 =
@@ -165,12 +164,11 @@
 	CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
 	LIB_OBJS = -lc
 	LDFLAGS =
-	UDEVD = $(DAEMON)
 endif
 
 CFLAGS += -I$(PWD)/libsysfs
 
-all: $(ROOT) $(SENDER) $(UDEVD) $(HELPER)
+all: $(ROOT) $(SENDER) $(DAEMON) $(HELPER)
 	@extras="$(EXTRAS)" ; for target in $$extras ; do \
 		echo $$target ; \
 		$(MAKE) prefix=$(prefix) \
diff -Nru a/klibc/klibc/Makefile b/klibc/klibc/Makefile
--- a/klibc/klibc/Makefile	Mon Feb  9 05:06:07 2004
+++ b/klibc/klibc/Makefile	Mon Feb  9 05:06:07 2004
@@ -23,7 +23,7 @@
 	  fwrite.o fwrite2.o fputc.o fputs.o puts.o \
 	  sleep.o usleep.o raise.o abort.o assert.o alarm.o pause.o \
 	  __signal.o signal.o bsd_signal.o siglist.o siglongjmp.o \
-	  sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
+	  sigaction.o siginterrupt.o sigpending.o sigprocmask.o sigsuspend.o \
 	  brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o getpagesize.o \
 	  memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
 	  memmove.o \
diff -Nru a/klibc/klibc/include/signal.h b/klibc/klibc/include/signal.h
--- a/klibc/klibc/include/signal.h	Mon Feb  9 05:06:07 2004
+++ b/klibc/klibc/include/signal.h	Mon Feb  9 05:06:07 2004
@@ -67,6 +67,7 @@
 __extern __sighandler_t signal(int, __sighandler_t);
 __extern __sighandler_t bsd_signal(int, __sighandler_t);
 __extern int sigaction(int, const struct sigaction *, struct sigaction *);
+__extern int siginterrupt(int, int);
 __extern int sigprocmask(int, const sigset_t *, sigset_t *);
 __extern int sigpending(sigset_t *);
 __extern int sigsuspend(const sigset_t *);
diff -Nru a/klibc/klibc/siginterrupt.c b/klibc/klibc/siginterrupt.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/klibc/klibc/siginterrupt.c	Mon Feb  9 05:06:07 2004
@@ -0,0 +1,21 @@
+/*
+ * siginterrupt.c
+ */
+
+#include <signal.h>
+
+int siginterrupt(int sig, int flag) {
+  int ret;
+  struct sigaction act;
+
+  sigaction(sig, 0, &act);
+
+  if (flag)
+    act.sa_flags &= ~SA_RESTART;
+  else
+    act.sa_flags |= SA_RESTART;
+
+  ret = sigaction(sig, &act, 0);
+
+  return ret;
+}
diff -Nru a/klibc/klibc/signal.c b/klibc/klibc/signal.c
--- a/klibc/klibc/signal.c	Mon Feb  9 05:06:07 2004
+++ b/klibc/klibc/signal.c	Mon Feb  9 05:06:07 2004
@@ -7,5 +7,5 @@
 __sighandler_t signal(int signum, __sighandler_t handler)
 {
   /* Linux/SysV signal() semantics */
-  return __signal(signum, handler, SA_RESETHAND);
+  return __signal(signum, handler, SA_NODEFER);
 }
diff -Nru a/udevd.c b/udevd.c
--- a/udevd.c	Mon Feb  9 05:06:07 2004
+++ b/udevd.c	Mon Feb  9 05:06:07 2004
@@ -108,14 +108,18 @@
 static void udev_run(struct hotplug_msg *msg)
 {
 	pid_t pid;
-	setenv("ACTION", msg->action, 1);
-	setenv("DEVPATH", msg->devpath, 1);
+	char action[32];
+	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();
 	switch (pid) {
 	case 0:
 		/* child */
-		execl(UDEV_BIN, "udev", msg->subsystem, NULL);
+		execle(UDEV_BIN, "udev", msg->subsystem, NULL, env);
 		dbg("exec of child failed");
 		exit(1);
 		break;
@@ -282,6 +286,7 @@
 
 	init_logging("udevd");
 
+	/* set signal handler */
 	signal(SIGINT, sig_handler);
 	signal(SIGTERM, sig_handler);
 	signal(SIGALRM, sig_handler);
@@ -304,7 +309,7 @@
 	}
 
 	/* 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) {
 		dbg("bind failed\n");
 		goto exit;
diff -Nru a/udevsend.c b/udevsend.c
--- a/udevsend.c	Mon Feb  9 05:06:07 2004
+++ b/udevsend.c	Mon Feb  9 05:06:07 2004
@@ -174,7 +174,7 @@
 	/* If we can't send, try to start daemon and resend message */
 	loop = UDEVSEND_CONNECT_RETRY;
 	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) {
 			retval = 0;
 			goto close_and_exit;

             reply	other threads:[~2004-02-09  4:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-09  4:41 Kay Sievers [this message]
2004-02-09 23:30 ` [patch] compile udevd with klibc Kay Sievers
2004-02-11 22:31 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040209044115.GA11755@vrfy.org \
    --to=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).