// SPDX-License-Identifier: CDDL-1.0 /* * This file and its contents are supplied under the terms of the * Common Development and Distribution License ("CDDL"), version 1.0. * You may only use this file in accordance with the terms of version * 1.0 of the CDDL. * * A full copy of the text of the CDDL should have accompanied this * source. A copy of the CDDL is also available via the Internet at * https://opensource.org/license/CDDL-1.0. */ /* Test for zfs channel program support */ #include #include #include #include #include #include #include #include int main(int argc, const char *const *argv) { if (argc != 2) errx(EXIT_FAILURE, "usage: %s pool", argv[0]); zfs_cmd_t zc = {}; (void) strlcpy(zc.zc_name, argv[1], sizeof (zc.zc_name)); char prog[8192] = {}; snprintf(prog, 8192, "zfs.exists(\"%s\")", zc.zc_name); int fd = open(ZFS_DEV, O_RDWR); if (fd == -1) err(EXIT_FAILURE, "%s", ZFS_DEV); nvlist_t *zc_args = fnvlist_alloc(); fnvlist_add_string(zc_args, ZCP_ARG_PROGRAM, prog); size_t sz = 0; char *packed_nvl = fnvlist_pack(zc_args, &sz); zc.zc_nvlist_src = (uint64_t)(uintptr_t)packed_nvl; zc.zc_nvlist_src_size = sz; int rc = EXIT_SUCCESS; if (ioctl(fd, ZFS_IOC_CHANNEL_PROGRAM, &zc) == ZFS_ERR_IOC_CMD_UNAVAIL) rc = EXIT_FAILURE; close(fd); fnvlist_free(zc_args); fnvlist_pack_free(packed_nvl, sz); return (rc); }