From 4a0f5e9d5bc076b3f7d3da99cdd910cbbf53cc19 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 21 Nov 2008 11:29:52 -0800 Subject: [PATCH] Add fix-no-zmod branch --- .topdeps | 1 + .topmsg | 11 +++++++++++ zfs/lib/libzpool/gzip.c | 27 ++++++++++++++++++++------- zfs/lib/libzpool/kernel.c | 26 -------------------------- 4 files changed, 32 insertions(+), 33 deletions(-) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000..1f7391f92b --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000..496d3a9af1 --- /dev/null +++ b/.topmsg @@ -0,0 +1,11 @@ +From: Brian Behlendorf +Subject: [PATCH] fix no zmod + +Do not use zmod.h in userspace. + +This has also been filed with the ZFS team. It makes the userspace +libzpool code use the zlib API, instead of the Solaris-only and +non-standard zmod.h. The zlib API is almost identical and is a de +facto standard, so this is a no-brainer. + +Signed-off-by: Brian Behlendorf diff --git a/zfs/lib/libzpool/gzip.c b/zfs/lib/libzpool/gzip.c index 94c76042db..327c756330 100644 --- a/zfs/lib/libzpool/gzip.c +++ b/zfs/lib/libzpool/gzip.c @@ -28,22 +28,35 @@ #include #include -#include #ifdef _KERNEL + #include -#else +#include + +typedef size_t zlen_t; +#define compress_func z_compress_level +#define uncompress_func z_uncompress + +#else /* _KERNEL */ + #include +#include + +typedef uLongf zlen_t; +#define compress_func compress2 +#define uncompress_func uncompress + #endif size_t gzip_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) { - size_t dstlen = d_len; + zlen_t dstlen = d_len; ASSERT(d_len <= s_len); - if (z_compress_level(d_start, &dstlen, s_start, s_len, n) != Z_OK) { + if (compress_func(d_start, &dstlen, s_start, s_len, n) != Z_OK) { if (d_len != s_len) return (s_len); @@ -51,18 +64,18 @@ gzip_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) return (s_len); } - return (dstlen); + return ((size_t) dstlen); } /*ARGSUSED*/ int gzip_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) { - size_t dstlen = d_len; + zlen_t dstlen = d_len; ASSERT(d_len >= s_len); - if (z_uncompress(d_start, &dstlen, s_start, s_len) != Z_OK) + if (uncompress_func(d_start, &dstlen, s_start, s_len) != Z_OK) return (-1); return (0); diff --git a/zfs/lib/libzpool/kernel.c b/zfs/lib/libzpool/kernel.c index 71317446de..bd5ca345d4 100644 --- a/zfs/lib/libzpool/kernel.c +++ b/zfs/lib/libzpool/kernel.c @@ -36,7 +36,6 @@ #include #include #include -#include #include /* @@ -801,31 +800,6 @@ kernel_fini(void) urandom_fd = -1; } -int -z_uncompress(void *dst, size_t *dstlen, const void *src, size_t srclen) -{ - int ret; - uLongf len = *dstlen; - - if ((ret = uncompress(dst, &len, src, srclen)) == Z_OK) - *dstlen = (size_t)len; - - return (ret); -} - -int -z_compress_level(void *dst, size_t *dstlen, const void *src, size_t srclen, - int level) -{ - int ret; - uLongf len = *dstlen; - - if ((ret = compress2(dst, &len, src, srclen, level)) == Z_OK) - *dstlen = (size_t)len; - - return (ret); -} - /*ARGSUSED*/ size_t u8_textprep_str(char *i, size_t *il, char *o, size_t *ol, int nf, size_t vers, int *err)