diff --git a/utils/Makefile b/utils/Makefile index 057e88a0..802fb221 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -81,6 +81,7 @@ memstat.1 \ pager.1 \ passwd.1 \ readlink.1 \ +uname.1 \ SBINS=\ chroot \ diff --git a/utils/uname.1 b/utils/uname.1 new file mode 100644 index 00000000..c117c605 --- /dev/null +++ b/utils/uname.1 @@ -0,0 +1,43 @@ +.Dd January 27, 2017 +.Dt UNAME 1 +.Os +.Sh NAME +.Nm uname +.Nd write system information +.Sh SYNOPSIS +.Nm +.Op Fl amnprstv +.Sh DESCRIPTION +.Nm +writes the system information specified by its options. +If no options were passed, +.Nm +writes the kernel name. +.Pp +The options are as follows: +.Bl -tag -width "12345678" +.It Fl a +Write all available information. +.It Fl m , \-machine +Write the system architecture. +.It Fl n , \-nodename +Write the network node name. +.It Fl p , \-processor +Write the processor architecture. +.It Fl r , \-kernel-release +Write the kernel release version. +.It Fl s , \-kernel-name +Write the kernel name. +.It Fl t , \-tagline +Write the release tagline. +.It Fl v , \-kernel-version +Write the kernel build date. +.El +.Sh EXIT STATUS +.Nm +will exit 0 on success and non-zero otherwise. +.Sh SEE ALSO +.Xr kernelinfo 1 , +.Xr uname 2 , +.Xr machine 4 , +.Xr sortix-release 4 diff --git a/utils/uname.c b/utils/uname.c index ff5704ee..8d177235 100644 --- a/utils/uname.c +++ b/utils/uname.c @@ -14,13 +14,13 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * uname.c - * Print system information. + * Write system information. */ #include +#include #include -#include #include #include #include @@ -55,20 +55,8 @@ static void compact_arguments(int* argc, char*** argv) } } -static void help(FILE* fp, const char* argv0) -{ - fprintf(fp, "Usage: %s [OPTION]...\n", argv0); - fprintf(fp, "Print certain system information.\n"); -} - -static void version(FILE* fp, const char* argv0) -{ - fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR); -} - int main(int argc, char* argv[]) { - const char* argv0 = argv[0]; int flags = 0; for ( int i = 1; i < argc; i++ ) { @@ -92,9 +80,7 @@ int main(int argc, char* argv[]) case 't': flags |= PRINT_TAGLINE; break; case 'v': flags |= PRINT_KERNELVER; break; default: - fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c); - help(stderr, argv0); - exit(1); + errx(1, "unknown option -- '%c'", c); } } else if ( !strcmp(arg, "--kernel-name") ) @@ -111,26 +97,18 @@ int main(int argc, char* argv[]) flags |= PRINT_PROCESSOR; else if ( !strcmp(arg, "--tagline") ) flags |= PRINT_TAGLINE; - else if ( !strcmp(arg, "--help") ) - help(stdout, argv0), exit(0); - else if ( !strcmp(arg, "--version") ) - version(stdout, argv0), exit(0); else - { - fprintf(stderr, "%s: unknown option: %s\n", argv0, arg); - help(stderr, argv0); - exit(1); - } + errx(1, "unknown option: %s", arg); } compact_arguments(&argc, &argv); if ( 1 < argc ) - error(1, 0, "extra operand"); + errx(1, "extra operand"); static struct utsname utsname; if ( uname(&utsname) < 0 ) - error(1, errno, "uname"); + err(1,"uname"); if ( !flags ) flags = PRINT_KERNELNAME;