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.
33 #include <sys/utsname.h>
38 char processor[8]; /* for "unknown" */
41 static const char options[] ALIGN1 = "snrvmpa";
42 static const unsigned short utsname_offset[] = {
43 offsetof(uname_info_t, name.sysname),
44 offsetof(uname_info_t, name.nodename),
45 offsetof(uname_info_t, name.release),
46 offsetof(uname_info_t, name.version),
47 offsetof(uname_info_t, name.machine),
48 offsetof(uname_info_t, processor)
51 int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
52 int uname_main(int argc ATTRIBUTE_UNUSED, char **argv)
54 uname_info_t uname_info;
55 #if defined(__sparc__) && defined(__linux__)
56 char *fake_sparc = getenv("FAKE_SPARC");
58 const unsigned short *delta;
61 toprint = getopt32(argv, options);
63 if (argv[optind]) { /* coreutils-6.9 compat */
67 if (toprint & (1 << 6)) { /* -a => all opts on */
71 if (toprint == 0) { /* no opts => -s (sysname) */
75 uname(&uname_info.name); /* never fails */
77 #if defined(__sparc__) && defined(__linux__)
78 if (fake_sparc && (fake_sparc[0] | 0x20) == 'y') {
79 strcpy(uname_info.name.machine, "sparc");
83 strcpy(uname_info.processor, "unknown");
85 delta = utsname_offset;
88 /* printf would not be safe here */
89 fputs((char *)(&uname_info) + *delta, stdout);
95 } while (toprint >>= 1);
98 fflush_stdout_and_exit(EXIT_SUCCESS); /* coreutils-6.9 compat */