summaryrefslogtreecommitdiffstats
path: root/super-mbr.c
diff options
context:
space:
mode:
authorJames Clarke <jrtc27@jrtc27.com>2016-10-17 22:16:01 +0200
committerJes Sorensen <Jes.Sorensen@redhat.com>2016-10-19 18:38:02 +0200
commit8e2bca513efc5deccb11cb90bad3c0891c4929e3 (patch)
treeb5ac710fc39b07c3fd6e4d5cc4442c3ba5974495 /super-mbr.c
parentsuper-intel: Reduce excessive parenthesis abuse (diff)
downloadmdadm-8e2bca513efc5deccb11cb90bad3c0891c4929e3.tar.xz
mdadm-8e2bca513efc5deccb11cb90bad3c0891c4929e3.zip
Fix bus error when accessing MBR partition records
Since the MBR layout only has partition records as 2-byte aligned, the 32-bit fields in them are not aligned. Thus, they cannot be accessed on some architectures (such as SPARC) by using a "struct MBR_part_record *" pointer, as the compiler can assume that the pointer is properly aligned. Instead, the records must be accessed by going through the MBR struct itself every time. Signed-off-by: James Clarke <jrtc27@jrtc27.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Diffstat (limited to 'super-mbr.c')
-rw-r--r--super-mbr.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/super-mbr.c b/super-mbr.c
index 62b3f031..f5e4ceab 100644
--- a/super-mbr.c
+++ b/super-mbr.c
@@ -57,6 +57,11 @@ static void examine_mbr(struct supertype *st, char *homehost)
printf(" MBR Magic : %04x\n", sb->magic);
for (i = 0; i < MBR_PARTITIONS; i++)
+ /*
+ * Have to make every access through sb rather than using a
+ * pointer to the partition table (or an entry), since the
+ * entries are not properly aligned.
+ */
if (sb->parts[i].blocks_num)
printf("Partition[%d] : %12lu sectors at %12lu (type %02x)\n",
i,
@@ -151,6 +156,11 @@ static void getinfo_mbr(struct supertype *st, struct mdinfo *info, char *map)
info->component_size = 0;
for (i = 0; i < MBR_PARTITIONS ; i++)
+ /*
+ * Have to make every access through sb rather than using a
+ * pointer to the partition table (or an entry), since the
+ * entries are not properly aligned.
+ */
if (sb->parts[i].blocks_num) {
unsigned long last =
(unsigned long)__le32_to_cpu(sb->parts[i].blocks_num)