'uname -p' prints the value of hw.machine_arch instead of hw.machine.

Reviewed by:		imp
No response from:	-arch
MFC after:		3 weeks
This commit is contained in:
Yoshihiro Takahashi 2002-01-14 12:49:46 +00:00
parent 17181b7b68
commit 1c6d3890d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=89346
2 changed files with 18 additions and 8 deletions

View file

@ -65,9 +65,7 @@ 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
Writes out the same value as
.Fl m .
This option is provided for backward compatibility with SVR4.
Write the type of the machine processor architecture to standard output.
.It Fl r
Write the current release level of the operating system
to standard output.

View file

@ -62,9 +62,10 @@ main(argc, argv)
{
#define MFLAG 0x01
#define NFLAG 0x02
#define RFLAG 0x04
#define SFLAG 0x08
#define VFLAG 0x10
#define PFLAG 0x04
#define RFLAG 0x08
#define SFLAG 0x10
#define VFLAG 0x20
u_int flags;
int ch, mib[2];
size_t len, tlen;
@ -77,13 +78,15 @@ main(argc, argv)
case 'a':
flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG);
break;
case 'p':
case 'm':
flags |= MFLAG;
break;
case 'n':
flags |= NFLAG;
break;
case 'p':
flags |= PFLAG;
break;
case 'r':
flags |= RFLAG;
break;
@ -157,6 +160,15 @@ main(argc, argv)
(void)printf("%s%.*s", prefix, (int)len, buf);
prefix = " ";
}
if (flags & PFLAG) {
mib[0] = CTL_HW;
mib[1] = HW_MACHINE_ARCH;
len = sizeof(buf);
if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
err(1, "sysctl");
(void)printf("%s%.*s", prefix, (int)len, buf);
prefix = " ";
}
(void)printf("\n");
exit (0);
}
@ -164,6 +176,6 @@ main(argc, argv)
void
usage()
{
(void)fprintf(stderr, "usage: uname [-amnrsv]\n");
(void)fprintf(stderr, "usage: uname [-amnprsv]\n");
exit(1);
}