Path: blob/main/sys/contrib/openzfs/cmd/zstream/zstream_token.c
48383 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* Copyright 2010 Sun Microsystems, Inc. All rights reserved.24* Use is subject to license terms.25*26* Portions Copyright 2012 Martin Matuska <[email protected]>27*/2829/*30* Copyright (c) 2020 by Datto Inc. All rights reserved.31*/3233#include <ctype.h>34#include <libnvpair.h>35#include <stdio.h>36#include <stdlib.h>37#include <string.h>38#include <unistd.h>39#include <stddef.h>4041#include <libzfs.h>42#include <libzfs_core.h>4344#include <sys/dmu.h>45#include <sys/zfs_ioctl.h>46#include "zstream.h"4748int49zstream_do_token(int argc, char *argv[])50{51char *resume_token = NULL;52libzfs_handle_t *hdl;5354if (argc < 2) {55(void) fprintf(stderr, "Need to pass the resume token\n");56zstream_usage();57}5859resume_token = argv[1];6061if ((hdl = libzfs_init()) == NULL) {62(void) fprintf(stderr, "%s\n", libzfs_error_init(errno));63return (1);64}6566nvlist_t *resume_nvl =67zfs_send_resume_token_to_nvlist(hdl, resume_token);6869if (resume_nvl == NULL) {70(void) fprintf(stderr,71"Unable to parse resume token: %s\n",72libzfs_error_description(hdl));73libzfs_fini(hdl);74return (1);75}7677dump_nvlist(resume_nvl, 5);78nvlist_free(resume_nvl);7980libzfs_fini(hdl);81return (0);82}838485