]>
Commit | Line | Data |
---|---|---|
ee6a228f MK |
1 | diff -urNp -x '*.orig' coreutils-8.32.org/src/uname.c coreutils-8.32/src/uname.c |
2 | --- coreutils-8.32.org/src/uname.c 2020-02-04 20:27:08.000000000 +0100 | |
3 | +++ coreutils-8.32/src/uname.c 2021-03-21 00:28:54.006899186 +0100 | |
4 | @@ -86,6 +86,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 | { | |
8165f7ad | 12 | {"all", no_argument, nullptr, 'a'}, |
68608205 JP |
13 | @@ -323,14 +323,12 @@ |
14 | element = "powerpc"; | |
15 | # endif | |
16 | #endif | |
40ce7301 | 17 | -#if HAVE_SYSINFO && defined SI_ARCHITECTURE |
68608205 JP |
18 | if (element == unknown) |
19 | { | |
20 | - static char processor[257]; | |
21 | - if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) | |
22 | - element = processor; | |
23 | + char processor[BUFSIZ]; | |
24 | + __sysinfo_processor_type(processor); | |
25 | + element = processor; | |
26 | } | |
40ce7301 | 27 | -#endif |
40ce7301 JB |
28 | #ifdef UNAME_PROCESSOR |
29 | if (element == unknown) | |
ee6a228f MK |
30 | { |
31 | @@ -374,3 +372,38 @@ main (int argc, char **argv) | |
40ce7301 | 32 | |
ee6a228f | 33 | return EXIT_SUCCESS; |
40ce7301 JB |
34 | } |
35 | + | |
36 | + | |
37 | +/* Carlos E. Gorges | |
38 | +return vendor_id from proc cpuinfo | |
39 | +*/ | |
40 | + | |
41 | +void | |
42 | +__sysinfo_processor_type (char* proc_info) { | |
43 | + FILE *ffd; | |
44 | + char *p,temp_string[BUFSIZ],final_string[BUFSIZ]="unknown"; | |
45 | + | |
46 | + if ((ffd=fopen("/proc/cpuinfo", "r") )!=NULL) { | |
47 | + while ( fscanf(ffd, "%s : ", temp_string) != EOF) | |
48 | + #ifdef __PPC__ | |
49 | + if (!(strcmp(temp_string, "machine"))) | |
50 | + #endif /* __PPC__ */ | |
51 | + #ifdef __sparc__ | |
52 | + if (!(strcmp(temp_string, "cpu"))) | |
53 | + #endif /* __sparc__ */ | |
aa6f5a2a | 54 | + #if defined(__i386__) || defined(__x86_64__) |
40ce7301 JB |
55 | + if (!(strcmp(temp_string, "name"))) |
56 | + #endif /* __x86__ */ | |
57 | + #ifdef __alpha__ | |
175289ca | 58 | + if (!(strcmp(temp_string, "model"))) |
40ce7301 JB |
59 | + #endif /* __alpha__ */ |
60 | + { | |
61 | + fgets(final_string, 64, ffd); | |
62 | + while (p=strchr(final_string, ' ')) *p='_'; | |
63 | + while (p=strchr(final_string, '\n')) *p=0; | |
64 | + break; | |
65 | + } | |
66 | + fclose(ffd); | |
67 | + } | |
68 | + strncpy(proc_info,final_string,BUFSIZ); | |
69 | +} |