Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/fstat Add rnd ops.



details:   https://anonhg.NetBSD.org/src/rev/3ecffdc07c06
branches:  trunk
changeset: 342590:3ecffdc07c06
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Dec 30 18:15:38 2015 +0000

description:
Add rnd ops.

diffstat:

 usr.bin/fstat/misc.c |  50 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 41 insertions(+), 9 deletions(-)

diffs (91 lines):

diff -r ad11f1fe7535 -r 3ecffdc07c06 usr.bin/fstat/misc.c
--- a/usr.bin/fstat/misc.c      Wed Dec 30 17:57:20 2015 +0000
+++ b/usr.bin/fstat/misc.c      Wed Dec 30 18:15:38 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.14 2014/08/10 16:44:37 tls Exp $    */
+/*     $NetBSD: misc.c,v 1.15 2015/12/30 18:15:38 christos Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: misc.c,v 1.14 2014/08/10 16:44:37 tls Exp $");
+__RCSID("$NetBSD: misc.c,v 1.15 2015/12/30 18:15:38 christos Exp $");
 
 #define _KMEMUSER
 #include <stdbool.h>
@@ -87,19 +87,21 @@
     { .n_name = "pipeops" },
 #define NL_PUTTER      9
     { .n_name = "putter_fileops", },
-#define NL_SEM         10
+#define NL_RND         10
+    { .n_name = "rnd_fileops", },
+#define NL_SEM         11
     { .n_name = "semops", },
-#define NL_SOCKET      11
+#define NL_SOCKET      12
     { .n_name = "socketops" },
-#define NL_SVR4_NET    12
+#define NL_SVR4_NET    13
     { .n_name = "svr4_netops" },
-#define NL_SVR4_32_NET 13
+#define NL_SVR4_32_NET 14
     { .n_name = "svr4_32_netops" },
-#define NL_TAP         14
+#define NL_TAP         15
     { .n_name = "tap_fileops", },
-#define NL_VNOPS       15
+#define NL_VNOPS       16
     { .n_name = "vnops" },
-#define NL_XENEVT      16
+#define NL_XENEVT      17
     { .n_name = "xenevt_fileops" },
 #define NL_MAX         18
     { .n_name = NULL }
@@ -182,6 +184,34 @@
 }
 
 static int
+p_rnd(struct file *f)
+{
+       struct cprng_strong {
+               char cs_name[16];
+               int  cs_flags;
+               /*...*/
+       } str;
+       struct rnd_ctx {
+               struct cprng_strong *rc_cprng;
+               bool rc_hard;
+       } ctx;
+       char buf[1024];
+
+       if (!KVM_READ(f->f_data, &ctx, sizeof(ctx))) {
+               dprintf("can't read rnd_ctx at %p for pid %d", f->f_data, Pid);
+               return 0;
+       }
+       if (!KVM_READ(ctx.rc_cprng, &str, sizeof(str))) {
+               dprintf("can't read cprng_strong at %p for pid %d", f->f_data,\
+                   Pid);
+               return 0;
+       }
+       snprintb(buf, sizeof(buf), CPRNG_FMT, str.cs_flags);
+       (void)printf("* rnd \"%s\" flags %s\n", str.cs_name, buf);
+       return 0;
+}
+
+static int
 p_kqueue(struct file *f)
 {
        struct kqueue kq;
@@ -225,6 +255,8 @@
                return p_mqueue(f);
        case NL_KQUEUE:
                return p_kqueue(f);
+       case NL_RND:
+               return p_rnd(f);
        case NL_SEM:
                return p_sem(f);
        case NL_TAP:



Home | Main Index | Thread Index | Old Index