mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Document kernelinfo(1).
This commit is contained in:
parent
48c60fd3a2
commit
e400e3578e
3 changed files with 44 additions and 31 deletions
|
@ -75,6 +75,7 @@ xinstall
|
||||||
|
|
||||||
MANPAGES=\
|
MANPAGES=\
|
||||||
chkblayout.1 \
|
chkblayout.1 \
|
||||||
|
kernelinfo.1 \
|
||||||
readlink.1 \
|
readlink.1 \
|
||||||
|
|
||||||
all: $(BINARIES)
|
all: $(BINARIES)
|
||||||
|
|
36
utils/kernelinfo.1
Normal file
36
utils/kernelinfo.1
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
.Dd October 01, 2016
|
||||||
|
.Dt KERNELINFO 1
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm kernelinfo
|
||||||
|
.Nd print kernel information
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Op Ar variable ...
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
.Nm
|
||||||
|
prints the specified kernel information.
|
||||||
|
.Pp
|
||||||
|
Possible values for
|
||||||
|
.Ar variable
|
||||||
|
are:
|
||||||
|
.Bl -tag -width builddate
|
||||||
|
.It Sy name
|
||||||
|
The name of the current kernel.
|
||||||
|
.It Sy version
|
||||||
|
The version of the current kernel.
|
||||||
|
.It Sy tagline
|
||||||
|
The tagline (slogan) of the release.
|
||||||
|
.It Sy builddate
|
||||||
|
The date on which the current kernel was built.
|
||||||
|
.It Sy buildtime
|
||||||
|
The time at which the current kernel was built.
|
||||||
|
.It Sy firmware
|
||||||
|
The firmware of the system (e.g. "bios" or "uefi")
|
||||||
|
.El
|
||||||
|
.Sh EXIT STATUS
|
||||||
|
.Nm
|
||||||
|
will exit 0 on success and non-zero otherwise.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr uname 1 ,
|
||||||
|
.Xr kernelinfo 2
|
|
@ -18,30 +18,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/kernelinfo.h>
|
#include <sys/kernelinfo.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
#include <err.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
|
#include <string.h>
|
||||||
static void help(FILE* fp, const char* argv0)
|
#include <stdio.h>
|
||||||
{
|
#include <stdlib.h>
|
||||||
fprintf(fp, "Usage: %s [OPTION]... REQUEST...\n", argv0);
|
|
||||||
fprintf(fp, "Prints a kernel information string.\n");
|
|
||||||
fprintf(fp, "example: %s name\n", argv0);
|
|
||||||
fprintf(fp, "example: %s version\n", argv0);
|
|
||||||
fprintf(fp, "example: %s builddate\n", argv0);
|
|
||||||
fprintf(fp, "example: %s buildtime\n", argv0);
|
|
||||||
}
|
|
||||||
|
|
||||||
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];
|
|
||||||
for ( int i = 1; i < argc; i++ )
|
for ( int i = 1; i < argc; i++ )
|
||||||
{
|
{
|
||||||
const char* arg = argv[i];
|
const char* arg = argv[i];
|
||||||
|
@ -56,21 +42,11 @@ int main(int argc, char* argv[])
|
||||||
while ( (c = *++arg) ) switch ( c )
|
while ( (c = *++arg) ) switch ( c )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c);
|
errx(1, "unknown option -- '%c'\n", c);
|
||||||
help(stderr, argv0);
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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\n", arg);
|
||||||
fprintf(stderr, "%s: unknown option: %s\n", argv0, arg);
|
|
||||||
help(stderr, argv0);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
size_t bufsize = 32;
|
size_t bufsize = 32;
|
||||||
char* buf = (char*) malloc(bufsize);
|
char* buf = (char*) malloc(bufsize);
|
||||||
|
|
Loading…
Reference in a new issue