1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * Copyright (c) 2014 Integros [integros.com] 29 * Copyright (c) 2013, 2015 by Delphix. All rights reserved. 30 * Copyright 2024 Oxide Computer Company 31 */ 32 33 #include <ctype.h> 34 #include <libnvpair.h> 35 #include <stdio.h> 36 #include <stdlib.h> 37 #include <strings.h> 38 #include <unistd.h> 39 #include <stddef.h> 40 41 #include <sys/hexdump.h> 42 #include <sys/dmu.h> 43 #include <sys/zfs_ioctl.h> 44 #include <sys/zio.h> 45 #include <zfs_fletcher.h> 46 47 /* 48 * If dump mode is enabled, the number of bytes to print per line 49 */ 50 #define BYTES_PER_LINE 16 51 /* 52 * If dump mode is enabled, the number of bytes to group together, separated 53 * by newlines or spaces 54 */ 55 #define DUMP_GROUPING 4 56 57 uint64_t total_write_size = 0; 58 uint64_t total_stream_len = 0; 59 FILE *send_stream = 0; 60 boolean_t do_byteswap = B_FALSE; 61 boolean_t do_cksum = B_TRUE; 62 63 static void 64 usage(void) 65 { 66 (void) fprintf(stderr, "usage: zstreamdump [-v] [-C] [-d] < file\n"); 67 (void) fprintf(stderr, "\t -v -- verbose\n"); 68 (void) fprintf(stderr, "\t -C -- suppress checksum verification\n"); 69 (void) fprintf(stderr, "\t -d -- dump contents of blocks modified, " 70 "implies verbose\n"); 71 exit(1); 72 } 73 74 static void * 75 safe_malloc(size_t size) 76 { 77 void *rv = malloc(size); 78 if (rv == NULL) { 79 (void) fprintf(stderr, "ERROR; failed to allocate %zu bytes\n", 80 size); 81 abort(); 82 } 83 return (rv); 84 } 85 86 /* 87 * ssread - send stream read. 88 * 89 * Read while computing incremental checksum 90 */ 91 static size_t 92 ssread(void *buf, size_t len, zio_cksum_t *cksum) 93 { 94 size_t outlen; 95 96 if ((outlen = fread(buf, len, 1, send_stream)) == 0) 97 return (0); 98 99 if (do_cksum) { 100 if (do_byteswap) 101 fletcher_4_incremental_byteswap(buf, len, cksum); 102 else 103 fletcher_4_incremental_native(buf, len, cksum); 104 } 105 total_stream_len += len; 106 return (outlen); 107 } 108 109 static size_t 110 read_hdr(dmu_replay_record_t *drr, zio_cksum_t *cksum) 111 { 112 ASSERT3U(offsetof(dmu_replay_record_t, drr_u.drr_checksum.drr_checksum), 113 ==, sizeof (dmu_replay_record_t) - sizeof (zio_cksum_t)); 114 size_t r = ssread(drr, sizeof (*drr) - sizeof (zio_cksum_t), cksum); 115 if (r == 0) 116 return (0); 117 zio_cksum_t saved_cksum = *cksum; 118 r = ssread(&drr->drr_u.drr_checksum.drr_checksum, 119 sizeof (zio_cksum_t), cksum); 120 if (r == 0) 121 return (0); 122 if (!ZIO_CHECKSUM_IS_ZERO(&drr->drr_u.drr_checksum.drr_checksum) && 123 !ZIO_CHECKSUM_EQUAL(saved_cksum, 124 drr->drr_u.drr_checksum.drr_checksum)) { 125 fprintf(stderr, "invalid checksum\n"); 126 (void) printf("Incorrect checksum in record header.\n"); 127 (void) printf("Expected checksum = %llx/%llx/%llx/%llx\n", 128 saved_cksum.zc_word[0], 129 saved_cksum.zc_word[1], 130 saved_cksum.zc_word[2], 131 saved_cksum.zc_word[3]); 132 return (0); 133 } 134 return (sizeof (*drr)); 135 } 136 137 /* 138 * print_block - Dump the contents of a modified block to STDOUT 139 */ 140 static void 141 print_block(char *buf, int length) 142 { 143 hexdump_t h; 144 145 hexdump_init(&h); 146 hexdump_set_width(&h, BYTES_PER_LINE); 147 hexdump_set_grouping(&h, DUMP_GROUPING); 148 hexdump_set_indent(&h, 1); 149 (void) hexdump_fileh(&h, (const uint8_t *)buf, length, 150 HDF_DEFAULT | HDF_DOUBLESPACE, stdout); 151 hexdump_fini(&h); 152 } 153 154 /* 155 * Print an array of bytes to stdout as hexidecimal characters. str must 156 * have buf_len * 2 + 1 bytes of space. 157 */ 158 static void 159 sprintf_bytes(char *str, uint8_t *buf, uint_t buf_len) 160 { 161 int i, n; 162 163 for (i = 0; i < buf_len; i++) { 164 n = sprintf(str, "%02x", buf[i] & 0xff); 165 str += n; 166 } 167 168 str[0] = '\0'; 169 } 170 171 int 172 main(int argc, char *argv[]) 173 { 174 char *buf = safe_malloc(SPA_MAXBLOCKSIZE); 175 uint64_t drr_record_count[DRR_NUMTYPES] = { 0 }; 176 char salt[ZIO_DATA_SALT_LEN * 2 + 1]; 177 char iv[ZIO_DATA_IV_LEN * 2 + 1]; 178 char mac[ZIO_DATA_MAC_LEN * 2 + 1]; 179 uint64_t total_records = 0; 180 uint64_t payload_size; 181 dmu_replay_record_t thedrr; 182 dmu_replay_record_t *drr = &thedrr; 183 struct drr_begin *drrb = &thedrr.drr_u.drr_begin; 184 struct drr_end *drre = &thedrr.drr_u.drr_end; 185 struct drr_object *drro = &thedrr.drr_u.drr_object; 186 struct drr_freeobjects *drrfo = &thedrr.drr_u.drr_freeobjects; 187 struct drr_write *drrw = &thedrr.drr_u.drr_write; 188 struct drr_write_byref *drrwbr = &thedrr.drr_u.drr_write_byref; 189 struct drr_free *drrf = &thedrr.drr_u.drr_free; 190 struct drr_spill *drrs = &thedrr.drr_u.drr_spill; 191 struct drr_write_embedded *drrwe = &thedrr.drr_u.drr_write_embedded; 192 struct drr_object_range *drror = &thedrr.drr_u.drr_object_range; 193 struct drr_checksum *drrc = &thedrr.drr_u.drr_checksum; 194 int c; 195 boolean_t verbose = B_FALSE; 196 boolean_t very_verbose = B_FALSE; 197 boolean_t first = B_TRUE; 198 /* 199 * dump flag controls whether the contents of any modified data blocks 200 * are printed to the console during processing of the stream. Warning: 201 * for large streams, this can obviously lead to massive prints. 202 */ 203 boolean_t dump = B_FALSE; 204 int err; 205 zio_cksum_t zc = { 0 }; 206 zio_cksum_t pcksum = { 0 }; 207 208 while ((c = getopt(argc, argv, ":vCd")) != -1) { 209 switch (c) { 210 case 'C': 211 do_cksum = B_FALSE; 212 break; 213 case 'v': 214 if (verbose) 215 very_verbose = B_TRUE; 216 verbose = B_TRUE; 217 break; 218 case 'd': 219 dump = B_TRUE; 220 verbose = B_TRUE; 221 very_verbose = B_TRUE; 222 break; 223 case ':': 224 (void) fprintf(stderr, 225 "missing argument for '%c' option\n", optopt); 226 usage(); 227 break; 228 case '?': 229 (void) fprintf(stderr, "invalid option '%c'\n", 230 optopt); 231 usage(); 232 break; 233 } 234 } 235 236 if (isatty(STDIN_FILENO)) { 237 (void) fprintf(stderr, 238 "Error: Backup stream can not be read " 239 "from a terminal.\n" 240 "You must redirect standard input.\n"); 241 exit(1); 242 } 243 244 fletcher_4_init(); 245 send_stream = stdin; 246 while (read_hdr(drr, &zc)) { 247 248 /* 249 * If this is the first DMU record being processed, check for 250 * the magic bytes and figure out the endian-ness based on them. 251 */ 252 if (first) { 253 if (drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC)) { 254 do_byteswap = B_TRUE; 255 if (do_cksum) { 256 ZIO_SET_CHECKSUM(&zc, 0, 0, 0, 0); 257 /* 258 * recalculate header checksum now 259 * that we know it needs to be 260 * byteswapped. 261 */ 262 fletcher_4_incremental_byteswap(drr, 263 sizeof (dmu_replay_record_t), &zc); 264 } 265 } else if (drrb->drr_magic != DMU_BACKUP_MAGIC) { 266 (void) fprintf(stderr, "Invalid stream " 267 "(bad magic number)\n"); 268 exit(1); 269 } 270 first = B_FALSE; 271 } 272 if (do_byteswap) { 273 drr->drr_type = BSWAP_32(drr->drr_type); 274 drr->drr_payloadlen = 275 BSWAP_32(drr->drr_payloadlen); 276 } 277 278 /* 279 * At this point, the leading fields of the replay record 280 * (drr_type and drr_payloadlen) have been byte-swapped if 281 * necessary, but the rest of the data structure (the 282 * union of type-specific structures) is still in its 283 * original state. 284 */ 285 if (drr->drr_type >= DRR_NUMTYPES) { 286 (void) printf("INVALID record found: type 0x%x\n", 287 drr->drr_type); 288 (void) printf("Aborting.\n"); 289 exit(1); 290 } 291 292 drr_record_count[drr->drr_type]++; 293 total_records++; 294 295 switch (drr->drr_type) { 296 case DRR_BEGIN: 297 if (do_byteswap) { 298 drrb->drr_magic = BSWAP_64(drrb->drr_magic); 299 drrb->drr_versioninfo = 300 BSWAP_64(drrb->drr_versioninfo); 301 drrb->drr_creation_time = 302 BSWAP_64(drrb->drr_creation_time); 303 drrb->drr_type = BSWAP_32(drrb->drr_type); 304 drrb->drr_flags = BSWAP_32(drrb->drr_flags); 305 drrb->drr_toguid = BSWAP_64(drrb->drr_toguid); 306 drrb->drr_fromguid = 307 BSWAP_64(drrb->drr_fromguid); 308 } 309 310 (void) printf("BEGIN record\n"); 311 (void) printf("\thdrtype = %lld\n", 312 DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo)); 313 (void) printf("\tfeatures = %llx\n", 314 DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo)); 315 (void) printf("\tmagic = %llx\n", 316 (u_longlong_t)drrb->drr_magic); 317 (void) printf("\tcreation_time = %llx\n", 318 (u_longlong_t)drrb->drr_creation_time); 319 (void) printf("\ttype = %u\n", drrb->drr_type); 320 (void) printf("\tflags = 0x%x\n", drrb->drr_flags); 321 (void) printf("\ttoguid = %llx\n", 322 (u_longlong_t)drrb->drr_toguid); 323 (void) printf("\tfromguid = %llx\n", 324 (u_longlong_t)drrb->drr_fromguid); 325 (void) printf("\ttoname = %s\n", drrb->drr_toname); 326 if (verbose) 327 (void) printf("\n"); 328 329 if (drr->drr_payloadlen != 0) { 330 nvlist_t *nv; 331 int sz = drr->drr_payloadlen; 332 333 if (sz > SPA_MAXBLOCKSIZE) { 334 free(buf); 335 buf = safe_malloc(sz); 336 } 337 (void) ssread(buf, sz, &zc); 338 if (ferror(send_stream)) 339 perror("fread"); 340 err = nvlist_unpack(buf, sz, &nv, 0); 341 if (err) 342 perror(strerror(err)); 343 nvlist_print(stdout, nv); 344 nvlist_free(nv); 345 } 346 break; 347 348 case DRR_END: 349 if (do_byteswap) { 350 drre->drr_checksum.zc_word[0] = 351 BSWAP_64(drre->drr_checksum.zc_word[0]); 352 drre->drr_checksum.zc_word[1] = 353 BSWAP_64(drre->drr_checksum.zc_word[1]); 354 drre->drr_checksum.zc_word[2] = 355 BSWAP_64(drre->drr_checksum.zc_word[2]); 356 drre->drr_checksum.zc_word[3] = 357 BSWAP_64(drre->drr_checksum.zc_word[3]); 358 } 359 /* 360 * We compare against the *previous* checksum 361 * value, because the stored checksum is of 362 * everything before the DRR_END record. 363 */ 364 if (do_cksum && !ZIO_CHECKSUM_EQUAL(drre->drr_checksum, 365 pcksum)) { 366 (void) printf("Expected checksum differs from " 367 "checksum in stream.\n"); 368 (void) printf("Expected checksum = " 369 "%llx/%llx/%llx/%llx\n", 370 pcksum.zc_word[0], 371 pcksum.zc_word[1], 372 pcksum.zc_word[2], 373 pcksum.zc_word[3]); 374 } 375 (void) printf("END checksum = %llx/%llx/%llx/%llx\n", 376 drre->drr_checksum.zc_word[0], 377 drre->drr_checksum.zc_word[1], 378 drre->drr_checksum.zc_word[2], 379 drre->drr_checksum.zc_word[3]); 380 381 ZIO_SET_CHECKSUM(&zc, 0, 0, 0, 0); 382 break; 383 384 case DRR_OBJECT: 385 if (do_byteswap) { 386 drro->drr_object = BSWAP_64(drro->drr_object); 387 drro->drr_type = BSWAP_32(drro->drr_type); 388 drro->drr_bonustype = 389 BSWAP_32(drro->drr_bonustype); 390 drro->drr_blksz = BSWAP_32(drro->drr_blksz); 391 drro->drr_bonuslen = 392 BSWAP_32(drro->drr_bonuslen); 393 drro->drr_raw_bonuslen = 394 BSWAP_32(drro->drr_raw_bonuslen); 395 drro->drr_toguid = BSWAP_64(drro->drr_toguid); 396 } 397 398 payload_size = DRR_OBJECT_PAYLOAD_SIZE(drro); 399 400 if (verbose) { 401 (void) printf("OBJECT object = %" PRIu64 402 "type = %u bonustype = %u blksz = %u " 403 "bonuslen = %u " 404 "raw_bonuslen = %u flags = %u maxblkid " 405 "= %llu " 406 "indblkshift = %u nlevels = %u " 407 "nblkptr = %u\n", 408 (u_longlong_t)drro->drr_object, 409 drro->drr_type, 410 drro->drr_bonustype, 411 drro->drr_blksz, 412 drro->drr_bonuslen, 413 drro->drr_raw_bonuslen, 414 drro->drr_flags, 415 (u_longlong_t)drro->drr_maxblkid, 416 drro->drr_indblkshift, 417 drro->drr_nlevels, 418 drro->drr_nblkptr); 419 } 420 if (drro->drr_bonuslen > 0) { 421 (void) ssread(buf, payload_size, &zc); 422 if (dump) 423 print_block(buf, payload_size); 424 } 425 break; 426 427 case DRR_FREEOBJECTS: 428 if (do_byteswap) { 429 drrfo->drr_firstobj = 430 BSWAP_64(drrfo->drr_firstobj); 431 drrfo->drr_numobjs = 432 BSWAP_64(drrfo->drr_numobjs); 433 drrfo->drr_toguid = BSWAP_64(drrfo->drr_toguid); 434 } 435 if (verbose) { 436 (void) printf("FREEOBJECTS firstobj = %llu " 437 "numobjs = %llu\n", 438 (u_longlong_t)drrfo->drr_firstobj, 439 (u_longlong_t)drrfo->drr_numobjs); 440 } 441 break; 442 443 case DRR_WRITE: 444 if (do_byteswap) { 445 drrw->drr_object = BSWAP_64(drrw->drr_object); 446 drrw->drr_type = BSWAP_32(drrw->drr_type); 447 drrw->drr_offset = BSWAP_64(drrw->drr_offset); 448 drrw->drr_logical_size = 449 BSWAP_64(drrw->drr_logical_size); 450 drrw->drr_toguid = BSWAP_64(drrw->drr_toguid); 451 drrw->drr_key.ddk_prop = 452 BSWAP_64(drrw->drr_key.ddk_prop); 453 drrw->drr_compressed_size = 454 BSWAP_64(drrw->drr_compressed_size); 455 } 456 457 payload_size = DRR_WRITE_PAYLOAD_SIZE(drrw); 458 459 /* 460 * If this is verbose and/or dump output, 461 * print info on the modified block 462 */ 463 if (verbose) { 464 sprintf_bytes(salt, drrw->drr_salt, 465 ZIO_DATA_SALT_LEN); 466 sprintf_bytes(iv, drrw->drr_iv, 467 ZIO_DATA_IV_LEN); 468 sprintf_bytes(mac, drrw->drr_mac, 469 ZIO_DATA_MAC_LEN); 470 471 (void) printf("WRITE object = %llu type = %u " 472 "checksum type = %u compression type = %u\n" 473 " flags = %u offset = %llu " 474 "logical_size = %llu " 475 "compressed_size = %llu " 476 "payload_size = %llu props = %llx " 477 "salt = %s iv = %s mac = %s\n", 478 (u_longlong_t)drrw->drr_object, 479 drrw->drr_type, 480 drrw->drr_checksumtype, 481 drrw->drr_compressiontype, 482 drrw->drr_flags, 483 (u_longlong_t)drrw->drr_offset, 484 (u_longlong_t)drrw->drr_logical_size, 485 (u_longlong_t)drrw->drr_compressed_size, 486 (u_longlong_t)payload_size, 487 (u_longlong_t)drrw->drr_key.ddk_prop, 488 salt, 489 iv, 490 mac); 491 } 492 493 /* 494 * Read the contents of the block in from STDIN to buf 495 */ 496 (void) ssread(buf, payload_size, &zc); 497 /* 498 * If in dump mode 499 */ 500 if (dump) { 501 print_block(buf, payload_size); 502 } 503 total_write_size += payload_size; 504 break; 505 506 case DRR_WRITE_BYREF: 507 if (do_byteswap) { 508 drrwbr->drr_object = 509 BSWAP_64(drrwbr->drr_object); 510 drrwbr->drr_offset = 511 BSWAP_64(drrwbr->drr_offset); 512 drrwbr->drr_length = 513 BSWAP_64(drrwbr->drr_length); 514 drrwbr->drr_toguid = 515 BSWAP_64(drrwbr->drr_toguid); 516 drrwbr->drr_refguid = 517 BSWAP_64(drrwbr->drr_refguid); 518 drrwbr->drr_refobject = 519 BSWAP_64(drrwbr->drr_refobject); 520 drrwbr->drr_refoffset = 521 BSWAP_64(drrwbr->drr_refoffset); 522 drrwbr->drr_key.ddk_prop = 523 BSWAP_64(drrwbr->drr_key.ddk_prop); 524 } 525 if (verbose) { 526 (void) printf("WRITE_BYREF object = %llu " 527 "checksum type = %u props = %llx\n" 528 " offset = %llu length = %llu\n" 529 "toguid = %llx refguid = %llx\n" 530 " refobject = %llu refoffset = %llu\n", 531 (u_longlong_t)drrwbr->drr_object, 532 drrwbr->drr_checksumtype, 533 (u_longlong_t)drrwbr->drr_key.ddk_prop, 534 (u_longlong_t)drrwbr->drr_offset, 535 (u_longlong_t)drrwbr->drr_length, 536 (u_longlong_t)drrwbr->drr_toguid, 537 (u_longlong_t)drrwbr->drr_refguid, 538 (u_longlong_t)drrwbr->drr_refobject, 539 (u_longlong_t)drrwbr->drr_refoffset); 540 } 541 break; 542 543 case DRR_FREE: 544 if (do_byteswap) { 545 drrf->drr_object = BSWAP_64(drrf->drr_object); 546 drrf->drr_offset = BSWAP_64(drrf->drr_offset); 547 drrf->drr_length = BSWAP_64(drrf->drr_length); 548 } 549 if (verbose) { 550 (void) printf("FREE object = %llu " 551 "offset = %llu length = %lld\n", 552 (u_longlong_t)drrf->drr_object, 553 (u_longlong_t)drrf->drr_offset, 554 (longlong_t)drrf->drr_length); 555 } 556 break; 557 case DRR_SPILL: 558 if (do_byteswap) { 559 drrs->drr_object = BSWAP_64(drrs->drr_object); 560 drrs->drr_length = BSWAP_64(drrs->drr_length); 561 drrs->drr_compressed_size = 562 BSWAP_64(drrs->drr_compressed_size); 563 drrs->drr_type = BSWAP_32(drrs->drr_type); 564 } 565 566 payload_size = DRR_SPILL_PAYLOAD_SIZE(drrs); 567 568 if (verbose) { 569 sprintf_bytes(salt, drrs->drr_salt, 570 ZIO_DATA_SALT_LEN); 571 sprintf_bytes(iv, drrs->drr_iv, 572 ZIO_DATA_IV_LEN); 573 sprintf_bytes(mac, drrs->drr_mac, 574 ZIO_DATA_MAC_LEN); 575 576 (void) printf("SPILL block for object = %llu " 577 "length = %llu flags = %u " 578 "compression type = %u " 579 "compressed_size = %llu " 580 "payload_size = %llu " 581 "salt = %s iv = %s mac = %s\n", 582 (u_longlong_t)drrs->drr_object, 583 (u_longlong_t)drrs->drr_length, 584 drrs->drr_flags, 585 drrs->drr_compressiontype, 586 (u_longlong_t)drrs->drr_compressed_size, 587 (u_longlong_t)payload_size, 588 salt, 589 iv, 590 mac); 591 } 592 (void) ssread(buf, payload_size, &zc); 593 if (dump) { 594 print_block(buf, payload_size); 595 } 596 break; 597 case DRR_WRITE_EMBEDDED: 598 if (do_byteswap) { 599 drrwe->drr_object = 600 BSWAP_64(drrwe->drr_object); 601 drrwe->drr_offset = 602 BSWAP_64(drrwe->drr_offset); 603 drrwe->drr_length = 604 BSWAP_64(drrwe->drr_length); 605 drrwe->drr_toguid = 606 BSWAP_64(drrwe->drr_toguid); 607 drrwe->drr_lsize = 608 BSWAP_32(drrwe->drr_lsize); 609 drrwe->drr_psize = 610 BSWAP_32(drrwe->drr_psize); 611 } 612 if (verbose) { 613 (void) printf("WRITE_EMBEDDED object = %llu " 614 "offset = %llu length = %llu\n" 615 " toguid = %llx comp = %u etype = %u " 616 "lsize = %u psize = %u\n", 617 (u_longlong_t)drrwe->drr_object, 618 (u_longlong_t)drrwe->drr_offset, 619 (u_longlong_t)drrwe->drr_length, 620 (u_longlong_t)drrwe->drr_toguid, 621 drrwe->drr_compression, 622 drrwe->drr_etype, 623 drrwe->drr_lsize, 624 drrwe->drr_psize); 625 } 626 (void) ssread(buf, 627 P2ROUNDUP(drrwe->drr_psize, 8), &zc); 628 break; 629 case DRR_OBJECT_RANGE: 630 if (do_byteswap) { 631 drror->drr_firstobj = 632 BSWAP_64(drror->drr_firstobj); 633 drror->drr_numslots = 634 BSWAP_64(drror->drr_numslots); 635 drror->drr_toguid = BSWAP_64(drror->drr_toguid); 636 } 637 if (verbose) { 638 sprintf_bytes(salt, drror->drr_salt, 639 ZIO_DATA_SALT_LEN); 640 sprintf_bytes(iv, drror->drr_iv, 641 ZIO_DATA_IV_LEN); 642 sprintf_bytes(mac, drror->drr_mac, 643 ZIO_DATA_MAC_LEN); 644 645 (void) printf("OBJECT_RANGE firstobj = %llu " 646 "numslots = %llu flags = %u " 647 "salt = %s iv = %s mac = %s\n", 648 (u_longlong_t)drror->drr_firstobj, 649 (u_longlong_t)drror->drr_numslots, 650 drror->drr_flags, 651 salt, 652 iv, 653 mac); 654 } 655 break; 656 case DRR_NUMTYPES: 657 /* should never be reached */ 658 exit(1); 659 } 660 if (drr->drr_type != DRR_BEGIN && very_verbose) { 661 (void) printf(" checksum = %llx/%llx/%llx/%llx\n", 662 (longlong_t)drrc->drr_checksum.zc_word[0], 663 (longlong_t)drrc->drr_checksum.zc_word[1], 664 (longlong_t)drrc->drr_checksum.zc_word[2], 665 (longlong_t)drrc->drr_checksum.zc_word[3]); 666 } 667 pcksum = zc; 668 } 669 free(buf); 670 fletcher_4_fini(); 671 672 /* Print final summary */ 673 674 (void) printf("SUMMARY:\n"); 675 (void) printf("\tTotal DRR_BEGIN records = %lld\n", 676 (u_longlong_t)drr_record_count[DRR_BEGIN]); 677 (void) printf("\tTotal DRR_END records = %lld\n", 678 (u_longlong_t)drr_record_count[DRR_END]); 679 (void) printf("\tTotal DRR_OBJECT records = %lld\n", 680 (u_longlong_t)drr_record_count[DRR_OBJECT]); 681 (void) printf("\tTotal DRR_FREEOBJECTS records = %lld\n", 682 (u_longlong_t)drr_record_count[DRR_FREEOBJECTS]); 683 (void) printf("\tTotal DRR_WRITE records = %lld\n", 684 (u_longlong_t)drr_record_count[DRR_WRITE]); 685 (void) printf("\tTotal DRR_WRITE_BYREF records = %lld\n", 686 (u_longlong_t)drr_record_count[DRR_WRITE_BYREF]); 687 (void) printf("\tTotal DRR_WRITE_EMBEDDED records = %lld\n", 688 (u_longlong_t)drr_record_count[DRR_WRITE_EMBEDDED]); 689 (void) printf("\tTotal DRR_FREE records = %lld\n", 690 (u_longlong_t)drr_record_count[DRR_FREE]); 691 (void) printf("\tTotal DRR_SPILL records = %lld\n", 692 (u_longlong_t)drr_record_count[DRR_SPILL]); 693 (void) printf("\tTotal records = %lld\n", 694 (u_longlong_t)total_records); 695 (void) printf("\tTotal write size = %lld (0x%llx)\n", 696 (u_longlong_t)total_write_size, (u_longlong_t)total_write_size); 697 (void) printf("\tTotal stream length = %lld (0x%llx)\n", 698 (u_longlong_t)total_stream_len, (u_longlong_t)total_stream_len); 699 return (0); 700 } 701