Fix code that guesses bios geometry from mbr info.

When asking for bios geometry, ask for sectors per track and heads
then calculate cylinders from volume size.
Write MBR_MAGIC into correct place when writing extened partitions.
This commit is contained in:
dsl 2003-07-14 09:59:00 +00:00
parent 2b846f3e47
commit a2d5357066
4 changed files with 49 additions and 37 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbr.c,v 1.47 2003/07/11 15:28:58 dsl Exp $ */
/* $NetBSD: mbr.c,v 1.48 2003/07/14 09:59:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -120,17 +120,22 @@ set_bios_geom(int cyl, int head, int sec)
char res[80];
msg_display_add(MSG_setbiosgeom);
snprintf(res, 80, "%d", cyl);
msg_prompt_add(MSG_cylinders, res, res, 80);
bcyl = atoi(res);
snprintf(res, 80, "%d", head);
msg_prompt_add(MSG_heads, res, res, 80);
bhead = atoi(res);
do {
snprintf(res, 80, "%d", sec);
msg_prompt_add(MSG_sectors, res, res, 80);
bsec = atoi(res);
} while (bsec <= 0 || bsec > 63);
snprintf(res, 80, "%d", sec);
msg_prompt_add(MSG_sectors, res, res, 80);
bsec = atoi(res);
do {
snprintf(res, 80, "%d", head);
msg_prompt_add(MSG_heads, res, res, 80);
bhead = atoi(res);
} while (bhead <= 0 || bhead > 256);
bcyl = dlsize / bsec / bhead;
if (dlsize != bcyl * bsec * bhead)
bcyl++;
}
#ifdef notdef
@ -1387,7 +1392,7 @@ write_mbr(const char *disk, mbr_info_t *mbri, int convert)
mbr = &ext->mbr;
#ifdef BOOTSEL
if (netbsd_bootcode) {
mbri->mbr.mbr_bootsel.mbrb_magic = htole16(MBR_MAGIC);
mbr->mbr_bootsel.mbrb_magic = htole16(MBR_MAGIC);
memcpy(&mbr->mbr_bootsel.mbrb_nametab, &ext->nametab,
sizeof mbr->mbr_bootsel.mbrb_nametab);
}
@ -1425,6 +1430,10 @@ write_mbr(const char *disk, mbr_info_t *mbri, int convert)
}
mbr->mbr_signature = htole16(MBR_MAGIC);
/*
* Sector zero is written outside the loop after we have
* set mbrb_defkey.
*/
if (ext->sector != 0 && pwrite(fd, mbr, sizeof *mbr,
ext->sector * (off_t)MBR_SECSIZE) < 0)
ret = -1;
@ -1544,17 +1553,22 @@ guess_biosgeom_from_mbr(mbr_info_t *mbri, int *cyl, int *head, int *sec)
* XXX relies on get_disks having been called.
*/
xcylinders = dlsize / xheads / xsectors;
if (dlsize != xcylinders * xheads * xsectors)
xcylinders++;
/* Now verify consistency with each of the partition table entries.
/*
* Now verify consistency with each of the partition table entries.
* Be willing to shove cylinders up a little bit to make things work,
* but translation mismatches are fatal. */
* but translation mismatches are fatal.
*/
for (i = 0; i < NMBRPART * 2; i++) {
if (get_mapping(parts, i, &c1, &h1, &s1, &a1) < 0)
continue;
if (c1 >= MAXCYL - 1)
/* Ignore anything that is near the CHS limit */
continue;
if (xsectors * (c1 * xheads + h1) + s1 != a1)
return -1;
if (c1 >= xcylinders)
xcylinders = c1 + 1;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mbr.en,v 1.8 2003/07/07 21:26:32 dsl Exp $ */
/* $NetBSD: msg.mbr.en,v 1.9 2003/07/14 09:59:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -83,16 +83,15 @@ start up properly. Should the NetBSD partition of the disk be marked active?}
message setbiosgeom
{
You will be prompted for the geometry. Please enter the values you
want. The number of cylinders should be <= 1024 and the number of sectors
should be <= 63. If you have the BIOS set up to use > 1024 cylinders just
truncate that number to 1024 here; NetBSD will know about the rest of the
cylinders.
You will be prompted for the geometry.
Please enter the number of sectors per track (maximum 63)
and number of heads (maximum 256) that the BIOS uses to access the disk.
The number of cylinders will be calculated from the disk size.
}
message nobiosgeom
{Sysinst could not automatically determine the BIOS geometry of the disk.
{Sysinst could not automatically determine the BIOS geometry of the disk.
The physical geometry is %d cylinders %d sectors %d heads\n}
message biosguess

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mbr.fr,v 1.9 2003/07/07 21:26:32 dsl Exp $ */
/* $NetBSD: msg.mbr.fr,v 1.10 2003/07/14 09:59:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -82,19 +82,18 @@ message noactivepart
Cela peut empêcher votre système de démarrer correctement.
Dois-je marquer la partition NetBSD active?}
message setbiosgeom
message setbiosgeom /* XXX translate */
{
On va vous demander la géométrie. SVP entrer les valeur que vous désirez.
Rappelez vous que le nombre de cylindre doit être <= 1024 et que le nombre
de secteur doit être <=63. Si votre BIOS est configuré avec plus de 1024
cylindre, tronquez ce nombre à 1024 ici, NetBSD saura utiliser les cylindres
restant.
On va vous demander la géométrie.
Please enter the number of sectors per track (maximum 63)
and number of heads (maximum 256) that the BIOS uses to access the disk.
The number of cylinders will be calculated from the disk size.
}
message nobiosgeom
{Sysinst n'a pas pu déterminer automatiquement la géométrie utilisée par le
BIOS pour votre disque.
BIOS pour votre disque.
La géométrie physique est %d cylindres %d secteurs %d têtes\n}
message biosguess

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mbr.pl,v 1.8 2003/07/07 21:26:32 dsl Exp $ */
/* $NetBSD: msg.mbr.pl,v 1.9 2003/07/14 09:59:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -79,17 +79,17 @@ message noactivepart
{Nie zaznaczyles aktywnej partycji. Moze to spowodowac, ze twoj system nie
uruchomi sie prawidlowo. Czy partycja NetBSD ma zostac zaznaczona jako aktynwa?}
message setbiosgeom
message setbiosgeom /* XXX translate */
{
Zostaniesz poproszony o podanie geometrii. Podaj wartosci jakie chcesz.
Ilosc cylindrow powinna byc <= 1024 a ilosc sektorow <= 63. Jesli twoj
BIOS jest ustawiony aby obslugiwac > 1024 cylindry po prostu zmniejsz
tutaj ta ilosc do 1024; NetBSD rozpozna reszte cylindrow.
Zostaniesz poproszony o podanie geometrii.
Please enter the number of sectors per track (maximum 63)
and number of heads (maximum 256) that the BIOS uses to access the disk.
The number of cylinders will be calculated from the disk size.
}
message nobiosgeom
{Sysinst nie mogl automatycznie rozpoznac geometrii dysku z BIOS.
{Sysinst nie mogl automatycznie rozpoznac geometrii dysku z BIOS.
Fizyczna geometria to %d cylindrow %d sektorow %d glowic\n}
message biosguess