zstream: consolidate shared code

zstream currently contains three identical copies of dump_record(),
which appear to all be drawn from libzfs_sendrecv.c. The original
is marked internal.

This PR adds zstream_util.[hc] and puts the shared code there along with
a couple of other items in common.

No functional changes.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Garth Snyder <garth@garthsnyder.com>
Closes #18284
This commit is contained in:
Garth Snyder
2026-03-05 15:33:03 -08:00
committed by GitHub
parent 5dad9459d5
commit d979457760
8 changed files with 173 additions and 119 deletions
+1 -12
View File
@@ -44,6 +44,7 @@
#include <sys/zio.h>
#include <zfs_fletcher.h>
#include "zstream.h"
#include "zstream_util.h"
/*
* If dump mode is enabled, the number of bytes to print per line
@@ -60,18 +61,6 @@ static FILE *send_stream = 0;
static boolean_t do_byteswap = B_FALSE;
static boolean_t do_cksum = B_TRUE;
void *
safe_malloc(size_t size)
{
void *rv = malloc(size);
if (rv == NULL) {
(void) fprintf(stderr, "ERROR; failed to allocate %zu bytes\n",
size);
abort();
}
return (rv);
}
/*
* ssread - send stream read.
*