uname.c revision cc22b130832529204c03214239a57aaadd05101f
/*
* CDDL HEADER START
*
* 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
* 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]
*
* CDDL HEADER END
*/
/*
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#define __EXTENSIONS__
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/systeminfo.h>
static void usage(void);
/* ARGSUSED */
int
{
char *nodename;
char *optstring = "asnrpvmiS:X";
int Xflg = 0;
char fmt_string[] = " %.*s";
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
switch (optlet) {
case 'a':
pflg++;
iflg++;
break;
case 's':
sflg++;
break;
case 'n':
nflg++;
break;
case 'r':
rflg++;
break;
case 'v':
vflg++;
break;
case 'm':
mflg++;
break;
case 'p':
pflg++;
break;
case 'i':
iflg++;
break;
case 'S':
Sflg++;
break;
case 'X':
Xflg++;
break;
case '?':
errflg++;
}
usage();
if ((Sflg > 1) ||
Xflg))) {
usage();
}
/* If we're changing the system name */
if (Sflg) {
"uname: name must be <= %d letters\n"),
SYS_NMLN-1);
exit(1);
}
"uname: error in setting name: %s\n"),
exit(1);
}
return (0);
}
/*
* "uname -s" is the default
*/
sflg++;
if (sflg) {
fs = fmt_string;
}
if (nflg) {
fs = fmt_string;
}
if (rflg) {
fs = fmt_string;
}
if (vflg) {
fs = fmt_string;
}
if (mflg) {
fs = fmt_string;
}
if (pflg) {
"uname: sysinfo failed\n"));
exit(1);
}
fs = fmt_string;
}
if (iflg) {
"uname: sysinfo failed\n"));
exit(1);
}
fs = fmt_string;
}
if (Xflg) {
int val;
/* Not availible on Solaris so hardcode the output */
/* Serialization is not supported in 2.6, so hard code output */
}
(void) putchar('\n');
return (0);
}
static void
usage(void)
{
{
"usage: uname [-snrvmapiX]\n"
" uname [-S system_name]\n"));
}
exit(1);
}