Check disklabel just read from disk and warn if:
(a) total sector size is different from the size of ccd, or (b) size of a partition exceeds the size of ccd.
This commit is contained in:
parent
6e8ffbdd58
commit
512a01869c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: ccd.c,v 1.46 1998/02/06 08:13:07 thorpej Exp $ */
|
/* $NetBSD: ccd.c,v 1.47 1998/02/22 06:50:08 enami Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
|
||||||
@ -1466,6 +1466,32 @@ ccdgetdisklabel(dev)
|
|||||||
cs->sc_dkdev.dk_label, cs->sc_dkdev.dk_cpulabel);
|
cs->sc_dkdev.dk_label, cs->sc_dkdev.dk_cpulabel);
|
||||||
if (errstring)
|
if (errstring)
|
||||||
ccdmakedisklabel(cs);
|
ccdmakedisklabel(cs);
|
||||||
|
else {
|
||||||
|
int i;
|
||||||
|
struct partition *pp;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanity check whether the found disklabel is valid.
|
||||||
|
*
|
||||||
|
* This is necessary since total size of ccd may vary
|
||||||
|
* when an interleave is changed even though exactly
|
||||||
|
* same componets are used, and old disklabel may used
|
||||||
|
* if that is found.
|
||||||
|
*/
|
||||||
|
if (lp->d_secperunit != cs->sc_size)
|
||||||
|
printf("WARNING: %s: "
|
||||||
|
"total sector size in disklabel (%d) != "
|
||||||
|
"the size of ccd (%d)\n", cs->sc_xname,
|
||||||
|
lp->d_secperunit, cs->sc_size);
|
||||||
|
for (i = 0; i < lp->d_npartitions; i++) {
|
||||||
|
pp = &lp->d_partitions[i];
|
||||||
|
if (pp->p_offset + pp->p_size > cs->sc_size)
|
||||||
|
printf("WARNING: %s: size of partition `%c' "
|
||||||
|
"(%d) exceeds the size of ccd (%d)\n",
|
||||||
|
cs->sc_xname, 'a' + i, pp->p_size,
|
||||||
|
cs->sc_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* It's actually extremely common to have unlabeled ccds. */
|
/* It's actually extremely common to have unlabeled ccds. */
|
||||||
|
Loading…
Reference in New Issue
Block a user