void-packages/srcpkgs/zfs/patches/musl-fixes.patch
2016-03-10 02:37:44 -05:00

352 lines
10 KiB
Diff

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
@@ -33,6 +33,7 @@
#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/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/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);
--- a/lib/libnvpair/Makefile.am.orig 2016-01-12 09:33:43.534468667 +0100
+++ b/lib/libnvpair/Makefile.am 2016-01-12 09:34:02.813433477 +0100
@@ -26,7 +26,7 @@ nodist_libnvpair_la_SOURCES = \
$(KERNEL_C)
libnvpair_la_LIBADD = \
- $(top_builddir)/lib/libuutil/libuutil.la
+ $(top_builddir)/lib/libuutil/libuutil.la $(TIRPC_LIBS)
libnvpair_la_LDFLAGS = -version-info 1:1:0