summaryrefslogtreecommitdiffstats
path: root/module/zfs/gzip.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-08-26 10:29:11 -0700
committerBrian Behlendorf <[email protected]>2010-08-31 08:38:46 -0700
commiteaa8687be33318ae07d61a91e0069244b326f450 (patch)
tree94aefff7ffd9ca2af5d270192a6c73e8b15b6c2b /module/zfs/gzip.c
parent3f504482929e4c4e098ec00b335ddc45509be716 (diff)
Fix zmod.h usage in userspace
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 <[email protected]>
Diffstat (limited to 'module/zfs/gzip.c')
-rw-r--r--module/zfs/gzip.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/module/zfs/gzip.c b/module/zfs/gzip.c
index aa0254806..155404efd 100644
--- a/module/zfs/gzip.c
+++ b/module/zfs/gzip.c
@@ -28,22 +28,35 @@
#include <sys/debug.h>
#include <sys/types.h>
-#include <sys/zmod.h>
#ifdef _KERNEL
+
#include <sys/systm.h>
-#else
+#include <sys/zmod.h>
+
+typedef size_t zlen_t;
+#define compress_func z_compress_level
+#define uncompress_func z_uncompress
+
+#else /* _KERNEL */
+
#include <strings.h>
+#include <zlib.h>
+
+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);