]> git.pld-linux.org Git - packages/coreutils.git/blame - coreutils-uname-cpuinfo.patch
- partially update from fedora, fixes test suite
[packages/coreutils.git] / coreutils-uname-cpuinfo.patch
CommitLineData
aa6f5a2a 1diff -urN coreutils-5.2.1-orig/src/uname.c coreutils-5.2.1/src/uname.c
2--- coreutils-5.2.1-orig/src/uname.c 2005-01-15 19:15:36.193346304 +0100
3+++ coreutils-5.2.1/src/uname.c 2005-01-15 19:19:06.918311240 +0100
4@@ -77,6 +77,8 @@
40ce7301
JB
5 /* Operating system. */
6 #define PRINT_OPERATING_SYSTEM 128
7
8+void __sysinfo_processor_type(char*);
9+
ce369209
AM
10 static struct option const uname_long_options[] =
11 {
12 {"all", no_argument, NULL, 'a'},
aa6f5a2a 13@@ -243,13 +245,9 @@
40ce7301
JB
14 if (toprint & PRINT_PROCESSOR)
15 {
16 char const *element = unknown;
17-#if HAVE_SYSINFO && defined SI_ARCHITECTURE
18- {
6fd30452
AM
19- static char processor[257];
20- if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
21- element = processor;
40ce7301
JB
22- }
23-#endif
24+ char processor[BUFSIZ];
25+ __sysinfo_processor_type(processor);
26+ element = processor;
27 #ifdef UNAME_PROCESSOR
28 if (element == unknown)
29 {
aa6f5a2a 30@@ -294,3 +292,38 @@
40ce7301
JB
31
32 exit (EXIT_SUCCESS);
33 }
34+
35+
36+/* Carlos E. Gorges
37+return vendor_id from proc cpuinfo
38+*/
39+
40+void
41+__sysinfo_processor_type (char* proc_info) {
42+ FILE *ffd;
43+ char *p,temp_string[BUFSIZ],final_string[BUFSIZ]="unknown";
44+
45+ if ((ffd=fopen("/proc/cpuinfo", "r") )!=NULL) {
46+ while ( fscanf(ffd, "%s : ", temp_string) != EOF)
47+ #ifdef __PPC__
48+ if (!(strcmp(temp_string, "machine")))
49+ #endif /* __PPC__ */
50+ #ifdef __sparc__
51+ if (!(strcmp(temp_string, "cpu")))
52+ #endif /* __sparc__ */
aa6f5a2a 53+ #if defined(__i386__) || defined(__x86_64__)
40ce7301
JB
54+ if (!(strcmp(temp_string, "name")))
55+ #endif /* __x86__ */
56+ #ifdef __alpha__
175289ca 57+ if (!(strcmp(temp_string, "model")))
40ce7301
JB
58+ #endif /* __alpha__ */
59+ {
60+ fgets(final_string, 64, ffd);
61+ while (p=strchr(final_string, ' ')) *p='_';
62+ while (p=strchr(final_string, '\n')) *p=0;
63+ break;
64+ }
65+ fclose(ffd);
66+ }
67+ strncpy(proc_info,final_string,BUFSIZ);
68+}
This page took 0.119054 seconds and 4 git commands to generate.