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 <allanjude@freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9511
This commit is contained in:
Matthew Macy
2019-11-12 10:40:39 -08:00
committed by Brian Behlendorf
parent 066e825221
commit 1f2f46be95
6 changed files with 44 additions and 8 deletions
+2 -1
View File
@@ -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
+6 -5
View File
@@ -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 {