This patch makes mixed-endian clusters to use
qdiskd. Unfortunately, the headers + CRCs in
the headers of each data block are stored in
little-endian format while the data itself is
stored in big-endian format. Ew. This patch
does not fix that, but ensures the data vs.
header blocks are stored in the right byte order
to preserve upgrade compatibility.
- header_decode(hdr);
/*
* verify the header's CRC32. Ok, we know it's overkill taking
* the CRC32 of a friggin' 16-byte (12 bytes, really) structure,
* but why not?
*/
bkupcrc = hdr->h_hcrc;
+
+ /* BUG: Headers are stored in little-endian form */
+ bkupcrc = le_swap32(hdr->h_hcrc);
+
hdr->h_hcrc = 0;
crc = clu_crc32((char *)hdr, sizeof(*hdr));
hdr->h_hcrc = bkupcrc;
if (bkupcrc != crc) {
-#ifdef DEBUG
logt_print(LOG_DEBUG, "Header CRC32 mismatch; Exp: 0x%08x "
"Got: 0x%08x
", bkupcrc, crc);
-#endif
return -1;
}
+ header_decode(hdr);
+
/*
* Verify the magic number.
*/
@@ -328,7 +331,6 @@ diskRawReadShadow(target_info_t *disk, off_t readOffset, char *buf, int len)
int ret;
shared_header_t *hdrp;
char *data;
- int datalen;
ret = lseek(disk->d_fd, readOffset, SEEK_SET);
if (ret != readOffset) {
@@ -350,8 +352,6 @@ diskRawReadShadow(target_info_t *disk, off_t readOffset, char *buf, int len)
/* Decode the header portion so we can run a checksum on it. */
hdrp = (shared_header_t *)buf;
data = (char *)buf + sizeof(*hdrp);
- swab_shared_header_t(hdrp);
- datalen = hdrp->h_length;
/* XXX this is horrible but we need to prioritize options as long as
@@ -32,10 +30,15 @@ main(int argc, char **argv)
switch (rv) {
case 'd':
++verbose_level;
+ if (verbose_level > LOG_DEBUG)
+ verbose_level = LOG_DEBUG;
break;
}
}
+ logt_init(PROGRAM_NAME, LOG_MODE_OUTPUT_STDERR,
+ verbose_level, verbose_level, verbose_level, NULL);
+
/* reset the option index to reparse */
optind = 0;