Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/net/lib/libshmif add -h which prints only the bus h...



details:   https://anonhg.NetBSD.org/src/rev/d9654d424df6
branches:  trunk
changeset: 758801:d9654d424df6
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Nov 15 22:45:23 2010 +0000

description:
add -h which prints only the bus header info

diffstat:

 sys/rump/net/lib/libshmif/dumpbus.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (57 lines):

diff -r d5ca3a1e518d -r d9654d424df6 sys/rump/net/lib/libshmif/dumpbus.c
--- a/sys/rump/net/lib/libshmif/dumpbus.c       Mon Nov 15 22:42:36 2010 +0000
+++ b/sys/rump/net/lib/libshmif/dumpbus.c       Mon Nov 15 22:45:23 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dumpbus.c,v 1.8 2010/08/13 11:45:47 pooka Exp $        */
+/*     $NetBSD: dumpbus.c,v 1.9 2010/11/15 22:45:23 pooka Exp $        */
 
 /*
  * Little utility to convert shmif bus traffic to a pcap file
@@ -26,7 +26,7 @@
 usage(void)
 {
 
-       fprintf(stderr, "usage: a.out [-p pcapfile] buspath\n");
+       fprintf(stderr, "usage: a.out [-h] [-p pcapfile] buspath\n");
        exit(1);
 }
 
@@ -42,9 +42,13 @@
        int fd, pfd, i, ch;
        int bonus;
        char *buf;
+       bool hflag = false;
 
-       while ((ch = getopt(argc, argv, "p:")) != -1) {
+       while ((ch = getopt(argc, argv, "hp:")) != -1) {
                switch (ch) {
+               case 'h':
+                       hflag = true;
+                       break;
                case 'p':
                        pcapfile = optarg;
                        break;
@@ -70,11 +74,11 @@
        if (fstat(fd, &sb) == -1)
                err(1, "stat");
 
-       busmem = mmap(NULL, sb.st_size, PROT_READ, MAP_FILE, fd, 0);
+       busmem = mmap(NULL, sb.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0);
        if (busmem == MAP_FAILED)
                err(1, "mmap");
+       bmem = busmem;
 
-       bmem = busmem;
        if (bmem->shm_magic != SHMIF_MAGIC)
                errx(1, "%s not a shmif bus", argv[0]);
        if (bmem->shm_version != SHMIF_VERSION)
@@ -85,6 +89,9 @@
            bmem->shm_version, bmem->shm_lock, bmem->shm_gen,
            bmem->shm_first, bmem->shm_last);
 
+       if (hflag)
+               exit(0);
+
        if (pcapfile) {
                struct pcap_file_header phdr;
 



Home | Main Index | Thread Index | Old Index