fix mandoc(1) warnings in sbin/
[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  * $DragonFly: src/sbin/hammer/hammer.c,v 1.44 2008/11/13 02:04:27 dillon Exp $
35  */
36
37 #include "hammer.h"
38 #include <signal.h>
39 #include <math.h>
40 #include <fstab.h>
41
42 static void hammer_parsedevs(const char *blkdevs);
43 static void sigalrm(int signo);
44 static void sigintr(int signo);
45 static void usage(int exit_code);
46
47 int RecurseOpt;
48 int VerboseOpt;
49 int QuietOpt;
50 int NoSyncOpt;
51 int TwoWayPipeOpt;
52 int TimeoutOpt;
53 int DelayOpt = 5;
54 char *SshPort;
55 int ForceYesOpt = 0;
56 int CompressOpt;
57 int ForceOpt;
58 int RunningIoctl;
59 int DidInterrupt;
60 int BulkOpt;
61 u_int64_t BandwidthOpt;
62 u_int64_t SplitupOpt = 4ULL * 1024ULL * 1024ULL * 1024ULL;
63 u_int64_t MemoryLimit = 1024LLU * 1024 * 1024;
64 const char *SplitupOptStr;
65 const char *CyclePath;
66 const char *LinkPath;
67 const char *RestrictTarget;
68
69 int
70 main(int ac, char **av)
71 {
72         char *blkdevs = NULL;
73         char *ptr;
74         char *restrictcmd = NULL;
75         u_int32_t status;
76         int ch;
77         int cacheSize = 0;
78
79         while ((ch = getopt(ac, av,
80                             "b:c:de:hf:i:m:p:qrs:t:v2yBC:FR:S:T:X")) != -1) {
81                 switch(ch) {
82                 case '2':
83                         TwoWayPipeOpt = 1;
84                         break;
85                 case 'y':
86                         ForceYesOpt = 1;
87                         break;
88                 case 'b':
89                         BandwidthOpt = strtoull(optarg, &ptr, 0);
90                         switch(*ptr) {
91                         case 'g':
92                         case 'G':
93                                 BandwidthOpt *= 1024;
94                                 /* fall through */
95                         case 'm':
96                         case 'M':
97                                 BandwidthOpt *= 1024;
98                                 /* fall through */
99                         case 'k':
100                         case 'K':
101                                 BandwidthOpt *= 1024;
102                                 break;
103                         case '\0':
104                                 /* bytes per second if no suffix */
105                                 break;
106                         default:
107                                 usage(1);
108                         }
109                         break;
110                 case 'S':
111                         SplitupOptStr = strdup(optarg);
112                         SplitupOpt = strtoull(optarg, &ptr, 0);
113                         switch(*ptr) {
114                         case 'g':
115                         case 'G':
116                                 SplitupOpt *= 1024;
117                                 /* fall through */
118                         case 'm':
119                         case 'M':
120                                 SplitupOpt *= 1024;
121                                 /* fall through */
122                         case 'k':
123                         case 'K':
124                                 SplitupOpt *= 1024;
125                                 break;
126                         case '\0':
127                                 /* bytes per second if no suffix */
128                                 break;
129                         default:
130                                 usage(1);
131                         }
132                         break;
133                 case 'c':
134                         CyclePath = optarg;
135                         break;
136                 case 'd':
137                         ++DebugOpt;
138                         break;
139                 case 'e':
140                         ScoreBoardFile = optarg;
141                         break;
142                 case 'h':
143                         usage(0);
144                         /* not reached */
145                 case 'i':
146                         DelayOpt = strtol(optarg, NULL, 0);
147                         break;
148                 case 'm':
149                         MemoryLimit = strtouq(optarg, &ptr, 0);
150                         switch(*ptr) {
151                         case 't':
152                         case 'T':
153                                 MemoryLimit *= 1024;
154                                 /* fall through */
155                         case 'g':
156                         case 'G':
157                                 MemoryLimit *= 1024;
158                                 /* fall through */
159                         case 'm':
160                         case 'M':
161                                 MemoryLimit *= 1024;
162                                 /* fall through */
163                         case 'k':
164                         case 'K':
165                                 MemoryLimit *= 1024;
166                                 /* fall through */
167                         default:
168                                 break;
169                         }
170
171                         /* minimum limit */
172                         if (MemoryLimit < 1024 * 1024)
173                                 MemoryLimit = 1024 * 1024;
174                         break;
175                 case 'p':
176                         SshPort = optarg;
177                         break;
178                 case 'r':
179                         RecurseOpt = 1;
180                         break;
181                 case 'f':
182                         blkdevs = optarg;
183                         break;
184                 case 's':
185                         LinkPath = optarg;
186                         break;
187                 case 't':
188                         TimeoutOpt = strtol(optarg, NULL, 0);
189                         break;
190                 case 'v':
191                         if (QuietOpt > 0)
192                                 --QuietOpt;
193                         else
194                                 ++VerboseOpt;
195                         break;
196                 case 'q':
197                         if (VerboseOpt > 0)
198                                 --VerboseOpt;
199                         else
200                                 ++QuietOpt;
201                         break;
202                 case 'B':
203                         BulkOpt = 1;
204                         break;
205                 case 'C':
206                         cacheSize = strtol(optarg, &ptr, 0);
207                         switch(*ptr) {
208                         case 'm':
209                         case 'M':
210                                 cacheSize *= 1024;
211                                 /* fall through */
212                         case 'k':
213                         case 'K':
214                                 cacheSize *= 1024;
215                                 ++ptr;
216                                 break;
217                         case '\0':
218                         case ':':
219                                 /* bytes if no suffix */
220                                 break;
221                         default:
222                                 usage(1);
223                         }
224                         if (*ptr == ':') {
225                                 UseReadAhead = strtol(ptr + 1, NULL, 0);
226                                 UseReadBehind = -UseReadAhead;
227                         }
228                         if (cacheSize < 1024 * 1024)
229                                 cacheSize = 1024 * 1024;
230                         if (UseReadAhead < 0)
231                                 usage(1);
232                         if (UseReadAhead * HAMMER_BUFSIZE / cacheSize / 16) {
233                                 UseReadAhead = cacheSize / 16 / HAMMER_BUFSIZE;
234                                 UseReadBehind = -UseReadAhead;
235                         }
236                         hammer_cache_set(cacheSize);
237                         break;
238                 case 'F':
239                         ForceOpt = 1;
240                         break;
241                 case 'R':
242                         if (restrictcmd == NULL)
243                                 restrictcmd = optarg;
244                         break;
245                 case 'T':
246                         if (RestrictTarget == NULL)
247                                 RestrictTarget = optarg;
248                         break;
249                 case 'X':
250                         CompressOpt = 1;
251                         break;
252                 default:
253                         usage(1);
254                         /* not reached */
255                 }
256         }
257         ac -= optind;
258         av += optind;
259         if (ac < 1) {
260                 usage(1);
261                 /* not reached */
262         }
263
264         signal(SIGALRM, sigalrm);
265         signal(SIGINT, sigintr);
266
267         /*
268          * Check command restriction (used by hammer ssh-remote).  Several
269          * commands may be iterated with a comma.
270          */
271         if (restrictcmd) {
272                 char *elm;
273
274                 ptr = strdup(restrictcmd);
275                 while ((elm = strsep(&ptr, ",")) != NULL) {
276                         if (strcmp(av[0], elm) == 0)
277                                 break;
278                 }
279                 if (elm == NULL) {
280                         fprintf(stderr, "hammer-remote: request does not match "
281                                         "restricted command\n");
282                         exit(1);
283                 }
284                 free(ptr);
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 = (u_int32_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], "status") == 0) {
384                 hammer_cmd_status(av + 1, ac - 1);
385                 exit(0);
386         }
387         if (strcmp(av[0], "prune") == 0) {
388                 hammer_cmd_softprune(av + 1, ac - 1, 0);
389                 exit(0);
390         }
391         if (strcmp(av[0], "config") == 0) {
392                 hammer_cmd_config(av + 1, ac - 1);
393                 exit(0);
394         }
395         if (strcmp(av[0], "viconfig") == 0) {
396                 hammer_cmd_viconfig(av + 1, ac - 1);
397                 exit(0);
398         }
399         if (strcmp(av[0], "cleanup") == 0) {
400                 hammer_cmd_cleanup(av + 1, ac - 1);
401                 exit(0);
402         }
403         if (strcmp(av[0], "info") == 0) {
404                 hammer_cmd_info();
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
450         if (strncmp(av[0], "history", 7) == 0) {
451                 hammer_cmd_history(av[0] + 7, av + 1, ac - 1);
452                 exit(0);
453         }
454         if (strcmp(av[0], "rebalance") == 0) {
455                 signal(SIGINT, sigalrm);
456                 hammer_cmd_rebalance(av + 1, ac - 1);
457                 exit(0);
458         }
459         if (strncmp(av[0], "reblock", 7) == 0) {
460                 signal(SIGINT, sigalrm);
461                 if (strcmp(av[0], "reblock") == 0)
462                         hammer_cmd_reblock(av + 1, ac - 1, -1);
463                 else if (strcmp(av[0], "reblock-btree") == 0)
464                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_BTREE);
465                 else if (strcmp(av[0], "reblock-inodes") == 0)
466                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_INODES);
467                 else if (strcmp(av[0], "reblock-dirs") == 0)
468                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_DIRS);
469                 else if (strcmp(av[0], "reblock-data") == 0)
470                         hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_DATA);
471                 else
472                         usage(1);
473                 exit(0);
474         }
475         if (strncmp(av[0], "mirror", 6) == 0) {
476                 if (strcmp(av[0], "mirror-read") == 0)
477                         hammer_cmd_mirror_read(av + 1, ac - 1, 0);
478                 else if (strcmp(av[0], "mirror-read-stream") == 0)
479                         hammer_cmd_mirror_read(av + 1, ac - 1, 1);
480                 else if (strcmp(av[0], "mirror-write") == 0)
481                         hammer_cmd_mirror_write(av + 1, ac - 1);
482                 else if (strcmp(av[0], "mirror-copy") == 0)
483                         hammer_cmd_mirror_copy(av + 1, ac - 1, 0);
484                 else if (strcmp(av[0], "mirror-stream") == 0)
485                         hammer_cmd_mirror_copy(av + 1, ac - 1, 1);
486                 else if (strcmp(av[0], "mirror-dump") == 0)
487                         hammer_cmd_mirror_dump();
488                 else
489                         usage(1);
490                 exit(0);
491         }
492         if (strcmp(av[0], "dedup-simulate") == 0) {
493                 hammer_cmd_dedup_simulate(av + 1, ac - 1);
494                 exit(0);
495         }
496         if (strcmp(av[0], "dedup") == 0) {
497                 hammer_cmd_dedup(av + 1, ac - 1);
498                 exit(0);
499         }
500         if (strcmp(av[0], "version") == 0) {
501                 hammer_cmd_get_version(av + 1, ac - 1);
502                 exit(0);
503         }
504         if (strcmp(av[0], "version-upgrade") == 0) {
505                 hammer_cmd_set_version(av + 1, ac - 1);
506                 exit(0);
507         }
508         if (strcmp(av[0], "volume-add") == 0) {
509                 hammer_cmd_volume_add(av + 1, ac - 1);
510                 exit(0);
511         }
512         if (strcmp(av[0], "volume-del") == 0) {
513                 hammer_cmd_volume_del(av + 1, ac - 1);
514                 exit(0);
515         }
516         if (strcmp(av[0], "volume-list") == 0) {
517                 hammer_cmd_volume_list(av + 1, ac - 1);
518                 exit(0);
519         }
520
521         uuid_name_lookup(&Hammer_FSType, "DragonFly HAMMER", &status);
522         if (status != uuid_s_ok) {
523                 errx(1, "uuids file does not have the DragonFly "
524                         "HAMMER filesystem type");
525         }
526
527         if (strcmp(av[0], "show") == 0) {
528                 u_int32_t lo = 0;
529                 intmax_t obj_id = (int64_t)HAMMER_MIN_OBJID;
530
531                 hammer_parsedevs(blkdevs);
532                 if (ac > 1)
533                         sscanf(av[1], "%08x:%jx", &lo, &obj_id);
534                 hammer_cmd_show(-1, lo, (int64_t)obj_id, 0, NULL, NULL);
535                 exit(0);
536         }
537         if (strcmp(av[0], "show-undo") == 0) {
538                 hammer_parsedevs(blkdevs);
539                 hammer_cmd_show_undo();
540                 exit(0);
541         }
542         if (strcmp(av[0], "recover") == 0) {
543                 hammer_parsedevs(blkdevs);
544                 if (ac <= 1)
545                         errx(1, "hammer recover required target directory");
546                 hammer_cmd_recover(av[1]);
547                 exit(0);
548         }
549         if (strcmp(av[0], "blockmap") == 0) {
550                 hammer_parsedevs(blkdevs);
551                 hammer_cmd_blockmap();
552                 exit(0);
553         }
554         if (strcmp(av[0], "checkmap") == 0) {
555                 hammer_parsedevs(blkdevs);
556                 hammer_cmd_checkmap();
557                 exit(0);
558         }
559         usage(1);
560         /* not reached */
561         return(0);
562 }
563
564 /*
565  * Parse the device specification.
566  *
567  * Multi-volume hammer devices are colon-separated.  Each element
568  * may be further expanded via /etc/devtab.  One may also specify
569  * a single element which is expanded into multiple elements via
570  * /etc/devtab.
571  */
572 static
573 void
574 hammer_parsedevs(const char *blkdevs)
575 {
576         char *copy;
577         char *volname;
578
579         if (blkdevs == NULL) {
580                 errx(1, "A -f blkdevs specification is required "
581                         "for this command");
582         }
583
584         copy = strdup(blkdevs);
585         while ((volname = copy) != NULL) {
586                 if ((copy = strchr(copy, ':')) != NULL)
587                         *copy++ = 0;
588                 volname = getdevpath(volname, 0);
589                 if (strchr(volname, ':'))
590                         hammer_parsedevs(volname);
591                 else
592                         setup_volume(-1, volname, 0, O_RDONLY);
593         }
594 }
595
596 static
597 void
598 sigalrm(int signo __unused)
599 {
600         /* do nothing (interrupts HAMMER ioctl) */
601 }
602
603 static
604 void
605 sigintr(int signo __unused)
606 {
607         if (RunningIoctl == 0)
608                 _exit(1);
609         DidInterrupt = 1;
610         /* do nothing (interrupts HAMMER ioctl) */
611 }
612
613 static
614 void
615 usage(int exit_code)
616 {
617         fprintf(stderr,
618                 "hammer -h\n"
619                 "hammer [-2BqrvXy] [-b bandwidth] [-C cachesize[:readahead]] [-c cyclefile]\n"
620                 "       [-f blkdevs] [-i delay] [-t seconds] [-S splitup]\n"
621                 "       command [argument ...]\n"
622                 "hammer synctid <filesystem> [quick]\n"
623                 "hammer bstats [interval]\n"
624                 "hammer iostats [interval]\n"
625                 "hammer history[@offset[,len]] <file> ...\n"
626                 "hammer namekey1 <path>\n"
627                 "hammer namekey2 <path>\n"
628                 "hammer namekey32 <path>\n"
629                 "hammer cleanup [<filesystem> ...]\n"
630                 "hammer info\n"
631                 "hammer snapshot [<filesystem>] <snapshot-dir>\n"
632                 "hammer snapshot <filesystem> <snapshot-dir> [<note>]\n"
633                 "hammer prune <softlink-dir>\n"
634                 "hammer prune-everything <filesystem>\n"
635                 "hammer rebalance <filesystem> [saturation_percentage]\n"
636                 "hammer reblock[-btree|-inodes|-dirs|-data] "
637                         "<filesystem> [fill_percentage]\n"
638                 "hammer pfs-status <dirpath> ...\n"
639                 "hammer pfs-master <dirpath> [options]\n"
640                 "hammer pfs-slave <dirpath> [options]\n"
641                 "hammer pfs-update <dirpath> [options]\n"
642                 "hammer pfs-upgrade <dirpath>\n"
643                 "hammer pfs-downgrade <dirpath>\n"
644                 "hammer pfs-destroy <dirpath>\n"
645                 "hammer mirror-read <filesystem> [begin-tid]\n"
646                 "hammer mirror-read-stream <filesystem> [begin-tid]\n"
647                 "hammer mirror-write <filesystem>\n"
648                 "hammer mirror-dump\n"
649                 "hammer mirror-copy [[user@]host:]<filesystem>"
650                                   " [[user@]host:]<filesystem>\n"
651                 "hammer mirror-stream [[user@]host:]<filesystem>"
652                                     " [[user@]host:]<filesystem>\n"
653                 "hammer ssh-remote command filesystem\n"
654                 "hammer version <filesystem>\n"
655                 "hammer version-upgrade <filesystem> <version> [force]\n"
656                 "hammer volume-add <device> <filesystem>\n"
657                 "hammer volume-del <device> <filesystem>\n"
658                 "hammer volume-list <filesystem>\n"
659         );
660
661         fprintf(stderr, "\nHAMMER utility version 3+ commands:\n");
662
663         fprintf(stderr,
664                 "hammer config [<filesystem> [<configfile>]]\n"
665                 "hammer viconfig [<filesystem>]\n"
666                 "hammer snap <path> [<note>]\n"
667                 "hammer snaplo <path> [<note>]\n"
668                 "hammer snapq <dir> [<note>]\n"
669                 "hammer snaprm <path> ...\n"
670                 "hammer snaprm <transid> ...\n"
671                 "hammer snaprm <filesystem> <transid> ...\n"
672                 "hammer snapls [<path> ...]\n"
673         );
674
675         fprintf(stderr, "\nHAMMER utility version 4+ commands:\n");
676
677         fprintf(stderr,
678                 "hammer -f blkdevs blockmap\n"
679                 "hammer -f blkdevs checkmap\n"
680                 "hammer -f blkdevs [-qqq] show [lo:objid]\n"
681                 "hammer -f blkdevs show-undo\n"
682                 "hammer -f blkdevs recover <target_dir>\n"
683         );
684
685         fprintf(stderr, "\nHAMMER utility version 5+ commands:\n");
686
687         fprintf(stderr,
688                 "hammer dedup-simulate <filesystem>\n"
689                 "hammer dedup <filesystem>\n"
690         );
691
692         exit(exit_code);
693 }
694