Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Feb 1998 14:30:02 -0800 (PST)
From:      Steve Price <sprice@hiwaay.net>
To:        freebsd-bugs
Subject:   Re: bin/5826: uname '-p' option
Message-ID:  <199802232230.OAA28159@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/5826; it has been noted by GNATS.

From: Steve Price <sprice@hiwaay.net>
To: alk@East.Sun.COM, freebsd-gnats-submit@FreeBSD.ORG
Cc:  Subject: Re: bin/5826: uname '-p' option
Date: Mon, 23 Feb 1998 16:21:44 -0600

 > I find many SVR4 scripts using the -p option of uname to get
 > BSD uname -m functionality.  Here's a one-line to provide
 > script-compatibility.
 
 Actually I think the intent of the -p option is to show
 the processor type of the machine, at least according to
 a Digital box running OSF1.  Maybe the attached patch 
 would be more appropriate?
 
 Steve
 
 Index: uname.1
 ===================================================================
 RCS file: /u/FreeBSD/cvs/src/usr.bin/uname/uname.1,v
 retrieving revision 1.5
 diff -u -r1.5 uname.1
 --- uname.1	1997/08/20 11:03:54	1.5
 +++ uname.1	1998/02/23 22:17:58
 @@ -39,7 +39,7 @@
  .Nd display information about the system
  .Sh SYNOPSIS
  .Nm
 -.Op Fl amnrsv
 +.Op Fl amnprsv
  .Sh DESCRIPTION
  The
  .Nm
 @@ -54,6 +54,7 @@
  Behave as though the options
  .Fl m ,
  .Fl n ,
 +.Fl p ,
  .Fl r ,
  .Fl s ,
  and
 @@ -63,6 +64,8 @@
  Write the type of the current hardware platform to standard output.
  .It Fl n
  Write the name of the system to standard output.
 +.It Fl p
 +Write the processor type to standard output.
  .It Fl r
  Write the current release level of the operating system
  to standard output.
 Index: uname.c
 ===================================================================
 RCS file: /u/FreeBSD/cvs/src/usr.bin/uname/uname.c,v
 retrieving revision 1.2
 diff -u -r1.2 uname.c
 --- uname.c	1997/03/29 04:33:22	1.2
 +++ uname.c	1998/02/23 22:19:01
 @@ -61,13 +61,14 @@
  #define	RFLAG	0x04
  #define	SFLAG	0x08
  #define	VFLAG	0x10
 +#define	PFLAG   0x20
  	u_int flags;
  	int ch, mib[2];
  	size_t len, tlen;
  	char *p, *prefix, buf[1024];
  
  	flags = 0;
 -	while ((ch = getopt(argc, argv, "amnrsv")) != -1)
 +	while ((ch = getopt(argc, argv, "amnprsv")) != -1)
  		switch(ch) {
  		case 'a':
  			flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG);
 @@ -78,6 +79,9 @@
  		case 'n':
  			flags |= NFLAG;
  			break;
 +		case 'p':
 +			flags |= PFLAG;
 +			break;
  		case 'r':
  			flags |= RFLAG;
  			break;
 @@ -145,6 +149,15 @@
  	if (flags & MFLAG) {
  		mib[0] = CTL_HW;
  		mib[1] = HW_MACHINE;
 +		len = sizeof(buf);
 +		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
 +			err(1, "sysctl");
 +		(void)printf("%s%.*s", prefix, len, buf);
 +		prefix = " ";
 +	}
 +	if (flags & PFLAG) {
 +		mib[0] = CTL_HW;
 +		mib[1] = HW_MODEL;
  		len = sizeof(buf);
  		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
  			err(1, "sysctl");

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199802232230.OAA28159>