Skip to contentSkip to conversation

sysklogd: fix build on musl

PATCH New Thomas Petazzoni 2 participants 4 messages Nov 28, 2016 – Dec 6, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysklogd: fix build on musl

This commit add a stack of small patches that make sysklogd build fine with the musl C library. Build with uClibc and glibc has been tested with those patches applied as well.

The first patch is slightly rework (better description and capital letter to the title) in preparation for upstream submission.

Fixes:

http://autobuild.buildroot.net/results/8fa2bf73f983330884bce2e5ac31e01dee112ba9/

---
 ...01-Replace-deprecated-union-wait-with-int.patch | 28 ++++++++
 ...01-replace-deprecated-union-wait-with-int.patch | 25 -------
 .../0002-Fix-improper-header-includes.patch        | 78 ++++++++++++++++++++++
 .../0003-Remove-include-of-linux-time.h.patch      | 50 ++++++++++++++
 ...s-hand-written-klogctl-syscall-implementa.patch | 38 +++++++++++
 .../0005-Add-missing-headers-for-open-flags.patch  | 46 +++++++++++++
 ...006-syslogd.c-rename-dprintf-to-mydprintf.patch | 39 +++++++++++
 7 files changed, 279 insertions(+), 25 deletions(-)
 create mode 100644 package/sysklogd/0001-Replace-deprecated-union-wait-with-int.patch
 delete mode 100644 package/sysklogd/0001-replace-deprecated-union-wait-with-int.patch
 create mode 100644 package/sysklogd/0002-Fix-improper-header-includes.patch
 create mode 100644 package/sysklogd/0003-Remove-include-of-linux-time.h.patch
 create mode 100644 package/sysklogd/0004-Remove-bogus-hand-written-klogctl-syscall-implementa.patch
 create mode 100644 package/sysklogd/0005-Add-missing-headers-for-open-flags.patch
 create mode 100644 package/sysklogd/0006-syslogd.c-rename-dprintf-to-mydprintf.patch
package/sysklogd/0001-Replace-deprecated-union-wait-with-int.patch new file +28 -0
new file mode 100644
index 0000000..d3fc0dc
@@ -0,0 +1,28 @@
+From 76685540a7882926c54bc0d1a8945b7a6abffe40 Mon Sep 17 00:00:00 2001
+From: Ryan Coe <[email protected]>
+Date: Fri, 7 Oct 2016 19:42:40 -0700
+Subject: [PATCH] Replace deprecated union wait with int
+
+This is needed for compatibility with glibc >= 2.24.
+
+Signed-off-by: Ryan Coe <[email protected]>
+---
+ syslogd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/syslogd.c b/syslogd.c
+index ea73ea5..ace96c8 100644
+--- a/syslogd.c
++++ b/syslogd.c
+@@ -2094,7 +2094,7 @@ void reapchild()
+ 	(void) signal(SIGCHLD, reapchild);	/* reset signal handler -ASP */
+ 	wait ((int *)0);
+ #else
+-	union wait status;
++	int status;
+ 
+ 	while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0)
+ 		;
+-- 
+2.7.4
+
package/sysklogd/0001-replace-deprecated-union-wait-with-int.patch deleted +0 -25
deleted file mode 100644
index c9a30e9..0000000
@@ -1,25 +0,0 @@
-From 86fe87cdf097e6286e76eadcc9c11c79be6258f2 Mon Sep 17 00:00:00 2001
-From: Ryan Coe <[email protected]>
-Date: Fri, 7 Oct 2016 19:42:40 -0700
-Subject: [PATCH 1/1] replace deprecated union wait with int
-
-Signed-off-by: Ryan Coe <[email protected]>
----
- syslogd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/syslogd.c b/syslogd.c
-index ea73ea5da5e935bb8cab328559f950cd3afc2d20..ace96c8be40f50d123120c0586a384a298212245 100644
---- a/syslogd.c
-+++ b/syslogd.c
-@@ -2094,7 +2094,7 @@ void reapchild()
-	(void) signal(SIGCHLD, reapchild);	/* reset signal handler -ASP */
-	wait ((int *)0);
- #else
--	union wait status;
-+	int status;
-
-	while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0)
-		;
---
-2.9.3
package/sysklogd/0002-Fix-improper-header-includes.patch new file +78 -0

78 lines not on this page · raw message

package/sysklogd/0003-Remove-include-of-linux-time.h.patch new file +50 -0

50 lines not on this page · raw message

package/sysklogd/0004-Remove-bogus-hand-written-klogctl-syscall-implementa.patch new file +38 -0
new file mode 100644
index 0000000..548f160
@@ -0,0 +1,38 @@
+From fe92a7a8197241f7d6b28ea3c8214bb6d2c7fda4 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Mon, 28 Nov 2016 23:10:55 +0100
+Subject: [PATCH] Remove bogus hand-written klogctl() syscall implementation
+
+The way the hand-written klogctl() syscall is written cannot compile, as
+_syscall3() is just a function provided by the C library, so calling it
+outside of a function doesn't build.
+
+Since the musl C library provides a klogctl() function, we don't need
+this hand-written system call anyway.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ klogd.c | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/klogd.c b/klogd.c
+index 6505d96..9219671 100644
+--- a/klogd.c
++++ b/klogd.c
+@@ -274,13 +274,8 @@
+ 
+ #define __LIBRARY__
+ #include <linux/unistd.h>
+-#if !defined(__GLIBC__)
+-# define __NR_ksyslog __NR_syslog
+-_syscall3(int,ksyslog,int, type, char *, buf, int, len);
+-#else
+ #include <sys/klog.h>
+ #define ksyslog klogctl
+-#endif
+ 
+ #define LOG_BUFFER_SIZE 4096
+ #define LOG_LINE_LENGTH 1000
+-- 
+2.7.4
+
package/sysklogd/0005-Add-missing-headers-for-open-flags.patch new file +46 -0

46 lines not on this page · raw message

package/sysklogd/0006-syslogd.c-rename-dprintf-to-mydprintf.patch new file +39 -0
new file mode 100644
index 0000000..a1fb533
@@ -0,0 +1,39 @@
+From 68213f6902d291d2ba1626fd950fd7d4a1329d33 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Mon, 28 Nov 2016 23:13:08 +0100
+Subject: [PATCH] syslogd.c: rename dprintf() to mydprintf()
+
+There is an existing kludge in syslogd.c to rename all dprintf()
+function calls and its definition to mydprintf(). This kludge is only
+applied when the glibc C library is used (i.e when GLIBC is defined),
+because glibc also provides a dprintf() function, with a different
+signature and behavior.
+
+However, the musl C library also provides the dprintf() function (with
+the same signature as the one in glibc, obviously), but does not define
+the GLIBC macro, causing a conflicting definition of dprintf.
+
+This commit fixes that by having the rename kludge used unconditionally.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ syslogd.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/syslogd.c b/syslogd.c
+index b5e8054..22a9ed5 100644
+--- a/syslogd.c
++++ b/syslogd.c
+@@ -818,9 +818,7 @@ void doexit(int sig);
+ void init();
+ void cfline(char *line, register struct filed *f);
+ int decode(char *name, struct code *codetab);
+-#if defined(__GLIBC__)
+ #define dprintf mydprintf
+-#endif /* __GLIBC__ */
+ static void dprintf(char *, ...);
+ static void allocate_log(void);
+ void sighup_handler();
+-- 
+2.7.4
+
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 sysklogd: fix build on musl

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

This commit add a stack of small patches that make sysklogd build fine with the musl C library. Build with uClibc and glibc has been tested with those patches applied as well.

Quoted 8 lines

The first patch is slightly rework (better description and capital letter to the title) in preparation for upstream submission.

Fixes:

http://autobuild.buildroot.net/results/8fa2bf73f983330884bce2e5ac31e01dee112ba9/

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH 1/1 sysklogd: fix build on musl

Hello,

Quoted 9 lines · Peter Korsgaard
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

This commit add a stack of small patches that make sysklogd build fine with the musl C library. Build with uClibc and glibc has been tested with those patches applied as well.

The first patch is slightly rework (better description and capital letter to the title) in preparation for upstream submission.

Quoted 7 lines
Quoted 5 lines

Fixes:

http://autobuild.buildroot.net/results/8fa2bf73f983330884bce2e5ac31e01dee112ba9/

Committed, thanks.

Thanks!

But then you didn't wait for me to fix the inappropriate description in the _syscall3() related patch?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 sysklogd: fix build on musl

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 4 lines

Thanks!

But then you didn't wait for me to fix the inappropriate description in the _syscall3() related patch?

Crap, I forgot. Will you send a followup or should I fix it?

Signature · 1 line
Bye, Peter Korsgaard