diff options
-rw-r--r-- | usr/src/cmd/prtconf/prtconf.c | 53 | ||||
-rw-r--r-- | usr/src/cmd/prtconf/prtconf.h | 1 | ||||
-rw-r--r-- | usr/src/man/man1m/prtconf.1m | 22 |
3 files changed, 45 insertions, 31 deletions
diff --git a/usr/src/cmd/prtconf/prtconf.c b/usr/src/cmd/prtconf/prtconf.c index cd07ce617d..b7551166cf 100644 --- a/usr/src/cmd/prtconf/prtconf.c +++ b/usr/src/cmd/prtconf/prtconf.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2011, Joyent, Inc. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -166,9 +167,9 @@ cleanup_path(const char *input_path, char *path) */ #ifdef DEBUG -static const char *optstring = "abcdDvVxpPFf:M:dLuC"; +static const char *optstring = "abcdDvVxmpPFf:M:dLuC"; #else -static const char *optstring = "abcdDvVxpPFf:uC"; +static const char *optstring = "abcdDvVxmpPFf:uC"; #endif /* DEBUG */ int @@ -201,6 +202,9 @@ main(int argc, char *argv[]) case 'v': ++opts.o_verbose; break; + case 'm': + ++opts.o_memory; + break; case 'p': ++opts.o_prominfo; break; @@ -338,34 +342,41 @@ main(int argc, char *argv[]) return (0); } - ret = sysinfo(SI_HW_PROVIDER, hw_provider, sizeof (hw_provider)); - /* - * If 0 bytes are returned (the system returns '1', for the \0), - * we're probably on x86, default to "Unknown Hardware Vendor". - */ - if (ret <= 1) { - (void) strncpy(hw_provider, "Unknown Hardware Vendor", + if (!opts.o_memory) { + ret = sysinfo(SI_HW_PROVIDER, hw_provider, sizeof (hw_provider)); + /* + * If 0 bytes are returned (the system returns '1', for the \0), + * we're probably on x86, default to "Unknown Hardware Vendor". + */ + if (ret <= 1) { + (void) strncpy(hw_provider, "Unknown Hardware Vendor", + sizeof (hw_provider)); + } + (void) printf("System Configuration: %s %s\n", hw_provider, + opts.o_uts.machine); } - (void) printf("System Configuration: %s %s\n", hw_provider, - opts.o_uts.machine); pagesize = sysconf(_SC_PAGESIZE); npages = sysconf(_SC_PHYS_PAGES); - (void) printf("Memory size: "); - if (pagesize == -1 || npages == -1) - (void) printf("unable to determine\n"); - else { - const int64_t kbyte = 1024; + if (pagesize == -1 || npages == -1) { + if (opts.o_memory) { + (void) printf("0\n"); + return (1); + } else { + (void) printf("Memory size: unable to determine\n"); + } + } else { const int64_t mbyte = 1024 * 1024; int64_t ii = (int64_t)pagesize * npages; - if (ii >= mbyte) - (void) printf("%ld Megabytes\n", + if (opts.o_memory) { + (void) printf("%ld\n", (long)((ii+mbyte-1) / mbyte)); + return (0); + } else { + (void) printf("Memory size: %ld Megabytes\n", (long)((ii+mbyte-1) / mbyte)); - else - (void) printf("%ld Kilobytes\n", - (long)((ii+kbyte-1) / kbyte)); + } } if (opts.o_prominfo) { diff --git a/usr/src/cmd/prtconf/prtconf.h b/usr/src/cmd/prtconf/prtconf.h index 5f9abe968c..0284cc8af1 100644 --- a/usr/src/cmd/prtconf/prtconf.h +++ b/usr/src/cmd/prtconf/prtconf.h @@ -54,6 +54,7 @@ struct prt_opts { int o_drv_name; int o_pseudodevs; int o_fbname; + int o_memory; int o_noheader; int o_prominfo; int o_productinfo; diff --git a/usr/src/man/man1m/prtconf.1m b/usr/src/man/man1m/prtconf.1m index d8ad9e72ba..acd40eaa63 100644 --- a/usr/src/man/man1m/prtconf.1m +++ b/usr/src/man/man1m/prtconf.1m @@ -4,18 +4,17 @@ .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the .\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH PRTCONF 1M "Jan 11, 2013" +.TH PRTCONF 1M "Mar 24, 2016" .SH NAME prtconf \- print system configuration .SH SYNOPSIS .LP .nf -\fB/usr/sbin/prtconf\fR [\fB-V\fR] | [\fB-F\fR] | [\fB-x\fR] | [\fB-bpv\fR] | [\fB-acdDPv\fR] +\fB/usr/sbin/prtconf\fR [\fB-V\fR] | [\fB-F\fR] | [\fB-m\fr] | [\fB-x\fR] | [\fB-bpv\fR] | [\fB-acdDPv\fR] [\fIdev_path\fR] .fi .SH DESCRIPTION -.sp .LP The \fBprtconf\fR command prints the system configuration information. The output includes the total amount of memory, and the configuration of system @@ -26,7 +25,6 @@ If a device path is specified on the command line for those command options that can take a device path, \fBprtconf\fR will only display information for that device node. .SH OPTIONS -.sp .LP The following options are supported: .sp @@ -100,6 +98,16 @@ console frame buffer on a SUNW,Ultra-30 is \fBffb\fR, the command returns: .sp .ne 2 .na +\fB\fB-m\fR\fR +.ad +.RS 6n +Displays the amount of system memory in megabytes. +This flag must be used by itself. +.RE + + +.ne 2 +.na \fB\fB-p\fR\fR .ad .RS 6n @@ -160,7 +168,6 @@ This flag overrides all other flags and must be used by itself. .RE .SH OPERANDS -.sp .LP The following operands are supported: .sp @@ -174,7 +181,6 @@ which device node configuration information is displayed .RE .SH EXIT STATUS -.sp .LP The following exit values are returned: .sp @@ -199,7 +205,6 @@ non-zero return value means that an error occurred. .RE .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -214,18 +219,15 @@ Interface Stability Unstable .TE .SH SEE ALSO -.sp .LP \fBfuser\fR(1M), \fBmodinfo\fR(1M), \fBsysdef\fR(1M), \fBattributes\fR(5) .sp .LP \fISun Hardware Platform Guide\fR .SS "SPARC Only" -.sp .LP \fBopenprom\fR(7D) .SH NOTES -.sp .LP The output of the \fBprtconf\fR command is highly dependent on the version of the \fBPROM\fR installed in the system. The output will be affected in |