hammer2 - Add debug ioctl
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 31 Mar 2014 01:42:25 +0000 (18:42 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 31 Mar 2014 01:42:25 +0000 (18:42 -0700)
* Add a a debugging command to dump the in-memory chain topology.

sbin/hammer2/cmd_debug.c
sbin/hammer2/hammer2.h
sbin/hammer2/main.c

index b19f7a4..c73f35d 100644 (file)
@@ -631,6 +631,22 @@ cmd_hash(int ac, const char **av)
        return(0);
 }
 
+int
+cmd_chaindump(const char *path)
+{
+       int dummy = 0;
+       int fd;
+
+       fd = open(path, O_RDONLY);
+       if (fd >= 0) {
+               ioctl(fd, HAMMER2IOC_DEBUG_DUMP, &dummy);
+               close(fd);
+       } else {
+               fprintf(stderr, "unable to open %s\n", path);
+       }
+       return 0;
+}
+
 
 static
 void
index 9d81c0d..2b2c1fa 100644 (file)
@@ -134,6 +134,7 @@ int cmd_stat(int ac, const char **av);
 int cmd_leaf(const char *sel_path);
 int cmd_shell(const char *hostname);
 int cmd_debugspan(const char *hostname);
+int cmd_chaindump(const char *path);
 int cmd_show(const char *devpath, int dofreemap);
 int cmd_rsainit(const char *dir_path);
 int cmd_rsaenc(const char **keys, int nkeys);
index be1a62c..0e83047 100644 (file)
@@ -149,6 +149,11 @@ main(int ac, char **av)
                        usage(1);
                }
                ecode = cmd_remote_connect(sel_path, av[1]);
+       } else if (strcmp(av[0], "chaindump") == 0) {
+               if (ac < 2)
+                       ecode = cmd_chaindump(".");
+               else
+                       ecode = cmd_chaindump(av[1]);
        } else if (strcmp(av[0], "debugspan") == 0) {
                /*
                 * Debug connection to the target hammer2 service and run