diff -u -r ./sh-utils-2.0/src/uname.c ./sh-utils-2.0.thrull/src/uname.c --- ./sh-utils-2.0/src/uname.c Wed Mar 31 07:36:01 1999 +++ ./sh-utils-2.0.thrull/src/uname.c Fri Nov 9 22:27:59 2001 @@ -44,7 +44,7 @@ /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "uname" -#define AUTHORS "David MacKenzie" +#define AUTHORS "David MacKenzie, Igor Popik" static void print_element PARAMS ((unsigned int mask, char *element)); @@ -85,7 +85,38 @@ {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} }; - +#ifdef __linux__ +static +int get_processor(char *processor, int size) +{ + FILE *f; + + f = fopen ("/proc/cpuinfo", "r"); + if (!f) + return -1; + while (!feof (f)) { + char line[255]; + + if (fgets (line, 255, f)) { + char *pos; + + if ((pos = strstr (line, "model name\t")) != NULL || + (pos = strstr (line, "cpu\t")) != NULL ) { + if ((pos = strchr (pos, ':')) != NULL) { + char *nl; + pos += 2; + if ((nl = strchr (pos, '\n')) != NULL) + *nl = '\0'; + strncpy (processor, pos, size); + break; + } + } + } + } + fclose(f); + return 0; +} +#endif void usage (int status) { @@ -184,7 +215,12 @@ if (sysinfo (SI_ARCHITECTURE, processor, sizeof (processor)) == -1) error (1, errno, _("cannot get processor type")); #else +#ifdef __linux__ + if (get_processor(processor, sizeof(processor)) == -1) + strcpy (processor, "unknown"); +#else strcpy (processor, "unknown"); +#endif #endif print_element (PRINT_SYSNAME, name.sysname);