mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Document uname(1).
This commit is contained in:
parent
eec161761d
commit
912a5448c5
3 changed files with 50 additions and 28 deletions
|
@ -81,6 +81,7 @@ memstat.1 \
|
||||||
pager.1 \
|
pager.1 \
|
||||||
passwd.1 \
|
passwd.1 \
|
||||||
readlink.1 \
|
readlink.1 \
|
||||||
|
uname.1 \
|
||||||
|
|
||||||
SBINS=\
|
SBINS=\
|
||||||
chroot \
|
chroot \
|
||||||
|
|
43
utils/uname.1
Normal file
43
utils/uname.1
Normal file
|
@ -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
|
|
@ -14,13 +14,13 @@
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* uname.c
|
* uname.c
|
||||||
* Print system information.
|
* Write system information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <error.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -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[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const char* argv0 = argv[0];
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
for ( int i = 1; i < argc; i++ )
|
for ( int i = 1; i < argc; i++ )
|
||||||
{
|
{
|
||||||
|
@ -92,9 +80,7 @@ int main(int argc, char* argv[])
|
||||||
case 't': flags |= PRINT_TAGLINE; break;
|
case 't': flags |= PRINT_TAGLINE; break;
|
||||||
case 'v': flags |= PRINT_KERNELVER; break;
|
case 'v': flags |= PRINT_KERNELVER; break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c);
|
errx(1, "unknown option -- '%c'", c);
|
||||||
help(stderr, argv0);
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !strcmp(arg, "--kernel-name") )
|
else if ( !strcmp(arg, "--kernel-name") )
|
||||||
|
@ -111,26 +97,18 @@ int main(int argc, char* argv[])
|
||||||
flags |= PRINT_PROCESSOR;
|
flags |= PRINT_PROCESSOR;
|
||||||
else if ( !strcmp(arg, "--tagline") )
|
else if ( !strcmp(arg, "--tagline") )
|
||||||
flags |= PRINT_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
|
else
|
||||||
{
|
errx(1, "unknown option: %s", arg);
|
||||||
fprintf(stderr, "%s: unknown option: %s\n", argv0, arg);
|
|
||||||
help(stderr, argv0);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compact_arguments(&argc, &argv);
|
compact_arguments(&argc, &argv);
|
||||||
|
|
||||||
if ( 1 < argc )
|
if ( 1 < argc )
|
||||||
error(1, 0, "extra operand");
|
errx(1, "extra operand");
|
||||||
|
|
||||||
static struct utsname utsname;
|
static struct utsname utsname;
|
||||||
if ( uname(&utsname) < 0 )
|
if ( uname(&utsname) < 0 )
|
||||||
error(1, errno, "uname");
|
err(1,"uname");
|
||||||
|
|
||||||
if ( !flags )
|
if ( !flags )
|
||||||
flags = PRINT_KERNELNAME;
|
flags = PRINT_KERNELNAME;
|
||||||
|
|
Loading…
Add table
Reference in a new issue