mirror of https://github.com/openzfs/zfs.git
Simplify and document OpenZFS library dependencies
For those not already familiar with the code base it can be a challenge to understand how the libraries are laid out. This has sometimes resulted in functionality being added in the wrong place. To help avoid that in the future this commit documents the high-level dependencies for easy reference in lib/Makefile.am. It also simplifies a few things. - Switched libzpool dependency on libzfs_core to libzutil. This change makes it clear libzpool should never depend on the ioctl() functionality provided by libzfs_core. - Moved zfs_ioctl_fd() from libzutil to libzfs_core and renamed it lzc_ioctl_fd(). Normal access to the kmods should all be funneled through the libzfs_core library. The sole exception is the pool_active() which was updated to not use lzc_ioctl_fd() to remove the libzfs_core dependency. - Removed libzfs_core dependency on libzutil. - Removed the lib/libzfs/os/freebsd/libzfs_ioctl_compat.c source file which was all dead code. - Removed libzfs_core dependency from mkbusy and ctime test utilities. It was only needed for some trivial wrapper functions and that code is easy to replicate to shed the unneeded dependency. Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Don Brady <don.brady@delphix.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #12602
This commit is contained in:
parent
48df24d4ce
commit
514498fef6
|
@ -41,6 +41,9 @@ extern "C" {
|
||||||
_LIBZFS_CORE_H int libzfs_core_init(void);
|
_LIBZFS_CORE_H int libzfs_core_init(void);
|
||||||
_LIBZFS_CORE_H void libzfs_core_fini(void);
|
_LIBZFS_CORE_H void libzfs_core_fini(void);
|
||||||
|
|
||||||
|
struct zfs_cmd;
|
||||||
|
_LIBZFS_CORE_H int lzc_ioctl_fd(int, unsigned long, struct zfs_cmd *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NB: this type should be kept binary-compatible with dmu_objset_type_t.
|
* NB: this type should be kept binary-compatible with dmu_objset_type_t.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -146,7 +146,6 @@ _LIBZUTIL_H int zpool_history_unpack(char *, uint64_t, uint64_t *, nvlist_t ***,
|
||||||
uint_t *);
|
uint_t *);
|
||||||
|
|
||||||
struct zfs_cmd;
|
struct zfs_cmd;
|
||||||
_LIBZUTIL_H int zfs_ioctl_fd(int fd, unsigned long request, struct zfs_cmd *zc);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of colors to use
|
* List of colors to use
|
||||||
|
|
|
@ -148,7 +148,6 @@ nvlist_t *zfs_ioctl_compat_outnvl(zfs_cmd_t *, nvlist_t *, const int,
|
||||||
int zfs_ioctl_legacy_to_ozfs(int request);
|
int zfs_ioctl_legacy_to_ozfs(int request);
|
||||||
int zfs_ioctl_ozfs_to_legacy(int request);
|
int zfs_ioctl_ozfs_to_legacy(int request);
|
||||||
void zfs_cmd_legacy_to_ozfs(zfs_cmd_legacy_t *src, zfs_cmd_t *dst);
|
void zfs_cmd_legacy_to_ozfs(zfs_cmd_legacy_t *src, zfs_cmd_t *dst);
|
||||||
void zfs_cmd_compat_get(zfs_cmd_t *, caddr_t, const int);
|
|
||||||
void zfs_cmd_ozfs_to_legacy(zfs_cmd_t *src, zfs_cmd_legacy_t *dst);
|
void zfs_cmd_ozfs_to_legacy(zfs_cmd_t *src, zfs_cmd_legacy_t *dst);
|
||||||
|
|
||||||
void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);
|
void zfs_cmd_compat_put(zfs_cmd_t *, caddr_t, const int, const int);
|
||||||
|
|
|
@ -1,5 +1,44 @@
|
||||||
|
#
|
||||||
|
# Shown below is a simplified dependency graph of the OpenZFS provided
|
||||||
|
# libraries. Administrative commands (`zfs`, `zpool`, etc) interface with
|
||||||
|
# the kernel modules using the `libzfs.so` and `libzfs_core.so` libraries.
|
||||||
|
# These libraries provide a stable ABI across OpenZFS point releases.
|
||||||
|
#
|
||||||
|
# The `libzpool.so` library is a user space build of the DMU and SPA layers
|
||||||
|
# used to implement debugging tools (zdb) and code validation tools (ztest).
|
||||||
|
# These library interfaces are subject to change at any time.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# CMDS: zhack/ztest/zdb/ zfs/zpool/zed/
|
||||||
|
# raidz_{test,bench} zinject/zstream
|
||||||
|
# | |
|
||||||
|
# LIBS: | | libzfsbootenv*
|
||||||
|
# | | |
|
||||||
|
# | | |
|
||||||
|
# libzpool libzfs* ----------------+
|
||||||
|
# | | | \ / | | |
|
||||||
|
# libicp --/ | | \ / | | \------- libshare
|
||||||
|
# | | \ / | |
|
||||||
|
# libzstd ---/ | \ / | \--------- libuutil
|
||||||
|
# | \ / \ | |
|
||||||
|
# libunicode --/ \ / \ | |
|
||||||
|
# \ / \ | |
|
||||||
|
# libzutil libzfs_core* | |
|
||||||
|
# | | | | \ | | | |
|
||||||
|
# | | | | | | | | |
|
||||||
|
# | | | | | | | | |
|
||||||
|
# libtpool -------------/ | | | \---- libnvpair* | | |
|
||||||
|
# | | | | | |
|
||||||
|
# libefi -----------------/ | \------ libavl* --------/ |
|
||||||
|
# | | |
|
||||||
|
# \-------- libspl ----+------/
|
||||||
|
#
|
||||||
|
# * - A stable ABI is provided for these libraries
|
||||||
|
#
|
||||||
|
#
|
||||||
# NB: GNU Automake Manual, Chapter 8.3.5: Libtool Convenience Libraries
|
# NB: GNU Automake Manual, Chapter 8.3.5: Libtool Convenience Libraries
|
||||||
# These nine libraries are intermediary build components.
|
# These nine libraries are intermediary build components.
|
||||||
|
#
|
||||||
SUBDIRS = libavl libicp libshare libspl libtpool libzstd
|
SUBDIRS = libavl libicp libshare libspl libtpool libzstd
|
||||||
CPPCHECKDIRS = libavl libicp libnvpair libshare libspl libtpool libunicode
|
CPPCHECKDIRS = libavl libicp libnvpair libshare libspl libtpool libunicode
|
||||||
CPPCHECKDIRS += libuutil libzfs libzfs_core libzfsbootenv libzpool libzutil
|
CPPCHECKDIRS += libuutil libzfs libzfs_core libzfsbootenv libzpool libzutil
|
||||||
|
|
|
@ -35,7 +35,6 @@ USER_C = \
|
||||||
if BUILD_FREEBSD
|
if BUILD_FREEBSD
|
||||||
USER_C += \
|
USER_C += \
|
||||||
os/freebsd/libzfs_compat.c \
|
os/freebsd/libzfs_compat.c \
|
||||||
os/freebsd/libzfs_ioctl_compat.c \
|
|
||||||
os/freebsd/libzfs_zmount.c
|
os/freebsd/libzfs_zmount.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -75,6 +74,7 @@ libzfs_la_LIBADD = \
|
||||||
$(abs_top_builddir)/lib/libshare/libshare.la \
|
$(abs_top_builddir)/lib/libshare/libshare.la \
|
||||||
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
|
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
|
||||||
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
|
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
|
||||||
|
$(abs_top_builddir)/lib/libzutil/libzutil.la \
|
||||||
$(abs_top_builddir)/lib/libuutil/libuutil.la
|
$(abs_top_builddir)/lib/libuutil/libuutil.la
|
||||||
|
|
||||||
libzfs_la_LIBADD += -lm $(LIBCRYPTO_LIBS) $(ZLIB_LIBS) $(LIBFETCH_LIBS) $(LTLIBINTL)
|
libzfs_la_LIBADD += -lm $(LIBCRYPTO_LIBS) $(ZLIB_LIBS) $(LIBFETCH_LIBS) $(LTLIBINTL)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,7 +22,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
|
* Copyright (c) 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
|
||||||
*/
|
*/
|
||||||
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
|
|
||||||
#include "../../libzfs_impl.h"
|
#include "../../libzfs_impl.h"
|
||||||
#include <libzfs.h>
|
#include <libzfs.h>
|
||||||
#include <libzutil.h>
|
#include <libzutil.h>
|
||||||
|
@ -224,7 +223,7 @@ libzfs_error_init(int error)
|
||||||
int
|
int
|
||||||
zfs_ioctl(libzfs_handle_t *hdl, int request, zfs_cmd_t *zc)
|
zfs_ioctl(libzfs_handle_t *hdl, int request, zfs_cmd_t *zc)
|
||||||
{
|
{
|
||||||
return (zfs_ioctl_fd(hdl->libzfs_fd, request, zc));
|
return (lzc_ioctl_fd(hdl->libzfs_fd, request, zc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,432 +0,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 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
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2013 Xin Li <delphij@FreeBSD.org>. All rights reserved.
|
|
||||||
* Copyright 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
|
|
||||||
* Portions Copyright 2005, 2010, Oracle and/or its affiliates.
|
|
||||||
* All rights reserved.
|
|
||||||
* Use is subject to license terms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/cred.h>
|
|
||||||
#include <sys/dmu.h>
|
|
||||||
#include <sys/zio.h>
|
|
||||||
#include <sys/nvpair.h>
|
|
||||||
#include <sys/dsl_deleg.h>
|
|
||||||
#include <sys/zfs_ioctl.h>
|
|
||||||
#include "zfs_namecheck.h"
|
|
||||||
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FreeBSD zfs_cmd compatibility with older binaries
|
|
||||||
* appropriately remap/extend the zfs_cmd_t structure
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
static int
|
|
||||||
zfs_ioctl_compat_get_nvlist(uint64_t nvl, size_t size, int iflag,
|
|
||||||
nvlist_t **nvp)
|
|
||||||
{
|
|
||||||
char *packed;
|
|
||||||
int error;
|
|
||||||
nvlist_t *list = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read in and unpack the user-supplied nvlist.
|
|
||||||
*/
|
|
||||||
if (size == 0)
|
|
||||||
return (EINVAL);
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
|
||||||
packed = kmem_alloc(size, KM_SLEEP);
|
|
||||||
if ((error = ddi_copyin((void *)(uintptr_t)nvl, packed, size,
|
|
||||||
iflag)) != 0) {
|
|
||||||
kmem_free(packed, size);
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
packed = (void *)(uintptr_t)nvl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
error = nvlist_unpack(packed, size, &list, 0);
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
|
||||||
kmem_free(packed, size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (error != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
*nvp = list;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
zfs_ioctl_compat_put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
|
|
||||||
{
|
|
||||||
char *packed = NULL;
|
|
||||||
int error = 0;
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
VERIFY(nvlist_size(nvl, &size, NV_ENCODE_NATIVE) == 0);
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
|
||||||
packed = kmem_alloc(size, KM_SLEEP);
|
|
||||||
VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE,
|
|
||||||
KM_SLEEP) == 0);
|
|
||||||
|
|
||||||
if (ddi_copyout(packed,
|
|
||||||
(void *)(uintptr_t)zc->zc_nvlist_dst, size, zc->zc_iflags) != 0)
|
|
||||||
error = EFAULT;
|
|
||||||
kmem_free(packed, size);
|
|
||||||
#else
|
|
||||||
packed = (void *)(uintptr_t)zc->zc_nvlist_dst;
|
|
||||||
VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE,
|
|
||||||
0) == 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
zc->zc_nvlist_dst_size = size;
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
zfs_ioctl_compat_fix_stats_nvlist(nvlist_t *nvl)
|
|
||||||
{
|
|
||||||
nvlist_t **child;
|
|
||||||
nvlist_t *nvroot = NULL;
|
|
||||||
vdev_stat_t *vs;
|
|
||||||
uint_t c, children, nelem;
|
|
||||||
|
|
||||||
if (nvlist_lookup_nvlist_array(nvl, ZPOOL_CONFIG_CHILDREN,
|
|
||||||
&child, &children) == 0) {
|
|
||||||
for (c = 0; c < children; c++) {
|
|
||||||
zfs_ioctl_compat_fix_stats_nvlist(child[c]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nvlist_lookup_nvlist(nvl, ZPOOL_CONFIG_VDEV_TREE,
|
|
||||||
&nvroot) == 0)
|
|
||||||
zfs_ioctl_compat_fix_stats_nvlist(nvroot);
|
|
||||||
if ((nvlist_lookup_uint64_array(nvl, "stats",
|
|
||||||
(uint64_t **)&vs, &nelem) == 0)) {
|
|
||||||
nvlist_add_uint64_array(nvl,
|
|
||||||
ZPOOL_CONFIG_VDEV_STATS,
|
|
||||||
(uint64_t *)vs, nelem);
|
|
||||||
nvlist_remove(nvl, "stats",
|
|
||||||
DATA_TYPE_UINT64_ARRAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
zfs_ioctl_compat_fix_stats(zfs_cmd_t *zc, const int nc)
|
|
||||||
{
|
|
||||||
nvlist_t *nv, *nvp = NULL;
|
|
||||||
nvpair_t *elem;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
if ((error = zfs_ioctl_compat_get_nvlist(zc->zc_nvlist_dst,
|
|
||||||
zc->zc_nvlist_dst_size, zc->zc_iflags, &nv)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
if (nc == 5) { /* ZFS_IOC_POOL_STATS */
|
|
||||||
elem = NULL;
|
|
||||||
while ((elem = nvlist_next_nvpair(nv, elem)) != NULL) {
|
|
||||||
if (nvpair_value_nvlist(elem, &nvp) == 0)
|
|
||||||
zfs_ioctl_compat_fix_stats_nvlist(nvp);
|
|
||||||
}
|
|
||||||
elem = NULL;
|
|
||||||
} else
|
|
||||||
zfs_ioctl_compat_fix_stats_nvlist(nv);
|
|
||||||
|
|
||||||
error = zfs_ioctl_compat_put_nvlist(zc, nv);
|
|
||||||
|
|
||||||
nvlist_free(nv);
|
|
||||||
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
zfs_ioctl_compat_pool_get_props(zfs_cmd_t *zc)
|
|
||||||
{
|
|
||||||
nvlist_t *nv, *nva = NULL;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
if ((error = zfs_ioctl_compat_get_nvlist(zc->zc_nvlist_dst,
|
|
||||||
zc->zc_nvlist_dst_size, zc->zc_iflags, &nv)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
if (nvlist_lookup_nvlist(nv, "used", &nva) == 0) {
|
|
||||||
nvlist_add_nvlist(nv, "allocated", nva);
|
|
||||||
nvlist_remove(nv, "used", DATA_TYPE_NVLIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nvlist_lookup_nvlist(nv, "available", &nva) == 0) {
|
|
||||||
nvlist_add_nvlist(nv, "free", nva);
|
|
||||||
nvlist_remove(nv, "available", DATA_TYPE_NVLIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
error = zfs_ioctl_compat_put_nvlist(zc, nv);
|
|
||||||
|
|
||||||
nvlist_free(nv);
|
|
||||||
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
|
||||||
int
|
|
||||||
zfs_ioctl_compat_pre(zfs_cmd_t *zc, int *vec, const int cflag)
|
|
||||||
{
|
|
||||||
int error = 0;
|
|
||||||
|
|
||||||
/* are we creating a clone? */
|
|
||||||
if (*vec == ZFS_IOC_CREATE && zc->zc_value[0] != '\0')
|
|
||||||
*vec = ZFS_IOC_CLONE;
|
|
||||||
|
|
||||||
if (cflag == ZFS_CMD_COMPAT_V15) {
|
|
||||||
switch (*vec) {
|
|
||||||
|
|
||||||
case 7: /* ZFS_IOC_POOL_SCRUB (v15) */
|
|
||||||
zc->zc_cookie = POOL_SCAN_SCRUB;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
zfs_ioctl_compat_post(zfs_cmd_t *zc, int vec, const int cflag)
|
|
||||||
{
|
|
||||||
if (cflag == ZFS_CMD_COMPAT_V15) {
|
|
||||||
switch (vec) {
|
|
||||||
case ZFS_IOC_POOL_CONFIGS:
|
|
||||||
case ZFS_IOC_POOL_STATS:
|
|
||||||
case ZFS_IOC_POOL_TRYIMPORT:
|
|
||||||
zfs_ioctl_compat_fix_stats(zc, vec);
|
|
||||||
break;
|
|
||||||
case 41: /* ZFS_IOC_POOL_GET_PROPS (v15) */
|
|
||||||
zfs_ioctl_compat_pool_get_props(zc);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nvlist_t *
|
|
||||||
zfs_ioctl_compat_innvl(zfs_cmd_t *zc, nvlist_t *innvl, const int vec,
|
|
||||||
const int cflag)
|
|
||||||
{
|
|
||||||
nvlist_t *nvl, *tmpnvl, *hnvl;
|
|
||||||
nvpair_t *elem;
|
|
||||||
char *poolname, *snapname;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC ||
|
|
||||||
cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP ||
|
|
||||||
cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
switch (vec) {
|
|
||||||
case ZFS_IOC_CREATE:
|
|
||||||
nvl = fnvlist_alloc();
|
|
||||||
fnvlist_add_int32(nvl, "type", zc->zc_objset_type);
|
|
||||||
if (innvl != NULL) {
|
|
||||||
fnvlist_add_nvlist(nvl, "props", innvl);
|
|
||||||
nvlist_free(innvl);
|
|
||||||
}
|
|
||||||
return (nvl);
|
|
||||||
break;
|
|
||||||
case ZFS_IOC_CLONE:
|
|
||||||
nvl = fnvlist_alloc();
|
|
||||||
fnvlist_add_string(nvl, "origin", zc->zc_value);
|
|
||||||
if (innvl != NULL) {
|
|
||||||
fnvlist_add_nvlist(nvl, "props", innvl);
|
|
||||||
nvlist_free(innvl);
|
|
||||||
}
|
|
||||||
return (nvl);
|
|
||||||
break;
|
|
||||||
case ZFS_IOC_SNAPSHOT:
|
|
||||||
if (innvl == NULL)
|
|
||||||
goto out;
|
|
||||||
nvl = fnvlist_alloc();
|
|
||||||
fnvlist_add_nvlist(nvl, "props", innvl);
|
|
||||||
tmpnvl = fnvlist_alloc();
|
|
||||||
snapname = kmem_asprintf("%s@%s", zc->zc_name, zc->zc_value);
|
|
||||||
fnvlist_add_boolean(tmpnvl, snapname);
|
|
||||||
kmem_free(snapname, strlen(snapname + 1));
|
|
||||||
/* check if we are doing a recursive snapshot */
|
|
||||||
if (zc->zc_cookie)
|
|
||||||
dmu_get_recursive_snaps_nvl(zc->zc_name, zc->zc_value,
|
|
||||||
tmpnvl);
|
|
||||||
fnvlist_add_nvlist(nvl, "snaps", tmpnvl);
|
|
||||||
fnvlist_free(tmpnvl);
|
|
||||||
nvlist_free(innvl);
|
|
||||||
/* strip dataset part from zc->zc_name */
|
|
||||||
zc->zc_name[strcspn(zc->zc_name, "/@")] = '\0';
|
|
||||||
return (nvl);
|
|
||||||
break;
|
|
||||||
case ZFS_IOC_SPACE_SNAPS:
|
|
||||||
nvl = fnvlist_alloc();
|
|
||||||
fnvlist_add_string(nvl, "firstsnap", zc->zc_value);
|
|
||||||
if (innvl != NULL)
|
|
||||||
nvlist_free(innvl);
|
|
||||||
return (nvl);
|
|
||||||
break;
|
|
||||||
case ZFS_IOC_DESTROY_SNAPS:
|
|
||||||
if (innvl == NULL && cflag == ZFS_CMD_COMPAT_DEADMAN)
|
|
||||||
goto out;
|
|
||||||
nvl = fnvlist_alloc();
|
|
||||||
if (innvl != NULL) {
|
|
||||||
fnvlist_add_nvlist(nvl, "snaps", innvl);
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* We are probably called by even older binaries,
|
|
||||||
* allocate and populate nvlist with recursive
|
|
||||||
* snapshots
|
|
||||||
*/
|
|
||||||
if (zfs_component_namecheck(zc->zc_value, NULL,
|
|
||||||
NULL) == 0) {
|
|
||||||
tmpnvl = fnvlist_alloc();
|
|
||||||
if (dmu_get_recursive_snaps_nvl(zc->zc_name,
|
|
||||||
zc->zc_value, tmpnvl) == 0)
|
|
||||||
fnvlist_add_nvlist(nvl, "snaps",
|
|
||||||
tmpnvl);
|
|
||||||
nvlist_free(tmpnvl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (innvl != NULL)
|
|
||||||
nvlist_free(innvl);
|
|
||||||
/* strip dataset part from zc->zc_name */
|
|
||||||
zc->zc_name[strcspn(zc->zc_name, "/@")] = '\0';
|
|
||||||
return (nvl);
|
|
||||||
break;
|
|
||||||
case ZFS_IOC_HOLD:
|
|
||||||
nvl = fnvlist_alloc();
|
|
||||||
tmpnvl = fnvlist_alloc();
|
|
||||||
if (zc->zc_cleanup_fd != -1)
|
|
||||||
fnvlist_add_int32(nvl, "cleanup_fd",
|
|
||||||
(int32_t)zc->zc_cleanup_fd);
|
|
||||||
if (zc->zc_cookie) {
|
|
||||||
hnvl = fnvlist_alloc();
|
|
||||||
if (dmu_get_recursive_snaps_nvl(zc->zc_name,
|
|
||||||
zc->zc_value, hnvl) == 0) {
|
|
||||||
elem = NULL;
|
|
||||||
while ((elem = nvlist_next_nvpair(hnvl,
|
|
||||||
elem)) != NULL) {
|
|
||||||
nvlist_add_string(tmpnvl,
|
|
||||||
nvpair_name(elem), zc->zc_string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nvlist_free(hnvl);
|
|
||||||
} else {
|
|
||||||
snapname = kmem_asprintf("%s@%s", zc->zc_name,
|
|
||||||
zc->zc_value);
|
|
||||||
nvlist_add_string(tmpnvl, snapname, zc->zc_string);
|
|
||||||
kmem_free(snapname, strlen(snapname + 1));
|
|
||||||
}
|
|
||||||
fnvlist_add_nvlist(nvl, "holds", tmpnvl);
|
|
||||||
nvlist_free(tmpnvl);
|
|
||||||
if (innvl != NULL)
|
|
||||||
nvlist_free(innvl);
|
|
||||||
/* strip dataset part from zc->zc_name */
|
|
||||||
zc->zc_name[strcspn(zc->zc_name, "/@")] = '\0';
|
|
||||||
return (nvl);
|
|
||||||
break;
|
|
||||||
case ZFS_IOC_RELEASE:
|
|
||||||
nvl = fnvlist_alloc();
|
|
||||||
tmpnvl = fnvlist_alloc();
|
|
||||||
if (zc->zc_cookie) {
|
|
||||||
hnvl = fnvlist_alloc();
|
|
||||||
if (dmu_get_recursive_snaps_nvl(zc->zc_name,
|
|
||||||
zc->zc_value, hnvl) == 0) {
|
|
||||||
elem = NULL;
|
|
||||||
while ((elem = nvlist_next_nvpair(hnvl,
|
|
||||||
elem)) != NULL) {
|
|
||||||
fnvlist_add_boolean(tmpnvl,
|
|
||||||
zc->zc_string);
|
|
||||||
fnvlist_add_nvlist(nvl,
|
|
||||||
nvpair_name(elem), tmpnvl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nvlist_free(hnvl);
|
|
||||||
} else {
|
|
||||||
snapname = kmem_asprintf("%s@%s", zc->zc_name,
|
|
||||||
zc->zc_value);
|
|
||||||
fnvlist_add_boolean(tmpnvl, zc->zc_string);
|
|
||||||
fnvlist_add_nvlist(nvl, snapname, tmpnvl);
|
|
||||||
kmem_free(snapname, strlen(snapname + 1));
|
|
||||||
}
|
|
||||||
nvlist_free(tmpnvl);
|
|
||||||
if (innvl != NULL)
|
|
||||||
nvlist_free(innvl);
|
|
||||||
/* strip dataset part from zc->zc_name */
|
|
||||||
zc->zc_name[strcspn(zc->zc_name, "/@")] = '\0';
|
|
||||||
return (nvl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
out:
|
|
||||||
return (innvl);
|
|
||||||
}
|
|
||||||
|
|
||||||
nvlist_t *
|
|
||||||
zfs_ioctl_compat_outnvl(zfs_cmd_t *zc, nvlist_t *outnvl, const int vec,
|
|
||||||
const int cflag)
|
|
||||||
{
|
|
||||||
nvlist_t *tmpnvl;
|
|
||||||
|
|
||||||
if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC ||
|
|
||||||
cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP ||
|
|
||||||
cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES)
|
|
||||||
return (outnvl);
|
|
||||||
|
|
||||||
switch (vec) {
|
|
||||||
case ZFS_IOC_SPACE_SNAPS:
|
|
||||||
(void) nvlist_lookup_uint64(outnvl, "used", &zc->zc_cookie);
|
|
||||||
(void) nvlist_lookup_uint64(outnvl, "compressed",
|
|
||||||
&zc->zc_objset_type);
|
|
||||||
(void) nvlist_lookup_uint64(outnvl, "uncompressed",
|
|
||||||
&zc->zc_perm_action);
|
|
||||||
nvlist_free(outnvl);
|
|
||||||
/* return empty outnvl */
|
|
||||||
tmpnvl = fnvlist_alloc();
|
|
||||||
return (tmpnvl);
|
|
||||||
break;
|
|
||||||
case ZFS_IOC_CREATE:
|
|
||||||
case ZFS_IOC_CLONE:
|
|
||||||
case ZFS_IOC_HOLD:
|
|
||||||
case ZFS_IOC_RELEASE:
|
|
||||||
nvlist_free(outnvl);
|
|
||||||
/* return empty outnvl */
|
|
||||||
tmpnvl = fnvlist_alloc();
|
|
||||||
return (tmpnvl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (outnvl);
|
|
||||||
}
|
|
||||||
#endif /* KERNEL */
|
|
|
@ -11,11 +11,27 @@ include $(top_srcdir)/config/Abigail.am
|
||||||
USER_C = \
|
USER_C = \
|
||||||
libzfs_core.c
|
libzfs_core.c
|
||||||
|
|
||||||
|
if BUILD_LINUX
|
||||||
|
USER_C += \
|
||||||
|
os/linux/libzfs_core_ioctl.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if BUILD_FREEBSD
|
||||||
|
DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs
|
||||||
|
|
||||||
|
USER_C += \
|
||||||
|
os/freebsd/libzfs_core_ioctl.c
|
||||||
|
|
||||||
|
VPATH += $(top_srcdir)/module/os/freebsd/zfs
|
||||||
|
|
||||||
|
nodist_libzfs_core_la_SOURCES = zfs_ioctl_compat.c
|
||||||
|
endif
|
||||||
|
|
||||||
libzfs_core_la_SOURCES = $(USER_C)
|
libzfs_core_la_SOURCES = $(USER_C)
|
||||||
|
|
||||||
libzfs_core_la_LIBADD = \
|
libzfs_core_la_LIBADD = \
|
||||||
$(abs_top_builddir)/lib/libzutil/libzutil.la \
|
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
|
||||||
$(abs_top_builddir)/lib/libnvpair/libnvpair.la
|
$(abs_top_builddir)/lib/libspl/libspl.la
|
||||||
|
|
||||||
libzfs_core_la_LIBADD += $(LTLIBINTL)
|
libzfs_core_la_LIBADD += $(LTLIBINTL)
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -209,7 +209,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (zfs_ioctl_fd(g_fd, ioc, &zc) != 0) {
|
while (lzc_ioctl_fd(g_fd, ioc, &zc) != 0) {
|
||||||
/*
|
/*
|
||||||
* If ioctl exited with ENOMEM, we retry the ioctl after
|
* If ioctl exited with ENOMEM, we retry the ioctl after
|
||||||
* increasing the size of the destination nvlist.
|
* increasing the size of the destination nvlist.
|
||||||
|
@ -298,7 +298,7 @@ lzc_promote(const char *fsname, char *snapnamebuf, int snapnamelen)
|
||||||
VERIFY3S(g_fd, !=, -1);
|
VERIFY3S(g_fd, !=, -1);
|
||||||
|
|
||||||
(void) strlcpy(zc.zc_name, fsname, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, fsname, sizeof (zc.zc_name));
|
||||||
if (zfs_ioctl_fd(g_fd, ZFS_IOC_PROMOTE, &zc) != 0) {
|
if (lzc_ioctl_fd(g_fd, ZFS_IOC_PROMOTE, &zc) != 0) {
|
||||||
int error = errno;
|
int error = errno;
|
||||||
if (error == EEXIST && snapnamebuf != NULL)
|
if (error == EEXIST && snapnamebuf != NULL)
|
||||||
(void) strlcpy(snapnamebuf, zc.zc_string, snapnamelen);
|
(void) strlcpy(snapnamebuf, zc.zc_string, snapnamelen);
|
||||||
|
@ -317,7 +317,7 @@ lzc_rename(const char *source, const char *target)
|
||||||
VERIFY3S(g_fd, !=, -1);
|
VERIFY3S(g_fd, !=, -1);
|
||||||
(void) strlcpy(zc.zc_name, source, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, source, sizeof (zc.zc_name));
|
||||||
(void) strlcpy(zc.zc_value, target, sizeof (zc.zc_value));
|
(void) strlcpy(zc.zc_value, target, sizeof (zc.zc_value));
|
||||||
error = zfs_ioctl_fd(g_fd, ZFS_IOC_RENAME, &zc);
|
error = lzc_ioctl_fd(g_fd, ZFS_IOC_RENAME, &zc);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
error = errno;
|
error = errno;
|
||||||
return (error);
|
return (error);
|
||||||
|
@ -468,7 +468,7 @@ lzc_exists(const char *dataset)
|
||||||
VERIFY3S(g_fd, !=, -1);
|
VERIFY3S(g_fd, !=, -1);
|
||||||
|
|
||||||
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
|
||||||
return (zfs_ioctl_fd(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0);
|
return (lzc_ioctl_fd(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -925,7 +925,7 @@ recv_impl(const char *snapname, nvlist_t *recvdprops, nvlist_t *localprops,
|
||||||
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)
|
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)
|
||||||
malloc(zc.zc_nvlist_dst_size);
|
malloc(zc.zc_nvlist_dst_size);
|
||||||
|
|
||||||
error = zfs_ioctl_fd(g_fd, ZFS_IOC_RECV, &zc);
|
error = lzc_ioctl_fd(g_fd, ZFS_IOC_RECV, &zc);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
error = errno;
|
error = errno;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,9 +23,8 @@
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/zfs_ioctl.h>
|
#include <sys/zfs_ioctl.h>
|
||||||
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
|
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
|
||||||
#include <libzutil.h>
|
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <libzfs_core.h>
|
||||||
|
|
||||||
int zfs_ioctl_version = ZFS_IOCVER_UNDEF;
|
int zfs_ioctl_version = ZFS_IOCVER_UNDEF;
|
||||||
|
|
||||||
|
@ -92,7 +91,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.
|
* error is returned zc_nvlist_dst_size won't be updated.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
zfs_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
|
lzc_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
|
||||||
{
|
{
|
||||||
size_t oldsize;
|
size_t oldsize;
|
||||||
int ret, cflag = ZFS_CMD_COMPAT_NONE;
|
int ret, cflag = ZFS_CMD_COMPAT_NONE;
|
|
@ -21,10 +21,10 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/zfs_ioctl.h>
|
#include <sys/zfs_ioctl.h>
|
||||||
#include <libzutil.h>
|
#include <libzfs_core.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
zfs_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
|
lzc_ioctl_fd(int fd, unsigned long request, zfs_cmd_t *zc)
|
||||||
{
|
{
|
||||||
return (ioctl(fd, request, zc));
|
return (ioctl(fd, request, zc));
|
||||||
}
|
}
|
|
@ -214,9 +214,9 @@ nodist_libzpool_la_SOURCES = \
|
||||||
libzpool_la_LIBADD = \
|
libzpool_la_LIBADD = \
|
||||||
$(abs_top_builddir)/lib/libicp/libicp.la \
|
$(abs_top_builddir)/lib/libicp/libicp.la \
|
||||||
$(abs_top_builddir)/lib/libunicode/libunicode.la \
|
$(abs_top_builddir)/lib/libunicode/libunicode.la \
|
||||||
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
|
|
||||||
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
|
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
|
||||||
$(abs_top_builddir)/lib/libzstd/libzstd.la
|
$(abs_top_builddir)/lib/libzstd/libzstd.la \
|
||||||
|
$(abs_top_builddir)/lib/libzutil/libzutil.la
|
||||||
|
|
||||||
libzpool_la_LIBADD += $(LIBCLOCK_GETTIME) $(ZLIB_LIBS) -ldl -lm
|
libzpool_la_LIBADD += $(LIBCLOCK_GETTIME) $(ZLIB_LIBS) -ldl -lm
|
||||||
|
|
||||||
|
|
|
@ -245,39 +245,96 @@ refresh_config(void *unused, nvlist_t *tryconfig)
|
||||||
return (spa_tryimport(tryconfig));
|
return (spa_tryimport(tryconfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <os/freebsd/zfs/sys/zfs_ioctl_compat.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
pool_active(void *unused, const char *name, uint64_t guid, boolean_t *isactive)
|
||||||
|
{
|
||||||
|
zfs_iocparm_t zp;
|
||||||
|
zfs_cmd_t *zc = NULL;
|
||||||
|
zfs_cmd_legacy_t *zcl = NULL;
|
||||||
|
unsigned long request;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
int fd = open(ZFS_DEV, O_RDWR | O_CLOEXEC);
|
||||||
|
if (fd < 0)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use ZFS_IOC_POOL_STATS to check if the pool is active. We want to
|
||||||
|
* avoid adding a dependency on libzfs_core solely for this ioctl(),
|
||||||
|
* therefore we manually craft the stats command. Note that the command
|
||||||
|
* ID is identical between the openzfs and legacy ioctl() formats.
|
||||||
|
*/
|
||||||
|
int ver = ZFS_IOCVER_NONE;
|
||||||
|
size_t ver_size = sizeof (ver);
|
||||||
|
|
||||||
|
sysctlbyname("vfs.zfs.version.ioctl", &ver, &ver_size, NULL, 0);
|
||||||
|
|
||||||
|
switch (ver) {
|
||||||
|
case ZFS_IOCVER_OZFS:
|
||||||
|
zc = umem_zalloc(sizeof (zfs_cmd_t), UMEM_NOFAIL);
|
||||||
|
|
||||||
|
(void) strlcpy(zc->zc_name, name, sizeof (zc->zc_name));
|
||||||
|
zp.zfs_cmd = (uint64_t)(uintptr_t)zc;
|
||||||
|
zp.zfs_cmd_size = sizeof (zfs_cmd_t);
|
||||||
|
zp.zfs_ioctl_version = ZFS_IOCVER_OZFS;
|
||||||
|
|
||||||
|
request = _IOWR('Z', ZFS_IOC_POOL_STATS, zfs_iocparm_t);
|
||||||
|
ret = ioctl(fd, request, &zp);
|
||||||
|
|
||||||
|
free((void *)(uintptr_t)zc->zc_nvlist_dst);
|
||||||
|
umem_free(zc, sizeof (zfs_cmd_t));
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ZFS_IOCVER_LEGACY:
|
||||||
|
zcl = umem_zalloc(sizeof (zfs_cmd_legacy_t), UMEM_NOFAIL);
|
||||||
|
|
||||||
|
(void) strlcpy(zcl->zc_name, name, sizeof (zcl->zc_name));
|
||||||
|
zp.zfs_cmd = (uint64_t)(uintptr_t)zcl;
|
||||||
|
zp.zfs_cmd_size = sizeof (zfs_cmd_legacy_t);
|
||||||
|
zp.zfs_ioctl_version = ZFS_IOCVER_LEGACY;
|
||||||
|
|
||||||
|
request = _IOWR('Z', ZFS_IOC_POOL_STATS, zfs_iocparm_t);
|
||||||
|
ret = ioctl(fd, request, &zp);
|
||||||
|
|
||||||
|
free((void *)(uintptr_t)zcl->zc_nvlist_dst);
|
||||||
|
umem_free(zcl, sizeof (zfs_cmd_legacy_t));
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "unrecognized zfs ioctl version %d", ver);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) close(fd);
|
||||||
|
|
||||||
|
*isactive = (ret == 0);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
#else
|
||||||
static int
|
static int
|
||||||
pool_active(void *unused, const char *name, uint64_t guid,
|
pool_active(void *unused, const char *name, uint64_t guid,
|
||||||
boolean_t *isactive)
|
boolean_t *isactive)
|
||||||
{
|
{
|
||||||
zfs_cmd_t *zcp;
|
int fd = open(ZFS_DEV, O_RDWR | O_CLOEXEC);
|
||||||
nvlist_t *innvl;
|
|
||||||
char *packed = NULL;
|
|
||||||
size_t size = 0;
|
|
||||||
int fd, ret;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use ZFS_IOC_POOL_SYNC to confirm if a pool is active
|
|
||||||
*/
|
|
||||||
|
|
||||||
fd = open(ZFS_DEV, O_RDWR | O_CLOEXEC);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
zcp = umem_zalloc(sizeof (zfs_cmd_t), UMEM_NOFAIL);
|
/*
|
||||||
|
* Use ZFS_IOC_POOL_STATS to check if a pool is active.
|
||||||
innvl = fnvlist_alloc();
|
*/
|
||||||
fnvlist_add_boolean_value(innvl, "force", B_FALSE);
|
zfs_cmd_t *zcp = umem_zalloc(sizeof (zfs_cmd_t), UMEM_NOFAIL);
|
||||||
|
|
||||||
(void) strlcpy(zcp->zc_name, name, sizeof (zcp->zc_name));
|
(void) strlcpy(zcp->zc_name, name, sizeof (zcp->zc_name));
|
||||||
packed = fnvlist_pack(innvl, &size);
|
|
||||||
zcp->zc_nvlist_src = (uint64_t)(uintptr_t)packed;
|
|
||||||
zcp->zc_nvlist_src_size = size;
|
|
||||||
|
|
||||||
ret = zfs_ioctl_fd(fd, ZFS_IOC_POOL_SYNC, zcp);
|
int ret = ioctl(fd, ZFS_IOC_POOL_STATS, zcp);
|
||||||
|
|
||||||
fnvlist_pack_free(packed, size);
|
|
||||||
free((void *)(uintptr_t)zcp->zc_nvlist_dst);
|
free((void *)(uintptr_t)zcp->zc_nvlist_dst);
|
||||||
nvlist_free(innvl);
|
|
||||||
umem_free(zcp, sizeof (zfs_cmd_t));
|
umem_free(zcp, sizeof (zfs_cmd_t));
|
||||||
|
|
||||||
(void) close(fd);
|
(void) close(fd);
|
||||||
|
@ -286,6 +343,7 @@ pool_active(void *unused, const char *name, uint64_t guid,
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const pool_config_ops_t libzpool_config_ops = {
|
const pool_config_ops_t libzpool_config_ops = {
|
||||||
.pco_refresh_config = refresh_config,
|
.pco_refresh_config = refresh_config,
|
||||||
|
|
|
@ -19,21 +19,13 @@ USER_C = \
|
||||||
if BUILD_LINUX
|
if BUILD_LINUX
|
||||||
USER_C += \
|
USER_C += \
|
||||||
os/linux/zutil_device_path_os.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
|
endif
|
||||||
|
|
||||||
if BUILD_FREEBSD
|
if BUILD_FREEBSD
|
||||||
DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs
|
|
||||||
|
|
||||||
USER_C += \
|
USER_C += \
|
||||||
os/freebsd/zutil_device_path_os.c \
|
os/freebsd/zutil_device_path_os.c \
|
||||||
os/freebsd/zutil_import_os.c \
|
os/freebsd/zutil_import_os.c
|
||||||
os/freebsd/zutil_compat.c
|
|
||||||
|
|
||||||
VPATH += $(top_srcdir)/module/os/freebsd/zfs
|
|
||||||
|
|
||||||
nodist_libzutil_la_SOURCES = zfs_ioctl_compat.c
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libzutil_la_SOURCES = $(USER_C)
|
libzutil_la_SOURCES = $(USER_C)
|
||||||
|
|
|
@ -159,7 +159,7 @@ lzc_ioctl_run(zfs_ioc_t ioc, const char *name, nvlist_t *innvl, int expected)
|
||||||
zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024);
|
zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024);
|
||||||
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)malloc(zc.zc_nvlist_dst_size);
|
zc.zc_nvlist_dst = (uint64_t)(uintptr_t)malloc(zc.zc_nvlist_dst_size);
|
||||||
|
|
||||||
if (zfs_ioctl_fd(zfs_fd, ioc, &zc) != 0)
|
if (lzc_ioctl_fd(zfs_fd, ioc, &zc) != 0)
|
||||||
error = errno;
|
error = errno;
|
||||||
|
|
||||||
if (error != expected) {
|
if (error != expected) {
|
||||||
|
@ -692,7 +692,7 @@ zfs_destroy(const char *dataset)
|
||||||
|
|
||||||
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
|
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
|
||||||
zc.zc_name[sizeof (zc.zc_name) - 1] = '\0';
|
zc.zc_name[sizeof (zc.zc_name) - 1] = '\0';
|
||||||
err = zfs_ioctl_fd(zfs_fd, ZFS_IOC_DESTROY, &zc);
|
err = lzc_ioctl_fd(zfs_fd, ZFS_IOC_DESTROY, &zc);
|
||||||
|
|
||||||
return (err == 0 ? 0 : errno);
|
return (err == 0 ? 0 : errno);
|
||||||
}
|
}
|
||||||
|
@ -900,7 +900,7 @@ zfs_ioc_input_tests(const char *pool)
|
||||||
if (ioc_tested[cmd])
|
if (ioc_tested[cmd])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (zfs_ioctl_fd(zfs_fd, ioc, &zc) != 0 &&
|
if (lzc_ioctl_fd(zfs_fd, ioc, &zc) != 0 &&
|
||||||
errno != ZFS_ERR_IOC_CMD_UNAVAIL) {
|
errno != ZFS_ERR_IOC_CMD_UNAVAIL) {
|
||||||
(void) fprintf(stderr, "cmd %d is missing a test case "
|
(void) fprintf(stderr, "cmd %d is missing a test case "
|
||||||
"(%d)\n", cmd, errno);
|
"(%d)\n", cmd, errno);
|
||||||
|
|
|
@ -4,5 +4,3 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin
|
||||||
|
|
||||||
pkgexec_PROGRAMS = mkbusy
|
pkgexec_PROGRAMS = mkbusy
|
||||||
mkbusy_SOURCES = mkbusy.c
|
mkbusy_SOURCES = mkbusy.c
|
||||||
|
|
||||||
mkbusy_LDADD = $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libzutil.h>
|
|
||||||
|
|
||||||
|
|
||||||
static __attribute__((noreturn)) void
|
static __attribute__((noreturn)) void
|
||||||
|
@ -64,6 +63,21 @@ daemonize(void)
|
||||||
(void) close(2);
|
(void) close(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_basename(const char *path)
|
||||||
|
{
|
||||||
|
const char *bn = strrchr(path, '/');
|
||||||
|
return (bn ? bn + 1 : path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t
|
||||||
|
get_dirnamelen(const char *path)
|
||||||
|
{
|
||||||
|
const char *end = strrchr(path, '/');
|
||||||
|
return (end ? end - path : -1);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -103,9 +117,9 @@ main(int argc, char *argv[])
|
||||||
arg[arglen - 1] = '\0';
|
arg[arglen - 1] = '\0';
|
||||||
|
|
||||||
/* Get the directory and file names. */
|
/* Get the directory and file names. */
|
||||||
fname = zfs_basename(arg);
|
fname = get_basename(arg);
|
||||||
dname = arg;
|
dname = arg;
|
||||||
if ((dnamelen = zfs_dirnamelen(arg)) != -1)
|
if ((dnamelen = get_dirnamelen(arg)) != -1)
|
||||||
arg[dnamelen] = '\0';
|
arg[dnamelen] = '\0';
|
||||||
else
|
else
|
||||||
dname = ".";
|
dname = ".";
|
||||||
|
|
|
@ -11,5 +11,3 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime
|
||||||
|
|
||||||
pkgexec_PROGRAMS = ctime
|
pkgexec_PROGRAMS = ctime
|
||||||
ctime_SOURCES = ctime.c
|
ctime_SOURCES = ctime.c
|
||||||
|
|
||||||
ctime_LDADD = $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la
|
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <libzutil.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -98,6 +97,13 @@ get_file_time(const char *pfile, int what, time_t *ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t
|
||||||
|
get_dirnamelen(const char *path)
|
||||||
|
{
|
||||||
|
const char *end = strrchr(path, '/');
|
||||||
|
return (end ? end - path : -1);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_read(const char *pfile)
|
do_read(const char *pfile)
|
||||||
{
|
{
|
||||||
|
@ -161,7 +167,7 @@ do_link(const char *pfile)
|
||||||
* the link file in the same directory.
|
* the link file in the same directory.
|
||||||
*/
|
*/
|
||||||
(void) snprintf(link_file, sizeof (link_file),
|
(void) snprintf(link_file, sizeof (link_file),
|
||||||
"%.*s/%s", (int)zfs_dirnamelen(pfile), pfile, "link_file");
|
"%.*s/%s", (int)get_dirnamelen(pfile), pfile, "link_file");
|
||||||
|
|
||||||
if (link(pfile, link_file) == -1) {
|
if (link(pfile, link_file) == -1) {
|
||||||
(void) fprintf(stderr, "link(%s, %s) failed with errno %d\n",
|
(void) fprintf(stderr, "link(%s, %s) failed with errno %d\n",
|
||||||
|
|
Loading…
Reference in New Issue