sbin/hammer - Hex data dump for misc & data records
[dragonfly.git] / sbin / hammer / cmd_show.c
1 /*
2  * Copyright (c) 2008 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 #include <libutil.h>
37
38 #define FLAG_TOOFARLEFT         0x0001
39 #define FLAG_TOOFARRIGHT        0x0002
40 #define FLAG_BADTYPE            0x0004
41 #define FLAG_BADCHILDPARENT     0x0008
42 #define FLAG_BADMIRRORTID       0x0010
43
44 typedef struct btree_search {
45         u_int32_t       lo;
46         int64_t         obj_id;
47 } *btree_search_t;
48
49 static void print_btree_node(hammer_off_t node_offset, btree_search_t search,
50                         int depth, hammer_tid_t mirror_tid,
51                         hammer_base_elm_t left_bound,
52                         hammer_base_elm_t right_bound);
53 static const char *check_data_crc(hammer_btree_elm_t elm);
54 static void print_record(hammer_btree_elm_t elm);
55 static void print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type,
56                         int flags, const char *label, const char *ext);
57 static int get_elm_flags(hammer_node_ondisk_t node, hammer_off_t node_offset,
58                         hammer_btree_elm_t elm, u_int8_t btype,
59                         hammer_base_elm_t left_bound,
60                         hammer_base_elm_t right_bound);
61 static void print_bigblock_fill(hammer_off_t offset);
62
63 void
64 hammer_cmd_show(hammer_off_t node_offset, u_int32_t lo, int64_t obj_id,
65                 int depth,
66                 hammer_base_elm_t left_bound, hammer_base_elm_t right_bound)
67 {
68         struct volume_info *volume;
69         struct btree_search search;
70         btree_search_t searchp;
71         int zone;
72
73         AssertOnFailure = 0;
74
75         if (node_offset == (hammer_off_t)-1) {
76                 volume = get_volume(RootVolNo);
77                 node_offset = volume->ondisk->vol0_btree_root;
78                 if (QuietOpt < 3) {
79                         printf("Volume header\trecords=%jd next_tid=%016jx\n",
80                                (intmax_t)volume->ondisk->vol0_stat_records,
81                                (uintmax_t)volume->ondisk->vol0_next_tid);
82                         printf("\t\tbufoffset=%016jx\n",
83                                (uintmax_t)volume->ondisk->vol_buf_beg);
84                         for (zone = 0; zone < HAMMER_MAX_ZONES; ++zone) {
85                                 printf("\t\tzone %d\tnext_offset=%016jx\n",
86                                         zone,
87                                         (uintmax_t)volume->ondisk->vol0_blockmap[zone].next_offset
88                                 );
89                         }
90                 }
91                 rel_volume(volume);
92         }
93
94         if (lo == 0 && obj_id == (int64_t)HAMMER_MIN_OBJID) {
95                 searchp = NULL;
96                 printf("show %016jx depth %d\n", (uintmax_t)node_offset, depth);
97         } else {
98                 search.lo = lo;
99                 search.obj_id = obj_id;
100                 searchp = &search;
101                 printf("show %016jx lo %08x obj_id %016jx depth %d\n",
102                         (uintmax_t)node_offset, lo, (uintmax_t)obj_id, depth);
103         }
104         print_btree_node(node_offset, searchp, depth, HAMMER_MAX_TID,
105                          left_bound, right_bound);
106
107         AssertOnFailure = 1;
108 }
109
110 static void
111 print_btree_node(hammer_off_t node_offset, btree_search_t search,
112                 int depth, hammer_tid_t mirror_tid,
113                 hammer_base_elm_t left_bound, hammer_base_elm_t right_bound)
114 {
115         struct buffer_info *buffer = NULL;
116         hammer_node_ondisk_t node;
117         hammer_btree_elm_t elm;
118         int i;
119         int flags;
120         int maxcount;
121         char badc;
122         char badm;
123         const char *ext;
124
125         node = get_node(node_offset, &buffer);
126
127         if (node == NULL) {
128                 printf("BI   NODE %016jx (IO ERROR)\n",
129                        (uintmax_t)node_offset);
130                 return;
131         }
132
133         if (crc32(&node->crc + 1, HAMMER_BTREE_CRCSIZE) == node->crc)
134                 badc = ' ';
135         else
136                 badc = 'B';
137
138         if (node->mirror_tid <= mirror_tid) {
139                 badm = ' ';
140         } else {
141                 badm = 'M';
142                 badc = 'B';
143         }
144
145         printf("%c%c   NODE %016jx cnt=%02d p=%016jx "
146                "type=%c depth=%d",
147                badc,
148                badm,
149                (uintmax_t)node_offset, node->count,
150                (uintmax_t)node->parent,
151                (node->type ? node->type : '?'), depth);
152         printf(" mirror %016jx", (uintmax_t)node->mirror_tid);
153         if (QuietOpt < 3) {
154                 printf(" fill=");
155                 print_bigblock_fill(node_offset);
156         }
157         printf(" {\n");
158
159         maxcount = (node->type == HAMMER_BTREE_TYPE_INTERNAL) ?
160                    HAMMER_BTREE_INT_ELMS : HAMMER_BTREE_LEAF_ELMS;
161
162         for (i = 0; i < node->count && i < maxcount; ++i) {
163                 elm = &node->elms[i];
164
165                 if (node->type != HAMMER_BTREE_TYPE_INTERNAL) {
166                         ext = NULL;
167                         if (search &&
168                             elm->base.localization == search->lo &&
169                              elm->base.obj_id == search->obj_id) {
170                                 ext = " *";
171                         }
172                 } else if (search) {
173                         ext = " *";
174                         if (elm->base.localization > search->lo ||
175                             (elm->base.localization == search->lo &&
176                              elm->base.obj_id > search->obj_id)) {
177                                 ext = NULL;
178                         }
179                         if (elm[1].base.localization < search->lo ||
180                             (elm[1].base.localization == search->lo &&
181                              elm[1].base.obj_id < search->obj_id)) {
182                                 ext = NULL;
183                         }
184                 } else {
185                         ext = NULL;
186                 }
187
188                 flags = get_elm_flags(node, node_offset,
189                                         elm, elm->base.btype,
190                                         left_bound, right_bound);
191                 print_btree_elm(elm, i, node->type, flags, "ELM", ext);
192         }
193         if (node->type == HAMMER_BTREE_TYPE_INTERNAL) {
194                 elm = &node->elms[i];
195
196                 flags = get_elm_flags(node, node_offset,
197                                         elm, 'I',
198                                         left_bound, right_bound);
199                 print_btree_elm(elm, i, node->type, flags, "RBN", NULL);
200         }
201         printf("     }\n");
202
203         for (i = 0; i < node->count; ++i) {
204                 elm = &node->elms[i];
205
206                 switch(node->type) {
207                 case HAMMER_BTREE_TYPE_INTERNAL:
208                         if (search) {
209                                 if (elm->base.localization > search->lo ||
210                                     (elm->base.localization == search->lo &&
211                                      elm->base.obj_id > search->obj_id)) {
212                                         break;
213                                 }
214                                 if (elm[1].base.localization < search->lo ||
215                                     (elm[1].base.localization == search->lo &&
216                                      elm[1].base.obj_id < search->obj_id)) {
217                                         break;
218                                 }
219                         }
220                         if (elm->internal.subtree_offset) {
221                                 print_btree_node(elm->internal.subtree_offset,
222                                                  search, depth + 1,
223                                                  elm->internal.mirror_tid,
224                                                  &elm[0].base, &elm[1].base);
225                                 /*
226                                  * Cause show to iterate after seeking to
227                                  * the lo:objid
228                                  */
229                                 search = NULL;
230                         }
231                         break;
232                 default:
233                         break;
234                 }
235         }
236         rel_buffer(buffer);
237 }
238
239 static
240 void
241 print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type,
242                 int flags, const char *label, const char *ext)
243 {
244         char flagstr[8] = { 0, '-', '-', '-', '-', '-', '-', 0 };
245
246         flagstr[0] = flags ? 'B' : 'G';
247         if (flags & FLAG_TOOFARLEFT)
248                 flagstr[2] = 'L';
249         if (flags & FLAG_TOOFARRIGHT)
250                 flagstr[3] = 'R';
251         if (flags & FLAG_BADTYPE)
252                 flagstr[4] = 'T';
253         if (flags & FLAG_BADCHILDPARENT)
254                 flagstr[5] = 'C';
255         if (flags & FLAG_BADMIRRORTID)
256                 flagstr[6] = 'M';
257
258         printf("%s\t%s %2d %c ",
259                flagstr, label, i,
260                (elm->base.btype ? elm->base.btype : '?'));
261         printf("lo=%08x obj=%016jx rt=%02x key=%016jx ot=%02x\n",
262                elm->base.localization,
263                (uintmax_t)elm->base.obj_id,
264                elm->base.rec_type,
265                (uintmax_t)elm->base.key,
266                elm->base.obj_type);
267         printf("\t       %c tids %016jx:%016jx ",
268                 (elm->base.delete_tid ? 'd' : ' '),
269                (uintmax_t)elm->base.create_tid,
270                (uintmax_t)elm->base.delete_tid);
271
272         switch(type) {
273         case HAMMER_BTREE_TYPE_INTERNAL:
274                 printf("suboff=%016jx",
275                        (uintmax_t)elm->internal.subtree_offset);
276                 if (QuietOpt < 3) {
277                         printf(" mirror %016jx",
278                                (uintmax_t)elm->internal.mirror_tid);
279                 }
280                 if (ext)
281                         printf(" %s", ext);
282                 break;
283         case HAMMER_BTREE_TYPE_LEAF:
284                 if (ext)
285                         printf(" %s", ext);
286                 switch(elm->base.btype) {
287                 case HAMMER_BTREE_TYPE_RECORD:
288                         if (QuietOpt < 3)
289                                 printf("\n%s\t         ", check_data_crc(elm));
290                         else
291                                 printf("\n\t         ");
292                         printf("dataoff=%016jx/%d",
293                                (uintmax_t)elm->leaf.data_offset,
294                                elm->leaf.data_len);
295                         if (QuietOpt < 3) {
296                                 printf(" crc=%04x", elm->leaf.data_crc);
297                                 printf("\n\t         fills=");
298                                 print_bigblock_fill(elm->leaf.data_offset);
299                         }
300                         if (QuietOpt < 2)
301                                 print_record(elm);
302                         break;
303                 }
304                 break;
305         default:
306                 break;
307         }
308         printf("\n");
309 }
310
311 static
312 int
313 get_elm_flags(hammer_node_ondisk_t node, hammer_off_t node_offset,
314                 hammer_btree_elm_t elm, u_int8_t btype,
315                 hammer_base_elm_t left_bound, hammer_base_elm_t right_bound)
316 {
317         int flags = 0;
318
319         switch(node->type) {
320         case HAMMER_BTREE_TYPE_INTERNAL:
321                 if (elm->internal.subtree_offset) {
322                         struct buffer_info *buffer = NULL;
323                         hammer_node_ondisk_t subnode;
324
325                         subnode = get_node(elm->internal.subtree_offset,
326                                            &buffer);
327                         if (subnode == NULL)
328                                 flags |= FLAG_BADCHILDPARENT;
329                         else if (subnode->parent != node_offset)
330                                 flags |= FLAG_BADCHILDPARENT;
331                         rel_buffer(buffer);
332                 }
333                 if (elm->internal.mirror_tid > node->mirror_tid)
334                         flags |= FLAG_BADMIRRORTID;
335
336                 switch(btype) {
337                 case HAMMER_BTREE_TYPE_INTERNAL:
338                         if (left_bound == NULL || right_bound == NULL)
339                                 break;
340                         if (hammer_btree_cmp(&elm->base, left_bound) < 0)
341                                 flags |= FLAG_TOOFARLEFT;
342                         if (hammer_btree_cmp(&elm->base, right_bound) > 0)
343                                 flags |= FLAG_TOOFARRIGHT;
344                         break;
345                 case HAMMER_BTREE_TYPE_LEAF:
346                         if (left_bound == NULL || right_bound == NULL)
347                                 break;
348                         if (hammer_btree_cmp(&elm->base, left_bound) < 0)
349                                 flags |= FLAG_TOOFARLEFT;
350                         if (hammer_btree_cmp(&elm->base, right_bound) >= 0)
351                                 flags |= FLAG_TOOFARRIGHT;
352                         break;
353                 default:
354                         flags |= FLAG_BADTYPE;
355                         break;
356                 }
357                 break;
358         case HAMMER_BTREE_TYPE_LEAF:
359                 if (node->mirror_tid == 0 &&
360                     !(node->parent == 0 && node->count == 2)) {
361                         flags |= FLAG_BADMIRRORTID;
362                 }
363                 if (elm->base.create_tid && node->mirror_tid &&
364                     elm->base.create_tid > node->mirror_tid) {
365                         flags |= FLAG_BADMIRRORTID;
366                 }
367                 if (elm->base.delete_tid && node->mirror_tid &&
368                     elm->base.delete_tid > node->mirror_tid) {
369                         flags |= FLAG_BADMIRRORTID;
370                 }
371                 switch(btype) {
372                 case HAMMER_BTREE_TYPE_RECORD:
373                         if (left_bound == NULL || right_bound == NULL)
374                                 break;
375                         if (hammer_btree_cmp(&elm->base, left_bound) < 0)
376                                 flags |= FLAG_TOOFARLEFT;
377                         if (hammer_btree_cmp(&elm->base, right_bound) >= 0)
378                                 flags |= FLAG_TOOFARRIGHT;
379                         break;
380                 default:
381                         flags |= FLAG_BADTYPE;
382                         break;
383                 }
384                 break;
385         default:
386                 flags |= FLAG_BADTYPE;
387                 break;
388         }
389         return(flags);
390 }
391
392 static
393 void
394 print_bigblock_fill(hammer_off_t offset)
395 {
396         struct hammer_blockmap_layer1 layer1;
397         struct hammer_blockmap_layer2 layer2;
398         int fill;
399         int error;
400
401         blockmap_lookup(offset, &layer1, &layer2, &error);
402         if (error) {
403                 printf("z%d:%lld=BADZ",
404                         HAMMER_ZONE_DECODE(offset),
405                         (offset & ~HAMMER_OFF_ZONE_MASK) /
406                             HAMMER_BIGBLOCK_SIZE
407                 );
408         } else {
409                 fill = layer2.bytes_free * 100 / HAMMER_BIGBLOCK_SIZE;
410                 fill = 100 - fill;
411
412                 printf("z%d:%lld=%d%%",
413                         HAMMER_ZONE_DECODE(offset),
414                         (offset & ~HAMMER_OFF_ZONE_MASK) /
415                             HAMMER_BIGBLOCK_SIZE,
416                         fill
417                 );
418         }
419 }
420
421 /*
422  * Check the generic crc on a data element.  Inodes record types are
423  * special in that some of their fields are not CRCed.
424  *
425  * Also check that the zone is valid.
426  */
427 static
428 const char *
429 check_data_crc(hammer_btree_elm_t elm)
430 {
431         struct buffer_info *data_buffer;
432         hammer_off_t data_offset;
433         int32_t data_len;
434         int32_t len;
435         u_int32_t crc;
436         int error;
437         char *ptr;
438
439         data_offset = elm->leaf.data_offset;
440         data_len = elm->leaf.data_len;
441         data_buffer = NULL;
442         if (data_offset == 0 || data_len == 0)
443                 return("Z");
444
445         crc = 0;
446         error = 0;
447         while (data_len) {
448                 blockmap_lookup(data_offset, NULL, NULL, &error);
449                 if (error)
450                         break;
451
452                 ptr = get_buffer_data(data_offset, &data_buffer, 0);
453                 len = HAMMER_BUFSIZE - ((int)data_offset & HAMMER_BUFMASK);
454                 if (len > data_len)
455                         len = (int)data_len;
456                 if (elm->leaf.base.rec_type == HAMMER_RECTYPE_INODE &&
457                     data_len == sizeof(struct hammer_inode_data)) {
458                         crc = crc32_ext(ptr, HAMMER_INODE_CRCSIZE, crc);
459                 } else {
460                         crc = crc32_ext(ptr, len, crc);
461                 }
462                 data_len -= len;
463                 data_offset += len;
464         }
465         if (data_buffer)
466                 rel_buffer(data_buffer);
467         if (error)
468                 return("BO");           /* bad offset */
469         if (crc == elm->leaf.data_crc)
470                 return("");
471         return("BX");                   /* bad crc */
472 }
473
474 static
475 void
476 print_config(char *cfgtxt)
477 {
478         char *token;
479
480         printf("\n%17stext=\"\n", "");
481         while((token = strsep(&cfgtxt, "\r\n")) != NULL) {
482                 printf("%17s  %s\n", "", token);
483         }
484         printf("%17s\"", "");
485 }
486
487 static
488 void
489 print_record(hammer_btree_elm_t elm)
490 {
491         struct buffer_info *data_buffer;
492         hammer_off_t data_offset;
493         int32_t data_len;
494         hammer_data_ondisk_t data;
495         u_int32_t status;
496         char *str1 = NULL;
497         char *str2 = NULL;
498
499         data_offset = elm->leaf.data_offset;
500         data_len = elm->leaf.data_len;
501         data_buffer = NULL;
502
503         if (data_offset)
504                 data = get_buffer_data(data_offset, &data_buffer, 0);
505         else
506                 data = NULL;
507
508         switch(elm->leaf.base.rec_type) {
509         case HAMMER_RECTYPE_UNKNOWN:
510                 printf("\n%17s", "");
511                 printf("unknown");
512                 break;
513         case HAMMER_RECTYPE_INODE:
514                 printf("\n%17s", "");
515                 printf("size=%jd nlinks=%jd",
516                        (intmax_t)data->inode.size,
517                        (intmax_t)data->inode.nlinks);
518                 if (QuietOpt < 1) {
519                         printf(" mode=%05o uflags=%08x\n",
520                                 data->inode.mode,
521                                 data->inode.uflags);
522                         printf("%17s", "");
523                         printf("ctime=%016jx pobjid=%016jx obj_type=%d\n",
524                                 (uintmax_t)data->inode.ctime,
525                                 (uintmax_t)data->inode.parent_obj_id,
526                                 data->inode.obj_type);
527                         printf("%17s", "");
528                         printf("mtime=%016jx", (uintmax_t)data->inode.mtime);
529                         printf(" caps=%02x", data->inode.cap_flags);
530                 }
531                 break;
532         case HAMMER_RECTYPE_DIRENTRY:
533                 printf("\n%17s", "");
534                 data_len -= HAMMER_ENTRY_NAME_OFF;
535                 printf("dir-entry ino=%016jx lo=%08x name=\"%*.*s\"",
536                        (uintmax_t)data->entry.obj_id,
537                        data->entry.localization,
538                        data_len, data_len, data->entry.name);
539                 break;
540         case HAMMER_RECTYPE_FIX:
541                 switch(elm->leaf.base.key) {
542                 case HAMMER_FIXKEY_SYMLINK:
543                         data_len -= HAMMER_SYMLINK_NAME_OFF;
544                         printf("\n%17s", "");
545                         printf("symlink=\"%*.*s\"", data_len, data_len,
546                                 data->symlink.name);
547                         break;
548                 default:
549                         break;
550                 }
551                 break;
552         case HAMMER_RECTYPE_PFS:
553                 printf("\n%17s", "");
554                 printf("sync_beg_tid=%016jx sync_end_tid=%016jx\n",
555                         (intmax_t)data->pfsd.sync_beg_tid,
556                         (intmax_t)data->pfsd.sync_end_tid);
557                 uuid_to_string(&data->pfsd.shared_uuid, &str1, &status);
558                 uuid_to_string(&data->pfsd.unique_uuid, &str2, &status);
559                 printf("%17s", "");
560                 printf("shared_uuid=%s\n", str1);
561                 printf("%17s", "");
562                 printf("unique_uuid=%s\n", str2);
563                 printf("%17s", "");
564                 printf("mirror_flags=%08x label=\"%s\"",
565                         data->pfsd.mirror_flags, data->pfsd.label);
566                 if (data->pfsd.snapshots[0])
567                         printf(" snapshots=\"%s\"", data->pfsd.snapshots);
568                 free(str1);
569                 free(str2);
570                 break;
571         case HAMMER_RECTYPE_SNAPSHOT:
572                 printf("\n%17s", "");
573                 printf("tid=%016jx label=\"%s\"",
574                         (intmax_t)data->snap.tid, data->snap.label);
575                 break;
576         case HAMMER_RECTYPE_CONFIG:
577                 if (VerboseOpt > 2) {
578                         print_config(data->config.text);
579                 }
580                 break;
581         case HAMMER_RECTYPE_DATA:
582         case HAMMER_RECTYPE_EXT:
583         case HAMMER_RECTYPE_DB:
584                 if (VerboseOpt > 2)
585                         printf("\n");
586                         hexdump(data, data_len, "\t\t  ", 0);
587                 break;
588         default:
589                 break;
590         }
591         if (data_buffer)
592                 rel_buffer(data_buffer);
593 }
594
595 /*
596  * Dump the UNDO FIFO
597  */
598 void
599 hammer_cmd_show_undo(void)
600 {
601         struct volume_info *volume;
602         hammer_blockmap_t rootmap;
603         hammer_off_t scan_offset;
604         hammer_fifo_any_t head;
605         struct buffer_info *data_buffer = NULL;
606
607         volume = get_volume(RootVolNo);
608         rootmap = &volume->ondisk->vol0_blockmap[HAMMER_ZONE_UNDO_INDEX];
609         printf("Volume header UNDO %016jx-%016jx/%016jx\n",
610                 (intmax_t)rootmap->first_offset,
611                 (intmax_t)rootmap->next_offset,
612                 (intmax_t)rootmap->alloc_offset);
613         printf("Undo map is %jdMB\n",
614                 (intmax_t)((rootmap->alloc_offset & HAMMER_OFF_LONG_MASK) /
615                            (1024 * 1024)));
616         scan_offset = HAMMER_ZONE_ENCODE(HAMMER_ZONE_UNDO_INDEX, 0);
617         while (scan_offset < rootmap->alloc_offset) {
618                 head = get_buffer_data(scan_offset, &data_buffer, 0);
619                 printf("%016jx ", scan_offset);
620
621                 switch(head->head.hdr_type) {
622                 case HAMMER_HEAD_TYPE_PAD:
623                         printf("PAD(%04x)\n", head->head.hdr_size);
624                         break;
625                 case HAMMER_HEAD_TYPE_DUMMY:
626                         printf("DUMMY(%04x) seq=%08x\n",
627                                 head->head.hdr_size, head->head.hdr_seq);
628                         break;
629                 case HAMMER_HEAD_TYPE_UNDO:
630                         printf("UNDO(%04x) seq=%08x "
631                                "dataoff=%016jx bytes=%d\n",
632                                 head->head.hdr_size, head->head.hdr_seq,
633                                 (intmax_t)head->undo.undo_offset,
634                                 head->undo.undo_data_bytes);
635                         break;
636                 case HAMMER_HEAD_TYPE_REDO:
637                         printf("REDO(%04x) seq=%08x flags=%08x "
638                                "objid=%016jx logoff=%016jx bytes=%d\n",
639                                 head->head.hdr_size, head->head.hdr_seq,
640                                 head->redo.redo_flags,
641                                 (intmax_t)head->redo.redo_objid,
642                                 (intmax_t)head->redo.redo_offset,
643                                 head->redo.redo_data_bytes);
644                         break;
645                 default:
646                         printf("UNKNOWN(%04x,%04x) seq=%08x\n",
647                                 head->head.hdr_type,
648                                 head->head.hdr_size,
649                                 head->head.hdr_seq);
650                         break;
651                 }
652                 if ((head->head.hdr_size & HAMMER_HEAD_ALIGN_MASK) ||
653                     head->head.hdr_size == 0 ||
654                     head->head.hdr_size > HAMMER_UNDO_ALIGN -
655                                     ((u_int)scan_offset & HAMMER_UNDO_MASK)) {
656                         printf("Illegal size field, skipping to "
657                                "next boundary\n");
658                         scan_offset = (scan_offset + HAMMER_UNDO_MASK) &
659                                         ~HAMMER_UNDO_MASK64;
660                 } else {
661                         scan_offset += head->head.hdr_size;
662                 }
663         }
664         if (data_buffer)
665                 rel_buffer(data_buffer);
666 }