LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File sysklogd-1.4.1-sysmap-prior-to-2.5.patch of Package syslogd.363 (Project openSUSE:12.1:Update)

From: Jeff Mahoney <jeffm@suse.com>
Subject: klogd: Silence System.map and symbol lookup warnings with modern kernels
References: bnc#505421

 klogd complains about not being able to parse the version of System.map and
 about not being able to load the kernel module symbol table.

 Since kernels starting with 2.5 accurately report their own symbol table in
 Oopses, this is no longer necessary. The warnings are a harmless annoyance,
 but an annoyance nonetheless.

 This patch detects if the running kernel is newer newer than 2.5.0 and
 disables the symbol lookup on startup, thus avoiding the warnings.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 klogd.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

--- klogd.c
+++ klogd.c	2009-08-12 12:19:17.333901686 +0000
@@ -275,6 +275,8 @@ _syscall3(int,ksyslog,int, type, char *,
 #define ksyslog klogctl
 #endif
 
+#include <sys/utsname.h>
+
 #define LOG_BUFFER_SIZE 4096
 #define LOG_LINE_LENGTH 1000
 
@@ -999,6 +1001,23 @@ static void SetBufSize(void)
 	}
 }
 
+#ifndef KERNEL_VERSION
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif
+
+static int
+need_lookup(void)
+{
+	struct utsname utsname;
+	int major, minor, patch;
+	if (uname(&utsname) < 0) {
+		Syslog(LOG_ERR, "Cannot get kernel version information.");
+		return 0;
+	}
+	sscanf(utsname.release, "%d.%d.%d", &major, &minor, &patch);
+
+	return (KERNEL_VERSION(major, minor, patch) < KERNEL_VERSION(2,5,0));
+}
 
 int main(argc, argv)
 
@@ -1166,6 +1185,9 @@ int main(argc, argv)
 	else
 		openlog("kernel", 0, LOG_KERN);
 
+	/* We don't need lookups on kernels > 2.4 */
+	if (symbol_lookup)
+		symbol_lookup = need_lookup();
 
 	/* Handle one-shot logging. */
 	if ( one_shot )