diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-02-24 00:06:01 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-02-24 00:06:01 +0000 |
commit | 40fb5d0c5bad5a2838b80673a846e31f48f73518 (patch) | |
tree | 288feec4c94f21db3f7bd1b61c324f5fb90db3a8 /usr.bin/uname | |
parent | 4e97ba3c159226abd085885853815789548debd5 (diff) |
add uname -p option, provides detailed cpu info
Diffstat (limited to 'usr.bin/uname')
-rw-r--r-- | usr.bin/uname/uname.1 | 6 | ||||
-rw-r--r-- | usr.bin/uname/uname.c | 25 |
2 files changed, 26 insertions, 5 deletions
diff --git a/usr.bin/uname/uname.1 b/usr.bin/uname/uname.1 index 8df79193321..29ea8b18c9a 100644 --- a/usr.bin/uname/uname.1 +++ b/usr.bin/uname/uname.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: uname.1,v 1.2 1996/06/26 05:42:06 deraadt Exp $ +.\" $OpenBSD: uname.1,v 1.3 1998/02/24 00:05:59 deraadt Exp $ .\" Copyright (c) 1990 The Regents of the University of California. .\" All rights reserved. .\" @@ -40,7 +40,7 @@ .Nd Print operating system name .Sh SYNOPSIS .Nm uname -.Op Fl amnsrv +.Op Fl amnpsrv .Sh DESCRIPTION The .Nm uname @@ -59,6 +59,8 @@ print the machine hardware name. print the nodename (the nodename may be a name that the system is known by to a communications network). +.It Fl p +print the processor type in more detail. .It Fl s print the operating system name. .It Fl r diff --git a/usr.bin/uname/uname.c b/usr.bin/uname/uname.c index 998262c74ba..441a2ffa730 100644 --- a/usr.bin/uname/uname.c +++ b/usr.bin/uname/uname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uname.c,v 1.2 1996/06/26 05:42:07 deraadt Exp $ */ +/* $OpenBSD: uname.c,v 1.3 1998/02/24 00:06:00 deraadt Exp $ */ /* * Copyright (c) 1994 Winning Strategies, Inc. @@ -32,13 +32,15 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: uname.c,v 1.2 1996/06/26 05:42:07 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: uname.c,v 1.3 1998/02/24 00:06:00 deraadt Exp $"; #endif /* not lint */ +#include <sys/param.h> #include <stdio.h> #include <locale.h> #include <unistd.h> #include <sys/utsname.h> +#include <sys/sysctl.h> #include <err.h> static void usage(); @@ -49,6 +51,7 @@ static void usage(); #define PRINT_VERSION 0x08 #define PRINT_MACHINE 0x10 #define PRINT_ALL 0x1f +#define PRINT_PROCESSOR 0x20 int main(argc, argv) @@ -62,7 +65,7 @@ main(argc, argv) setlocale(LC_ALL, ""); - while ((c = getopt(argc,argv,"amnrsv")) != -1 ) { + while ((c = getopt(argc,argv,"amnrsvp")) != -1 ) { switch ( c ) { case 'a': print_mask |= PRINT_ALL; @@ -82,6 +85,9 @@ main(argc, argv) case 'v': print_mask |= PRINT_VERSION; break; + case 'p': + print_mask |= PRINT_PROCESSOR; + break; default: usage(); /* NOTREACHED */ @@ -122,6 +128,19 @@ main(argc, argv) if (space++) putchar(' '); fputs(u.machine, stdout); } + if (print_mask & PRINT_PROCESSOR) { + char buf[1024]; + size_t len; + int mib[2]; + + if (space++) putchar(' '); + mib[0] = CTL_HW; + mib[1] = HW_MODEL; + len = sizeof(buf); + if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) + err(1, "sysctl"); + printf("%.*s", len, buf); + } putchar('\n'); exit(0); |