Subject: Skipping Ontrack Disk Manager drivers
To: None <tech-kern@netbsd.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 12/25/2005 21:07:28
------=_Part_19675_15332301.1135541248581
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi all,

A couple weeks ago I was lend a hard disk that had the Ontrack
Disk Manager drivers on it.  These create a fake partition table on
the first sector of the disk and the real partition table is shifted to
sector 63 (I don't know if this number depends on something or if
it is always the same), so I couldn't read what I needed.

I patched subr_disk_mbr.c to detect these specific drivers and jump
to the correct MBR before scanning for partitions.  The patch is
attached.

I think it'd be a good idea to have this in the kernel so that those
disks magically work.  But I'm not sure if the way I did it is the best
one: is the code in the correct place?  Should this depend on some
kernel option?  Anything else?

Please comment.

Thank you!

--
Julio M. Merino Vidal <jmmv84@gmail.com>
The Julipedia - http://julipedia.blogspot.com/
The NetBSD Project - http://www.NetBSD.org/

------=_Part_19675_15332301.1135541248581
Content-Type: text/x-patch; name=patch.diff; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="patch.diff"

Index: subr_disk_mbr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_disk_mbr.c,v
retrieving revision 1.13
diff -u -r1.13 subr_disk_mbr.c
--- subr_disk_mbr.c	18 Dec 2005 17:02:45 -0000	1.13
+++ subr_disk_mbr.c	25 Dec 2005 20:01:44 -0000
@@ -140,6 +140,23 @@
 		/* Copy data out of buffer so action can use bp */
 		memcpy(ptns, &mbr->mbr_parts, sizeof ptns);
 
+		/* Look for drivers and skip them */
+		if (ptns[0].mbrp_type == MBR_PTYPE_DM6_DDO) {
+			/* We've found DM6 DDO drivers.  Ensure that there
+			 * are no other partitions in the MBR and jump to
+			 * the real MBR. */
+			boolean_t ok = TRUE;
+
+			for (i = 1; i < MBR_PART_COUNT; i++)
+				if (ptns[i].mbrp_type != MBR_PTYPE_UNUSED)
+					ok = FALSE;
+
+			if (ok) {
+				this_ext = le32toh(63);
+				continue;
+			}
+		}
+
 		/* look for NetBSD partition */
 		next_ext = 0;
 		dp = ptns;


------=_Part_19675_15332301.1135541248581--