1 /* vi: set sw=4 ts=4: */
2 /* uname -- print system information
3 Copyright (C) 1989-1999 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 -a, --all SunOS rocky8 4.0 sun
28 The default behavior is equivalent to `-s'.
30 David MacKenzie <djm@gnu.ai.mit.edu> */
32 /* Busyboxed by Erik Andersen */
34 /* Further size reductions by Glenn McGrath and Manuel Novoa III. */
40 #include <sys/types.h>
41 #include <sys/utsname.h>
47 char processor[8]; /* for "unknown" */
50 static const char options[] = "snrvmpa";
51 static const char flags[] = "\x01\x02\x04\x08\x10\x20\x3f";
52 static const unsigned short int utsname_offset[] = {
53 offsetof(uname_info_t,name.sysname),
54 offsetof(uname_info_t,name.nodename),
55 offsetof(uname_info_t,name.release),
56 offsetof(uname_info_t,name.version),
57 offsetof(uname_info_t,name.machine),
58 offsetof(uname_info_t,processor)
61 int uname_main(int argc, char **argv)
63 uname_info_t uname_info;
65 #if defined(__sparc__) && defined(__linux__)
66 char *fake_sparc = getenv("FAKE_SPARC");
69 const unsigned short int *delta;
73 while ((opt = getopt(argc, argv, options)) != -1) {
74 const char *p = strchr(options,opt);
78 toprint |= flags[(int)(p-options)];
82 toprint = flags[0]; /* sysname */
85 if (uname(&uname_info.name) == -1) {
86 error_msg_and_die("cannot get system name");
89 #if defined(__sparc__) && defined(__linux__)
90 if ((fake_sparc != NULL)
91 && ((fake_sparc[0] == 'y')
92 || (fake_sparc[0] == 'Y'))) {
93 strcpy(uname_info.name.machine, "sparc");
97 strcpy(uname_info.processor, "unknown");
99 for (opt=0,delta=utsname_offset ; toprint ; delta++, toprint >>= 1) {
101 printf("%s%s", (opt++==0)? "": " ", ((char *)(&uname_info)) + *delta);