Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 88380 Details for
Bug 135562
uname -a no longer prints hardware platform in Linux
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add UNAME_HARDWARE_PLATFORM back for linux systems
003_all_coreutils-gentoo-uname.patch (text/plain), 3.54 KB, created by
Joshua Kinard
on 2006-06-04 13:57:03 UTC
(
hide
)
Description:
Add UNAME_HARDWARE_PLATFORM back for linux systems
Filename:
MIME Type:
Creator:
Joshua Kinard
Created:
2006-06-04 13:57:03 UTC
Size:
3.54 KB
patch
obsolete
>diff -Naurp coreutils-5.96.orig/src/uname.c coreutils-5.96/src/uname.c >--- coreutils-5.96.orig/src/uname.c 2005-09-15 15:57:04 -0400 >+++ coreutils-5.96/src/uname.c 2006-06-04 21:03:58 -0400 >@@ -51,6 +51,11 @@ > # include <mach-o/arch.h> > #endif > >+#if defined (__linux__) >+# define USE_PROCINFO >+# define UNAME_HARDWARE_PLATFORM >+#endif >+ > #include "system.h" > #include "error.h" > #include "quote.h" >@@ -138,6 +143,95 @@ Print certain system information. With > exit (status); > } > >+#if defined(USE_PROCINFO) >+ >+# if defined(__s390__) || defined(__s390x__) >+# define CPUINFO_FILE "/proc/sysinfo" >+# define CPUINFO_FORMAT "%[^\t :]%*[ :]%[^\n]\n" >+# else >+# define CPUINFO_FILE "/proc/cpuinfo" >+# define CPUINFO_FORMAT "%[^\t:]\t:%[^\n]\n" >+# endif >+ >+# define PROCINFO_ARCHITECTURE 0 >+# define PROCINFO_HARDWARE_PLATFORM 1 >+ >+static void __eat_cpuinfo_space(char *buf) >+{ >+ /* first eat trailing space */ >+ char *tmp = buf + strlen(buf) - 1; >+ while (tmp > buf && isspace(*tmp)) >+ *tmp-- = '\0'; >+ /* then eat leading space */ >+ tmp = buf; >+ while (*tmp && isspace(*tmp)) >+ *tmp++; >+ if (tmp != buf) >+ memmove(buf, tmp, strlen(tmp)+1); >+} >+ >+static int __linux_procinfo (int x, char *fstr, size_t s) >+{ >+ FILE *fp; >+ >+ char *procinfo_keys[] = { >+ #if defined(__i386__) || defined(__x86_64__) >+ "model name", "vendor_id" >+ #elif defined(__ia64__) >+ "family", "vendor" >+ #elif defined(__alpha__) >+ "cpu model", "system type" >+ #elif defined(sparc) || defined(__sparc__) >+ "type", "cpu" >+ #elif defined(__hppa__) >+ "cpu", "model" >+ #elif defined(__mips__) >+ "cpu model", "system type" >+ #elif defined(__powerpc__) || defined(__powerpc64__) >+ "cpu", "machine" >+ #elif defined(__arm__) >+ "Processor", "Hardware" >+ #elif defined(__s390__) || defined(__s390x__) >+ "Type", "Manufacturer" >+ #elif defined(__sh__) >+ "cpu family", "machine" >+ #elif defined(__m68k__) >+ "CPU", "MMU" >+ #elif defined(__cris__) >+ "cpu", "cpu model" >+ #elif defined(__frv__) >+ "CPU-Core", "System" >+ #elif defined(bfin) >+ "CPU", "BOARD Name" >+ #else >+ "unknown", "unknown" >+ #endif >+ }; >+ >+ if ((fp = fopen(CPUINFO_FILE, "r")) != NULL) { >+ char key[64], value[257], *ret = NULL; >+ >+ while (fscanf(fp, CPUINFO_FORMAT, key, value) != EOF) { >+ __eat_cpuinfo_space(key); >+ if (!strcmp(key, procinfo_keys[x])) { >+ __eat_cpuinfo_space(value); >+ ret = value; >+ break; >+ } >+ } >+ fclose(fp); >+ >+ if (ret) { >+ strncpy(fstr, ret, s); >+ return 0; >+ } >+ } >+ >+ return -1; >+} >+ >+#endif >+ > /* Print ELEMENT, preceded by a space if something has already been > printed. */ > >@@ -250,10 +344,14 @@ main (int argc, char **argv) > if (toprint & PRINT_PROCESSOR) > { > char const *element = unknown; >-#if HAVE_SYSINFO && defined SI_ARCHITECTURE >+#if ( HAVE_SYSINFO && defined SI_ARCHITECTURE ) || defined(USE_PROCINFO) > { > static char processor[257]; >+#if defined(USE_PROCINFO) >+ if (0 <= __linux_procinfo (PROCINFO_ARCHITECTURE, processor, sizeof processor)) >+#else > if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) >+#endif > element = processor; > } > #endif >@@ -306,9 +404,13 @@ main (int argc, char **argv) > if (element == unknown) > { > static char hardware_platform[257]; >+#if defined(USE_PROCINFO) >+ if (0 <= __linux_procinfo (PROCINFO_HARDWARE_PLATFORM, hardware_platform, sizeof hardware_platform)) >+#else > size_t s = sizeof hardware_platform; > static int mib[] = { CTL_HW, UNAME_HARDWARE_PLATFORM }; > if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0) >+#endif > element = hardware_platform; > } > #endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 135562
: 88380