1 /* vi: set sw=4 ts=4: */
2 /* uname -- print system information
3 * Copyright (C) 1989-1999 Free Software Foundation, Inc.
5 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 /* BB_AUDIT SUSv3 compliant */
9 /* http://www.opengroup.org/onlinepubs/007904975/utilities/uname.html */
18 -a, --all SunOS rocky8 4.0 sun
20 The default behavior is equivalent to `-s'.
22 David MacKenzie <djm@gnu.ai.mit.edu> */
24 /* Busyboxed by Erik Andersen */
26 /* Further size reductions by Glenn McGrath and Manuel Novoa III. */
28 /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
30 * Now does proper error checking on i/o. Plus some further space savings.
38 #include <sys/types.h>
39 #include <sys/utsname.h>
44 char processor[8]; /* for "unknown" */
47 static const char options[] = "snrvmpa";
48 static const unsigned short int utsname_offset[] = {
49 offsetof(uname_info_t,name.sysname),
50 offsetof(uname_info_t,name.nodename),
51 offsetof(uname_info_t,name.release),
52 offsetof(uname_info_t,name.version),
53 offsetof(uname_info_t,name.machine),
54 offsetof(uname_info_t,processor)
57 int uname_main(int argc, char **argv)
59 uname_info_t uname_info;
60 #if defined(__sparc__) && defined(__linux__)
61 char *fake_sparc = getenv("FAKE_SPARC");
63 const unsigned short int *delta;
66 toprint = getopt32(argc, argv, options);
72 if (toprint & (1 << 6)) {
77 toprint = 1; /* sysname */
80 if (uname(&uname_info.name) == -1) {
81 bb_error_msg_and_die("cannot get system name");
84 #if defined(__sparc__) && defined(__linux__)
85 if ((fake_sparc != NULL)
86 && ((fake_sparc[0] == 'y')
87 || (fake_sparc[0] == 'Y'))) {
88 strcpy(uname_info.name.machine, "sparc");
92 strcpy(uname_info.processor, "unknown");
94 delta = utsname_offset;
97 printf(((char *)(&uname_info)) + *delta);
103 } while (toprint >>= 1);
106 fflush_stdout_and_exit(EXIT_SUCCESS);