diff options
author | Brian Behlendorf <[email protected]> | 2021-10-07 10:31:26 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-10-07 11:31:26 -0600 |
commit | 514498fef6977e4d1d6dc676710567384d6f6b39 (patch) | |
tree | dea185662b7c79bc5937dae3adad3bc31bd7fecc /tests | |
parent | 48df24d4ce7bbf14fedc10c5f33396d6cb42f5db (diff) |
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 <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Don Brady <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #12602
Diffstat (limited to 'tests')
-rw-r--r-- | tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c | 6 | ||||
-rw-r--r-- | tests/zfs-tests/cmd/mkbusy/Makefile.am | 2 | ||||
-rw-r--r-- | tests/zfs-tests/cmd/mkbusy/mkbusy.c | 20 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/ctime/Makefile.am | 2 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/ctime/ctime.c | 10 |
5 files changed, 28 insertions, 12 deletions
diff --git a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c index b671af7d8..0e552c268 100644 --- a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c +++ b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.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 = (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; if (error != expected) { @@ -692,7 +692,7 @@ zfs_destroy(const char *dataset) (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name)); 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); } @@ -900,7 +900,7 @@ zfs_ioc_input_tests(const char *pool) if (ioc_tested[cmd]) 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) { (void) fprintf(stderr, "cmd %d is missing a test case " "(%d)\n", cmd, errno); diff --git a/tests/zfs-tests/cmd/mkbusy/Makefile.am b/tests/zfs-tests/cmd/mkbusy/Makefile.am index 8d5885e08..abae69dea 100644 --- a/tests/zfs-tests/cmd/mkbusy/Makefile.am +++ b/tests/zfs-tests/cmd/mkbusy/Makefile.am @@ -4,5 +4,3 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin pkgexec_PROGRAMS = mkbusy mkbusy_SOURCES = mkbusy.c - -mkbusy_LDADD = $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la diff --git a/tests/zfs-tests/cmd/mkbusy/mkbusy.c b/tests/zfs-tests/cmd/mkbusy/mkbusy.c index 58ea1d07a..e1cbd95cd 100644 --- a/tests/zfs-tests/cmd/mkbusy/mkbusy.c +++ b/tests/zfs-tests/cmd/mkbusy/mkbusy.c @@ -29,7 +29,6 @@ #include <unistd.h> #include <errno.h> #include <string.h> -#include <libzutil.h> static __attribute__((noreturn)) void @@ -64,6 +63,21 @@ daemonize(void) (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 main(int argc, char *argv[]) { @@ -103,9 +117,9 @@ main(int argc, char *argv[]) arg[arglen - 1] = '\0'; /* Get the directory and file names. */ - fname = zfs_basename(arg); + fname = get_basename(arg); dname = arg; - if ((dnamelen = zfs_dirnamelen(arg)) != -1) + if ((dnamelen = get_dirnamelen(arg)) != -1) arg[dnamelen] = '\0'; else dname = "."; diff --git a/tests/zfs-tests/tests/functional/ctime/Makefile.am b/tests/zfs-tests/tests/functional/ctime/Makefile.am index 3174f78c6..e7479ae81 100644 --- a/tests/zfs-tests/tests/functional/ctime/Makefile.am +++ b/tests/zfs-tests/tests/functional/ctime/Makefile.am @@ -11,5 +11,3 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime pkgexec_PROGRAMS = ctime ctime_SOURCES = ctime.c - -ctime_LDADD = $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la diff --git a/tests/zfs-tests/tests/functional/ctime/ctime.c b/tests/zfs-tests/tests/functional/ctime/ctime.c index 2d515d957..b755be2fe 100644 --- a/tests/zfs-tests/tests/functional/ctime/ctime.c +++ b/tests/zfs-tests/tests/functional/ctime/ctime.c @@ -37,7 +37,6 @@ #include <utime.h> #include <stdio.h> #include <stdlib.h> -#include <libzutil.h> #include <unistd.h> #include <strings.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 do_read(const char *pfile) { @@ -161,7 +167,7 @@ do_link(const char *pfile) * the link file in the same directory. */ (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) { (void) fprintf(stderr, "link(%s, %s) failed with errno %d\n", |