From 0f29fd8ac81a166103f311c180fd06d956dc6dc4 Mon Sep 17 00:00:00 2001 From: Carlo Landmeter Date: Tue, 1 Mar 2016 15:13:44 +0100 Subject: [PATCH 2/8] Add support for libtirpc This introduces the --with-tirpc configure switch to compile with libtirpc. This is needed for libc's which do not have their own RPC libary (ie musl libc). --- cmd/mount_zfs/Makefile.am | 3 ++- cmd/zdb/Makefile.am | 2 +- cmd/zed/Makefile.am | 3 ++- cmd/zfs/Makefile.am | 2 +- cmd/zhack/Makefile.am | 2 +- cmd/zinject/Makefile.am | 3 ++- cmd/zpool/Makefile.am | 2 +- cmd/zstreamdump/Makefile.am | 2 +- cmd/ztest/Makefile.am | 2 +- config/tirpc.m4 | 17 +++++++++++++++++ config/user.m4 | 1 + lib/libnvpair/Makefile.am | 2 +- lib/libspl/Makefile.am | 6 +++--- lib/libspl/include/rpc/xdr.h | 2 ++ lib/libspl/xdr.c | 2 ++ module/nvpair/nvpair.c | 4 ++++ 16 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 config/tirpc.m4 diff --git a/cmd/mount_zfs/Makefile.am b/cmd/mount_zfs/Makefile.am index b1d9389..4be1135 100644 --- a/cmd/mount_zfs/Makefile.am +++ b/cmd/mount_zfs/Makefile.am @@ -19,4 +19,5 @@ mount_zfs_LDADD = \ $(top_builddir)/lib/libuutil/libuutil.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la \ - $(top_builddir)/lib/libzfs_core/libzfs_core.la + $(top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(TIRPC_LIBS) diff --git a/cmd/zdb/Makefile.am b/cmd/zdb/Makefile.am index c22186a..181a821 100644 --- a/cmd/zdb/Makefile.am +++ b/cmd/zdb/Makefile.am @@ -19,4 +19,4 @@ zdb_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -zdb_LDADD += $(ZLIB) +zdb_LDADD += $(ZLIB) $(TIRPC_LIBS) diff --git a/cmd/zed/Makefile.am b/cmd/zed/Makefile.am index 70e4f7f..ce16ceb 100644 --- a/cmd/zed/Makefile.am +++ b/cmd/zed/Makefile.am @@ -30,7 +30,8 @@ zed_LDADD = \ $(top_builddir)/lib/libspl/libspl.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la \ - $(top_builddir)/lib/libzfs_core/libzfs_core.la + $(top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(TIRPC_LIBS) zedconfdir = $(sysconfdir)/zfs/zed.d diff --git a/cmd/zfs/Makefile.am b/cmd/zfs/Makefile.am index 3cac73d..ea35555 100644 --- a/cmd/zfs/Makefile.am +++ b/cmd/zfs/Makefile.am @@ -19,5 +19,5 @@ zfs_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -zfs_LDADD += $(ZLIB) +zfs_LDADD += $(ZLIB) $(TIRPC_LIBS) zfs_LDFLAGS = -pthread diff --git a/cmd/zhack/Makefile.am b/cmd/zhack/Makefile.am index 53e3241..07b5fab 100644 --- a/cmd/zhack/Makefile.am +++ b/cmd/zhack/Makefile.am @@ -16,4 +16,4 @@ zhack_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -zhack_LDADD += $(ZLIB) +zhack_LDADD += $(ZLIB) $(TIRPC_LIBS) diff --git a/cmd/zinject/Makefile.am b/cmd/zinject/Makefile.am index 2500bee..2d069d3 100644 --- a/cmd/zinject/Makefile.am +++ b/cmd/zinject/Makefile.am @@ -16,4 +16,5 @@ zinject_LDADD = \ $(top_builddir)/lib/libuutil/libuutil.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la \ - $(top_builddir)/lib/libzfs_core/libzfs_core.la + $(top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(TIRPC_LIBS) diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am index c11951b..a59bf32 100644 --- a/cmd/zpool/Makefile.am +++ b/cmd/zpool/Makefile.am @@ -19,4 +19,4 @@ zpool_LDADD = \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(LIBBLKID) + $(LIBBLKID) $(TIRPC_LIBS) diff --git a/cmd/zstreamdump/Makefile.am b/cmd/zstreamdump/Makefile.am index 654863a..f800a8e 100644 --- a/cmd/zstreamdump/Makefile.am +++ b/cmd/zstreamdump/Makefile.am @@ -16,4 +16,4 @@ zstreamdump_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -zstreamdump_LDADD += $(ZLIB) +zstreamdump_LDADD += $(ZLIB) $(TIRPC_LIBS) diff --git a/cmd/ztest/Makefile.am b/cmd/ztest/Makefile.am index e3be39a..1953fe8 100644 --- a/cmd/ztest/Makefile.am +++ b/cmd/ztest/Makefile.am @@ -19,4 +19,4 @@ ztest_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -ztest_LDADD += -lm -ldl +ztest_LDADD += -lm -ldl $(TIRPC_LIBS) diff --git a/config/tirpc.m4 b/config/tirpc.m4 new file mode 100644 index 0000000..ec15785 --- /dev/null +++ b/config/tirpc.m4 @@ -0,0 +1,17 @@ +dnl +dnl musl support +dnl + +AC_DEFUN([ZFS_AC_CONFIG_USER_TIRPC], [ +AH_TEMPLATE([WITH_TIRPC], + [Define to 1 if libtirpc is being used as the RPC library]) +AC_ARG_WITH(tirpc, +AC_HELP_STRING([--with-tirpc], [compile with libtirpc]), +[if test x$withval = xyes; then + AC_DEFINE([WITH_TIRPC], 1, [Define if you have musl]) + PKG_CHECK_MODULES([TIRPC],[libtirpc]) + AC_DEFINE([WITH_TIRPC], 1, [Define if you have libtirpc]) + AC_SUBST(TIRPC_CFLAGS) + AC_SUBST(TIRPC_LIBS) +fi]) +]) diff --git a/config/user.m4 b/config/user.m4 index 7f79420..820b8d3 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -13,6 +13,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_LIBBLKID ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN ZFS_AC_CONFIG_USER_RUNSTATEDIR + ZFS_AC_CONFIG_USER_TIRPC dnl # dnl # Checks for library functions AC_CHECK_FUNCS([mlockall]) diff --git a/lib/libnvpair/Makefile.am b/lib/libnvpair/Makefile.am index c9ac1f1..985285a 100644 --- a/lib/libnvpair/Makefile.am +++ b/lib/libnvpair/Makefile.am @@ -4,7 +4,7 @@ VPATH = \ $(top_srcdir)/module/nvpair \ $(top_srcdir)/lib/libnvpair -AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) +AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(TIRPC_CFLAGS) DEFAULT_INCLUDES += \ -I$(top_srcdir)/include \ diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am index a569446..9cedfaa 100644 --- a/lib/libspl/Makefile.am +++ b/lib/libspl/Makefile.am @@ -4,13 +4,13 @@ VPATH = \ $(top_srcdir)/lib/libspl \ $(top_srcdir)/lib/libspl/$(TARGET_ASM_DIR) -AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) +AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(TIRPC_CFLAGS) SUBDIRS = include $(TARGET_ASM_DIR) DIST_SUBDIRS = include asm-generic asm-i386 asm-x86_64 DEFAULT_INCLUDES += \ - -I$(top_srcdir)/lib/libspl/include + -I$(top_srcdir)/lib/libspl/include $(TIRPC_CFLAGS) AM_CCASFLAGS = \ -I$(top_srcdir)/lib/libspl/include @@ -42,6 +42,6 @@ nodist_libspl_la_SOURCES = \ $(USER_ASM) \ $(KERNEL_C) -libspl_la_LIBADD = -lrt +libspl_la_LIBADD = -lrt $(TIRPC_LDFLAGS) EXTRA_DIST = $(USER_C) diff --git a/lib/libspl/include/rpc/xdr.h b/lib/libspl/include/rpc/xdr.h index 99500d6..cd2d17a 100644 --- a/lib/libspl/include/rpc/xdr.h +++ b/lib/libspl/include/rpc/xdr.h @@ -60,6 +60,8 @@ typedef struct xdr_bytesrec { #define XDR_RDMAGET 4 #define XDR_RDMASET 5 +#ifndef WITH_TIRPC extern bool_t xdr_control(XDR *xdrs, int request, void *info); +#endif #endif diff --git a/lib/libspl/xdr.c b/lib/libspl/xdr.c index 288a338..f122496 100644 --- a/lib/libspl/xdr.c +++ b/lib/libspl/xdr.c @@ -29,6 +29,7 @@ * under license from the Regents of the University of California. */ +#ifndef WITH_TIRPC #include /* @@ -76,3 +77,4 @@ xdr_control(XDR *xdrs, int request, void *info) } return (FALSE); } +#endif diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 1eca0fe..efd6287 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -3251,8 +3251,12 @@ nvs_xdr_nvpair(nvstream_t *nvs, nvpair_t *nvp, size_t *size) return (0); /* sanity check the size parameter */ +#ifndef WITH_TIRPC if (!xdr_control(xdr, XDR_GET_BYTES_AVAIL, &bytesrec)) return (EFAULT); +#else + xdr_control(xdr, XDR_GET_BYTES_AVAIL, &bytesrec); +#endif if (*size > NVS_XDR_MAX_LEN(bytesrec.xc_num_avail)) return (EFAULT); -- 2.7.2