Commit 11d43f1e authored by Ryan Jackson's avatar Ryan Jackson

Added patch to support relative-to-slice BSD disklabels.

Currently only works if the partition type is 0xa5 (FreeBSD) as neither
NetBSD nor OpenBSD use relative offsets (as far as I can tell).
parent cb506e7d
--- linux-2.6.26/fs/partitions/msdos.c 2008-11-21 18:26:28.000000000 -0500
+++ linux-2.6.26/fs/partitions/msdos.c 2008-11-21 18:29:15.000000000 -0500
@@ -250,6 +250,7 @@
Sector sect;
struct bsd_disklabel *l;
struct bsd_partition *p;
+ u32 rawoffset;
l = (struct bsd_disklabel *)read_dev_sector(bdev, offset+1, &sect);
if (!l)
@@ -262,6 +263,21 @@
if (le16_to_cpu(l->d_npartitions) < max_partitions)
max_partitions = le16_to_cpu(l->d_npartitions);
+
+ /* FreeBSD accepts relative offsets from the start of the
+ * MBR partition. We try to detect that and do the right
+ * thing here.
+ */
+ rawoffset = 0;
+ if ((strcmp(flavour, "bsd") == 0) && (max_partitions >= 3)) {
+ p = &l->d_partitions[2];
+
+ if ((p->p_fstype == BSD_FS_UNUSED) &&
+ (le32_to_cpu(p->p_size) == size) &&
+ (le32_to_cpu(p->p_offset) == 0))
+ rawoffset = offset;
+ }
+
for (p = l->d_partitions; p - l->d_partitions < max_partitions; p++) {
u32 bsd_start, bsd_size;
@@ -269,7 +285,7 @@
break;
if (p->p_fstype == BSD_FS_UNUSED)
continue;
- bsd_start = le32_to_cpu(p->p_offset);
+ bsd_start = rawoffset + le32_to_cpu(p->p_offset);
bsd_size = le32_to_cpu(p->p_size);
if (offset == bsd_start && size == bsd_size)
/* full parent partition, we have it already */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment