2005-04-21 16:53:53 +02:00
|
|
|
/* uname() - get system info Author: Kees J. Bot
|
|
|
|
* 7 Nov 1994
|
|
|
|
* Returns information about the Minix system. Alas most
|
|
|
|
* of it is gathered at compile time, so machine is wrong, and
|
|
|
|
* release and version become wrong if not recompiled.
|
|
|
|
* More chip types and Minix versions need to be added.
|
|
|
|
*/
|
|
|
|
#define uname _uname
|
|
|
|
#define open _open
|
|
|
|
#define read _read
|
|
|
|
#define close _close
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <minix/config.h>
|
2005-06-17 10:53:33 +02:00
|
|
|
#include <minix/com.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <minix/minlib.h>
|
|
|
|
|
|
|
|
int uname(name) struct utsname *name;
|
|
|
|
{
|
|
|
|
int hf, n, err;
|
2005-06-17 10:53:33 +02:00
|
|
|
struct kinfo kinfo;
|
2005-04-21 16:53:53 +02:00
|
|
|
char *nl;
|
|
|
|
|
|
|
|
/* Read the node name from /etc/hostname.file. */
|
|
|
|
if ((hf = open("/etc/hostname.file", O_RDONLY)) < 0) {
|
|
|
|
if (errno != ENOENT) return(-1);
|
|
|
|
strcpy(name->nodename, "noname");
|
|
|
|
} else {
|
|
|
|
n = read(hf, name->nodename, sizeof(name->nodename) - 1);
|
|
|
|
err = errno;
|
|
|
|
close(hf);
|
|
|
|
errno = err;
|
|
|
|
if (n < 0) return(-1);
|
|
|
|
name->nodename[n] = 0;
|
|
|
|
if ((nl = strchr(name->nodename, '\n')) != NULL) {
|
|
|
|
memset(nl, 0, (name->nodename + sizeof(name->nodename)) - nl);
|
|
|
|
}
|
|
|
|
}
|
2005-06-17 10:53:33 +02:00
|
|
|
|
|
|
|
getsysinfo(PM_PROC_NR, SI_KINFO, &kinfo);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
strcpy(name->sysname, "Minix");
|
2005-06-17 10:53:33 +02:00
|
|
|
strcpy(name->release, kinfo.release);
|
|
|
|
strcpy(name->version, kinfo.version);
|
2005-04-21 16:53:53 +02:00
|
|
|
#if (CHIP == INTEL)
|
|
|
|
name->machine[0] = 'i';
|
|
|
|
strcpy(name->machine + 1, itoa(getprocessor()));
|
|
|
|
#if _WORD_SIZE == 4
|
|
|
|
strcpy(name->arch, "i386");
|
|
|
|
#else
|
|
|
|
strcpy(name->arch, "i86");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return(0);
|
|
|
|
}
|