uname(2)
NAME
uname, sysuname - get or set system info
SYNOPSIS
#include <sys/utsname.h>
int uname(struct utsname *name)
#include <sys/types.h>
#define _MINIX_SOURCE 1
#include <sys/utsname.h>
int sysuname(int req, int field, char *value, size_t len)
DESCRIPTION
Uname() fills a struct utsname with system information. This structure
is described in <sys/utsname.h> as follows:
struct utsname {
char sysname[15+1]; /* System name */
char nodename[255+1]; /* Node/Network name */
char release[15+1]; /* O.S. release */
char version[11+1]; /* O.S. version */
char machine[11+1]; /* Machine hardware */
/* Minix additions */
char arch[11+1]; /* Architecture */
char kernel[11+1]; /* Kernel architecture */
char hostname[15+1]; /* Hostname */
char bus[11+1]; /* Bus architecture */
};
The strings are always null terminated, and may be of a different length
then shown here. The first five are required by POSIX, the last four are
Minix specific.
Sysuname() up or downloads a single string from/to an array value of size
len. The req and field arguments are defined as follows:
/* req: Get or set a string. */
#define _UTS_GET 0
#define _UTS_SET 1
/* field: What field to get or set. */
#define _UTS_ARCH 0
#define _UTS_KERNEL 1
#define _UTS_MACHINE 2
#define _UTS_HOSTNAME 3
#define _UTS_NODENAME 4
#define _UTS_RELEASE 5
#define _UTS_VERSION 6
#define _UTS_SYSNAME 7
#define _UTS_BUS 8
#define _UTS_MAX 9 /* Number of strings. */
Only the super-user may use sysuname() to set values, and not even for
all fields.
DIAGNOSTICS
Both functions return -1 on error and set errno. Uname() returns 0 on
success, sysuname() returns the number of bytes copied. You know that
the receiving buffer is large enough if the return value is less than len
or the result is null terminated.
SEE ALSO
uname(1).
AUTHOR
Kees J. Bot (kjb@cs.vu.nl)