Document kernelinfo(1).

This commit is contained in:
Daniel Roskams 2016-10-01 21:47:19 +08:00 committed by Jonas 'Sortie' Termansen
parent 48c60fd3a2
commit e400e3578e
3 changed files with 44 additions and 31 deletions

View File

@ -75,6 +75,7 @@ xinstall
MANPAGES=\
chkblayout.1 \
kernelinfo.1 \
readlink.1 \
all: $(BINARIES)

36
utils/kernelinfo.1 Normal file
View 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

View File

@ -18,30 +18,16 @@
*/
#include <sys/kernelinfo.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <errno.h>
#include <error.h>
static void help(FILE* fp, const char* argv0)
{
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);
}
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
const char* argv0 = argv[0];
for ( int i = 1; i < argc; i++ )
{
const char* arg = argv[i];
@ -56,21 +42,11 @@ int main(int argc, char* argv[])
while ( (c = *++arg) ) switch ( c )
{
default:
fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c);
help(stderr, argv0);
exit(1);
errx(1, "unknown option -- '%c'\n", c);
}
}
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\n", arg);
}
size_t bufsize = 32;
char* buf = (char*) malloc(bufsize);