diff --git a/lib/libzfs_core/Makefile.am b/lib/libzfs_core/Makefile.am index d1c6fb86d..42ac6081c 100644 --- a/lib/libzfs_core/Makefile.am +++ b/lib/libzfs_core/Makefile.am @@ -1,18 +1,21 @@ libzfs_core_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) libzfs_core_la_CFLAGS += -fvisibility=hidden +libzfs_core_la_CPPFLAGS = $(AM_CPPFLAGS) +libzfs_core_la_CPPFLAGS += -I$(srcdir)/%D% + lib_LTLIBRARIES += libzfs_core.la CPPCHECKTARGETS += libzfs_core.la libzfs_core_la_SOURCES = \ - %D%/libzfs_core.c + %D%/libzfs_core.c \ + %D%/libzfs_core_impl.h if BUILD_LINUX libzfs_core_la_SOURCES += \ %D%/os/linux/libzfs_core_ioctl.c endif -libzfs_core_la_CPPFLAGS = $(AM_CPPFLAGS) if BUILD_FREEBSD libzfs_core_la_CPPFLAGS += -Iinclude/os/freebsd/zfs diff --git a/lib/libzfs_core/libzfs_core.c b/lib/libzfs_core/libzfs_core.c index 4b1e797bf..5958cd98d 100644 --- a/lib/libzfs_core/libzfs_core.c +++ b/lib/libzfs_core/libzfs_core.c @@ -96,6 +96,8 @@ #define BIG_PIPE_SIZE (64 * 1024) /* From sys/pipe.h */ #endif +#include "libzfs_core_impl.h" + static int g_fd = -1; static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; static int g_refcount; @@ -171,6 +173,12 @@ libzfs_core_fini(void) (void) pthread_mutex_unlock(&g_lock); } +int +lzc_ioctl_fd(int fd, unsigned long ioc, zfs_cmd_t *zc) +{ + return (lzc_ioctl_fd_os(fd, ioc, zc)); +} + static int lzc_ioctl(zfs_ioc_t ioc, const char *name, nvlist_t *source, nvlist_t **resultp) diff --git a/lib/libzfs_core/libzfs_core_impl.h b/lib/libzfs_core/libzfs_core_impl.h new file mode 100644 index 000000000..baf9a7a95 --- /dev/null +++ b/lib/libzfs_core/libzfs_core_impl.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: CDDL-1.0 +/* + * 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 https://opensource.org/licenses/CDDL-1.0. + * 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 + */ + +/* + * Copyright (c) 2012, 2020 by Delphix. All rights reserved. + * Copyright 2017 RackTop Systems. + * Copyright (c) 2017 Open-E, Inc. All Rights Reserved. + * Copyright (c) 2019 Datto Inc. + */ + +#ifndef _LIBZFS_CORE_IMPL_H +#define _LIBZFS_CORE_IMPL_H + +struct zfs_cmd; +int lzc_ioctl_fd_os(int, unsigned long, struct zfs_cmd *); + +#endif /* _LIBZFS_CORE_IMPL_H */ diff --git a/lib/libzfs_core/os/freebsd/libzfs_core_ioctl.c b/lib/libzfs_core/os/freebsd/libzfs_core_ioctl.c index b3b93dc91..39e217a93 100644 --- a/lib/libzfs_core/os/freebsd/libzfs_core_ioctl.c +++ b/lib/libzfs_core/os/freebsd/libzfs_core_ioctl.c @@ -26,6 +26,7 @@ #include #include #include +#include "libzfs_core_impl.h" int zfs_ioctl_version = ZFS_IOCVER_UNDEF; @@ -101,7 +102,7 @@ zcmd_ioctl_compat(int fd, int request, zfs_cmd_t *zc, const int cflag) * error is returned zc_nvlist_dst_size won't be updated. */ int -lzc_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc) +lzc_ioctl_fd_os(int fd, unsigned long request, zfs_cmd_t *zc) { size_t oldsize; int ret, cflag = ZFS_CMD_COMPAT_NONE; diff --git a/lib/libzfs_core/os/linux/libzfs_core_ioctl.c b/lib/libzfs_core/os/linux/libzfs_core_ioctl.c index ee76274c0..6823588e2 100644 --- a/lib/libzfs_core/os/linux/libzfs_core_ioctl.c +++ b/lib/libzfs_core/os/linux/libzfs_core_ioctl.c @@ -23,9 +23,10 @@ #include #include #include +#include "libzfs_core_impl.h" int -lzc_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc) +lzc_ioctl_fd_os(int fd, unsigned long request, zfs_cmd_t *zc) { return (ioctl(fd, request, zc)); }