From fa5ca9d6025a8ca4acac3c6505539e2737a87c55 Mon Sep 17 00:00:00 2001 From: glewis Date: Fri, 6 Aug 2004 18:00:53 +0000 Subject: . Add ACPI support. [1] . Make this compile on FreeBSD 4.x. I've hacked the version being committed to actually compile on 4.x. The submitted patch only partially fixed 4.x build problems. [2] PR: 70039 [1], 70041 [2] Submitted by: Roman Bogorodskiy (maintainer) --- sysutils/torsmo/Makefile | 4 --- sysutils/torsmo/files/freebsd.c | 53 +++++++++++++++++++++++++++++------- sysutils/torsmo/files/patch-fs.c | 37 +++++++++++++++++++++++++ sysutils/torsmo/files/patch-torsmo.c | 11 ++++++++ 4 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 sysutils/torsmo/files/patch-fs.c create mode 100644 sysutils/torsmo/files/patch-torsmo.c (limited to 'sysutils') diff --git a/sysutils/torsmo/Makefile b/sysutils/torsmo/Makefile index 060988df4a71..434f4342cafc 100644 --- a/sysutils/torsmo/Makefile +++ b/sysutils/torsmo/Makefile @@ -26,10 +26,6 @@ PORTDOCS= AUTHORS ChangeLog NEWS README .include -.if ${OSVERSION} < 500000 -BROKEN= does not build, use statvfs interface which is only present on FreeBSD 5.0 or newer -.endif - post-extract: @${CP} ${FILESDIR}/freebsd.c ${WRKSRC} diff --git a/sysutils/torsmo/files/freebsd.c b/sysutils/torsmo/files/freebsd.c index d8d65ef73f81..b973050d6b97 100644 --- a/sysutils/torsmo/files/freebsd.c +++ b/sysutils/torsmo/files/freebsd.c @@ -11,11 +11,12 @@ #include #include #include +#include #include -#include -#include #include #include +#include +#include #include #include #include @@ -28,6 +29,7 @@ void net_init(); #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) +#define KELVTOC(x) ((x - 2732) / 10.0) static int getsysctl(char *name, void *ptr, size_t len) { @@ -144,15 +146,15 @@ void update_net_stats() { struct net_stat *ns; double delta; long long r, t, last_recv, last_trans; + struct ifaddrs *ifap, *ifa; + struct if_data *ifd; + /* get delta */ delta = current_update_time - last_update_time; if (delta <= 0.0001) return; - struct ifaddrs *ifap, *ifa; - struct if_data *ifd; - if (getifaddrs(&ifap) < 0) return; @@ -237,7 +239,11 @@ int get_running_processes() { if (kd != NULL) { p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes); for (i = 0; i + #include + #include +-#include + #include + #include + ++#include ++#include ++ + /* TODO: benchmark which is faster, fstatvfs() or pre-opened fd and + * statvfs() (fstatvfs() would handle mounts I think...) */ + +@@ -15,16 +17,16 @@ + + void update_fs_stats() { + unsigned int i; +- struct statvfs s; ++ struct statfs s; + for (i=0; i<16; i++) { + if (fs_stats[i].fd <= 0) + break; + +- fstatvfs(fs_stats[i].fd, &s); ++ fstatfs(fs_stats[i].fd, &s); + +- fs_stats[i].size = (long long) s.f_blocks * s.f_frsize; ++ fs_stats[i].size = (long long) s.f_blocks * s.f_bsize; + /* bfree (root) or bavail (non-roots) ? */ +- fs_stats[i].avail = (long long) s.f_bavail * s.f_frsize; ++ fs_stats[i].avail = (long long) s.f_bavail * s.f_bsize; + } + } + diff --git a/sysutils/torsmo/files/patch-torsmo.c b/sysutils/torsmo/files/patch-torsmo.c new file mode 100644 index 000000000000..c32c6aa662a3 --- /dev/null +++ b/sysutils/torsmo/files/patch-torsmo.c @@ -0,0 +1,11 @@ +--- torsmo.c.orig Thu Aug 5 19:39:06 2004 ++++ torsmo.c Thu Aug 5 19:39:20 2004 +@@ -998,7 +998,7 @@ + } + OBJ(acpitemp) { + /* does anyone have decimals in acpi temperature? */ +- snprintf(p, n, "%d", (int) get_acpi_temperature(obj->data.i)); ++ snprintf(p, n, "%0.1f", (int) get_acpi_temperature(obj->data.i)); + } + OBJ(acpifan) { + snprintf(p, n, "%s", get_acpi_fan()); -- cgit