Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 May 2009 04:30:30 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r192955 - in user/kmacy/releng_7_2_fcs/sys: conf net
Message-ID:  <200905280430.n4S4UUAr022684@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Thu May 28 04:30:29 2009
New Revision: 192955
URL: http://svn.freebsd.org/changeset/base/192955

Log:
  switch to freebsd zlib compression routines where possible

Modified:
  user/kmacy/releng_7_2_fcs/sys/conf/files
  user/kmacy/releng_7_2_fcs/sys/net/zlib.c

Modified: user/kmacy/releng_7_2_fcs/sys/conf/files
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/conf/files	Thu May 28 04:25:38 2009	(r192954)
+++ user/kmacy/releng_7_2_fcs/sys/conf/files	Thu May 28 04:30:29 2009	(r192955)
@@ -1853,8 +1853,8 @@ net/rtsock.c			standard
 net/slcompress.c		optional netgraph_vjc | ppp | sl | sppp | \
 					 netgraph_sppp
 net/zlib.c			optional crypto | geom_uzip | ipsec | \
-					 mxge | ppp_deflate | netgraph_deflate | \
-					 ddb_ctf
+					 mxge | ppp_deflate | zfs | \
+					 netgraph_deflate | ddb_ctf 
 net80211/ieee80211.c		optional wlan
 net80211/ieee80211_acl.c	optional wlan_acl
 net80211/ieee80211_amrr.c	optional wlan_amrr
@@ -2449,30 +2449,16 @@ cddl/contrib/opensolaris/uts/common/os/n
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
 cddl/contrib/opensolaris/uts/common/os/taskq.c		optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
-
-
-cddl/contrib/opensolaris/uts/common/zmod/adler32.c	optional zfs \
-	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
-cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.c	optional zfs \
-	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
-cddl/contrib/opensolaris/uts/common/zmod/deflate.c	optional zfs \
-	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
-cddl/contrib/opensolaris/uts/common/zmod/inffast.c	optional zfs \
-	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
 cddl/contrib/opensolaris/uts/common/zmod/inflate.c	optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
 cddl/contrib/opensolaris/uts/common/zmod/inftrees.c	optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
-cddl/contrib/opensolaris/uts/common/zmod/trees.c	optional zfs \
+cddl/contrib/opensolaris/uts/common/zmod/adler32.c	optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
-cddl/contrib/opensolaris/uts/common/zmod/zmod.c		optional zfs \
+cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.c	optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
 cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c	optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
-cddl/contrib/opensolaris/uts/common/zmod/zutil.c	optional zfs \
-	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
-
-
 
 
 
@@ -2627,3 +2613,21 @@ cddl/contrib/opensolaris/uts/common/fs/z
 
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	optional zfs \
 	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
+
+/*
+ * Compression routines conflicting with ZFS
+ *
+ */
+
+#cddl/contrib/opensolaris/uts/common/zmod/deflate.c	optional zfs \
+#	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
+#cddl/contrib/opensolaris/uts/common/zmod/inffast.c	optional zfs \
+#	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
+#cddl/contrib/opensolaris/uts/common/zmod/trees.c	optional zfs \
+#	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
+#cddl/contrib/opensolaris/uts/common/zmod/zmod.c		optional zfs \
+#	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
+#cddl/contrib/opensolaris/uts/common/zmod/zutil.c	optional zfs \
+#	compile-with "${ZFS_C} ${OPENSOLARIS_INC} ${ZFS_INC} ${ZFS_CFLAGS}"
+
+

Modified: user/kmacy/releng_7_2_fcs/sys/net/zlib.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/net/zlib.c	Thu May 28 04:25:38 2009	(r192954)
+++ user/kmacy/releng_7_2_fcs/sys/net/zlib.c	Thu May 28 04:30:29 2009	(r192955)
@@ -5405,3 +5405,97 @@ static moduledata_t zlib_mod = {
 DECLARE_MODULE(zlib, zlib_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
 MODULE_VERSION(zlib, 1);
 #endif /* _KERNEL */
+
+/**********************************************************************/
+/**********************************************************************/
+/**********************************************************************/
+
+/*
+ *
+ * Compression utility routines
+ * 
+ */
+ 
+
+/*
+ * Uncompress the buffer 'src' into the buffer 'dst'.  The caller must store
+ * the expected decompressed data size externally so it can be passed in.
+ * The resulting decompressed size is then returned through dstlen.  This
+ * function return Z_OK on success, or another error code on failure.
+ */
+int
+z_uncompress(void *dst, size_t *dstlen, const void *src, size_t srclen)
+{
+	z_stream zs;
+	int err;
+
+	bzero(&zs, sizeof (zs));
+	zs.next_in = (u_char *)src;
+	zs.avail_in = srclen;
+	zs.next_out = dst;
+	zs.avail_out = *dstlen;
+
+	/*
+	 * Call inflateInit2() specifying a window size of DEF_WBITS
+	 * with the 6th bit set to indicate that the compression format
+	 * type (zlib or gzip) should be automatically detected.
+	 */
+	if ((err = inflateInit2(&zs, DEF_WBITS | 0x20)) != Z_OK)
+		return (err);
+
+	if ((err = inflate(&zs, Z_FINISH)) != Z_STREAM_END) {
+		(void) inflateEnd(&zs);
+		return (err == Z_OK ? Z_BUF_ERROR : err);
+	}
+
+	*dstlen = zs.total_out;
+	return (inflateEnd(&zs));
+}
+
+int
+z_compress_level(void *dst, size_t *dstlen, const void *src, size_t srclen,
+    int level)
+{
+
+	z_stream zs;
+	int err;
+
+	bzero(&zs, sizeof (zs));
+	zs.next_in = (u_char *)src;
+	zs.avail_in = srclen;
+	zs.next_out = dst;
+	zs.avail_out = *dstlen;
+
+	if ((err = deflateInit(&zs, level)) != Z_OK)
+		return (err);
+
+	if ((err = deflate(&zs, Z_FINISH)) != Z_STREAM_END) {
+		(void) deflateEnd(&zs);
+		return (err == Z_OK ? Z_BUF_ERROR : err);
+	}
+
+	*dstlen = zs.total_out;
+	return (deflateEnd(&zs));
+}
+
+int
+z_compress(void *dst, size_t *dstlen, const void *src, size_t srclen)
+{
+	return (z_compress_level(dst, dstlen, src, srclen,
+	    Z_DEFAULT_COMPRESSION));
+}
+
+/*
+ * Convert a zlib error code into a string error message.
+ */
+const char *
+z_strerror(int err)
+{
+	int i = Z_NEED_DICT - err;
+
+	if (i < 0 || i > Z_NEED_DICT - Z_VERSION_ERROR)
+		return ("unknown error");
+
+	return (ERR_MSG(err));
+}
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905280430.n4S4UUAr022684>