summaryrefslogtreecommitdiffstats
path: root/patches/procps-3.2.8/40_gnu-kbsd-version.dpatch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/procps-3.2.8/40_gnu-kbsd-version.dpatch')
-rw-r--r--patches/procps-3.2.8/40_gnu-kbsd-version.dpatch40
1 files changed, 40 insertions, 0 deletions
diff --git a/patches/procps-3.2.8/40_gnu-kbsd-version.dpatch b/patches/procps-3.2.8/40_gnu-kbsd-version.dpatch
new file mode 100644
index 000000000..79c3ff991
--- /dev/null
+++ b/patches/procps-3.2.8/40_gnu-kbsd-version.dpatch
@@ -0,0 +1,40 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 40_gnu-kbsd-version.dpatch by <csmall@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Rework version parsing so its ok with other OSes
+
+@DPATCH@
+diff -urNad procps-3.2.7~/proc/version.c procps-3.2.7/proc/version.c
+--- procps-3.2.7~/proc/version.c 2006-06-27 08:55:32.000000000 +1000
++++ procps-3.2.7/proc/version.c 2006-06-27 09:02:25.000000000 +1000
+@@ -35,15 +35,23 @@
+
+ static void init_Linux_version(void) __attribute__((constructor));
+ static void init_Linux_version(void) {
+- static struct utsname uts;
+ int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
++ FILE *fp;
++ char buf[256];
+
+- if (uname(&uts) == -1) /* failure implies impending death */
+- exit(1);
+- if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
++ if ( (fp=fopen("/proc/version","r")) == NULL) /* failure implies impending death */
++ exit(1);
++ if (fgets(buf, 256, fp) == NULL) {
++ fprintf(stderr, "Cannot read kernel version from /proc/version\n");
++ fclose(fp);
++ exit(1);
++ }
++ fclose(fp);
++ if (sscanf(buf, "Linux version %d.%d.%d", &x, &y, &z) < 3)
+ fprintf(stderr, /* *very* unlikely to happen by accident */
+ "Non-standard uts for running kernel:\n"
+- "release %s=%d.%d.%d gives version code %d\n",
+- uts.release, x, y, z, LINUX_VERSION(x,y,z));
++ "release %s=%d.%d.%d gives version code %d\n",
++ buf,
++ x, y, z, LINUX_VERSION(x,y,z));
+ linux_version_code = LINUX_VERSION(x, y, z);
+ }