Path: blob/main/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall.c
48529 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* 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.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/2122/*23* Portions Copyright 2020 iXsystems, Inc.24*/2526/*27* Test a corner case : a "doall" send without children datasets.28*/2930#include <libzfs.h>31#include <libzfs_core.h>3233#include <fcntl.h>34#include <stdlib.h>35#include <string.h>36#include <unistd.h>37#include <sysexits.h>38#include <err.h>3940static void41usage(const char *name)42{43fprintf(stderr, "usage: %s snap\n", name);44exit(EX_USAGE);45}4647int48main(int argc, char const * const argv[])49{50sendflags_t flags = { 0 };51libzfs_handle_t *zhdl;52zfs_handle_t *zhp;53const char *tofull, *fsname, *tosnap, *p;54int error;5556if (argc != 2)57usage(argv[0]);5859tofull = argv[1];6061p = strchr(tofull, '@');62if (p == NULL)63usage(argv[0]);64tosnap = p + 1;6566fsname = strndup(tofull, p - tofull);6768zhdl = libzfs_init();69if (zhdl == NULL)70errx(EX_OSERR, "libzfs_init(): %s", libzfs_error_init(errno));7172zhp = zfs_open(zhdl, fsname, ZFS_TYPE_FILESYSTEM);73if (zhp == NULL)74err(EX_OSERR, "zfs_open(\"%s\")", fsname);7576flags.doall = B_TRUE;7778error = zfs_send(zhp, NULL, tosnap, &flags,79STDOUT_FILENO, NULL, NULL, NULL);8081zfs_close(zhp);8283libzfs_fini(zhdl);84free((void *)fsname);8586return (error);87}888990