sbin/hammer: Cleanup prototypes
[dragonfly.git] / sbin / hammer / hammer.c
1 /*
2  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
3  *
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@backplane.com>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34
35 #include "hammer.h"
36
37 static void hammer_parsedevs(const char *blkdevs, int oflags);
38 static void hammer_parsedevs_noverify(const char *blkdevs, int oflags);
39 static void sigalrm(int signo);
40 static void sigintr(int signo);
41 static void usage(int exit_code);
42
43 int RecurseOpt;
44 int VerboseOpt;
45 int QuietOpt;
46 int NoSyncOpt;
47 int TwoWayPipeOpt;
48 int TimeoutOpt;
49 int DelayOpt = 5;
50 char *SshPort;
51 int ForceYesOpt;
52 int CompressOpt;
53 int ForceOpt;
54 int RunningIoctl;
55 int DidInterrupt;
56 int BulkOpt;
57 int AllPFS;
58 uint64_t BandwidthOpt;
59 uint64_t SplitupOpt = 4ULL * 1024ULL * 1024ULL * 1024ULL;
60 uint64_t MemoryLimit = 1024LLU * 1024 * 1024;
61 const char *SplitupOptStr;
62 const char *CyclePath;
63
64 int
65 main(int ac, char **av)
66 {
67         char *blkdevs = NULL;
68         char *ptr;
69         char *restrictcmd = NULL;
70         uint32_t status;
71         int ch;
72
73         while ((ch = getopt(ac, av,
74                             "b:c:de:hf:i:m:p:qrt:v2yABC:FR:S:T:X")) != -1) {
75                 switch(ch) {
76                 case '2':
77                         TwoWayPipeOpt = 1;
78                         break;
79                 case 'y':
80                         ForceYesOpt = 1;
81                         break;
82                 case 'b':
83                         BandwidthOpt = strtoull(optarg, &ptr, 0);
84                         switch(*ptr) {
85                         case 'g':
86                         case 'G':
87                                 BandwidthOpt *= 1024;
88                                 /* fall through */
89                         case 'm':
90                         case 'M':
91                                 BandwidthOpt *= 1024;
92                                 /* fall through */
93                         case 'k':
94                         case 'K':
95                                 BandwidthOpt *= 1024;
96                                 break;
97                         case '\0':
98                                 /* bytes per second if no suffix */
99                                 break;
100                         default:
101                                 usage(1);
102                                 /* not reached */
103                         }
104                         break;
105                 case 'S':
106                         SplitupOptStr = strdup(optarg);
107                         SplitupOpt = strtoull(optarg, &ptr, 0);
108                         switch(*ptr) {
109                         case 'g':
110                         case 'G':
111                                 SplitupOpt *= 1024;
112                                 /* fall through */
113                         case 'm':
114                         case 'M':
115                                 SplitupOpt *= 1024;
116                                 /* fall through */
117                         case 'k':
118                         case 'K':
119                                 SplitupOpt *= 1024;
120                                 break;
121                         case '\0':
122                                 /* bytes per second if no suffix */
123                                 break;
124                         default:
125                                 usage(1);
126                                 /* not reached */
127                         }
128                         break;
129                 case 'c':
130                         CyclePath = optarg;
131                         break;
132                 case 'd':
133                         ++DebugOpt;
134                         break;
135                 case 'e':
136                         ScoreBoardFile = optarg;
137                         break;
138                 case 'h':
139                         usage(0);
140                         /* not reached */
141                 case 'i':
142                         DelayOpt = strtol(optarg, NULL, 0);
143                         break;
144                 case 'm':
145                         MemoryLimit = strtouq(optarg, &ptr, 0);
146                         switch(*ptr) {
147                         case 't':
148                         case 'T':
149                                 MemoryLimit *= 1024;
150                                 /* fall through */
151                         case 'g':
152                         case 'G':
153                                 MemoryLimit *= 1024;
154                                 /* fall through */
155                         case 'm':
156                         case 'M':
157                                 MemoryLimit *= 1024;
158                                 /* fall through */
159                         case 'k':
160                         case 'K':
161                                 MemoryLimit *= 1024;
162                                 /* fall through */
163                         default:
164                                 break;
165                         }
166
167                         /* minimum limit */
168                         if (MemoryLimit < 1024 * 1024)
169                                 MemoryLimit = 1024 * 1024;
170                         break;
171                 case 'p':
172                         SshPort = optarg;
173                         break;
174                 case 'r':
175                         RecurseOpt = 1;
176                         break;
177                 case 'f':
178                         blkdevs = optarg;
179                         break;
180                 case 't':
181                         TimeoutOpt = strtol(optarg, NULL, 0);
182                         break;
183                 case 'v':
184                         if (QuietOpt > 0)
185                                 --QuietOpt;
186                         else
187                                 ++VerboseOpt;
188                         break;
189                 case 'q':
190                         if (VerboseOpt > 0)
191                                 --VerboseOpt;
192                         else
193                                 ++QuietOpt;
194                         break;
195                 case 'A':
196                         AllPFS = 1;
197                         break;
198                 case 'B':
199                         BulkOpt = 1;
200                         break;
201                 case 'C':
202                         if (hammer_parse_cache_size(optarg) == -1) {
203                                 usage(1);
204                                 /* not reached */
205                         }
206                         break;
207                 case 'F':
208                         ForceOpt = 1;
209                         break;
210                 case 'R':
211                         if (restrictcmd == NULL)
212                                 restrictcmd = optarg;
213                         break;
214                 case 'T':
215                         if (RestrictTarget == NULL)
216                                 RestrictTarget = optarg;
217                         break;
218                 case 'X':
219                         CompressOpt = 1;
220                         break;
221                 default:
222                         usage(1);
223                         /* not reached */
224                 }
225         }
226         ac -= optind;
227         av += optind;
228         if (ac < 1) {
229                 usage(1);
230                 /* not reached */
231         }
232
233         signal(SIGALRM, sigalrm);
234         signal(SIGINT, sigintr);
235
236         /*
237          * Check command restriction (used by hammer ssh-remote).  Several
238          * commands may be iterated with a comma.
239          */
240         if (restrictcmd) {
241                 char *elm, *dup;
242
243                 dup = ptr = strdup(restrictcmd);
244                 while ((elm = strsep(&ptr, ",")) != NULL) {
245                         if (strcmp(av[0], elm) == 0)
246                                 break;
247                 }
248                 if (elm == NULL) {
249                         errx(1, "hammer-remote: request does not match "
250                                 "restricted command");
251                         /* not reached */
252                 }
253                 free(dup);
254         }
255
256         /*
257          * Lookup the filesystem type
258          */
259         uuid_name_lookup(&Hammer_FSType, HAMMER_FSTYPE_STRING, &status);
260         if (status != uuid_s_ok) {
261                 errx(1, "uuids file does not have the DragonFly "
262                         "HAMMER filesystem type");
263                 /* not reached */
264         }
265
266         /*
267          * Parse commands
268          */
269         if (strcmp(av[0], "synctid") == 0) {
270                 hammer_cmd_synctid(av + 1, ac - 1);
271                 exit(0);
272         }
273         if (strcmp(av[0], "namekey2") == 0) {
274                 int64_t key;
275                 int32_t crcx;
276                 int len;
277                 const char *aname = av[1];
278
279                 if (aname == NULL) {
280                         usage(1);
281                         /* not reached */
282                 }
283                 len = strlen(aname);
284                 key = (uint32_t)crc32(aname, len) & 0xFFFFFFFEU;
285
286                 switch(len) {
287                 default:
288                         crcx = crc32(aname + 3, len - 5);
289                         crcx = crcx ^ (crcx >> 6) ^ (crcx >> 12);
290                         key |= (int64_t)(crcx & 0x3F) << 42;
291                         /* fall through */
292                 case 5:
293                 case 4:
294                         /* fall through */
295                 case 3:
296                         key |= ((int64_t)(aname[2] & 0x1F) << 48);
297                         /* fall through */
298                 case 2:
299                         key |= ((int64_t)(aname[1] & 0x1F) << 53) |
300                                ((int64_t)(aname[len-2] & 0x1F) << 37);
301                         /* fall through */
302                 case 1:
303                         key |= ((int64_t)(aname[0] & 0x1F) << 58) |
304                                ((int64_t)(aname[len-1] & 0x1F) << 32);
305                         /* fall through */
306                 case 0:
307                         break;
308                 }
309                 if (key == 0)
310                         key |= 0x100000000LL;
311                 printf("0x%016jx\n", (uintmax_t)key);
312                 exit(0);
313         }
314         if (strcmp(av[0], "namekey1") == 0) {
315                 int64_t key;
316
317                 if (av[1] == NULL) {
318                         usage(1);
319                         /* not reached */
320                 }
321                 key = (int64_t)(crc32(av[1], strlen(av[1])) & 0x7FFFFFFF) << 32;
322                 if (key == 0)
323                         key |= 0x100000000LL;
324                 printf("0x%016jx\n", (uintmax_t)key);
325                 exit(0);
326         }
327         if (strcmp(av[0], "namekey32") == 0) {
328                 int32_t key;
329
330                 if (av[1] == NULL) {
331                         usage(1);
332                         /* not reached */
333                 }
334                 key = crc32(av[1], strlen(av[1])) & 0x7FFFFFFF;
335                 if (key == 0)
336                         ++key;
337                 printf("0x%08x\n", key);
338                 exit(0);
339         }
340         if (strcmp(av[0], "pfs-status") == 0) {
341                 hammer_cmd_pseudofs_status(av + 1, ac - 1);
342                 exit(0);
343         }
344         if (strcmp(av[0], "pfs-master") == 0) {
345                 hammer_cmd_pseudofs_create(av + 1, ac - 1, 0);
346                 exit(0);
347         }
348         if (strcmp(av[0], "pfs-slave") == 0) {
349                 hammer_cmd_pseudofs_create(av + 1, ac - 1, 1);
350                 exit(0);
351         }
352         if (strcmp(av[0], "pfs-update") == 0) {
353                 hammer_cmd_pseudofs_update(av + 1, ac - 1);
354                 exit(0);
355         }
356         if (strcmp(av[0], "pfs-upgrade") == 0) {
357                 hammer_cmd_pseudofs_upgrade(av + 1, ac - 1);
358                 exit(0);
359         }
360         if (strcmp(av[0], "pfs-downgrade") == 0) {
361                 hammer_cmd_pseudofs_downgrade(av + 1, ac - 1);
362                 exit(0);
363         }
364         if (strcmp(av[0], "pfs-destroy") == 0) {
365                 hammer_cmd_pseudofs_destroy(av + 1, ac - 1);
366                 exit(0);
367         }
368         if (strcmp(av[0], "prune") == 0) {
369                 hammer_cmd_softprune(av + 1, ac - 1, 0);
370                 exit(0);
371         }
372         if (strcmp(av[0], "prune-everything") == 0) {
373                 hammer_cmd_softprune(av + 1, ac - 1, 1);
374                 exit(0);
375         }
376         if (strcmp(av[0], "config") == 0) {
377                 hammer_cmd_config(av + 1, ac - 1);
378                 exit(0);
379         }
380         if (strcmp(av[0], "viconfig") == 0) {
381                 hammer_cmd_viconfig(av + 1, ac - 1);
382                 exit(0);
383         }
384         if (strcmp(av[0], "cleanup") == 0) {
385                 hammer_cmd_cleanup(av + 1, ac - 1);
386                 exit(0);
387         }
388         if (strcmp(av[0], "abort-cleanup") == 0) {
389                 hammer_cmd_abort_cleanup(av + 1, ac - 1);
390                 exit(0);
391         }
392         if (strcmp(av[0], "info") == 0) {
393                 hammer_cmd_info(av + 1, ac - 1);
394                 exit(0);
395         }
396         if (strcmp(av[0], "ssh-remote") == 0) {
397                 if (ac != 3) {
398                         usage(1);
399                         /* not reached */
400                 }
401                 hammer_cmd_sshremote(av[1], av[2]);
402                 exit(0);
403         }
404         if (strcmp(av[0], "snap") == 0) {
405                 hammer_cmd_snap(av + 1, ac - 1, 0, 1);
406                 exit(0);
407         }
408         if (strcmp(av[0], "snaplo") == 0) {
409                 hammer_cmd_snap(av + 1, ac - 1, 0, 0);
410                 exit(0);
411         }
412         if (strcmp(av[0], "snapq") == 0) {
413                 hammer_cmd_snap(av + 1, ac - 1, 1, 0);
414                 exit(0);
415         }
416         if (strcmp(av[0], "snapls") == 0) {
417                 hammer_cmd_snapls(av + 1, ac - 1);
418                 exit(0);
419         }
420         if (strcmp(av[0], "snaprm") == 0) {
421                 hammer_cmd_snaprm(av + 1, ac - 1);
422                 exit(0);
423         }
424         if (strcmp(av[0], "snapshot") == 0) {
425                 hammer_cmd_snapshot(av + 1, ac - 1);
426                 exit(0);
427         }
428         if (strcmp(av[0], "bstats") == 0) {
429                 hammer_cmd_bstats(av + 1, ac - 1);
430                 exit(0);
431         }
432         if (strcmp(av[0], "iostats") == 0) {
433                 hammer_cmd_iostats(av + 1, ac - 1);
434                 exit(0);
435         }
436         if (strcmp(av[0], "stats") == 0) {
437                 hammer_cmd_stats(av + 1, ac - 1);
438                 exit(0);
439         }
440
441         if (strncmp(av[0], "history", 7) == 0) {
442                 hammer_cmd_history(av[0] + 7, av + 1, ac - 1);
443                 exit(0);
444         }
445         if (strcmp(av[0], "rebalance") == 0) {
446                 signal(SIGINT, sigalrm);
447                 hammer_cmd_rebalance(av + 1, ac - 1);
448                 exit(0);
449         }
450         if (strncmp(av[0], "reblock", 7) == 0) {
451                 signal(SIGINT, sigalrm);
452                 if (strcmp(av[0], "reblock") == 0)
453                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_FLAGS);
454                 else if (strcmp(av[0], "reblock-btree") == 0)
455                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_BTREE);
456                 else if (strcmp(av[0], "reblock-inodes") == 0)
457                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_INODES);
458                 else if (strcmp(av[0], "reblock-dirs") == 0)
459                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_DIRS);
460                 else if (strcmp(av[0], "reblock-data") == 0)
461                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_DATA);
462                 else {
463                         usage(1);
464                         /* not reached */
465                 }
466                 exit(0);
467         }
468         if (strncmp(av[0], "mirror", 6) == 0) {
469                 if (strcmp(av[0], "mirror-read") == 0)
470                         hammer_cmd_mirror_read(av + 1, ac - 1, 0);
471                 else if (strcmp(av[0], "mirror-read-stream") == 0)
472                         hammer_cmd_mirror_read(av + 1, ac - 1, 1);
473                 else if (strcmp(av[0], "mirror-write") == 0)
474                         hammer_cmd_mirror_write(av + 1, ac - 1);
475                 else if (strcmp(av[0], "mirror-copy") == 0)
476                         hammer_cmd_mirror_copy(av + 1, ac - 1, 0);
477                 else if (strcmp(av[0], "mirror-stream") == 0)
478                         hammer_cmd_mirror_copy(av + 1, ac - 1, 1);
479                 else if (strcmp(av[0], "mirror-dump") == 0)
480                         hammer_cmd_mirror_dump(av + 1, ac - 1);
481                 else {
482                         usage(1);
483                         /* not reached */
484                 }
485                 exit(0);
486         }
487         if (strcmp(av[0], "dedup-simulate") == 0) {
488                 hammer_cmd_dedup_simulate(av + 1, ac - 1);
489                 exit(0);
490         }
491         if (strcmp(av[0], "dedup") == 0) {
492                 hammer_cmd_dedup(av + 1, ac - 1);
493                 exit(0);
494         }
495         if (strcmp(av[0], "version") == 0) {
496                 hammer_cmd_get_version(av + 1, ac - 1);
497                 exit(0);
498         }
499         if (strcmp(av[0], "version-upgrade") == 0) {
500                 hammer_cmd_set_version(av + 1, ac - 1);
501                 exit(0);
502         }
503         if (strcmp(av[0], "volume-add") == 0) {
504                 hammer_cmd_volume_add(av + 1, ac - 1);
505                 exit(0);
506         }
507         if (strcmp(av[0], "volume-del") == 0) {
508                 hammer_cmd_volume_del(av + 1, ac - 1);
509                 exit(0);
510         }
511         if (strcmp(av[0], "volume-list") == 0) {
512                 hammer_cmd_volume_list(av + 1, ac - 1);
513                 exit(0);
514         }
515         if (strcmp(av[0], "volume-blkdevs") == 0) {
516                 hammer_cmd_volume_blkdevs(av + 1, ac - 1);
517                 exit(0);
518         }
519
520         if (strcmp(av[0], "show") == 0) {
521                 const char *arg = NULL;
522                 char *p, *dup;
523                 int filter = -1;
524                 int obfuscate = 0;
525                 int indent = 0;
526
527                 hammer_parsedevs(blkdevs, O_RDONLY);
528                 if (ac > 3) {
529                         errx(1, "Too many options specified");
530                         /* not reached */
531                 }
532                 if (ac > 1)
533                         arg = av[1];
534                 if (ac > 2) {
535                         dup = ptr = strdup(av[2]);
536                         while ((p = strsep(&ptr, ",")) != NULL) {
537                                 if (strcmp(p, "filter") == 0)
538                                         filter = 1;
539                                 else if (strcmp(p, "nofilter") == 0)
540                                         filter = 0;
541                                 else if (strcmp(p, "obfuscate") == 0)
542                                         obfuscate = 1;
543                                 else if (strcmp(p, "indent") == 0)
544                                         indent = 1;
545                         }
546                         free(dup);
547                 }
548                 hammer_cmd_show(arg, filter, obfuscate, indent);
549                 exit(0);
550         }
551         if (strcmp(av[0], "show-undo") == 0) {
552                 hammer_parsedevs(blkdevs, O_RDONLY);
553                 hammer_cmd_show_undo();
554                 exit(0);
555         }
556         if (strcmp(av[0], "recover") == 0) {
557                 hammer_parsedevs_noverify(blkdevs, O_RDONLY);
558                 hammer_cmd_recover(av + 1, ac - 1);
559                 exit(0);
560         }
561         if (strcmp(av[0], "blockmap") == 0) {
562                 hammer_parsedevs(blkdevs, O_RDONLY);
563                 hammer_cmd_blockmap();
564                 exit(0);
565         }
566         if (strcmp(av[0], "checkmap") == 0) {
567                 hammer_parsedevs(blkdevs, O_RDONLY);
568                 hammer_cmd_checkmap();
569                 exit(0);
570         }
571         if (strcmp(av[0], "strip") == 0) {
572                 hammer_parsedevs(blkdevs, O_RDWR);
573                 hammer_cmd_strip();
574                 exit(0);
575         }
576
577         usage(1);
578         /* not reached */
579         return(0);
580 }
581
582 /*
583  * Parse the device specification.
584  *
585  * Multi-volume hammer devices are colon-separated.  Each element
586  * may be further expanded via /etc/devtab.  One may also specify
587  * a single element which is expanded into multiple elements via
588  * /etc/devtab.
589  */
590 static
591 void
592 __hammer_parsedevs(const char *blkdevs, int oflags, int verify)
593 {
594         struct volume_info *volume = NULL;
595         char *copy;
596         char *volname;
597         int volnum = 0;
598
599         if (blkdevs == NULL) {
600                 errx(1, "A -f blkdevs specification is required "
601                         "for this command");
602                 /* not reached */
603         }
604
605         copy = strdup(blkdevs);
606         while ((volname = copy) != NULL) {
607                 if ((copy = strchr(copy, ':')) != NULL)
608                         *copy++ = 0;
609                 volname = getdevpath(volname, 0);
610                 if (strchr(volname, ':')) {
611                         __hammer_parsedevs(volname, oflags, verify);
612                 } else {
613                         volume = load_volume(volname, oflags, verify);
614                         assert(volume);
615                         ++volnum;
616                 }
617                 free(volname);
618         }
619         free(copy);
620
621         /*
622          * All volumes have the same vol_count.
623          */
624         assert(volume);
625         if (volnum != volume->ondisk->vol_count) {
626                 errx(1, "Volume header says %d volumes, but %d specified.",
627                         volume->ondisk->vol_count, volnum);
628                 /* not reached */
629         }
630
631         if (get_root_volume() == NULL) {
632                 errx(1, "No root volume found");
633                 /* not reached */
634         }
635 }
636
637 static __inline
638 void
639 hammer_parsedevs(const char *blkdevs, int oflags)
640 {
641         __hammer_parsedevs(blkdevs, oflags, 1);
642 }
643
644 static __inline
645 void
646 hammer_parsedevs_noverify(const char *blkdevs, int oflags)
647 {
648         __hammer_parsedevs(blkdevs, oflags, 0);
649 }
650
651 static
652 void
653 sigalrm(int signo __unused)
654 {
655         /* do nothing (interrupts HAMMER ioctl) */
656 }
657
658 static
659 void
660 sigintr(int signo __unused)
661 {
662         if (RunningIoctl == 0)
663                 _exit(1);
664         DidInterrupt = 1;
665         /* do nothing (interrupts HAMMER ioctl) */
666 }
667
668 static
669 void
670 usage(int exit_code)
671 {
672         fprintf(stderr,
673                 "hammer -h\n"
674                 "hammer [-2ABFqrvXy] [-b bandwidth] [-C cachesize[:readahead]] \n"
675                 "       [-R restrictcmd] [-T restrictpath] [-c cyclefile]\n"
676                 "       [-e scoreboardfile] [-f blkdevs] [-i delay] [-p ssh-port]\n"
677                 "       [-S splitsize] [-t seconds] [-m memlimit] command [argument ...]\n"
678                 "hammer synctid <filesystem> [quick]\n"
679                 "hammer bstats [interval]\n"
680                 "hammer iostats [interval]\n"
681                 "hammer stats [interval]\n"
682                 "hammer history[@offset[,len]] <file> ...\n"
683                 "hammer namekey1 <path>\n"
684                 "hammer namekey2 <path>\n"
685                 "hammer namekey32 <path>\n"
686                 "hammer cleanup [<filesystem> ...]\n"
687                 "hammer abort-cleanup\n"
688                 "hammer info [<dirpath> ...]\n"
689                 "hammer snapshot [<filesystem>] <snapshot-dir>\n"
690                 "hammer snapshot <filesystem> <snapshot-dir> [<note>]\n"
691                 "hammer prune <softlink-dir>\n"
692                 "hammer prune-everything <filesystem>\n"
693                 "hammer rebalance <filesystem> [saturation_percentage]\n"
694                 "hammer reblock[-btree|-inodes|-dirs|-data] "
695                         "<filesystem> [fill_percentage]\n"
696                 "hammer pfs-status <dirpath> ...\n"
697                 "hammer pfs-master <dirpath> [options]\n"
698                 "hammer pfs-slave <dirpath> [options]\n"
699                 "hammer pfs-update <dirpath> [options]\n"
700                 "hammer pfs-upgrade <dirpath>\n"
701                 "hammer pfs-downgrade <dirpath>\n"
702                 "hammer pfs-destroy <dirpath>\n"
703                 "hammer mirror-read <filesystem> [begin-tid]\n"
704                 "hammer mirror-read-stream <filesystem> [begin-tid]\n"
705                 "hammer mirror-write <filesystem>\n"
706                 "hammer mirror-dump [header]\n"
707                 "hammer mirror-copy [[user@]host:]<filesystem>"
708                                   " [[user@]host:]<filesystem>\n"
709                 "hammer mirror-stream [[user@]host:]<filesystem>"
710                                     " [[user@]host:]<filesystem>\n"
711                 "hammer ssh-remote command filesystem\n"
712                 "hammer version <filesystem>\n"
713                 "hammer version-upgrade <filesystem> <version> [force]\n"
714                 "hammer volume-add <device> <filesystem>\n"
715                 "hammer volume-del <device> <filesystem>\n"
716                 "hammer volume-list <filesystem>\n"
717                 "hammer volume-blkdevs <filesystem>\n"
718         );
719
720         fprintf(stderr, "\nHAMMER utility version 3+ commands:\n");
721
722         fprintf(stderr,
723                 "hammer config [<filesystem> [<configfile>]]\n"
724                 "hammer viconfig [<filesystem>]\n"
725                 "hammer snap <path> [<note>]\n"
726                 "hammer snaplo <path> [<note>]\n"
727                 "hammer snapq <dir> [<note>]\n"
728                 "hammer snaprm <path> ...\n"
729                 "hammer snaprm <transid> ...\n"
730                 "hammer snaprm <filesystem> <transid> ...\n"
731                 "hammer snapls [<path> ...]\n"
732         );
733
734         fprintf(stderr, "\nHAMMER utility version 4+ commands:\n");
735
736         fprintf(stderr,
737                 "hammer -f blkdevs blockmap\n"
738                 "hammer -f blkdevs checkmap\n"
739                 "hammer -f blkdevs [-qqq] show [lo:objid]\n"
740                 "hammer -f blkdevs show-undo\n"
741                 "hammer -f blkdevs recover <target_dir> [full|quick]\n"
742                 "hammer -f blkdevs strip\n"
743         );
744
745         fprintf(stderr, "\nHAMMER utility version 5+ commands:\n");
746
747         fprintf(stderr,
748                 "hammer dedup-simulate <filesystem>\n"
749                 "hammer dedup <filesystem>\n"
750         );
751
752         exit(exit_code);
753 }
754