HAMMER - Implement volume-list command
[dragonfly.git] / sbin / hammer / hammer.c
index e3e150a..88b51c4 100644 (file)
@@ -59,6 +59,7 @@ int RunningIoctl;
 int DidInterrupt;
 int BulkOpt;
 u_int64_t BandwidthOpt;
+u_int64_t SplitupOpt = 4ULL * 1024ULL * 1024ULL * 1024ULL;
 const char *CyclePath;
 const char *LinkPath;
 
@@ -71,7 +72,7 @@ main(int ac, char **av)
        int ch;
        int cacheSize = 0;
 
-       while ((ch = getopt(ac, av, "b:c:dhf:i:p:qrs:t:v2yBC:FX")) != -1) {
+       while ((ch = getopt(ac, av, "b:c:dhf:i:p:qrs:t:v2yBC:FS:X")) != -1) {
                switch(ch) {
                case '2':
                        TwoWayPipeOpt = 1;
@@ -101,6 +102,28 @@ main(int ac, char **av)
                                usage(1);
                        }
                        break;
+               case 'S':
+                       SplitupOpt = strtoull(optarg, &ptr, 0);
+                       switch(*ptr) {
+                       case 'g':
+                       case 'G':
+                               SplitupOpt *= 1024;
+                               /* fall through */
+                       case 'm':
+                       case 'M':
+                               SplitupOpt *= 1024;
+                               /* fall through */
+                       case 'k':
+                       case 'K':
+                               SplitupOpt *= 1024;
+                               break;
+                       case '\0':
+                               /* bytes per second if no suffix */
+                               break;
+                       default:
+                               usage(1);
+                       }
+                       break;
                case 'c':
                        CyclePath = optarg;
                        break;
@@ -393,6 +416,14 @@ main(int ac, char **av)
                        usage(1);
                exit(0);
        }
+       if (strcmp(av[0], "dedup-simulate") == 0) {
+               hammer_cmd_dedup_simulate(av + 1, ac - 1);
+               exit(0);
+       }
+       if (strcmp(av[0], "dedup") == 0) {
+               hammer_cmd_dedup(av + 1, ac - 1);
+               exit(0);
+       }
        if (strcmp(av[0], "version") == 0) {
                hammer_cmd_get_version(av + 1, ac - 1);
                exit(0);
@@ -409,6 +440,10 @@ main(int ac, char **av)
                hammer_cmd_volume_del(av + 1, ac - 1);
                exit(0);
        }
+       if (strcmp(av[0], "volume-list") == 0) {
+               hammer_cmd_volume_list(av + 1, ac - 1);
+               exit(0);
+       }
 
        uuid_name_lookup(&Hammer_FSType, "DragonFly HAMMER", &status);
        if (status != uuid_s_ok) {
@@ -431,11 +466,23 @@ main(int ac, char **av)
                hammer_cmd_show_undo();
                exit(0);
        }
+       if (strcmp(av[0], "recover") == 0) {
+               hammer_parsedevs(blkdevs);
+               if (ac <= 1)
+                       errx(1, "hammer recover required target directory");
+               hammer_cmd_recover(av[1]);
+               exit(0);
+       }
        if (strcmp(av[0], "blockmap") == 0) {
                hammer_parsedevs(blkdevs);
                hammer_cmd_blockmap();
                exit(0);
        }
+       if (strcmp(av[0], "checkmap") == 0) {
+               hammer_parsedevs(blkdevs);
+               hammer_cmd_checkmap();
+               exit(0);
+       }
        usage(1);
        /* not reached */
        return(0);
@@ -496,14 +543,13 @@ usage(int exit_code)
 {
        fprintf(stderr, 
                "hammer -h\n"
-               "hammer [-2Bqrvy] [-b bandwidth] [-C cachesize[:readahead]] [-c cyclefile]\n"
-               "       [-f blkdevs] [-i delay] [-t seconds] command [argument ...]\n"
+               "hammer [-2BqrvXy] [-b bandwidth] [-C cachesize[:readahead]] [-c cyclefile]\n"
+               "       [-f blkdevs] [-i delay] [-t seconds] [-S splitup]\n"
+               "       command [argument ...]\n"
                "hammer synctid <filesystem> [quick]\n"
-               "hammer -f blkdevs blockmap\n"
                "hammer bstats [interval]\n"
                "hammer iostats [interval]\n"
                "hammer history[@offset[,len]] <file> ...\n"
-               "hammer -f blkdevs [-qqq] show [lo:objid]\n"
                "hammer namekey1 <path>\n"
                "hammer namekey2 <path>\n"
                "hammer namekey32 <path>\n"
@@ -535,6 +581,7 @@ usage(int exit_code)
                "hammer version-upgrade <filesystem> <version> [force]\n"
                "hammer volume-add <device> <filesystem>\n"
                "hammer volume-del <device> <filesystem>\n"
+               "hammer volume-list <filesystem>\n"
        );
 
        fprintf(stderr, "\nHAMMER utility version 3+ commands:\n");
@@ -545,14 +592,27 @@ usage(int exit_code)
                "hammer snap <path> [<note>]\n"
                "hammer snaplo <path> [<note>]\n"
                "hammer snapq <dir> [<note>]\n"
-               "hammer snaprm {<path> | <transid>} ...\n"
+               "hammer snaprm <path> ...\n"
+               "hammer snaprm <transid> ...\n"
+               "hammer snaprm <filesystem> <transid> ...\n"
                "hammer snapls [<path> ...]\n"
        );
 
        fprintf(stderr, "\nHAMMER utility version 4+ commands:\n");
 
        fprintf(stderr,
+               "hammer -f blkdevs blockmap\n"
+               "hammer -f blkdevs checkmap\n"
+               "hammer -f blkdevs [-qqq] show [lo:objid]\n"
                "hammer -f blkdevs show-undo\n"
+               "hammer -f blkdevs recover <target_dir>\n"
+       );
+
+       fprintf(stderr, "\nHAMMER utility version 5+ commands:\n");
+
+       fprintf(stderr,
+               "hammer dedup-simulate <filesystem>\n"
+               "hammer dedup <filesystem>\n"
        );
 
        exit(exit_code);