Module Name: src
Committed By: christos
Date: Sun Nov 25 15:30:29 UTC 2012
Modified Files:
src/usr.bin/fstat: misc.c
Log Message:
support printing rnd descriptor info
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/fstat/misc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/fstat/misc.c
diff -u src/usr.bin/fstat/misc.c:1.10 src/usr.bin/fstat/misc.c:1.11
--- src/usr.bin/fstat/misc.c:1.10 Sat Nov 24 20:05:49 2012
+++ src/usr.bin/fstat/misc.c Sun Nov 25 10:30:28 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.10 2012/11/25 01:05:49 christos Exp $ */
+/* $NetBSD: misc.c,v 1.11 2012/11/25 15:30:28 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: misc.c,v 1.10 2012/11/25 01:05:49 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.11 2012/11/25 15:30:28 christos Exp $");
#define _KMEMUSER
#include <stdbool.h>
@@ -50,6 +50,10 @@ __RCSID("$NetBSD: misc.c,v 1.10 2012/11/
#include <sys/file.h>
#define copyout_t int
#include <sys/ksem.h>
+#define _LIB_LIBKERN_LIBKERN_H_
+#define mutex_enter(a)
+#define mutex_exit(a)
+#include <sys/cprng.h>
#undef _KERNEL
#include <sys/vnode.h>
#include <sys/mount.h>
@@ -57,6 +61,7 @@ __RCSID("$NetBSD: misc.c,v 1.10 2012/11/
#include <net/bpfdesc.h>
#include <err.h>
+#include <util.h>
#include <string.h>
#include <kvm.h>
#include "fstat.h"
@@ -96,7 +101,9 @@ static struct nlist nl[] = {
{ .n_name = "vnops" },
#define NL_XENEVT 16
{ .n_name = "xenevt_fileops" },
-#define NL_MAX 17
+#define NL_RND 17
+ { .n_name = "rnd_fileops" },
+#define NL_MAX 18
{ .n_name = NULL }
};
@@ -189,6 +196,35 @@ p_kqueue(struct file *f)
return 0;
}
+static int
+p_rnd(struct file *f)
+{
+ rp_ctx_t rp;
+
+ if (!KVM_READ(f->f_data, &rp, sizeof(rp))) {
+ dprintf("can't read rnd at %p for pid %d", f->f_data, Pid);
+ return 0;
+ }
+ (void)printf("* rnd ");
+ if (rp.hard)
+ printf("bytesonkey=%d, ", rp.bytesonkey);
+ if (rp.cprng) {
+ cprng_strong_t cprng;
+ if (!KVM_READ(rp.cprng, &cprng, sizeof(cprng))) {
+ dprintf("can't read rnd cprng at %p for pid %d",
+ rp.cprng, Pid);
+ } else {
+ char buf[128];
+ snprintb(buf, sizeof(buf), CPRNG_FMT, cprng.flags);
+ (void)printf("name=%s, serial=%d%s, flags=%s\n",
+ cprng.name, cprng.entropy_serial,
+ cprng.reseed_pending ? ", reseed" : "", buf);
+ return 0;
+ }
+ }
+ printf("\n");
+ return 0;
+}
int
pmisc(struct file *f, const char *name)
{
@@ -222,6 +258,8 @@ pmisc(struct file *f, const char *name)
return p_kqueue(f);
case NL_SEM:
return p_sem(f);
+ case NL_RND:
+ return p_rnd(f);
case NL_TAP:
printf("* tap %lu\n", (unsigned long)(intptr_t)f->f_data);
return 0;
@@ -229,7 +267,7 @@ pmisc(struct file *f, const char *name)
printf("* crypto %p\n", f->f_data);
return 0;
case NL_MAX:
- printf("* %s %p\n", name, f->f_data);
+ printf("* %s ops=%p %p\n", name, f->f_ops, f->f_data);
return 0;
default:
printf("* %s %p\n", nl[i].n_name, f->f_data);