diff options
author | Matthew Macy <[email protected]> | 2019-11-12 10:40:39 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-11-12 10:40:39 -0800 |
commit | 1f2f46be9576964c90ca25805c9741d56bbaccdf (patch) | |
tree | c97f1f0f4d02df788bb4e16350aed7e0c577304c /lib | |
parent | 066e825221012e1e81ccf46b0448772bdd7e5483 (diff) |
Add wrapper stub for zfs_cmd ioctl to libzpool
FreeBSD needs a wrapper for handling zfs_cmd ioctls.
In libzfs this is handled by zfs_ioctl. However, here
we need to wrap the call directly.
Reviewed-by: Allan Jude <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Closes #9511
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs_core/Makefile.am | 3 | ||||
-rw-r--r-- | lib/libzfs_core/libzfs_core.c | 11 | ||||
-rw-r--r-- | lib/libzpool/util.c | 2 | ||||
-rw-r--r-- | lib/libzutil/Makefile.am | 3 | ||||
-rw-r--r-- | lib/libzutil/os/linux/zutil_compat.c | 30 |
5 files changed, 41 insertions, 8 deletions
diff --git a/lib/libzfs_core/Makefile.am b/lib/libzfs_core/Makefile.am index bc3d309f8..dca81e01a 100644 --- a/lib/libzfs_core/Makefile.am +++ b/lib/libzfs_core/Makefile.am @@ -9,7 +9,8 @@ nodist_libzfs_core_la_SOURCES = $(USER_C) libzfs_core_la_LIBADD = \ $(top_builddir)/lib/libnvpair/libnvpair.la \ - $(top_builddir)/lib/libuutil/libuutil.la + $(top_builddir)/lib/libuutil/libuutil.la \ + $(top_builddir)/lib/libzutil/libzutil.la libzfs_core_la_LDFLAGS = -version-info 1:0:0 diff --git a/lib/libzfs_core/libzfs_core.c b/lib/libzfs_core/libzfs_core.c index 7430a845a..2f31edcc2 100644 --- a/lib/libzfs_core/libzfs_core.c +++ b/lib/libzfs_core/libzfs_core.c @@ -84,6 +84,7 @@ #include <errno.h> #include <fcntl.h> #include <pthread.h> +#include <libzutil.h> #include <sys/nvpair.h> #include <sys/param.h> #include <sys/types.h> @@ -208,7 +209,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name, } } - while (ioctl(g_fd, ioc, &zc) != 0) { + while (zfs_ioctl_fd(g_fd, ioc, &zc) != 0) { /* * If ioctl exited with ENOMEM, we retry the ioctl after * increasing the size of the destination nvlist. @@ -297,7 +298,7 @@ lzc_promote(const char *fsname, char *snapnamebuf, int snapnamelen) VERIFY3S(g_fd, !=, -1); (void) strlcpy(zc.zc_name, fsname, sizeof (zc.zc_name)); - if (ioctl(g_fd, ZFS_IOC_PROMOTE, &zc) != 0) { + if (zfs_ioctl_fd(g_fd, ZFS_IOC_PROMOTE, &zc) != 0) { int error = errno; if (error == EEXIST && snapnamebuf != NULL) (void) strlcpy(snapnamebuf, zc.zc_string, snapnamelen); @@ -315,7 +316,7 @@ lzc_rename(const char *source, const char *target) VERIFY3S(g_fd, !=, -1); (void) strlcpy(zc.zc_name, source, sizeof (zc.zc_name)); (void) strlcpy(zc.zc_value, target, sizeof (zc.zc_value)); - error = ioctl(g_fd, ZFS_IOC_RENAME, &zc); + error = zfs_ioctl_fd(g_fd, ZFS_IOC_RENAME, &zc); if (error != 0) error = errno; return (error); @@ -465,7 +466,7 @@ lzc_exists(const char *dataset) VERIFY3S(g_fd, !=, -1); (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name)); - return (ioctl(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0); + return (zfs_ioctl_fd(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0); } /* @@ -937,7 +938,7 @@ recv_impl(const char *snapname, nvlist_t *recvdprops, nvlist_t *localprops, zc.zc_nvlist_dst = (uint64_t)(uintptr_t) malloc(zc.zc_nvlist_dst_size); - error = ioctl(g_fd, ZFS_IOC_RECV, &zc); + error = zfs_ioctl_fd(g_fd, ZFS_IOC_RECV, &zc); if (error != 0) { error = errno; } else { diff --git a/lib/libzpool/util.c b/lib/libzpool/util.c index 67bc209ce..df1084cb6 100644 --- a/lib/libzpool/util.c +++ b/lib/libzpool/util.c @@ -237,7 +237,7 @@ pool_active(void *unused, const char *name, uint64_t guid, zcp->zc_nvlist_src = (uint64_t)(uintptr_t)packed; zcp->zc_nvlist_src_size = size; - ret = ioctl(fd, ZFS_IOC_POOL_SYNC, zcp); + ret = zfs_ioctl_fd(fd, ZFS_IOC_POOL_SYNC, zcp); fnvlist_pack_free(packed, size); free((void *)(uintptr_t)zcp->zc_nvlist_dst); diff --git a/lib/libzutil/Makefile.am b/lib/libzutil/Makefile.am index 8b53c374e..e5c6a340d 100644 --- a/lib/libzutil/Makefile.am +++ b/lib/libzutil/Makefile.am @@ -17,7 +17,8 @@ USER_C = \ if BUILD_LINUX USER_C += \ os/linux/zutil_device_path_os.c \ - os/linux/zutil_import_os.c + os/linux/zutil_import_os.c \ + os/linux/zutil_compat.c endif nodist_libzutil_la_SOURCES = $(USER_C) diff --git a/lib/libzutil/os/linux/zutil_compat.c b/lib/libzutil/os/linux/zutil_compat.c new file mode 100644 index 000000000..173ae9cb6 --- /dev/null +++ b/lib/libzutil/os/linux/zutil_compat.c @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +#include <sys/types.h> +#include <sys/param.h> +#include <sys/zfs_ioctl.h> +#include <libzutil.h> + +int +zfs_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc) +{ + return (ioctl(fd, request, zc)); +} |