From 619213ff3f701271abfc79c0c74fd57719b60eba Mon Sep 17 00:00:00 2001 From: marcel Date: Sun, 4 Jan 2009 07:32:06 +0000 Subject: 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 --- sys/geom/part/g_part_pc98.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sys/geom/part') diff --git a/sys/geom/part/g_part_pc98.c b/sys/geom/part/g_part_pc98.c index f0f1474..c7d9d97 100644 --- a/sys/geom/part/g_part_pc98.c +++ b/sys/geom/part/g_part_pc98.c @@ -333,7 +333,7 @@ g_part_pc98_probe(struct g_part_table *table, struct g_consumer *cp) 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 *table, struct g_consumer *cp) 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; } -- cgit v1.1