Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > 1c4c24e15663085b2a11540262606a1d > files > 1

dmraid-1.0.0.rc13-9.el5.src.rpm

--- dmraid/1.0.0.rc13/lib/format/ddf/ddf1.c	2006-09-22 10:25:45.000000000 -0400
+++ dmraid/1.0.0.rc13/lib/format/ddf/ddf1.c	2006-11-07 07:03:22.000000000 -0500
@@ -353,7 +353,7 @@ static int read_extended(struct lib_cont
 
 	if (ddf1->adapter &&
 	    ddf1->adapter->pci_vendor == PCI_VENDOR_ID_ADAPTEC2) {
-		log_notice(lc, "%s: Adaptec mode discvered on %s",
+		log_notice(lc, "%s: Adaptec mode discovered on %s",
 			   handler, di->path);
 		ddf1->adaptec_mode = 1;
 	}
@@ -682,7 +682,7 @@ static uint64_t get_size(struct lib_cont
 			 struct ddf1_config_record *cr,
 			 struct ddf1_phys_drive *pd)
 {
-	if (cr)
+	if (cr && cr->sectors)
 		/* Some Adaptec controllers need this clamping. */
 		return type(lc, ddf1, cr) == t_raid0 ?
 		       cr->sectors - cr->sectors % stride(cr) : cr->sectors;
--- dmraid/1.0.0.rc13/lib/format/ddf/ddf1_crc.c	2006-09-14 12:11:03.000000000 -0400
+++ dmraid/1.0.0.rc13/lib/format/ddf/ddf1_crc.c	2006-11-08 12:11:53.000000000 -0500
@@ -16,11 +16,51 @@
 #include "ddf1.h"
 #include "ddf1_crc.h"
 #include "ddf1_lib.h"
-#include "zlib.h"
 
 #define DM_BYTEORDER_SWAB
 #include <datastruct/byteorder.h>
 
+/*
+ * CRC table code to avoid linking to zlib, because Ubuntu has
+ * problems with that plus this additionally saves space.
+ */
+
+/* Make the table for a fast CRC. */
+#define	CRC_TABLE_SIZE	256
+static inline void crc_table_init(uint32_t *crc_table)
+{
+	static int new = 1; /* Flag for table not yet computed. */
+
+	if (new) {
+		uint32_t c, n, k;
+
+		for (new = n = 0; n < CRC_TABLE_SIZE; *(crc_table++) = c, n++) {
+			for (c = n, k = 0; k < 8; k++)
+				c = (c & 1) ? (c >> 1) ^ 0xEDB88320L : c >> 1;
+		}
+	}
+}
+
+/*
+ * Update a running CRC with the bytes buf[0..len-1] -- the CRC
+ * should be initialized to all 1's, and the transmitted value
+ * is the 1's complement of the final running CRC (see the
+ * crc() routine below).
+ */
+/* Return the CRC of the bytes buf[0..len-1]. */
+static uint32_t crc(uint32_t crc, unsigned char *buf, int len)
+{
+	int n;
+	static uint32_t crc_table[CRC_TABLE_SIZE]; /* CRCs of 8-bit messages. */
+
+	crc_table_init(crc_table);
+	for (n = 0; n < len; n++)
+		crc = crc_table[(crc ^ buf[n]) & (CRC_TABLE_SIZE - 1)] ^
+		      (crc >> 8);
+
+	return crc ^ 0xFFFFFFFFL;
+}
+
 /* CRC info for various functions below */
 struct crc_info {
 	void *p;
@@ -32,22 +72,23 @@ struct crc_info {
 /* Compute the checksum of a table */
 static uint32_t do_crc32(struct lib_context *lc, struct crc_info *ci)
 {
-	uint32_t old_csum = *ci->crc, ret = crc32(0, NULL, 0); /* Init CRC */
+	uint32_t old_csum = *ci->crc, ret = 0xFFFFFFFF;
 
-	*ci->crc = 0xFFFFFFFF;
-	ret = crc32(ret, ci->p, ci->size); /* zlib */
+	*ci->crc = ret;
+	ret = crc(ret, ci->p, ci->size);
 	*ci->crc = old_csum;
 	return ret;
 }
 
+/* Return VD record size. */
 static inline size_t record_size(struct ddf1 *ddf1)
 {
 	return ddf1->primary->vd_config_record_len * DDF1_BLKSIZE;
 }
 
-#define CRC32(postfix, record_type, macro) \
-static int crc32_ ## postfix(struct lib_context *lc, struct dev_info *di, \
-			     struct ddf1 *ddf1, int idx) \
+#define CRC32(suffix, record_type, macro) \
+static int crc32_ ## suffix(struct lib_context *lc, struct dev_info *di, \
+			    struct ddf1 *ddf1, int idx) \
 { \
 	struct record_type *r = macro(ddf1, idx); \
 	struct crc_info ci = { \
@@ -86,9 +127,10 @@ static int check_crc(struct lib_context 
 
 	crc32 = do_crc32(lc, ci);
 	if (*ci->crc != crc32)
-		log_warn(lc, "%s: %s with CRC %X, expected %X on %s",
+		log_print(lc, "%s: %s with CRC %X, expected %X on %s",
 			 HANDLER, ci->text, crc32, *ci->crc, di->path);
 	
+	
 	return 1;
 
 }
@@ -159,7 +201,7 @@ static int all_crcs(struct lib_context *
 		}
 	}
 
-	return type == CHECK ? ret & check_cfg_crc(lc, di, ddf1) :
+	return type == CHECK ? (ret & check_cfg_crc(lc, di, ddf1)) :
 			       update_cfg_crc(lc, di, ddf1);
 }
 
--- dmraid/1.0.0.rc13/lib/format/ddf/ddf1_lib.c	2006-09-13 09:42:04.000000000 -0400
+++ dmraid/1.0.0.rc13/lib/format/ddf/ddf1_lib.c	2006-10-26 09:15:28.000000000 -0400
@@ -57,7 +57,9 @@ uint16_t ddf1_cr_off_maxpds_helper(struc
 	struct ddf1_header *h = ddf1->primary;
 
 	/* The 0xFFFF nonsense is a weird Adaptec quirk */
-	return (h->max_primary_elements == 0xFFFF && ddf1->adaptec_mode) ?
+//	bz211016
+//	return (h->max_primary_elements == 0xFFFF && ddf1->adaptec_mode) ?
+	return (h->max_primary_elements == 0xFFFF) ?
 		h->max_phys_drives : h->max_primary_elements;
 }
 
--- dmraid/1.0.0.rc13/lib/format/format.c	2006-09-21 06:17:05.000000000 -0400
+++ dmraid/1.0.0.rc13/lib/format/format.c	2006-11-08 11:44:08.000000000 -0500
@@ -18,7 +18,7 @@
  * Comment next line out to avoid pre-registration
  * checks on metadata format handlers.
  */
-#define	CHECK_FORMAT_HANDLER
+// #define	CHECK_FORMAT_HANDLER
 #ifdef	CHECK_FORMAT_HANDLER
 /*
  * Check that mandatory members of a metadata form handler are present.
--- dmraid/1.0.0.rc13/tools/Makefile.in	2006-07-25 04:06:04.000000000 -0400
+++ dmraid/1.0.0.rc14/tools/Makefile.in	2006-11-08 12:29:09.000000000 -0500
@@ -20,7 +20,7 @@ SOURCES=\
 TARGETS=\
 	dmraid
 
-DMRAIDLIBS=-ldmraid -lz
+DMRAIDLIBS=-ldmraid
 
 include $(top_srcdir)/make.tmpl