1 /* uname(3) - describe the machine. Author: Kees J. Bot
10 #include <sys/types.h>
11 #include <sys/utsname.h>
13 #define uts_get(field, string) \
14 if (sysuname(_UTS_GET, field, name->string, sizeof(name->string)) < 0) \
16 name->string[sizeof(name->string)-1]= 0;
24 /* Get each of the strings with a sysuname call. Null terminate them,
25 * because the buffers in the kernel may grow before this and the
26 * programs are recompiled.
28 uts_get(_UTS_SYSNAME
, sysname
);
29 uts_get(_UTS_NODENAME
, nodename
);
30 uts_get(_UTS_RELEASE
, release
);
31 uts_get(_UTS_VERSION
, version
);
32 uts_get(_UTS_MACHINE
, machine
);
33 uts_get(_UTS_ARCH
, arch
);
35 uts_get(_UTS_KERNEL
, kernel
);
36 uts_get(_UTS_HOSTNAME
, hostname
);
37 uts_get(_UTS_BUS
, bus
);
40 /* Try to read the node name from /etc/hostname.file. This information
41 * should be stored in the kernel.
43 if ((hf
= open("/etc/hostname.file", O_RDONLY
)) < 0) {
44 if (errno
!= ENOENT
) return(-1);
46 n
= read(hf
, name
->nodename
, sizeof(name
->nodename
) - 1);
50 if (n
< 0) return(-1);
51 name
->nodename
[n
] = 0;
52 if ((nl
= strchr(name
->nodename
, '\n')) != NULL
) {
53 memset(nl
, 0, (name
->nodename
+
54 sizeof(name
->nodename
)) - nl
);
61 * $PchId: _uname.c,v 1.4 1995/11/27 20:09:08 philip Exp $