Skip to contentSkip to conversation

latest klibc for udev

PATCH Kay Sievers 5 participants 9 messages Sep 17, 2004 – Sep 29, 2004 Kbuild

lore
Share & tools
lore
#0 lore raw

This patch make it possible to run udev with the latest klibc.

One patch for the udev/Makefile to match the moved include/ dir. Another one for klibc's string fuctions, that are causing segfaults:

strncpy.c: the while() gets n == -1 and memset() dies strncat.c: cat's only strlen(dest) count of chars from src to dest

Thanks,
Kay

===== Makefile 1.169 vs edited =====

Makefile +2 -2
@@ -140,7 +140,7 @@
 ifeq ($(strip $(USE_KLIBC)),true)
 	KLIBC_BASE	= $(PWD)/klibc
 	KLIBC_DIR	= $(KLIBC_BASE)/klibc
-	INCLUDE_DIR	:= $(KLIBC_DIR)/include
+	INCLUDE_DIR	:= $(KLIBC_BASE)/include
 	LINUX_INCLUDE_DIR	:= $(KERNEL_DIR)/include
 #	LINUX_INCLUDE_DIR	:= $(KLIBC_BASE)/linux/include
 	include $(KLIBC_DIR)/arch/$(ARCH)/MCONFIG
@@ -155,7 +155,7 @@
 		$(OPTFLAGS)				\
 		-D__KLIBC__ -fno-builtin-printf		\
 		-I$(INCLUDE_DIR)			\
-		-I$(KLIBC_DIR)/arch/$(ARCH)/include	\
+		-I$(INCLUDE_DIR)/arch/$(ARCH)		\
 		-I$(INCLUDE_DIR)/bits$(BITSIZE)		\
 		-I$(GCCINCDIR)				\
 		-I$(LINUX_INCLUDE_DIR)
klibc/strncpy.c renamed from klibc-0.177/klibc/strncpy.c +2 -1
@@ -10,7 +10,8 @@ char *strncpy(char *dst, const char *src
   const char *p = src;
   char ch;
 
-  while ( n-- ) {
+  while (n) {
+    n--;
     *q++ = ch = *p++;
     if ( !ch )
       break;
klibc/strncat.c renamed from klibc-0.177/klibc/strncat.c +8 -3
@@ -8,13 +8,18 @@
 char *strncat(char *dst, const char *src, size_t n)
 {
   char *q = strchr(dst, '\0');
+  const char *p = src;
+  char ch;
   size_t nn = q-dst;
 
   if ( __likely(nn <= n) )
-    n = nn;
+    n -= nn;
 
-  memcpy(q, src, n);
-  q[n] = '\0';
+  while (n--) {
+    *q++ = ch = *p++;
+    if ( !ch )
+      break;
+  }
 
   return dst;
 }
#1 lore raw
Quoted 8 lines · Kay Sievers

This patch make it possible to run udev with the latest klibc.

One patch for the udev/Makefile to match the moved include/ dir. Another one for klibc's string fuctions, that are causing segfaults:

strncpy.c: the while() gets n = -1 and memset() dies strncat.c: cat's only strlen(dest) count of chars from src to dest

Thanks. The definition of these functions is pretty bizarre; hence I added strlcpy() and strlcat() as well.

-hpa

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Kay Sievers

Kay -

On Fri, 17 Sep 2004 21:11 you wrote

Quoted 1 line

This patch make it possible to run udev with the latest klibc.

Many thanks for your fast fix. It works fine.

The only development snapshot available on the klibc ftp site is klibc-0.178, and it includes "ash" which does not compile. The udev Makefile calls the Makefile in the klibc root directory, so I patched that to omit ash:
=============

Makefile 2004-09-18 18:41:13.000000000 +0200 renamed from Makefile.orig 2004-09-18 22:27:01.091279104 +0200 +1 -1
@@ -1,5 +1,5 @@
 VERSION := $(shell cat version)
-SUBDIRS = klibc ash ipconfig nfsmount utils kinit gzip
+SUBDIRS = klibc ipconfig nfsmount utils kinit gzip
 
 all:

=============
With that patch and yours, udev-032 with klibc-0.178 compiles and runs OK.

Does your klibc-0.177 have "ash"? If not, perhaps it's a better fit for udev. Either way, the udev package needs to provide or use klibc-0.17x to support the 2.6.9-rc2 kernel.

Thanks,

Bob Barry

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Kay Sievers
Quoted 3 lines · Bob Barry

Does your klibc-0.177 have "ash"? If not, perhaps it's a better fit for udev. Either way, the udev package needs to provide or use klibc-0.17x to support the 2.6.9-rc2 kernel.

That's only true if you're building against raw kernel headers, right? If you build against the latest linux-libc-headers, it should work fine.

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#4 lore raw
In reply to Kay Sievers

Kevin -

Quoted 5 lines · you
Quoted 3 lines

Does your klibc-0.177 have "ash"?  If not, perhaps it's a better fit for udev.  Either way, the udev package needs to provide or use klibc-0.17x to support the 2.6.9-rc2 kernel.

That's only true if you're building against raw kernel headers, right?

What's "that"? Compilation failure of ash?

Quoted 1 line

If you build against the latest linux-libc-headers, it should work fine.

Can you refer me to an explanation of this dependency? Can you give me a URL for appropriate headers?

Thanks,

Bob Barry

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#5 lore raw
In reply to Kay Sievers
Quoted 1 line · Bob Barry

What's "that"? Compilation failure of ash?

No, you said that the udev package needs to "provide klibc-0.17x" the support the 2.6.9-rc2 kernel, and I was disagreeing. That should only be necessary if you are allowing udev/klibc to build against raw kernel headers, instead of sanitized headers. I run udev-032 against 2.6.9-rc2 kernels here and have not had any trouble.

Quoted 1 line

Can you refer me to an explanation of this dependency?

Sorry, I don't know of one. There are many, many threads on the linux-kernel mailing list archives that talk about this issue, though.

Quoted 1 line

Can you give me a URL for appropriate headers?

Google for "linux-libc-headers", it's the first link listed.

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#6 lore raw
In reply to Kay Sievers

Kevin & Kay-

Quoted 5 lines · On Mon, 20 Sep 2004 07:51 Kevin wrote:

...you said that the udev package needs to "provide klibc-0.17x" the support the 2.6.9-rc2 kernel, and I was disagreeing. That should only be necessary if you are allowing udev/klibc to build against raw kernel headers, instead of sanitized headers. I run udev-032 against 2.6.9-rc2 kernels here and have not had any trouble.

I got the latest linux-libc-headers and installed them, and upgraded my glibc from 2.3.2 to 2.3.3, but compilation of klibc still failed under linux-2.6.9-rc2. The failure was always in compilation of ash (which I didn't really want anyway). I finally found that ash requires a recent version of bison; version 1.35 failed, but 1.75 succeeds. Makefile in klibc root directory should test for bison version.

Does udev use ash? Might it be used in future? The udev build would be quicker, and independent of yacc and bison, if ash were not built.

The following script, in same directory as Kay's patches, builds udev with recent klibc:
#!/bin/ksh
rm -rf udev-032
tar xjvf /usr/portage/distfiles/udev-032.tar.bz2
cd udev-032
tar xjvf /usr/portage/distfiles/klibc-0.179.tar.bz2
mv klibc-0.179 klibc
patch -p1 < ../udev-klibc-last-01.patch
patch -p0 < ../klibc-bug-01.patch
ln -s /usr/src/linux-2.6.9-rc2 klibc/linux
make KERNEL_DIR=/usr/src/linux-2.6.9-rc2 USE_KLIBC=true USE_LOGúlse DEBUGúlse

If line "ln -s /usr/src/linux-2.6.9-rc2 klibc/linux" is omitted, script fails despite KERNEL_DIR parameter in make command.

Running
make KERNEL_DIR=/usr/src/linux-2.6.9-rc2 USE_KLIBC=true USE_LOGúlse DEBUGúlse
on unpatched udev-032 fails every time.
Running
make KERNEL_DIR=/usr/src/linux-2.6.9-rc1 USE_KLIBC=true USE_LOGúlse DEBUGúlse
on unpatched udev-032 succeeds.

Thanks,

Bob Barry

-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#7 lore raw
In reply to Kay Sievers
Quoted 6 lines · H. Peter Anvin
Quoted 5 lines · Kay Sievers

This patch make it possible to run udev with the latest klibc.

One patch for the udev/Makefile to match the moved include/ dir. Another one for klibc's string fuctions, that are causing segfaults:

Quoted 6 lines
Quoted 3 lines

strncpy.c: the while() gets n = -1 and memset() dies strncat.c: cat's only strlen(dest) count of chars from src to dest

Thanks. The definition of these functions is pretty bizarre; hence I added strlcpy() and strlcat() as well.

Any reason why this patch hasn't been merged yet (at least as of klibc-0.180)? Without this patch udev-based initramfs' don't work...

Regards,

Jürg

Signature · 13 lines
Jürg Billeter <[email protected]>



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#8 lore raw
In reply to Kay Sievers
Quoted 4 lines · Jürg Billeter

Any reason why this patch hasn't been merged yet (at least as of klibc-0.180)? Without this patch udev-based initramfs' don't work...

Did I miss it? Let me check...

-hpa

-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel