diff options
11 files changed, 730 insertions, 456 deletions
diff --git a/testing/zfs-grsec/0001-Add-missing-fcntl.h-to-includes-in-mount_zfs.c.patch b/testing/zfs-grsec/0001-Add-missing-fcntl.h-to-includes-in-mount_zfs.c.patch new file mode 100644 index 0000000000..ca8909c425 --- /dev/null +++ b/testing/zfs-grsec/0001-Add-missing-fcntl.h-to-includes-in-mount_zfs.c.patch @@ -0,0 +1,11 @@ +--- ./cmd/mount_zfs/mount_zfs.c.orig ++++ ./cmd/mount_zfs/mount_zfs.c +@@ -32,6 +32,7 @@ + #include <sys/stat.h> + #include <libzfs.h> + #include <locale.h> + #include <getopt.h> ++#include <fcntl.h> + + #define ZS_COMMENT 0x00000000 /* comment */ + #define ZS_ZFSUTIL 0x00000001 /* caller is zfs(8) */ diff --git a/testing/zfs-grsec/0001-Add-support-for-alpine-linux.patch b/testing/zfs-grsec/0001-Add-support-for-alpine-linux.patch new file mode 100644 index 0000000000..54d55e6ea5 --- /dev/null +++ b/testing/zfs-grsec/0001-Add-support-for-alpine-linux.patch @@ -0,0 +1,122 @@ +From 00aa1a096d2c9ecaf28faa51aca5feb9d406aab0 Mon Sep 17 00:00:00 2001 +From: Carlo Landmeter <clandmeter@gmail.com> +Date: Tue, 1 Mar 2016 16:36:28 +0100 +Subject: [PATCH] Add support for alpine linux + +Both Alpine Linux and Gentoo use OpenRC so we share its logic +--- + config/zfs-build.m4 | 7 ++++++- + etc/init.d/Makefile.am | 2 +- + etc/init.d/zfs-import.in | 2 +- + etc/init.d/zfs-mount.in | 2 +- + etc/init.d/zfs-share.in | 2 +- + etc/init.d/zfs-zed.in | 2 +- + 6 files changed, 11 insertions(+), 6 deletions(-) + +diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 +index f93c5b5..9d3f0a6 100644 +--- a/config/zfs-build.m4 ++++ b/config/zfs-build.m4 +@@ -266,6 +266,8 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ + VENDOR=ubuntu ; + elif test -f /etc/debian_version ; then + VENDOR=debian ; ++ elif test -f /etc/alpine-release ; then ++ VENDOR=alpine ; + else + VENDOR= ; + fi +@@ -278,6 +280,7 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ + redhat) DEFAULT_PACKAGE=rpm ;; + fedora) DEFAULT_PACKAGE=rpm ;; + gentoo) DEFAULT_PACKAGE=tgz ;; ++ alpine) DEFAULT_PACKAGE=tgz ;; + arch) DEFAULT_PACKAGE=tgz ;; + sles) DEFAULT_PACKAGE=rpm ;; + slackware) DEFAULT_PACKAGE=tgz ;; +@@ -299,7 +302,8 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ + toss) DEFAULT_INIT_SCRIPT=redhat ;; + redhat) DEFAULT_INIT_SCRIPT=redhat ;; + fedora) DEFAULT_INIT_SCRIPT=fedora ;; +- gentoo) DEFAULT_INIT_SCRIPT=gentoo ;; ++ gentoo) DEFAULT_INIT_SCRIPT=openrc ;; ++ alpine) DEFAULT_INIT_SCRIPT=openrc ;; + arch) DEFAULT_INIT_SCRIPT=lsb ;; + sles) DEFAULT_INIT_SCRIPT=lsb ;; + slackware) DEFAULT_INIT_SCRIPT=lsb ;; +@@ -313,6 +317,7 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ + + AC_MSG_CHECKING([default init config direectory]) + case "$VENDOR" in ++ alpine) DEFAULT_INITCONF_DIR=/etc/conf.d ;; + gentoo) DEFAULT_INITCONF_DIR=/etc/conf.d ;; + toss) DEFAULT_INITCONF_DIR=/etc/sysconfig ;; + redhat) DEFAULT_INITCONF_DIR=/etc/sysconfig ;; +diff --git a/etc/init.d/Makefile.am b/etc/init.d/Makefile.am +index 5f70fc6..c6e29d1 100644 +--- a/etc/init.d/Makefile.am ++++ b/etc/init.d/Makefile.am +@@ -21,7 +21,7 @@ $(init_SCRIPTS) $(initconf_SCRIPTS) $(initcommon_SCRIPTS): $(EXTRA_DIST) + else \ + NFS_SRV=nfs; \ + fi; \ +- if [ -e /etc/gentoo-release ]; then \ ++ if [ -e /sbin/openrc-run ]; then \ + SHELL=/sbin/runscript; \ + else \ + SHELL=/bin/sh; \ +diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in +index 2258638..354bbc6 100755 +--- a/etc/init.d/zfs-import.in ++++ b/etc/init.d/zfs-import.in +@@ -308,7 +308,7 @@ do_start() + + # ---------------------------------------------------- + +-if [ ! -e /etc/gentoo-release ] ++if [ ! -e /sbin/openrc-run ] + then + case "$1" in + start) +diff --git a/etc/init.d/zfs-mount.in b/etc/init.d/zfs-mount.in +index 05cea9b..34db057 100755 +--- a/etc/init.d/zfs-mount.in ++++ b/etc/init.d/zfs-mount.in +@@ -199,7 +199,7 @@ do_stop() + + # ---------------------------------------------------- + +-if [ ! -e /etc/gentoo-release ] ++if [ ! -e /sbin/openrc-run ] + then + case "$1" in + start) +diff --git a/etc/init.d/zfs-share.in b/etc/init.d/zfs-share.in +index 1b70da4..ce3cc1c 100755 +--- a/etc/init.d/zfs-share.in ++++ b/etc/init.d/zfs-share.in +@@ -58,7 +58,7 @@ do_stop() + + # ---------------------------------------------------- + +-if [ ! -e /etc/gentoo-release ]; then ++if [ ! -e /sbin/openrc-run ]; then + case "$1" in + start) + do_start +diff --git a/etc/init.d/zfs-zed.in b/etc/init.d/zfs-zed.in +index 86e3185..d0086ee 100755 +--- a/etc/init.d/zfs-zed.in ++++ b/etc/init.d/zfs-zed.in +@@ -98,7 +98,7 @@ do_reload() + + # ---------------------------------------------------- + +-if [ ! -e /etc/gentoo-release ]; then ++if [ ! -e /sbin/openrc-run ]; then + case "$1" in + start) + do_start +-- +2.7.2 + diff --git a/testing/zfs-grsec/0002-Add-support-for-libtirpc.patch b/testing/zfs-grsec/0002-Add-support-for-libtirpc.patch new file mode 100644 index 0000000000..1a44c757b4 --- /dev/null +++ b/testing/zfs-grsec/0002-Add-support-for-libtirpc.patch @@ -0,0 +1,250 @@ +From 0f29fd8ac81a166103f311c180fd06d956dc6dc4 Mon Sep 17 00:00:00 2001 +From: Carlo Landmeter <clandmeter@gmail.com> +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 <rpc/xdr.h> + + /* +@@ -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 + diff --git a/testing/zfs-grsec/0003-Use-the-correct-macro-to-include-backtrace.patch b/testing/zfs-grsec/0003-Use-the-correct-macro-to-include-backtrace.patch new file mode 100644 index 0000000000..9be8757535 --- /dev/null +++ b/testing/zfs-grsec/0003-Use-the-correct-macro-to-include-backtrace.patch @@ -0,0 +1,34 @@ +From d8eadaf30347d1d67e8125ae7c299239d3b730dc Mon Sep 17 00:00:00 2001 +From: Carlo Landmeter <clandmeter@gmail.com> +Date: Tue, 1 Mar 2016 15:23:09 +0100 +Subject: [PATCH 3/8] Use the correct macro to include backtrace + +--- + cmd/ztest/ztest.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c +index 42643ef..a824da9 100644 +--- a/cmd/ztest/ztest.c ++++ b/cmd/ztest/ztest.c +@@ -123,7 +123,7 @@ + #include <math.h> + #include <sys/fs/zfs.h> + #include <libnvpair.h> +-#ifdef __GNUC__ ++#ifdef __GLIBC__ + #include <execinfo.h> /* for backtrace() */ + #endif + +@@ -490,7 +490,7 @@ _umem_logging_init(void) + static void sig_handler(int signo) + { + struct sigaction action; +-#ifdef __GNUC__ /* backtrace() is a GNU extension */ ++#ifdef __GLIBC__ /* backtrace() is a GNU extension */ + int nptrs; + void *buffer[BACKTRACE_SZ]; + +-- +2.7.2 + diff --git a/testing/zfs-grsec/0004-Ensure-correct-return-value-type.patch b/testing/zfs-grsec/0004-Ensure-correct-return-value-type.patch new file mode 100644 index 0000000000..7e801f2aa5 --- /dev/null +++ b/testing/zfs-grsec/0004-Ensure-correct-return-value-type.patch @@ -0,0 +1,26 @@ +From b2197a57c1261591e34d92a6ad7444ea97819db6 Mon Sep 17 00:00:00 2001 +From: Carlo Landmeter <clandmeter@gmail.com> +Date: Tue, 1 Mar 2016 15:32:52 +0100 +Subject: [PATCH 4/8] Ensure correct return value type + +When compiling with musl libc the return type will be incorrect. +--- + include/sys/zfs_context.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h +index cc626fd..e68223e 100644 +--- a/include/sys/zfs_context.h ++++ b/include/sys/zfs_context.h +@@ -637,7 +637,7 @@ extern void delay(clock_t ticks); + #define maxclsyspri -20 + #define defclsyspri 0 + +-#define CPU_SEQID (pthread_self() & (max_ncpus - 1)) ++#define CPU_SEQID ((uintptr_t)pthread_self() & (max_ncpus - 1)) + + #define kcred NULL + #define CRED() NULL +-- +2.7.2 + diff --git a/testing/zfs-grsec/0006-Include-sys-types.h-in-devid.h.patch b/testing/zfs-grsec/0006-Include-sys-types.h-in-devid.h.patch new file mode 100644 index 0000000000..9301c52f1c --- /dev/null +++ b/testing/zfs-grsec/0006-Include-sys-types.h-in-devid.h.patch @@ -0,0 +1,25 @@ +From 9104430ec34fe257ccb6e199771c804d38f0003a Mon Sep 17 00:00:00 2001 +From: Carlo Landmeter <clandmeter@gmail.com> +Date: Tue, 1 Mar 2016 15:56:26 +0100 +Subject: [PATCH 6/8] Include sys/types.h in devid.h + +This is needed for musl libc +--- + lib/libspl/include/devid.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/libspl/include/devid.h b/lib/libspl/include/devid.h +index 5406c33..4b346da 100644 +--- a/lib/libspl/include/devid.h ++++ b/lib/libspl/include/devid.h +@@ -27,6 +27,7 @@ + #ifndef _LIBSPL_DEVID_H + #define _LIBSPL_DEVID_H + ++#include <sys/types.h> + #include <stdlib.h> + + typedef int ddi_devid_t; +-- +2.7.2 + diff --git a/testing/zfs-grsec/0008-Set-_DATE_FMT-to-if-not-defined-in-libspl-timestamp..patch b/testing/zfs-grsec/0008-Set-_DATE_FMT-to-if-not-defined-in-libspl-timestamp..patch new file mode 100644 index 0000000000..81cf4387f0 --- /dev/null +++ b/testing/zfs-grsec/0008-Set-_DATE_FMT-to-if-not-defined-in-libspl-timestamp..patch @@ -0,0 +1,28 @@ +From b49e2287871f612167dc40eb0d86e1c8b2d6311e Mon Sep 17 00:00:00 2001 +From: Carlo Landmeter <clandmeter@gmail.com> +Date: Tue, 1 Mar 2016 16:23:12 +0100 +Subject: [PATCH 8/8] Set _DATE_FMT to '%+' if not defined in + libspl/timestamp.c + +--- + lib/libspl/timestamp.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/lib/libspl/timestamp.c b/lib/libspl/timestamp.c +index a4f4cf4..85b7ecf 100644 +--- a/lib/libspl/timestamp.c ++++ b/lib/libspl/timestamp.c +@@ -28,6 +28,10 @@ + #include <langinfo.h> + #include "statcommon.h" + ++#ifndef _DATE_FMT ++#define _DATE_FMT "%+" ++#endif ++ + /* + * Print timestamp as decimal reprentation of time_t value (-T u was specified) + * or in date(1) format (-T d was specified). +-- +2.7.2 + diff --git a/testing/zfs-grsec/3bca72de3c30598c585c910208459a0cf05b9f0d.patch b/testing/zfs-grsec/3bca72de3c30598c585c910208459a0cf05b9f0d.patch new file mode 100644 index 0000000000..a3ce7a6a6a --- /dev/null +++ b/testing/zfs-grsec/3bca72de3c30598c585c910208459a0cf05b9f0d.patch @@ -0,0 +1,46 @@ +From 3bca72de3c30598c585c910208459a0cf05b9f0d Mon Sep 17 00:00:00 2001 +From: Carlo Landmeter <clandmeter@gmail.com> +Date: Fri, 25 Mar 2016 13:21:53 +0100 +Subject: [PATCH] Move hrtime_t timestruc_t and timespec_t and change + longlong_t to long long + +hrtime_t timestruc_t and timespec_t should have originally be included in +sys/time.h so lets move them. + +longlong_t is not defined by any standard so change it to long long +--- + lib/libspl/include/sys/time.h | 5 +++++ + lib/libspl/include/sys/types.h | 4 ---- + 2 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h +index f0da440..03da3f7 100644 +--- a/lib/libspl/include/sys/time.h ++++ b/lib/libspl/include/sys/time.h +@@ -58,6 +58,11 @@ + #define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) + #endif + ++typedef long long hrtime_t; ++typedef struct timespec timestruc_t; ++typedef struct timespec timespec_t; ++ ++ + extern hrtime_t gethrtime(void); + extern void gethrestime(timestruc_t *); + +diff --git a/lib/libspl/include/sys/types.h b/lib/libspl/include/sys/types.h +index 25d56be..8996af9 100644 +--- a/lib/libspl/include/sys/types.h ++++ b/lib/libspl/include/sys/types.h +@@ -55,10 +55,6 @@ typedef longlong_t diskaddr_t; + typedef ulong_t pgcnt_t; /* number of pages */ + typedef long spgcnt_t; /* signed number of pages */ + +-typedef longlong_t hrtime_t; +-typedef struct timespec timestruc_t; +-typedef struct timespec timespec_t; +- + typedef short pri_t; + + typedef int zoneid_t; diff --git a/testing/zfs-grsec/468e0c54b8d34d93043c9631cab954fb88fff8cb.patch b/testing/zfs-grsec/468e0c54b8d34d93043c9631cab954fb88fff8cb.patch new file mode 100644 index 0000000000..040f1251ad --- /dev/null +++ b/testing/zfs-grsec/468e0c54b8d34d93043c9631cab954fb88fff8cb.patch @@ -0,0 +1,144 @@ +From 468e0c54b8d34d93043c9631cab954fb88fff8cb Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf <behlendorf1@llnl.gov> +Date: Tue, 1 Mar 2016 15:45:43 +0100 +Subject: [PATCH] Remove complicated libspl assert wrappers + +Effectively provide our own version of assert()/verify() for use +in user space. This minimizes our dependencies and aligns the +user space assertion error messages with those from the kernel. +spl.ko module. + +Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> +--- + include/libzfs_impl.h | 5 --- + lib/libspl/include/assert.h | 76 +++++++++++++++++++-------------------------- + 2 files changed, 32 insertions(+), 49 deletions(-) + +diff --git a/include/libzfs_impl.h b/include/libzfs_impl.h +index e805e3e..ff02fa7 100644 +--- a/include/libzfs_impl.h ++++ b/include/libzfs_impl.h +@@ -46,11 +46,6 @@ + extern "C" { + #endif + +-#ifdef VERIFY +-#undef VERIFY +-#endif +-#define VERIFY verify +- + typedef struct libzfs_fru { + char *zf_device; + char *zf_fru; +diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h +index 52924e8..b30626e 100644 +--- a/lib/libspl/include/assert.h ++++ b/lib/libspl/include/assert.h +@@ -32,68 +32,54 @@ + #include <stdio.h> + #include <stdlib.h> + +-#ifndef __assert_c99 +-static inline void +-__assert_c99(const char *expr, const char *file, int line, const char *func) ++static inline int ++libspl_assert(const char *buf, const char *file, const char *func, int line) + { +- fprintf(stderr, "%s:%i: %s: Assertion `%s` failed.\n", +- file, line, func, expr); ++ fprintf(stderr, "%s\n", buf); ++ fprintf(stderr, "ASSERT at %s:%d:%s()", file, line, func); + abort(); + } +-#endif /* __assert_c99 */ +- +-#ifndef verify +-#if defined(__STDC__) +-#if __STDC_VERSION__ - 0 >= 199901L +-#define verify(EX) (void)((EX) || \ +- (__assert_c99(#EX, __FILE__, __LINE__, __func__), 0)) +-#else +-#define verify(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0)) +-#endif /* __STDC_VERSION__ - 0 >= 199901L */ +-#else +-#define verify(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0)) +-#endif /* __STDC__ */ +-#endif /* verify */ +- +-#undef VERIFY +-#undef ASSERT + +-#define VERIFY verify +-#define ASSERT assert ++#ifdef verify ++#undef verify ++#endif + +-extern void __assert(const char *, const char *, int); ++#define VERIFY(cond) \ ++ (void) ((!(cond)) && \ ++ libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__)) ++#define verify(cond) \ ++ (void) ((!(cond)) && \ ++ libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__)) + +-static inline int +-assfail(const char *buf, const char *file, int line) +-{ +- __assert(buf, file, line); +- return (0); +-} +- +-/* BEGIN CSTYLED */ +-#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \ +- const TYPE __left = (TYPE)(LEFT); \ +- const TYPE __right = (TYPE)(RIGHT); \ +- if (!(__left OP __right)) { \ +- char *__buf = alloca(256); \ +- (void) snprintf(__buf, 256, "%s %s %s (0x%llx %s 0x%llx)", \ +- #LEFT, #OP, #RIGHT, \ +- (u_longlong_t)__left, #OP, (u_longlong_t)__right); \ +- assfail(__buf, __FILE__, __LINE__); \ +- } \ ++#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) \ ++do { \ ++ const TYPE __left = (TYPE)(LEFT); \ ++ const TYPE __right = (TYPE)(RIGHT); \ ++ if (!(__left OP __right)) { \ ++ char *__buf = alloca(256); \ ++ (void) snprintf(__buf, 256, \ ++ "%s %s %s (0x%llx %s 0x%llx)", #LEFT, #OP, #RIGHT, \ ++ (u_longlong_t)__left, #OP, (u_longlong_t)__right); \ ++ libspl_assert(__buf, __FILE__, __FUNCTION__, __LINE__); \ ++ } \ + } while (0) +-/* END CSTYLED */ + + #define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t) + #define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t) + #define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t) + #define VERIFY0(x) VERIFY3_IMPL(x, ==, 0, uint64_t) + ++#ifdef assert ++#undef assert ++#endif ++ + #ifdef NDEBUG + #define ASSERT3S(x, y, z) ((void)0) + #define ASSERT3U(x, y, z) ((void)0) + #define ASSERT3P(x, y, z) ((void)0) + #define ASSERT0(x) ((void)0) ++#define ASSERT(x) ((void)0) ++#define assert(x) ((void)0) + #define ASSERTV(x) + #define IMPLY(A, B) ((void)0) + #define EQUIV(A, B) ((void)0) +@@ -102,6 +88,8 @@ assfail(const char *buf, const char *file, int line) + #define ASSERT3U(x, y, z) VERIFY3U(x, y, z) + #define ASSERT3P(x, y, z) VERIFY3P(x, y, z) + #define ASSERT0(x) VERIFY0(x) ++#define ASSERT(x) VERIFY(x) ++#define assert(x) VERIFY(x) + #define ASSERTV(x) x + #define IMPLY(A, B) \ + ((void)(((!(A)) || (B)) || \ diff --git a/testing/zfs-grsec/APKBUILD b/testing/zfs-grsec/APKBUILD index e3cf61e2e9..0f58ac71ef 100644 --- a/testing/zfs-grsec/APKBUILD +++ b/testing/zfs-grsec/APKBUILD @@ -9,8 +9,8 @@ _kpkg=linux-$_flavor _kver=4.4.6 _kpkgrel=0 -_realver=0.6.5 -_mypkgrel=0 +_realver=0.6.5.6 +_mypkgrel=1 # source the kernel version if [ -f ../../main/linux-$_flavor/APKBUILD ]; then @@ -27,7 +27,7 @@ pkgver=$_kver pkgrel=$(($_kpkgrel + $_mypkgrel)) pkgdesc="ZFS for Linux" url="http://zfsonlinux.org" -#arch="x86 x86_64" +arch="x86 x86_64" arch= license="CDDL" depends="spl-$_flavor" @@ -37,8 +37,17 @@ makedepends="$depends_dev automake autoconf libtool linux-headers" install="" subpackages="$pkgname-dev $pkgname-doc zfs-utils:utils" source="http://archive.zfsonlinux.org/downloads/zfsonlinux/zfs/zfs-$_realver.tar.gz - musl-fixes.patch - " + 0001-Add-missing-fcntl.h-to-includes-in-mount_zfs.c.patch + 0001-Add-support-for-alpine-linux.patch + 0002-Add-support-for-libtirpc.patch + 0003-Use-the-correct-macro-to-include-backtrace.patch + 0004-Ensure-correct-return-value-type.patch + 0006-Include-sys-types.h-in-devid.h.patch + 0008-Set-_DATE_FMT-to-if-not-defined-in-libspl-timestamp..patch + + 468e0c54b8d34d93043c9631cab954fb88fff8cb.patch + 3bca72de3c30598c585c910208459a0cf05b9f0d.patch + " _builddir="$srcdir/$_realname-$_realver" @@ -95,9 +104,33 @@ utils() { "$pkgdir"/lib || return 1 } -md5sums="76a3675a56acce7c9fd36578173304e4 zfs-0.6.5.tar.gz -68b420d0dd707921701d3d2c9544df90 musl-fixes.patch" -sha256sums="b38e9c04e9e7e1930adbc16b694f2401812e7674ae3bb526098a2a7c6435534d zfs-0.6.5.tar.gz -bc4ccb90eb93de774f5d935b3ea734e11be617faa78be76d6ecebcbe8b61524f musl-fixes.patch" -sha512sums="e6749ebfb8aefc31ec88ab7de5224e7148daa883ea2beed1c9b38e98ec7495da6fb62fc1b6a393fdb168ca5eb204b1bb940f13af6ed9e80fdd5c39436856295c zfs-0.6.5.tar.gz -aff25fd556911d64ac426fc15fd16dd1a49f55d90936607d5093bdc70970b3cf5559a1b0c531b15a64c48ad540986ed0a6ee3c5260984b9c3b4a1ca3911d9143 musl-fixes.patch" +md5sums="8c05b3cfcb0c25b1469032404ec032fe zfs-0.6.5.6.tar.gz +7b4ee1de2404c0baa9848de309819fc9 0001-Add-missing-fcntl.h-to-includes-in-mount_zfs.c.patch +ce98b83e44621e99e686cb384b36aaeb 0001-Add-support-for-alpine-linux.patch +8633a50fa103f91b7c08cba35c38fffd 0002-Add-support-for-libtirpc.patch +51f8e000510747abc1610779820c90e2 0003-Use-the-correct-macro-to-include-backtrace.patch +f380fed6034db74b1b1d80d717e51ad2 0004-Ensure-correct-return-value-type.patch +3853a26f7a7a14607c99020373c9691e 0006-Include-sys-types.h-in-devid.h.patch +5050558e710d4c763dc4dddcad89b153 0008-Set-_DATE_FMT-to-if-not-defined-in-libspl-timestamp..patch +6388b1fbd8a335db158b8c84d023c8a2 468e0c54b8d34d93043c9631cab954fb88fff8cb.patch +7522a01aa31d474fe148945dd4de5329 3bca72de3c30598c585c910208459a0cf05b9f0d.patch" +sha256sums="c349d46d86b4f61cd53a0891acad916cfc3f0d6754127db7f60a0bd98185aeff zfs-0.6.5.6.tar.gz +2166987d985fc1e9058943e75642177178a2c140d3a261a97378696205f0d77d 0001-Add-missing-fcntl.h-to-includes-in-mount_zfs.c.patch +f06e42db7c7e41481dfb068d80c9b763d7c9aead4c8f017e9398f88d58424092 0001-Add-support-for-alpine-linux.patch +88535d0c974ac7d878958dc835f27a5d1090a3cb0c90234f5f1cede65f7fdc83 0002-Add-support-for-libtirpc.patch +3ee3d49a5f6ed0df37cdbe60330ee4ff9e6feb9ac0872250482ddfc039617eef 0003-Use-the-correct-macro-to-include-backtrace.patch +03695ab8313cf4e30289bdfa9a611f7538ce712253e7163de755fbe2fed9d1d8 0004-Ensure-correct-return-value-type.patch +7d26389c31c2720fde8865fee8a1613a92d264a3a3c8aec5f9dea4426f19221d 0006-Include-sys-types.h-in-devid.h.patch +2c8bda14b9de33ccae073c3738fc76136818fc60702c96a03229b210b6985d6b 0008-Set-_DATE_FMT-to-if-not-defined-in-libspl-timestamp..patch +c8e2d08023fbd7c754fda6432f663fd04a8b4f4a96d7d83fb5575bbffe8ca7b8 468e0c54b8d34d93043c9631cab954fb88fff8cb.patch +d372afa34cc4a76de326788c5017a9f5741511f3760b64f207991d80788e5605 3bca72de3c30598c585c910208459a0cf05b9f0d.patch" +sha512sums="94c55a50f0f9a90ce07a45dc72bb2730b2a41373ab5a12845df00ef38bb22e4a80ab2fb6e31a9c3a45e51516cdea441bb9da1d0acf71f2f88b38c7c3e9e995b0 zfs-0.6.5.6.tar.gz +549a15c393806176e1640ee5c47d76fb142b40d96a68be854379fa96c987e86ff29dac5172cc619b33bb2ebb1f9eb3bc1e92bceced3f25e63c16ddc9ef2ac578 0001-Add-missing-fcntl.h-to-includes-in-mount_zfs.c.patch +d2efb627f493bab06f8049dc4bcb7c39269ff9dcd66879a0f96fa5040e1c7468f9e684277ec3e54841b3a5f8734d9470f2c6a1af470e3f1a71f759f9155b7ede 0001-Add-support-for-alpine-linux.patch +bab158b4f32e34d346f5a97406ba1d58783e5965906e60cae1ef40d1a7a78f505558d0eaaff62f03f4965ae3b4168b5b469636556f6393553cf8540ec400a9b5 0002-Add-support-for-libtirpc.patch +94ecaeb8ec16c1af3b40eb44081e4db4f5dd5f8c0c3edece2b6bdec7ac2be993f041066c41c0b94cb75f9413681be0c846249413956712096f8181aa0f26736b 0003-Use-the-correct-macro-to-include-backtrace.patch +12c0d3d81e788c6f13aa0435b72ae64af32170ae30b98bb2b112984a82231f67ec5f46d7867264eba27b22d899f3132bf9687c9a7973eb43055597a994e1bf73 0004-Ensure-correct-return-value-type.patch +d5de48b1206583543f0f324e41abaea3ee3628f513cdb059e17758943ed1d97fcd685f463d9f8a52f5d85ac9b94630b9332e849cf2466852a83279acec4ca977 0006-Include-sys-types.h-in-devid.h.patch +4b6638ee3dde6c92f93208434b831076542437a7552a4d779c6bd104195be2cf01e09716e08ab7fd231ae2297f8f427a4e3985c1fa85e7f4becea281b923da4a 0008-Set-_DATE_FMT-to-if-not-defined-in-libspl-timestamp..patch +5707e8e7957e0e849ef68fb126fea61f4f2d54b8a8f29f1bad2aeefb851fc4f8cffaf5a1f1e8c02ca7d47471bc97ac364b864c1f9a4d03c7c552eab86484e368 468e0c54b8d34d93043c9631cab954fb88fff8cb.patch +2227fa9906741ba335ee94abeb1db29f39a885d791f8455bae6e3f63392c55923ad8d01a2163fbcf85dcd473312aeeba8e13462feb3c099559fdc35623d45797 3bca72de3c30598c585c910208459a0cf05b9f0d.patch" diff --git a/testing/zfs-grsec/musl-fixes.patch b/testing/zfs-grsec/musl-fixes.patch deleted file mode 100644 index f174f3a737..0000000000 --- a/testing/zfs-grsec/musl-fixes.patch +++ /dev/null @@ -1,445 +0,0 @@ -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/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c -index e3e8cfc..91efda6 100644 ---- a/cmd/mount_zfs/mount_zfs.c -+++ b/cmd/mount_zfs/mount_zfs.c -@@ -32,6 +32,7 @@ - #include <sys/stat.h> - #include <libzfs.h> - #include <locale.h> -+#include <fcntl.h> - - #define ZS_COMMENT 0x00000000 /* comment */ - #define ZS_ZFSUTIL 0x00000001 /* caller is zfs(8) */ -diff --git a/cmd/zdb/Makefile.am b/cmd/zdb/Makefile.am -index bc47cff..b8200da 100644 ---- a/cmd/zdb/Makefile.am -+++ b/cmd/zdb/Makefile.am -@@ -17,4 +17,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..2554011 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 ef4d99f..3c1ae75 100644 ---- a/cmd/ztest/Makefile.am -+++ b/cmd/ztest/Makefile.am -@@ -18,4 +18,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/cmd/ztest/ztest.c b/cmd/ztest/ztest.c -index afe6faa..40524ed 100644 ---- a/cmd/ztest/ztest.c -+++ b/cmd/ztest/ztest.c -@@ -123,7 +123,7 @@ - #include <math.h> - #include <sys/fs/zfs.h> - #include <libnvpair.h> --#ifdef __GNUC__ -+#ifdef __GLIBC__ - #include <execinfo.h> /* for backtrace() */ - #endif - -@@ -490,7 +490,7 @@ _umem_logging_init(void) - static void sig_handler(int signo) - { - struct sigaction action; --#ifdef __GNUC__ /* backtrace() is a GNU extension */ -+#ifdef __GLIBC__ /* backtrace() is a GNU extension */ - int nptrs; - void *buffer[BACKTRACE_SZ]; - -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/config/zfs-build.m4 b/config/zfs-build.m4 -index f93c5b5..ebcb1c2 100644 ---- a/config/zfs-build.m4 -+++ b/config/zfs-build.m4 -@@ -266,6 +266,8 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ - VENDOR=ubuntu ; - elif test -f /etc/debian_version ; then - VENDOR=debian ; -+ elif test -f /etc/alpine-release ; then -+ VENDOR=alpine ; - else - VENDOR= ; - fi -@@ -278,6 +280,7 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ - redhat) DEFAULT_PACKAGE=rpm ;; - fedora) DEFAULT_PACKAGE=rpm ;; - gentoo) DEFAULT_PACKAGE=tgz ;; -+ alpine) DEFAULT_PACKAGE=tgz ;; - arch) DEFAULT_PACKAGE=tgz ;; - sles) DEFAULT_PACKAGE=rpm ;; - slackware) DEFAULT_PACKAGE=tgz ;; -@@ -299,7 +302,8 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ - toss) DEFAULT_INIT_SCRIPT=redhat ;; - redhat) DEFAULT_INIT_SCRIPT=redhat ;; - fedora) DEFAULT_INIT_SCRIPT=fedora ;; -- gentoo) DEFAULT_INIT_SCRIPT=gentoo ;; -+ alpine) DEFAULT_INIT_SCRIPT=openrc ;; -+ gentoo) DEFAULT_INIT_SCRIPT=openrc ;; - arch) DEFAULT_INIT_SCRIPT=lsb ;; - sles) DEFAULT_INIT_SCRIPT=lsb ;; - slackware) DEFAULT_INIT_SCRIPT=lsb ;; -@@ -313,6 +317,7 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ - - AC_MSG_CHECKING([default init config direectory]) - case "$VENDOR" in -+ alpine) DEFAULT_INITCONF_DIR=/etc/conf.d ;; - gentoo) DEFAULT_INITCONF_DIR=/etc/conf.d ;; - toss) DEFAULT_INITCONF_DIR=/etc/sysconfig ;; - redhat) DEFAULT_INITCONF_DIR=/etc/sysconfig ;; -diff --git a/etc/init.d/Makefile.am b/etc/init.d/Makefile.am -index 5f70fc6..c6e29d1 100644 ---- a/etc/init.d/Makefile.am -+++ b/etc/init.d/Makefile.am -@@ -21,7 +21,7 @@ $(init_SCRIPTS) $(initconf_SCRIPTS) $(initcommon_SCRIPTS): $(EXTRA_DIST) - else \ - NFS_SRV=nfs; \ - fi; \ -- if [ -e /etc/gentoo-release ]; then \ -+ if [ -e /sbin/openrc-run ]; then \ - SHELL=/sbin/runscript; \ - else \ - SHELL=/bin/sh; \ -diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in -index a3d6c14..7f65797 100755 ---- a/etc/init.d/zfs-import.in -+++ b/etc/init.d/zfs-import.in -@@ -334,7 +334,7 @@ do_stop() - - # ---------------------------------------------------- - --if [ ! -e /etc/gentoo-release ] -+if [ ! -e /sbin/openrc-run ] - then - case "$1" in - start) -diff --git a/etc/init.d/zfs-mount.in b/etc/init.d/zfs-mount.in -index 95aefd6..08b6146 100755 ---- a/etc/init.d/zfs-mount.in -+++ b/etc/init.d/zfs-mount.in -@@ -207,7 +207,7 @@ do_stop() - - # ---------------------------------------------------- - --if [ ! -e /etc/gentoo-release ] -+if [ ! -e /sbin/openrc-run ] - then - case "$1" in - start) -diff --git a/etc/init.d/zfs-share.in b/etc/init.d/zfs-share.in -index 2b66afe..f88fbba 100755 ---- a/etc/init.d/zfs-share.in -+++ b/etc/init.d/zfs-share.in -@@ -66,7 +66,7 @@ do_stop() - - # ---------------------------------------------------- - --if [ ! -e /etc/gentoo-release ]; then -+if [ ! -e /sbin/openrc-run ]; then - case "$1" in - start) - do_start -diff --git a/etc/init.d/zfs-zed.in b/etc/init.d/zfs-zed.in -index 0f900b2..2863491 100755 ---- a/etc/init.d/zfs-zed.in -+++ b/etc/init.d/zfs-zed.in -@@ -96,7 +96,7 @@ do_reload() - - # ---------------------------------------------------- - --if [ ! -e /etc/gentoo-release ]; then -+if [ ! -e /sbin/openrc-run ]; then - case "$1" in - start) - do_start -diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h -index 4f7e328..78e33e1 100644 ---- a/include/sys/zfs_context.h -+++ b/include/sys/zfs_context.h -@@ -623,7 +623,7 @@ extern void delay(clock_t ticks); - #define maxclsyspri -20 - #define defclsyspri 0 - --#define CPU_SEQID (pthread_self() & (max_ncpus - 1)) -+#define CPU_SEQID ((uintptr_t)pthread_self() & (max_ncpus - 1)) - - #define kcred NULL - #define CRED() NULL -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/assert.h b/lib/libspl/include/assert.h -index 52924e8..63ca9dd 100644 ---- a/lib/libspl/include/assert.h -+++ b/lib/libspl/include/assert.h -@@ -42,6 +42,17 @@ __assert_c99(const char *expr, const char *file, int line, const char *func) - } - #endif /* __assert_c99 */ - -+#ifndef __assert -+static inline void -+__assert(const char *expr, const char *file, int line) -+{ -+ fprintf(stderr, "%s:%i: %s: Assertion failed.\n", file, line, expr); -+ abort(); -+} -+#else -+extern void __assert(const char *, const char *, int); -+#endif -+ - #ifndef verify - #if defined(__STDC__) - #if __STDC_VERSION__ - 0 >= 199901L -@@ -61,8 +72,6 @@ __assert_c99(const char *expr, const char *file, int line, const char *func) - #define VERIFY verify - #define ASSERT assert - --extern void __assert(const char *, const char *, int); -- - static inline int - assfail(const char *buf, const char *file, int line) - { -diff --git a/lib/libspl/include/devid.h b/lib/libspl/include/devid.h -index 5406c33..4b346da 100644 ---- a/lib/libspl/include/devid.h -+++ b/lib/libspl/include/devid.h -@@ -27,6 +27,7 @@ - #ifndef _LIBSPL_DEVID_H - #define _LIBSPL_DEVID_H - -+#include <sys/types.h> - #include <stdlib.h> - - typedef int ddi_devid_t; -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/include/sys/time.h b/lib/libspl/include/sys/time.h -index f0da440..aa96c39 100644 ---- a/lib/libspl/include/sys/time.h -+++ b/lib/libspl/include/sys/time.h -@@ -58,6 +58,11 @@ - #define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) - #endif - -+#ifndef HAVE_HR_TYPES -+typedef long long longlong_t; -+typedef longlong_t hrtime_t; -+typedef struct timespec timestruc_t; -+#endif - extern hrtime_t gethrtime(void); - extern void gethrestime(timestruc_t *); - -diff --git a/lib/libspl/timestamp.c b/lib/libspl/timestamp.c -index a4f4cf4..a177270 100644 ---- a/lib/libspl/timestamp.c -+++ b/lib/libspl/timestamp.c -@@ -28,6 +28,10 @@ - #include <langinfo.h> - #include "statcommon.h" - -+#ifndef _DATE_FMT -+#define _DATE_FMT D_FMT -+#endif -+ - /* - * Print timestamp as decimal reprentation of time_t value (-T u was specified) - * or in date(1) format (-T d was specified). -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 <rpc/xdr.h> - - /* -@@ -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); |