svn commit: r186733 - head/sys/geom/part

Marcel Moolenaar marcel at FreeBSD.org
Sat Jan 3 23:32:07 PST 2009


Author: marcel
Date: Sun Jan  4 07:32:06 2009
New Revision: 186733
URL: http://svn.freebsd.org/changeset/base/186733

Log:
  Improve probing.
  o   Don't check the dummy fields.
  o   The entry is unused if either dp_mid is 0 or dp_sid is 0.
  o   The start or end cylinder cannot be 0.
  o   The start CHS cannot be equal to the end CHS.
  
  Submitted by:	nyan

Modified:
  head/sys/geom/part/g_part_pc98.c

Modified: head/sys/geom/part/g_part_pc98.c
==============================================================================
--- head/sys/geom/part/g_part_pc98.c	Sun Jan  4 07:29:04 2009	(r186732)
+++ head/sys/geom/part/g_part_pc98.c	Sun Jan  4 07:32:06 2009	(r186733)
@@ -333,7 +333,7 @@ g_part_pc98_probe(struct g_part_table *t
 	struct g_provider *pp;
 	u_char *buf, *p;
 	int error, index, res, sum;
-	uint16_t magic;
+	uint16_t magic, ecyl, scyl;
 
 	pp = cp->provider;
 
@@ -365,11 +365,15 @@ g_part_pc98_probe(struct g_part_table *t
 
 	for (index = 0; index < NDOSPART; index++) {
 		p = buf + SECSIZE + index * DOSPARTSIZE;
-		if (p[2] != 0 || p[3] != 0)
-			goto out;
-		if (p[1] == 0)
+		if (p[0] == 0 || p[1] == 0)	/* !dp_mid || !dp_sid */
 			continue;
-		if (le16dec(p + 10) == 0)
+		scyl = le16dec(p + 10);
+		ecyl = le16dec(p + 14);
+		if (scyl == 0 || ecyl == 0)
+			goto out;
+		if (p[8] == p[12] &&		/* dp_ssect == dp_esect */
+		    p[9] == p[13] &&		/* dp_shd == dp_ehd */
+		    scyl == ecyl)
 			goto out;
 	}
 


More information about the svn-src-head mailing list