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