MFC: also look for BSD label at 512-byte offset, if we can't find

it on the very beginning of the second sector. This makes it compatible
with labels created by disklabel(8) on non-512-byte-per-sector
devices.

Approved by:	re
This commit is contained in:
sobomax 2006-03-23 22:40:28 +00:00
parent f119cdd464
commit 4257df9039

View File

@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#define BSD_CLASS_NAME "BSD"
#define ALPHA_LABEL_OFFSET 64
#define HISTORIC_LABEL_OFFSET 512
#define LABELSIZE (148 + 16 * MAXPARTITIONS)
@ -536,6 +537,15 @@ g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
/* First look for a label at the start of the second sector. */
error = g_bsd_try(gp, gsp, cp, secsize, ms, secsize);
/*
* If sector size is not 512 the label still can be at
* offset 512, not at the start of the second sector. At least
* it's true for labels created by the FreeBSD's bsdlabel(8).
*/
if (error && secsize != HISTORIC_LABEL_OFFSET)
error = g_bsd_try(gp, gsp, cp, secsize, ms,
HISTORIC_LABEL_OFFSET);
/* Next, look for alpha labels */
if (error)
error = g_bsd_try(gp, gsp, cp, secsize, ms,