[BACK]Return to uname.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / uname

Diff for /src/usr.bin/uname/uname.c between version 1.11 and 1.12

version 1.11, 2009/10/27 23:59:46 version 1.12, 2011/10/21 14:48:02
Line 37 
Line 37 
 #include <locale.h>  #include <locale.h>
 #include <unistd.h>  #include <unistd.h>
 #include <sys/utsname.h>  #include <sys/utsname.h>
 #include <sys/sysctl.h>  
 #include <err.h>  #include <err.h>
   
 static void usage(void);  static void usage(void);
   
 #define PRINT_SYSNAME   0x01  #define PRINT_SYSNAME           0x01
 #define PRINT_NODENAME  0x02  #define PRINT_NODENAME          0x02
 #define PRINT_RELEASE   0x04  #define PRINT_RELEASE           0x04
 #define PRINT_VERSION   0x08  #define PRINT_VERSION           0x08
 #define PRINT_MACHINE   0x10  #define PRINT_MACHINE           0x10
 #define PRINT_ALL       0x1f  #define PRINT_ALL               0x1f
 #define PRINT_PROCESSOR 0x20  #define PRINT_MACHINE_ARCH      0x20
   
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
Line 81 
Line 80 
                         print_mask |= PRINT_VERSION;                          print_mask |= PRINT_VERSION;
                         break;                          break;
                 case 'p':                  case 'p':
                         print_mask |= PRINT_PROCESSOR;                          print_mask |= PRINT_MACHINE_ARCH;
                         break;                          break;
                 default:                  default:
                         usage();                          usage();
Line 123 
Line 122 
                 if (space++) putchar(' ');                  if (space++) putchar(' ');
                 fputs(u.machine, stdout);                  fputs(u.machine, stdout);
         }          }
         if (print_mask & PRINT_PROCESSOR) {          if (print_mask & PRINT_MACHINE_ARCH) {
                 char buf[1024];  
                 size_t len;  
                 int mib[2];  
   
                 if (space++) putchar(' ');                  if (space++) putchar(' ');
                 mib[0] = CTL_HW;                  fputs(MACHINE_ARCH, stdout);
                 mib[1] = HW_MODEL;  
                 len = sizeof(buf);  
                 if (sysctl(mib, 2, buf, &len, NULL, 0) == -1)  
                         err(1, "sysctl");  
                 printf("%.*s", (int)len, buf);  
         }          }
         putchar('\n');          putchar('\n');
   

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12