I'm attaching two patches.

--

libldm-read-shadow-problem.patch

Fixes the shadowing error caused by the redefinition of read (mips and mipsel).

--

libldm-uint64_t-in-big-endian.patch

Fixes the error caused by passing a 32-bit argument (on big endian) when a 
64-bit one is expected (mips).
diff -uNr libldm-0.2.3/src/ldm libldm-0.2.3.mine/src/mbr.c
--- libldm-0.2.3/src/mbr.c	2012-09-21 10:34:41.000000000 +0000
+++ libldm-0.2.3.mine/src/mbr.c	2014-06-12 14:52:55.306826659 +0000
@@ -47,13 +47,13 @@
 {
     struct _mbr _mbr;
 
-    size_t read = 0;
-    while (read < sizeof(_mbr)) {
-        ssize_t in = pread(fd, &_mbr + read, sizeof(struct _mbr) - read, read);
+    size_t rb = 0;
+    while (rb < sizeof(_mbr)) {
+        ssize_t in = pread(fd, &_mbr + rb, sizeof(struct _mbr) - rb, rb);
         if (in == 0) return -MBR_ERROR_INVALID;
         if (in == -1) return -MBR_ERROR_READ;
 
-        read += in;
+        rb += in;
     }
 
     if (_mbr.magic[0] != 0x55 || _mbr.magic[1] != 0xAA)
diff -uNr libldm-0.2.3/src/ldm.c libldm-0.2.3.mine/src/ldm.c > libldm-uint64_t-in-big-endian.patch
--- libldm-0.2.3/src/ldm.c	2014-06-12 14:59:56.000000000 +0000
+++ libldm-0.2.3.mine/src/ldm.c	2014-06-12 14:36:49.538024603 +0000
@@ -1076,6 +1076,7 @@
         return FALSE;
     }
 
+
     g_debug("TOCBLOCK: %s\n"
             "  Sequence1: %" PRIu64 "\n"
             "  Sequence2: %" PRIu64 "\n"
@@ -1090,25 +1091,25 @@
             "    Size: %" PRIu64 "\n"
             "    Flags2: %016" PRIo64,
             path,
-            be64toh(tocblock->seq1),
-            be64toh(tocblock->seq2),
+            (uint64_t)be64toh(tocblock->seq1),
+            (uint64_t)be64toh(tocblock->seq2),
             tocblock->bitmap[0].name,
-            be16toh(tocblock->bitmap[0].flags1),
-            be64toh(tocblock->bitmap[0].start),
-            be64toh(tocblock->bitmap[0].size),
-            be64toh(tocblock->bitmap[0].flags2),
+            (uint32_t)be16toh(tocblock->bitmap[0].flags1),
+            (uint64_t)be64toh(tocblock->bitmap[0].start),
+            (uint64_t)be64toh(tocblock->bitmap[0].size),
+            (uint64_t)be64toh(tocblock->bitmap[0].flags2),
             tocblock->bitmap[1].name,
-            be16toh(tocblock->bitmap[1].flags1),
-            be64toh(tocblock->bitmap[1].start),
-            be64toh(tocblock->bitmap[1].size),
-            be64toh(tocblock->bitmap[1].flags2));
+            (uint32_t)be16toh(tocblock->bitmap[1].flags1),
+            (uint64_t)be64toh(tocblock->bitmap[1].start),
+            (uint64_t)be64toh(tocblock->bitmap[1].size),
+            (uint64_t)be64toh(tocblock->bitmap[1].flags2));
 
     /* Find the start of the DB */
     *vmdb = NULL;
     for (int i = 0; i < 2; i++) {
         const struct _tocblock_bitmap *bitmap = &tocblock->bitmap[i];
         if (strcmp(bitmap->name, "config") == 0) {
-            *vmdb = config + be64toh(tocblock->bitmap[i].start) * secsize;
+            *vmdb = config + (uint64_t)be64toh(tocblock->bitmap[i].start) * secsize;
             break;
         }
     }
@@ -1150,8 +1151,8 @@
             be16toh((*vmdb)->version_major),
             be16toh((*vmdb)->version_minor),
             (*vmdb)->disk_group_guid,
-            be64toh((*vmdb)->committed_seq),
-            be64toh((*vmdb)->pending_seq),
+            (uint64_t)be64toh((*vmdb)->committed_seq),
+            (uint64_t)be64toh((*vmdb)->pending_seq),
             be32toh((*vmdb)->n_committed_vblks_vol),
             be32toh((*vmdb)->n_committed_vblks_comp),
             be32toh((*vmdb)->n_committed_vblks_part),
@@ -1187,9 +1188,9 @@
     }
 
     const uint64_t config_start =
-        be64toh(privhead->ldm_config_start) * secsize;
+        (uint64_t)be64toh(privhead->ldm_config_start) * secsize;
     const uint64_t config_size =
-        be64toh(privhead->ldm_config_size) * secsize;
+        (uint64_t)be64toh(privhead->ldm_config_size) * secsize;
 
     if (config_start > size) {
         g_set_error(err, LDM_ERROR, LDM_ERROR_INVALID,
@@ -1276,10 +1277,10 @@
             be16toh(privhead->version_minor),
             privhead->disk_guid,
             privhead->disk_group_guid,
-            be64toh(privhead->logical_disk_start),
-            be64toh(privhead->logical_disk_size),
-            be64toh(privhead->ldm_config_start),
-            be64toh(privhead->ldm_config_size));
+            (uint64_t)be64toh(privhead->logical_disk_start),
+            (uint64_t)be64toh(privhead->logical_disk_size),
+            (uint64_t)be64toh(privhead->ldm_config_start),
+            (uint64_t)be64toh(privhead->ldm_config_size));
 
     return TRUE;
 }
@@ -1650,8 +1651,8 @@
     /* Log Commit ID */
     vblk += 8;
 
-    part->start = be64toh(*(uint64_t *)vblk); vblk += 8;
-    part->vol_offset = be64toh(*(uint64_t *)vblk); vblk += 8;
+    part->start = (uint64_t)be64toh(*(uint64_t *)vblk); vblk += 8;
+    part->vol_offset = (uint64_t)be64toh(*(uint64_t *)vblk); vblk += 8;
 
     if (!_parse_var_int64(&vblk, &part->size, "size", "partition", err))
         return FALSE;
@@ -1861,7 +1862,7 @@
     GArray *spanned = g_array_new(FALSE, FALSE, sizeof(gpointer));
     g_array_set_clear_func(spanned, _free_pointer);
 
-    dg->sequence = be64toh(vmdb->committed_seq);
+    dg->sequence = (uint64_t)be64toh(vmdb->committed_seq);
 
     guint32 n_disks = be32toh(vmdb->n_committed_vblks_disk);
     guint32 n_parts = be32toh(vmdb->n_committed_vblks_part);
@@ -2258,7 +2259,7 @@
         dg = dg_o->priv;
 
         /* Check this disk is consistent with other disks */
-        uint64_t committed = be64toh(vmdb->committed_seq);
+        uint64_t committed = (uint64_t)be64toh(vmdb->committed_seq);
         if (committed != dg->sequence) {
             g_set_error(err, LDM_ERROR, LDM_ERROR_INCONSISTENT,
                         "Members of disk group " UUID_FMT " are inconsistent: "
@@ -2278,10 +2279,10 @@
 
         if (uuid_compare(disk_guid, disk->guid) == 0) {
             disk->device = g_strdup(path);
-            disk->data_start = be64toh(privhead.logical_disk_start);
-            disk->data_size = be64toh(privhead.logical_disk_size);
-            disk->metadata_start = be64toh(privhead.ldm_config_start);
-            disk->metadata_size = be64toh(privhead.ldm_config_size);
+            disk->data_start = (uint64_t)be64toh(privhead.logical_disk_start);
+            disk->data_size = (uint64_t)be64toh(privhead.logical_disk_size);
+            disk->metadata_start = (uint64_t)be64toh(privhead.ldm_config_start);
+            disk->metadata_size = (uint64_t)be64toh(privhead.ldm_config_size);
             break;
         }
     }

Attachment: signature.asc
Description: Digital signature

Reply via email to