aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwkj <devnull@localhost>2005-01-07 17:38:08 +0000
committerwkj <devnull@localhost>2005-01-07 17:38:08 +0000
commit8a830ad0906b8a488aa2a7743bce168fd0332a1e (patch)
tree96800a3ccd14dbe76b893f30559065134e0cb799 /src
parentb4135f04f136150b27a89876d51797ba2a8a78c0 (diff)
downloadplan9port-8a830ad0906b8a488aa2a7743bce168fd0332a1e.tar.gz
plan9port-8a830ad0906b8a488aa2a7743bce168fd0332a1e.tar.bz2
plan9port-8a830ad0906b8a488aa2a7743bce168fd0332a1e.zip
First pass at supporting FreeBSD 5.x.
I do not yet have a way of testing this.
Diffstat (limited to 'src')
-rw-r--r--src/cmd/auxstats/FreeBSD.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/cmd/auxstats/FreeBSD.c b/src/cmd/auxstats/FreeBSD.c
index d881ad86..2d0fd57e 100644
--- a/src/cmd/auxstats/FreeBSD.c
+++ b/src/cmd/auxstats/FreeBSD.c
@@ -18,6 +18,8 @@
#include <bio.h>
#include "dat.h"
+/* XXX: #if __FreeBSD_version */
+
void xapm(int);
void xloadavg(int);
void xcpu(int);
@@ -104,9 +106,15 @@ xnet(int first)
out = in = outb = inb = err = 0;
addr = (ulong)TAILQ_FIRST(&ifnethead);
while(addr){
+#if __FreeBSD_version < 500000
if(kread(addr, (char*)&ifnet, sizeof ifnet) < 0
|| kread((ulong)ifnet.if_name, name, 16) < 0)
return;
+#else
+ if(kread(addr, (char*)&ifnet, sizeof ifnet) < 0
+ || kread((ulong)ifnet.if_dname, name, 16) < 0)
+ return;
+#endif
name[15] = 0;
addr = (ulong)TAILQ_NEXT(&ifnet, if_link);
out += ifnet.if_opackets;
@@ -124,6 +132,28 @@ xnet(int first)
Bprint(&bout, "etherb %lud 1000000\n", inb+outb);
}
+#if __FreeBSD_version >= 500000
+int
+xacpi(int first)
+{
+ int rv;
+ int val, len;
+
+ len = sizeof(val);
+ rv = sysctlbyname("hw.acpi.battery.life", &val, &len, nil, 0);
+ if(rv != 0)
+ return -1;
+ Bprint(&bout, "battery =%d 100\n", val);
+ return 0;
+}
+#else
+int
+xacpi(int first)
+{
+ return -1;
+}
+#endif
+
void
xapm(int first)
{
@@ -131,10 +161,14 @@ xapm(int first)
struct apm_info ai;
if(first){
+ xacpi(first);
fd = open("/dev/apm", OREAD);
return;
}
+ if(xacpi(0) >= 0)
+ return;
+
if(ioctl(fd, APMIO_GETINFO, &ai) < 0)
return;