1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

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
This commit is contained in:
Marcel Moolenaar 2009-01-04 07:32:06 +00:00
parent a2ea8684d7
commit 90886ebcc2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186733

View File

@ -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;
}