[293] in NetBSD-Development
Re: short questions related to olc
daemon@ATHENA.MIT.EDU (Greg Hudson)
Wed Dec 21 03:06:54 1994
To: Greg Hudson <ghudson@MIT.EDU>
Cc: yoav@MIT.EDU, netbsd-dev@MIT.EDU
In-Reply-To: Your message of "Wed, 21 Dec 1994 03:00:06 EST."
<9412210800.AA12472@maze.MIT.EDU>
Date: Wed, 21 Dec 1994 03:06:32 EST
From: Greg Hudson <ghudson@MIT.EDU>
>> c) which versions (I assume /kern/something will do that)
> /kern/version has two versions, the first of which is relevant.
> "uname -r" or sysctl()
Let's try finishing that:
/kern/version has two lines, the first of which is relevant.
"/usr/bin/uname -r" gives the kernel version number, as does
"/usr/sbin/sysctl -n kern.version | head -1 | awk '{print $2;}'"
In C code:
#include <sys/sysctl.h>
int ctl[2] = { CTL_KERN, KERN_VERSION };
char *buf;
size_t len;
sysctl(ctl, 2, NULL, &len, NULL, 0);
buf = malloc(len);
if (!buf)
die("horribly");
sysctl(ctl, 2, buf, &len, NULL, 0);
Also, my C code for getting physical memory was wrong, and should read:
#include <sys/sysctl.h>
int ctl[2] = { CTL_HW, HW_PHYSMEM }, mem;
size_t len = sizeof(int);
sysctl(ctl, 2, &mem, &len, NULL, 0);