summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--libglusterfs/src/Makefile.am2
-rw-r--r--libglusterfs/src/checksum.c39
3 files changed, 9 insertions, 35 deletions
diff --git a/configure.ac b/configure.ac
index 024b4ef24a8..54364cda71f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -364,7 +364,10 @@ AC_CHECK_HEADERS([sys/ioctl.h], AC_DEFINE(HAVE_IOCTL_IN_SYS_IOCTL_H, 1, [have sy
AC_CHECK_HEADERS([sys/extattr.h])
+# libglusterfs/checksum
AC_CHECK_HEADERS([openssl/md5.h])
+AC_CHECK_LIB([z], [adler32], [ZLIB_LIBS="-lz"], AC_MSG_ERROR([zlib is required to build glusterfs]))
+AC_SUBST(ZLIB_LIBS)
AC_CHECK_HEADERS([linux/falloc.h])
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index bb57425e110..d117cc17605 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -7,7 +7,7 @@ libglusterfs_la_CPPFLAGS = $(GF_CPPFLAGS) -D__USE_FILE_OFFSET64 \
-I$(CONTRIBDIR)/libexecinfo ${ARGP_STANDALONE_CPPFLAGS} \
-DSBIN_DIR=\"$(sbindir)\"
-libglusterfs_la_LIBADD = @LEXLIB@
+libglusterfs_la_LIBADD = @LEXLIB@ $(ZLIB_LIBS)
libglusterfs_la_LDFLAGS = -version-info $(LIBGLUSTERFS_LT_VERSION)
lib_LTLIBRARIES = libglusterfs.la
diff --git a/libglusterfs/src/checksum.c b/libglusterfs/src/checksum.c
index e14a3044c20..5fac1330094 100644
--- a/libglusterfs/src/checksum.c
+++ b/libglusterfs/src/checksum.c
@@ -9,57 +9,28 @@
*/
#include <openssl/md5.h>
+#include <zlib.h>
#include <stdint.h>
-#include "glusterfs.h"
-
/*
- * The "weak" checksum required for the rsync algorithm,
- * adapted from the rsync source code. The following comment
- * appears there:
- *
- * "a simple 32 bit checksum that can be upadted from either end
- * (inspired by Mark Adler's Adler-32 checksum)"
+ * The "weak" checksum required for the rsync algorithm.
*
* Note: these functions are only called to compute checksums on
* pathnames; they don't need to handle arbitrarily long strings of
* data. Thus int32_t and uint32_t are sufficient
*/
-
uint32_t
gf_rsync_weak_checksum (unsigned char *buf, size_t len)
{
- int32_t i = 0;
- uint32_t s1, s2;
-
- uint32_t csum;
-
- s1 = s2 = 0;
- if (len >= 4) {
- for (; i < (len-4); i+=4) {
- s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3];
- s1 += buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3];
- }
- }
-
- for (; i < len; i++) {
- s1 += buf[i];
- s2 += s1;
- }
-
- csum = (s1 & 0xffff) + (s2 << 16);
-
- return csum;
+ return adler32 (0, buf, len);
}
/*
- * The "strong" checksum required for the rsync algorithm,
- * adapted from the rsync source code.
+ * The "strong" checksum required for the rsync algorithm.
*/
-
void
gf_rsync_strong_checksum (unsigned char *data, size_t len, unsigned char *md5)
{
- MD5(data, len, md5);
+ MD5 (data, len, md5);
}