summaryrefslogtreecommitdiffstats
path: root/lib/libdevstat
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-04-27 08:13:43 +0000
committersjg <sjg@FreeBSD.org>2014-04-27 08:13:43 +0000
commit0c7e03a54c8e7ddc9c3fe710f83d9ca53173692e (patch)
treeb92e741b68057a24e381faa9809f32030d65574c /lib/libdevstat
parentc244fcbcaa61dc2a15995e7dbdf3ae8107bc2111 (diff)
parent69c3e6933b6946c49fe99b19986f018d71621980 (diff)
downloadFreeBSD-src-0c7e03a54c8e7ddc9c3fe710f83d9ca53173692e.zip
FreeBSD-src-0c7e03a54c8e7ddc9c3fe710f83d9ca53173692e.tar.gz
Merge head
Diffstat (limited to 'lib/libdevstat')
-rw-r--r--lib/libdevstat/devstat.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/libdevstat/devstat.c b/lib/libdevstat/devstat.c
index 0f313fb..ade8738 100644
--- a/lib/libdevstat/devstat.c
+++ b/lib/libdevstat/devstat.c
@@ -150,7 +150,9 @@ static const char *namelist[] = {
"_devstat_version",
#define X_DEVICE_STATQ 3
"_device_statq",
-#define X_END 4
+#define X_TIME_UPTIME 4
+ "_time_uptime",
+#define X_END 5
};
/*
@@ -199,7 +201,7 @@ devstat_getnumdevs(kvm_t *kd)
* supplied in a more atmoic manner by the kern.devstat.all sysctl.
* Because this generation sysctl is separate from the statistics sysctl,
* the device list and the generation could change between the time that
- * this function is called and the device list is retreived.
+ * this function is called and the device list is retrieved.
*/
long
devstat_getgeneration(kvm_t *kd)
@@ -349,10 +351,10 @@ devstat_getdevs(kvm_t *kd, struct statinfo *stats)
oldnumdevs = dinfo->numdevs;
oldgeneration = dinfo->generation;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- stats->snap_time = ts.tv_sec + ts.tv_nsec * 1e-9;
-
if (kd == NULL) {
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ stats->snap_time = ts.tv_sec + ts.tv_nsec * 1e-9;
+
/* If this is our first time through, mem_ptr will be null. */
if (dinfo->mem_ptr == NULL) {
/*
@@ -433,6 +435,11 @@ devstat_getdevs(kvm_t *kd, struct statinfo *stats)
}
} else {
+ if (KREADNL(kd, X_TIME_UPTIME, ts.tv_sec) == -1)
+ return(-1);
+ else
+ stats->snap_time = ts.tv_sec;
+
/*
* This is of course non-atomic, but since we are working
* on a core dump, the generation is unlikely to change
OpenPOWER on IntegriCloud