1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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);
}
|