]> git.pld-linux.org Git - packages/coreutils.git/blob - coreutils-uname-cpuinfo.patch
- install su man page
[packages/coreutils.git] / coreutils-uname-cpuinfo.patch
1 diff -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 @@
5  /* Operating system.  */
6  #define PRINT_OPERATING_SYSTEM 128
7  
8 +void __sysinfo_processor_type(char*);
9 +
10  static struct option const uname_long_options[] =
11  {
12    {"all", no_argument, NULL, 'a'},
13 @@ -243,13 +245,9 @@
14    if (toprint & PRINT_PROCESSOR)
15      {
16        char const *element = unknown;
17 -#if HAVE_SYSINFO && defined SI_ARCHITECTURE
18 -      {
19 -        static char processor[257];
20 -        if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
21 -          element = processor;
22 -      }
23 -#endif
24 +      char processor[BUFSIZ];
25 +      __sysinfo_processor_type(processor);
26 +      element = processor;
27  #ifdef UNAME_PROCESSOR
28        if (element == unknown)
29         {
30 @@ -294,3 +292,38 @@
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__ */
53 + #if defined(__i386__) || defined(__x86_64__)
54 +       if (!(strcmp(temp_string, "name"))) 
55 + #endif /* __x86__ */
56 + #ifdef __alpha__
57 +       if (!(strcmp(temp_string, "model"))) 
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.119552 seconds and 3 git commands to generate.