Fix -Wuse-after-free warning in dbuf_issue_final_prefetch_done()
[zfs.git] / cmd / zstream / zstream_token.c
blobbedb6893c508096fbfdc209dd51b750cb6c05bbf
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 * Portions Copyright 2012 Martin Matuska <martin@matuska.org>
30 * Copyright (c) 2020 by Datto Inc. All rights reserved.
33 #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>
41 #include <libzfs.h>
42 #include <libzfs_core.h>
44 #include <sys/dmu.h>
45 #include <sys/zfs_ioctl.h>
46 #include "zstream.h"
48 int
49 zstream_do_token(int argc, char *argv[])
51 char *resume_token = NULL;
53 if (argc < 2) {
54 (void) fprintf(stderr, "Need to pass the resume token\n");
55 zstream_usage();
58 resume_token = argv[1];
60 libzfs_handle_t *hdl = libzfs_init();
62 nvlist_t *resume_nvl =
63 zfs_send_resume_token_to_nvlist(hdl, resume_token);
65 if (resume_nvl == NULL) {
66 (void) fprintf(stderr,
67 "Unable to parse resume token: %s\n",
68 libzfs_error_description(hdl));
69 libzfs_fini(hdl);
70 return (1);
73 dump_nvlist(resume_nvl, 5);
74 nvlist_free(resume_nvl);
76 libzfs_fini(hdl);
77 return (0);