75 lines
2.3 KiB
Text
75 lines
2.3 KiB
Text
$NetBSD: patch-aa,v 1.13 2006/06/05 02:35:30 christos Exp $
|
|
|
|
--- bsd/kernel.cc.orig 2006-06-04 22:19:00.000000000 -0400
|
|
+++ bsd/kernel.cc 2006-06-04 22:31:47.000000000 -0400
|
|
@@ -21,6 +21,8 @@
|
|
/* NetBSD pulls in stdio.h via one of the other includes, but
|
|
* the other BSDs don't. */
|
|
# include <stdio.h>
|
|
+#else
|
|
+# define UVM
|
|
#endif
|
|
|
|
#include <fcntl.h>
|
|
@@ -115,6 +117,13 @@
|
|
// in __NetBSD_Version__ for us if needed.
|
|
#if defined(XOSVIEW_NETBSD) && defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106010000)
|
|
#define NETBSD_1_6A
|
|
+#ifdef HW_DISKSTATS
|
|
+static int dmib[3] = {CTL_HW, HW_DISKSTATS, sizeof(struct disk_sysctl)};
|
|
+#endif
|
|
+#ifdef HW_IOSTATS
|
|
+static int dmib[3] = {CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl)};
|
|
+#include <sys/iostat.h>
|
|
+#endif
|
|
#endif
|
|
|
|
#include "general.h"
|
|
@@ -773,13 +782,12 @@
|
|
#ifdef NETBSD_1_6A
|
|
// Do a sysctl with a NULL data pointer to get the size that would
|
|
// have been returned, and use that to figure out # drives.
|
|
- int mib[3] = {CTL_HW, HW_DISKSTATS, sizeof(struct disk_sysctl)};
|
|
size_t size;
|
|
- if (sysctl(mib, 3, NULL, &size, NULL, 0) < 0) {
|
|
+ if (sysctl(dmib, 3, NULL, &size, NULL, 0) < 0) {
|
|
warnx("!!! The DiskMeter sysctl failed. Disabling DiskMeter.");
|
|
return 0;
|
|
}
|
|
- NetBSD_N_Drives = size / sizeof(struct disk_sysctl);
|
|
+ NetBSD_N_Drives = size / dmib[2];
|
|
return 1;
|
|
#endif
|
|
return ValidSymbol(DISKLIST_SYM_INDEX);
|
|
@@ -816,19 +824,28 @@
|
|
#else
|
|
#if defined(NETBSD_1_6A)
|
|
// Use the new sysctl to do this for us.
|
|
- int mib[3] = {CTL_HW, HW_DISKSTATS, sizeof(struct disk_sysctl)};
|
|
- size_t sysctl_sz = NetBSD_N_Drives * sizeof(struct disk_sysctl);
|
|
+ size_t sysctl_sz = NetBSD_N_Drives * dmib[2];
|
|
+#ifdef HW_DISKSTATS
|
|
struct disk_sysctl drive_stats[NetBSD_N_Drives];
|
|
+#endif
|
|
+#ifdef HW_IOSTATS
|
|
+ struct io_sysctl drive_stats[NetBSD_N_Drives];
|
|
+#endif
|
|
|
|
// Do the sysctl.
|
|
- if (sysctl(mib, 3, drive_stats, &sysctl_sz, NULL, 0) < 0) {
|
|
+ if (sysctl(dmib, 3, drive_stats, &sysctl_sz, NULL, 0) < 0) {
|
|
err(1, "sysctl hw.diskstats failed");
|
|
}
|
|
|
|
// Now accumulate the total.
|
|
unsigned long long xferred = 0;
|
|
for (unsigned int i = 0; i < NetBSD_N_Drives; i++) {
|
|
+#ifdef HW_DISKSTATS
|
|
xferred += drive_stats[i].dk_rbytes + drive_stats[i].dk_wbytes;
|
|
+#endif
|
|
+#ifdef HW_IOSTATS
|
|
+ xferred += drive_stats[i].rbytes + drive_stats[i].wbytes;
|
|
+#endif
|
|
}
|
|
*bytesXferred = xferred;
|
|
#else
|