Path: blob/main/sys/contrib/openzfs/cmd/zstream/zstream_util.h
178703 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* This file and its contents are supplied under the terms of the5* Common Development and Distribution License ("CDDL"), version 1.0.6* You may only use this file in accordance with the terms of version7* 1.0 of the CDDL.8*9* A full copy of the text of the CDDL should have accompanied this10* source. A copy of the CDDL is also available via the Internet at11* http://www.illumos.org/license/CDDL.12*13* CDDL HEADER END14*/1516/*17* Copyright (c) 2026 by Garth Snyder. All rights reserved.18*/1920#ifndef _ZSTREAM_UTIL_H21#define _ZSTREAM_UTIL_H2223#ifdef __cplusplus24extern "C" {25#endif2627#include <stddef.h>28#include <sys/zfs_ioctl.h>29#include <sys/zio_checksum.h>3031/*32* The safe_ versions of the functions below terminate the process if the33* operation doesn't succeed instead of returning an error.34*/35extern void *36safe_malloc(size_t size);3738extern void *39safe_calloc(size_t n);4041extern int42sfread(void *buf, size_t size, FILE *fp);4344/*45* 1) Update checksum with the record header up to drr_checksum.46* 2) Update checksum field in the record header.47* 3) Update checksum with the checksum field in the record header.48* 4) Update checksum with the contents of the payload.49* 5) Write header and payload to fd.50*/51extern int52dump_record(dmu_replay_record_t *drr, void *payload, size_t payload_len,53zio_cksum_t *zc, int outfd);5455#ifdef __cplusplus56}57#endif5859#endif /* _ZSTREAM_UTIL_H */606162