summaryrefslogtreecommitdiffstats
path: root/usr.bin/ktrdump
diff options
context:
space:
mode:
authorneel <neel@FreeBSD.org>2014-03-14 22:07:08 +0000
committerneel <neel@FreeBSD.org>2014-03-14 22:07:08 +0000
commit1efaaf7b72943ca2ad57c626f037cd0cf255b87c (patch)
treec4345593ab9cf371f28dd4ff187fb5b222b22775 /usr.bin/ktrdump
parenteeed81169f15bfde49ac6706ec6fdd8fe607e86f (diff)
downloadFreeBSD-src-1efaaf7b72943ca2ad57c626f037cd0cf255b87c.zip
FreeBSD-src-1efaaf7b72943ca2ad57c626f037cd0cf255b87c.tar.gz
Don't dump entries that were modified during the time the KTR buffer was being
copied to userspace. Failing to do this would result in entries at the bottom of the ktrdump output to be more recent than entries at the top. With this change the timestamps are monotonically decreasing going from the top to the bottom of the ktrdump output.
Diffstat (limited to 'usr.bin/ktrdump')
-rw-r--r--usr.bin/ktrdump/ktrdump.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/ktrdump/ktrdump.c b/usr.bin/ktrdump/ktrdump.c
index d55aa72..11e78e9 100644
--- a/usr.bin/ktrdump/ktrdump.c
+++ b/usr.bin/ktrdump/ktrdump.c
@@ -93,7 +93,7 @@ main(int ac, char **av)
char *p;
int version;
int entries;
- int index;
+ int index, index2;
int parm;
int in;
int c;
@@ -182,7 +182,8 @@ main(int ac, char **av)
if (kvm_read(kd, nl[2].n_value, &index, sizeof(index)) == -1 ||
kvm_read(kd, nl[3].n_value, &bufptr,
sizeof(bufptr)) == -1 ||
- kvm_read(kd, bufptr, buf, sizeof(*buf) * entries) == -1)
+ kvm_read(kd, bufptr, buf, sizeof(*buf) * entries) == -1 ||
+ kvm_read(kd, nl[2].n_value, &index2, sizeof(index2)) == -1)
errx(1, "%s", kvm_geterr(kd));
}
@@ -289,7 +290,14 @@ next: if ((c = *p++) == '\0')
parms[4], parms[5]);
fprintf(out, "\n");
if (!iflag) {
- if (i == index)
+ /*
+ * 'index' and 'index2' are the values of 'ktr_idx'
+ * before and after the KTR buffer was copied into
+ * 'buf'. Since the KTR entries between 'index' and
+ * 'index2' were in flux while the KTR buffer was
+ * being copied to userspace we don't dump them.
+ */
+ if (i == index2)
break;
if (--i < 0)
i = entries - 1;
OpenPOWER on IntegriCloud