Bug 109761 - FreeBSD UFS2 file systems are not recognized on MS DOS (MBR) partitions
Summary: FreeBSD UFS2 file systems are not recognized on MS DOS (MBR) partitions
Status: CLOSED CODE_FIX
Alias: None
Product: File System
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 high
Assignee: fs_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-21 23:14 UTC by Richard Narron
Modified: 2019-12-20 00:54 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.4-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Patch to block/partitions/msdos.c for FreeBSD partitions (444 bytes, application/octet-stream)
2015-12-21 23:14 UTC, Richard Narron
Details
prettier patch to block/partitions/msdos.c for FreeBSD partitions (492 bytes, application/octet-stream)
2015-12-29 20:57 UTC, Richard Narron
Details
Linux 4.12-rc3 version of the patch (468 bytes, patch)
2017-05-31 20:06 UTC, Richard Narron
Details | Diff

Description Richard Narron 2015-12-21 23:14:50 UTC
Created attachment 197951 [details]
Patch to block/partitions/msdos.c for FreeBSD partitions

The code in block/partitions/msdos.c recognizes FreeBSD, OpenBSD and NetBSD partitions and does a reasonable job picking out OpenBSD and NetBSD UFS subpartitions

But for FreeBSD the subpartitions are always "bad".

    Kernel: <bsd:bad subpartition - ignored

Though all 3 of these BSD systems use UFS as a file system, only FreeBSD uses relative start addresses in the subpartition declarations.

The following patch fixes this for FreeBSD partitions and leaves the code for OpenBSD and NetBSD intact:

--- block/partitions/msdos.c.orig	2015-12-13 17:42:58.000000000 -0800
+++ block/partitions/msdos.c	2015-12-17 18:32:21.832267195 -0800
@@ -300,6 +300,9 @@
 			continue;
 		bsd_start = le32_to_cpu(p->p_offset);
 		bsd_size = le32_to_cpu(p->p_size);
+		if (memcmp(flavour,"bsd\0",4) == 0) {
+			bsd_start = bsd_start + offset;
+		}
 		if (offset == bsd_start && size == bsd_size)
 			/* full parent partition, we have it already */
 			continue;
Comment 1 Richard Narron 2015-12-21 23:17:58 UTC
I have tested the patch on Slackware current Linux 4.4-rc6, 4.4-RC5 and 4.1.15 
And on Slackware 14.1 Linux 3.10.94

Needless to say the patch can be back ported to earlier kernels...
Comment 2 Richard Narron 2015-12-29 20:57:07 UTC
Created attachment 198461 [details]
prettier patch to block/partitions/msdos.c for FreeBSD partitions

This patch is "prettier" per the scripts/checkpatch.pl script.
Comment 3 Richard Narron 2015-12-29 20:58:53 UTC
prettier version of the patch:

--- linux/block/partitions/msdos.c.orig	2015-12-27 18:17:37.000000000 -0800
+++ linux/block/partitions/msdos.c	2015-12-29 10:44:25.813773357 -0800
@@ -300,6 +300,8 @@ static void parse_bsd(struct parsed_part
 			continue;
 		bsd_start = le32_to_cpu(p->p_offset);
 		bsd_size = le32_to_cpu(p->p_size);
+		if (memcmp(flavour, "bsd\0", 4) == 0)
+			bsd_start = bsd_start + offset;
 		if (offset == bsd_start && size == bsd_size)
 			/* full parent partition, we have it already */
 			continue;
Comment 4 Richard Narron 2017-05-16 21:09:00 UTC
The patch still works on current kernels (4.4.68 4.9.28 4.12.1-rc1)
Comment 5 Richard Narron 2017-05-29 11:36:49 UTC
This is now fixed in Linux-4.12-rc3

It was submitted to the kernel-block forum and thanks to Christoph Hellwig and Jens Axboe it was accepted by Linus.
Comment 6 Richard Narron 2017-05-31 20:06:57 UTC
Created attachment 256817 [details]
Linux 4.12-rc3 version of the patch

Attached is the Linux 4.12-rc3 version of the patch that was accepted by Linus.
Comment 7 Richard Narron 2019-12-20 00:54:29 UTC
This is fixed.

Note You need to log in before you can comment on or make changes to this bug.