source: patches/coreutils-8.27-uname-1.patch@ 352dce0

systemd
Last change on this file since 352dce0 was 9edf96a, checked in by William Harrington <kb0iic@…>, 8 years ago

Update Coreutils to 8.27.

  • Property mode set to 100644
File size: 4.9 KB
RevLine 
[1ca50e7]1Submitted By: Jim Gifford <jim at cross-lfs dot org>
2Date: 2010-07-26
3Initial Package Version: 5.97
4Upstream Status: Not Accepted
5Origin: Gentoo - http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/coreutils
6Description: Display CPU Information from /proc/cpuinfo or /proc/sysinfo
7
8Rediffed for 7.1 by Jim Gifford
9Rediffed for 7.5 by Jim Gifford
10Rediffed for 8.4 by Joe Ciccone
11Rediffed for 8.9 by Joe Ciccone
12Rediffed for 8.16 by Jonathan Norman - 2012-06-10
13Rediffed for 8.19 by William Harrington - 2012-08-27
14Renamed for 8.20 by William Harrington - 2012-11-01
15Rediffed for 8.21 by William Harrington 2013-05-31
16Renamed for 8.22 by William Harrington - 2013-12-14
17Renamed for 8.23 by William Harrington - 2014-10-30
[9edf96a]18Renamed for 8.27 by William Harrington - 2017-05-24
[1ca50e7]19
20diff -Naur coreutils-8.21.orig/src/uname.c coreutils-8.21/src/uname.c
21--- coreutils-8.21.orig/src/uname.c 2013-01-31 00:46:24.000000000 +0000
22+++ coreutils-8.21/src/uname.c 2013-05-31 13:41:32.683326834 +0000
23@@ -49,6 +49,11 @@
24 # include <mach-o/arch.h>
25 #endif
26
27+#if defined (__linux__)
28+# define USE_PROCINFO
29+# define UNAME_HARDWARE_PLATFORM
30+#endif
31+
32 #include "system.h"
33 #include "error.h"
34 #include "quote.h"
35@@ -153,6 +158,117 @@
36 exit (status);
37 }
38
39+#if defined(USE_PROCINFO)
40+
41+# if defined(__s390__) || defined(__s390x__)
42+# define CPUINFO_FILE "/proc/sysinfo"
43+# define CPUINFO_FORMAT "%64[^\t :]%*[ :]%256[^\n]%c"
44+# else
45+# define CPUINFO_FILE "/proc/cpuinfo"
46+# define CPUINFO_FORMAT "%64[^\t:]\t:%256[^\n]%c"
47+# endif
48+
49+# define PROCINFO_PROCESSOR 0
50+# define PROCINFO_HARDWARE_PLATFORM 1
51+
52+static void __eat_cpuinfo_space(char *buf)
53+{
54+ /* first eat trailing space */
55+ char *tmp = buf + strlen(buf) - 1;
56+ while (tmp > buf && isspace(*tmp))
57+ *tmp-- = '\0';
58+ /* then eat leading space */
59+ tmp = buf;
60+ while (*tmp && isspace(*tmp))
61+ tmp++;
62+ if (tmp != buf)
63+ memmove(buf, tmp, strlen(tmp)+1);
64+ /* finally collapse whitespace */
65+ tmp = buf;
66+ while (tmp[0] && tmp[1]) {
67+ if (isspace(tmp[0]) && isspace(tmp[1])) {
68+ memmove(tmp, tmp+1, strlen(tmp));
69+ continue;
70+ }
71+ ++tmp;
72+ }
73+}
74+
75+static int __linux_procinfo (int x, char *fstr, size_t s)
76+{
77+ FILE *fp;
78+
79+ char *procinfo_keys[] = {
80+ /* --processor --hardware-platform */
81+ #if defined(__alpha__)
82+ "cpu model", "system type"
83+ #elif defined(__arm__)
84+ "Processor", "Hardware"
85+ #elif defined(__avr32__)
86+ "processor", "cpu family"
87+ #elif defined(__bfin__)
88+ "CPU", "BOARD Name"
89+ #elif defined(__cris__)
90+ "cpu", "cpu model"
91+ #elif defined(__frv__)
92+ "CPU-Core", "System"
93+ #elif defined(__i386__) || defined(__x86_64__)
94+ "model name", "vendor_id"
95+ #elif defined(__ia64__)
96+ "family", "vendor"
97+ #elif defined(__hppa__)
98+ "cpu", "model"
99+ #elif defined(__m68k__)
100+ "CPU", "MMU"
101+ #elif defined(__mips__)
102+ "cpu model", "system type"
103+ #elif defined(__powerpc__) || defined(__powerpc64__)
104+ "cpu", "machine"
105+ #elif defined(__s390__) || defined(__s390x__)
106+ "Type", "Manufacturer"
107+ #elif defined(__sh__)
108+ "cpu type", "machine"
109+ #elif defined(sparc) || defined(__sparc__)
110+ "type", "cpu"
111+ #elif defined(__vax__)
112+ "cpu type", "cpu"
113+ #else
114+ "unknown", "unknown"
115+ #endif
116+ };
117+
118+ if ((fp = fopen(CPUINFO_FILE, "r")) != NULL) {
119+ char key[65], value[257], eol, *ret = NULL;
120+
121+ while (fscanf(fp, CPUINFO_FORMAT, key, value, &eol) != EOF) {
122+ __eat_cpuinfo_space(key);
123+ if (!strcmp(key, procinfo_keys[x])) {
124+ __eat_cpuinfo_space(value);
125+ ret = value;
126+ break;
127+ }
128+ if (eol != '\n') {
129+ /* we need two fscanf's here in case the previous
130+ * length limit caused us to read right up to the
131+ * newline ... doing "%*[^\n]\n" wont eat the newline
132+ */
133+ fscanf(fp, "%*[^\n]");
134+ fscanf(fp, "\n");
135+ }
136+ }
137+ fclose(fp);
138+
139+ if (ret) {
140+ strncpy(fstr, ret, s);
141+ return 0;
142+ }
143+ }
144+
145+ return -1;
146+}
147+
148+#endif
149+
150 /* Print ELEMENT, preceded by a space if something has already been
151 printed. */
152
153@@ -300,10 +416,14 @@
154 if (toprint & PRINT_PROCESSOR)
155 {
156 char const *element = unknown;
157-#if HAVE_SYSINFO && defined SI_ARCHITECTURE
158+#if ( HAVE_SYSINFO && defined SI_ARCHITECTURE ) || defined(USE_PROCINFO)
159 {
160 static char processor[257];
161+#if defined(USE_PROCINFO)
162+ if (0 <= __linux_procinfo (PROCINFO_PROCESSOR, processor, sizeof processor))
163+#else
164 if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
165+#endif
166 element = processor;
167 }
168 #endif
169@@ -356,9 +476,13 @@
170 if (element == unknown)
171 {
172 static char hardware_platform[257];
173+#if defined(USE_PROCINFO)
174+ if (0 <= __linux_procinfo (PROCINFO_HARDWARE_PLATFORM, hardware_platform, sizeof hardware_platform))
175+#else
176 size_t s = sizeof hardware_platform;
177 static int mib[] = { CTL_HW, UNAME_HARDWARE_PLATFORM };
178 if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0)
179+#endif
180 element = hardware_platform;
181 }
182 #endif
Note: See TracBrowser for help on using the repository browser.