Use C structure mbr_sector_t instead of char[] for 'mbr'.

(I hope the edits for the ports I can't build are right!)
i386/amd64 pick up a minor change to the md_read_bootcode which
might preseve the bootselect config.
This commit is contained in:
dsl 2003-05-07 10:20:18 +00:00
parent 3e8fcf58f8
commit d5c9f83022
41 changed files with 274 additions and 342 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.2 2003/05/03 17:04:09 fvdl Exp $ */
/* $NetBSD: md.c,v 1.3 2003/05/07 10:20:19 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -46,15 +46,17 @@
#include <sys/stat.h>
#include <machine/cpu.h>
#include <stdio.h>
#include <stddef.h>
#include <util.h>
#include <dirent.h>
#include "defs.h"
#include "md.h"
#include "endian.h"
#include "msg_defs.h"
#include "menu_defs.h"
char mbr[512];
mbr_sector_t mbr;
char kernstr[STRSIZE];
int mbr_present, mbr_len;
int c1024_resp;
@ -64,7 +66,7 @@ struct biosdisk_info *biosdisk = NULL;
int netbsd_mbr_installed = 0;
int netbsd_bootsel_installed = 0;
static int md_read_bootcode (char *, char *, size_t);
static int md_read_bootcode (const char *, mbr_sector_t *);
static int count_mbr_parts (struct mbr_partition *);
static int mbr_part_above_chs (struct mbr_partition *);
static int mbr_partstart_above_chs (struct mbr_partition *);
@ -81,19 +83,18 @@ int defbootselpart, defbootseldisk;
int
md_get_info()
{
read_mbr(diskdev, mbr, sizeof mbr);
if (!valid_mbr(mbr)) {
memset(&mbr[MBR_PARTOFF], 0,
NMBRPART * sizeof (struct mbr_partition));
read_mbr(diskdev, &mbr, sizeof mbr);
if (!valid_mbr(&mbr)) {
memset(&mbr.mbr_parts, 0, sizeof mbr.mbr_parts);
/* XXX check result and give up if < 0 */
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
mbr_len = md_read_bootcode(_PATH_MBR, &mbr);
netbsd_mbr_installed = 1;
} else
mbr_len = MBR_SECSIZE;
md_bios_info(diskdev);
edit:
edit_mbr((struct mbr_partition *)&mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
if (mbr_part_above_chs(part) &&
(biosdisk == NULL || !(biosdisk->bi_flags & BIFLAG_EXTINT13))) {
@ -107,21 +108,19 @@ edit:
msg_display(MSG_installbootsel);
process_menu(MENU_yesno);
if (yesno) {
mbr_len =
md_read_bootcode(_PATH_BOOTSEL, mbr, sizeof mbr);
mbr_len = md_read_bootcode(_PATH_BOOTSEL, &mbr);
configure_bootsel();
netbsd_mbr_installed = netbsd_bootsel_installed = 1;
} else {
msg_display(MSG_installnormalmbr);
process_menu(MENU_yesno);
if (yesno) {
mbr_len = md_read_bootcode(_PATH_MBR, mbr,
sizeof mbr);
mbr_len = md_read_bootcode(_PATH_MBR, &mbr);
netbsd_mbr_installed = 1;
}
}
} else {
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
mbr_len = md_read_bootcode(_PATH_MBR, &mbr);
netbsd_mbr_installed = 1;
}
@ -129,7 +128,7 @@ edit:
msg_display(MSG_installmbr);
process_menu(MENU_yesno);
if (yesno) {
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
mbr_len = md_read_bootcode(_PATH_MBR, &mbr);
netbsd_mbr_installed = 1;
}
}
@ -138,36 +137,37 @@ edit:
}
/*
* Read MBR code from a file. It may be a maximum of "len" bytes
* long. This function skips the partition table. Space for this
* is assumed to be in the file, but a table already in the buffer
* is not overwritten.
* Read MBR code from a file.
* The existing partition table and bootselect configuration is kept.
*/
static int
md_read_bootcode(path, buf, len)
char *path, *buf;
size_t len;
md_read_bootcode(path, mbr)
const char *path;
mbr_sector_t *mbr;
{
int fd, cc;
struct stat st;
size_t len;
fd = open(path, O_RDONLY);
if (fd < 0)
return -1;
if (fstat(fd, &st) < 0 || st.st_size > len || st.st_size < MBR_SECSIZE){
if (fstat(fd, &st) < 0 || st.st_size != sizeof *mbr) {
close(fd);
return -1;
}
if (read(fd, buf, MBR_PARTOFF) != MBR_PARTOFF) {
if (mbr->mbr_bootsel.mbrb_magic != native_to_le16(MBR_MAGIC))
len = offsetof(mbr_sector_t, mbr_parts);
else
len = offsetof(mbr_sector_t, mbr_bootsel);
if (read(fd, mbr, len) != len) {
close(fd);
return -1;
}
if (lseek(fd, MBR_MAGICOFF, SEEK_SET) < 0) {
close(fd);
return -1;
}
cc = read(fd, &buf[MBR_MAGICOFF], st.st_size - MBR_MAGICOFF);
mbr->mbr_signature = native_to_le16(MBR_MAGIC);
close(fd);
@ -180,7 +180,7 @@ md_pre_disklabel()
msg_display(MSG_dofdisk);
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);
return 1;
@ -371,7 +371,7 @@ custom:
/* XXX UGH! need arguments to process_menu */
switch (c1024_resp) {
case 1:
edit_mbr((struct mbr_partition *)&mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
/*FALLTHROUGH*/
case 2:
goto editlab;
@ -450,10 +450,10 @@ md_upgrade_mbrtype()
struct mbr_partition *mbrp;
int i, netbsdpart = -1, oldbsdpart = -1, oldbsdcount = 0;
if (read_mbr(diskdev, mbr, sizeof mbr) < 0)
if (read_mbr(diskdev, &mbr, sizeof mbr) < 0)
return;
mbrp = (struct mbr_partition *)&mbr[MBR_PARTOFF];
mbrp = &mbr.mbr_parts[0];
for (i = 0; i < NMBRPART; i++) {
if (mbrp[i].mbrp_typ == MBR_PTYPE_386BSD) {
@ -465,7 +465,7 @@ md_upgrade_mbrtype()
if (netbsdpart == -1 && oldbsdcount == 1) {
mbrp[oldbsdpart].mbrp_typ = MBR_PTYPE_NETBSD;
write_mbr(diskdev, mbr, sizeof mbr, 0);
write_mbr(diskdev, &mbr, sizeof mbr, 0);
}
}
@ -536,7 +536,7 @@ md_bios_info(dev)
if (nip == NULL || nip->ni_nmatches == 0) {
nogeom:
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else
@ -600,12 +600,11 @@ mbr_partstart_above_chs(pt)
static void
configure_bootsel()
{
struct mbr_partition *parts =
(struct mbr_partition *)&mbr[MBR_PARTOFF];
struct mbr_partition *parts = &mbr.mbr_parts[0];
int i;
mbs = (struct mbr_bootsel *)&mbr[MBR_BOOTSELOFF];
mbs = &mbr.mbr_bootsel;
mbs->mbrb_flags = BFL_SELACTIVE;
/* Setup default labels for partitions, since if not done by user */

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.2 2003/05/03 17:04:09 fvdl Exp $ */
/* $NetBSD: menus.md.en,v 1.3 2003/05/07 10:20:19 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -81,8 +81,7 @@ menu dlgeom, title "Choose an option";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -97,8 +96,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], editpart,-1);
disp_cur_part(&mbr.mbr_parts[0], editpart,-1);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;
@ -287,7 +285,7 @@ menu biosmultmatch;
menu configbootsel, y=16, title "Change a bootmenu item", exit;
display action { msg_display(MSG_configbootsel);
disp_bootsel((struct mbr_partition *)&mbr[MBR_PARTOFF], mbs);
disp_bootsel(&mbr.mbr_parts[0], mbs);
msg_display_add(MSG_bootseltimeout, (1000 * mbs->mbrb_timeo) / 18200);
msg_display_add(MSG_defbootselopt);
if (mbs->mbrb_defkey == SCAN_ENTER)

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.2 2003/05/03 17:04:09 fvdl Exp $ */
/* $NetBSD: menus.md.fr,v 1.3 2003/05/07 10:20:19 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -82,8 +82,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -98,8 +97,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "du type de FS", sub menu chooseid;
@ -259,7 +257,7 @@ menu biosmultmatch;
menu configbootsel, title "Changer une entree du menu", exit;
display action { msg_display(MSG_configbootsel);
disp_bootsel((struct mbr_partition *)&mbr[MBR_PARTOFF], mbs);
disp_bootsel(&mbr.mbr_parts[0], mbs);
msg_display_add(MSG_bootseltimeout, (1000 * mbs->mbrb_timeo) / 18200);
msg_display_add(MSG_defbootselopt);
if (mbs->mbrb_defkey == SCAN_ENTER)

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.2 2003/05/03 17:04:09 fvdl Exp $ */
/* $NetBSD: menus.md.pl,v 1.3 2003/05/07 10:20:19 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.36 2001/11/29 23:20:58 thorpej Exp */
@ -83,8 +83,7 @@ menu dlgeom, title "Wybierz opcje";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -99,8 +98,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], editpart,-1);
disp_cur_part(&mbr.mbr_parts[0], editpart,-1);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;
@ -288,7 +286,7 @@ menu biosmultmatch;
menu configbootsel, y=16, title "Zmien bootmenu", exit;
display action { msg_display(MSG_configbootsel);
disp_bootsel((struct mbr_partition *)&mbr[MBR_PARTOFF], mbs);
disp_bootsel(&mbr.mbr_parts[0], mbs);
msg_display_add(MSG_bootseltimeout, (1000 * mbs->mbrb_timeo) / 18200);
msg_display_add(MSG_defbootselopt);
if (mbs->mbrb_defkey == SCAN_ENTER)

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.6 2001/11/29 23:20:57 thorpej Exp $ */
/* $NetBSD: menus.md.fr,v 1.7 2003/05/07 10:20:19 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_printf_add ("\n");
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.6 2003/01/12 21:49:50 christos Exp $ */
/* $NetBSD: md.c,v 1.7 2003/05/07 10:20:20 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -54,9 +54,8 @@
#include "menu_defs.h"
char mbr[512] __attribute__((aligned(4)));
char kernstr[STRSIZE];
int mbr_present, mbr_len;
mbr_sector_t mbr;
int mbr_len;
int c1024_resp;
struct disklist *disklist = NULL;
struct nativedisk_info *nativedisk;
@ -70,18 +69,17 @@ static void md_upgrade_mbrtype (void);
int
md_get_info()
{
read_mbr(diskdev, mbr, sizeof mbr);
if (!valid_mbr(mbr)) {
memset(&mbr[MBR_PARTOFF], 0,
NMBRPART * sizeof (struct mbr_partition));
read_mbr(diskdev, &mbr, sizeof mbr);
if (!valid_mbr(&mbr)) {
memset(&mbr.mbr_parts, 0, sizeof mbr.mbr_parts);
/* XXX check result and give up if < 0 */
*((uint16_t *)&mbr[MBR_MAGICOFF]) = MBR_MAGIC;
mbr->mbr_signature = MBR_MAGIC;
mbr_len = MBR_SECSIZE;
} else
mbr_len = MBR_SECSIZE;
md_bios_info(diskdev);
edit_mbr((struct mbr_partition *)&mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
return 1;
}
@ -92,7 +90,7 @@ md_pre_disklabel()
msg_display(MSG_dofdisk);
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);
return 1;
@ -301,10 +299,10 @@ md_upgrade_mbrtype()
struct mbr_partition *mbrp;
int i, netbsdpart = -1, oldbsdpart = -1, oldbsdcount = 0;
if (read_mbr(diskdev, mbr, sizeof mbr) < 0)
if (read_mbr(diskdev, &mbr, sizeof mbr) < 0)
return;
mbrp = (struct mbr_partition *)&mbr[MBR_PARTOFF];
mbrp = &mbr.mbr_parts[0];
for (i = 0; i < NMBRPART; i++) {
if (mbrp[i].mbrp_typ == MBR_PTYPE_386BSD) {
@ -316,7 +314,7 @@ md_upgrade_mbrtype()
if (netbsdpart == -1 && oldbsdcount == 1) {
mbrp[oldbsdpart].mbrp_typ = MBR_PTYPE_NETBSD;
write_mbr(diskdev, mbr, sizeof mbr, 0);
write_mbr(diskdev, &mbr, sizeof mbr, 0);
}
}
@ -351,7 +349,7 @@ md_bios_info(dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.3 2002/09/09 10:53:48 grant Exp $ */
/* $NetBSD: menus.md.en,v 1.4 2003/05/07 10:20:20 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,8 +77,7 @@ menu dlgeom, title "Choose an option";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -93,8 +92,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], editpart,-1);
disp_cur_part(&mbr.mbr_parts[0], editpart,-1);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.4 2002/09/27 15:21:52 grant Exp $ */
/* $NetBSD: menus.md.fr,v 1.5 2003/05/07 10:20:20 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.2 2002/04/09 19:48:02 hubertf Exp $ */
/* $NetBSD: menus.md.pl,v 1.3 2003/05/07 10:20:20 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.2 2001/11/29 23:20:57 thorpej Exp */
@ -79,8 +79,7 @@ menu dlgeom, title "Wybierz opcje";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -95,8 +94,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], editpart,-1);
disp_cur_part(&mbr.mbr_parts[0], editpart,-1);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.28 2003/01/12 21:49:50 christos Exp $ */
/* $NetBSD: md.c,v 1.29 2003/05/07 10:20:20 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -50,7 +50,7 @@
int mbr_present;
int c1024_resp;
char mbr[512];
mbr_partition_t mbr;
/* prototypes */
@ -58,9 +58,9 @@ char mbr[512];
int md_get_info()
{
read_mbr(diskdev, mbr, sizeof mbr);
read_mbr(diskdev, &mbr, sizeof mbr);
md_bios_info(diskdev);
return edit_mbr((struct mbr_partition *) &mbr[MBR_PARTOFF]);
return edit_mbr(&mbr);
}
int md_pre_disklabel()
@ -68,7 +68,7 @@ int md_pre_disklabel()
printf ("%s", msg_string (MSG_dofdisk));
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);
return 1;
@ -280,7 +280,7 @@ editlab:
/* XXX UGH! need arguments to process_menu */
switch (c1024_resp) {
case 1:
edit_mbr((struct mbr_partition *) &mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
/*FALLTHROUGH*/
case 2:
goto editlab;
@ -382,7 +382,7 @@ md_bios_info(dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.15 2002/09/09 10:53:49 grant Exp $ */
/* $NetBSD: menus.md.en,v 1.16 2003/05/07 10:20:20 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,7 +77,7 @@ menu dlgeom, title "Choose an option";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -92,8 +92,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.16 2002/09/27 15:21:53 grant Exp $ */
/* $NetBSD: menus.md.fr,v 1.17 2003/05/07 10:20:20 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.2 2002/04/09 19:48:02 hubertf Exp $ */
/* $NetBSD: menus.md.pl,v 1.3 2003/05/07 10:20:20 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.14 2001/11/29 23:20:57 thorpej Exp */
@ -79,8 +79,7 @@ menu dlgeom, title "Wybierz opcje";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -95,8 +94,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.4 2003/01/12 21:49:51 christos Exp $ */
/* $NetBSD: md.c,v 1.5 2003/05/07 10:20:21 dsl Exp $ */
/*
* Copyright 1997,2002 Piermont Information Systems Inc.
@ -50,7 +50,7 @@
int mbr_present;
int c1024_resp;
char mbr[512];
mbr_sector_t mbr;
/* prototypes */
@ -58,9 +58,9 @@ char mbr[512];
int md_get_info()
{
read_mbr(diskdev, mbr, sizeof mbr);
read_mbr(diskdev, &mbr, sizeof mbr);
md_bios_info(diskdev);
return edit_mbr((struct mbr_partition *) &mbr[MBR_PARTOFF]);
return edit_mbr(&mbr);
}
int md_pre_disklabel()
@ -68,7 +68,7 @@ int md_pre_disklabel()
printf ("%s", msg_string (MSG_dofdisk));
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);
return 1;
@ -283,7 +283,7 @@ editlab:
/* XXX UGH! need arguments to process_menu */
switch (c1024_resp) {
case 1:
edit_mbr((struct mbr_partition *) &mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
/*FALLTHROUGH*/
case 2:
goto editlab;
@ -385,7 +385,7 @@ md_bios_info(dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.1 2002/12/09 14:13:14 scw Exp $ */
/* $NetBSD: menus.md.en,v 1.2 2003/05/07 10:20:21 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,7 +77,7 @@ menu dlgeom, title "Choose an option";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -92,8 +92,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.1 2002/12/09 14:13:15 scw Exp $ */
/* $NetBSD: menus.md.fr,v 1.2 2003/05/07 10:20:21 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.1 2002/12/09 14:13:15 scw Exp $ */
/* $NetBSD: menus.md.pl,v 1.2 2003/05/07 10:20:21 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.2 2001/11/29 23:21:01 thorpej Exp */
@ -79,8 +79,7 @@ menu dlgeom, title "Wybierz opcje";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -95,8 +94,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.1 2002/02/10 01:14:05 gmcgarry Exp $ */
/* $NetBSD: menus.md.fr,v 1.2 2003/05/07 10:20:21 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_printf_add ("\n");
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.20 2003/05/07 08:45:43 dsl Exp $ */
/* $NetBSD: md.c,v 1.21 2003/05/07 10:20:21 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -52,9 +52,9 @@
#ifdef __mips__
extern char mbr[512];
extern mbr_sector_t mbr;
#else
char mbr[512];
mbr_sector_t mbr;
#endif
int mbr_present, mbr_len;
int c1024_resp;
@ -75,18 +75,17 @@ int defbootselpart, defbootseldisk;
int
md_get_info()
{
read_mbr(diskdev, mbr, sizeof mbr);
if (!valid_mbr(mbr)) {
memset(&mbr[MBR_PARTOFF], 0,
NMBRPART * sizeof (struct mbr_partition));
read_mbr(diskdev, &mbr, sizeof mbr);
if (!valid_mbr(&mbr)) {
memset(&mbr.mbr_parts, 0, sizeof mbr.mbr_parts);
/* XXX check result and give up if < 0 */
*((u_int16_t *)&mbr[MBR_MAGICOFF]) = le_to_native16(MBR_MAGIC);
mbr.mbr_signature = le_to_native16(MBR_MAGIC);
netbsd_mbr_installed = 1;
} else
mbr_len = MBR_SECSIZE;
md_bios_info(diskdev);
edit_mbr((struct mbr_partition *)&mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
/* Compute minimum NetBSD partition sizes (in sectors). */
minfsdmb = STDNEEDMB * (MEG / sectorsize);
@ -101,7 +100,7 @@ md_pre_disklabel()
msg_display(MSG_dofdisk);
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);
return 1;
@ -362,10 +361,10 @@ md_upgrade_mbrtype()
struct mbr_partition *mbrp;
int i, netbsdpart = -1, oldbsdpart = -1, oldbsdcount = 0;
if (read_mbr(diskdev, mbr, sizeof mbr) < 0)
if (read_mbr(diskdev, &mbr, sizeof mbr) < 0)
return;
mbrp = (struct mbr_partition *)&mbr[MBR_PARTOFF];
mbrp = &mbr/mbr_parts[0];
for (i = 0; i < NMBRPART; i++) {
if (mbrp[i].mbrp_typ == MBR_PTYPE_386BSD) {
@ -377,7 +376,7 @@ md_upgrade_mbrtype()
if (netbsdpart == -1 && oldbsdcount == 1) {
mbrp[oldbsdpart].mbrp_typ = MBR_PTYPE_NETBSD;
write_mbr(diskdev, mbr, sizeof mbr, 0);
write_mbr(diskdev, &mbr, sizeof mbr, 0);
}
}
@ -411,7 +410,7 @@ md_bios_info(dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.10 2003/05/07 08:45:43 dsl Exp $ */
/* $NetBSD: menus.md.en,v 1.11 2003/05/07 10:20:21 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,8 +77,7 @@ menu dlgeom, title "Choose an option";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -93,8 +92,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], editpart,-1);
disp_cur_part(&mbr.mbr_parts[0], editpart,-1);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.10 2003/05/07 08:45:43 dsl Exp $ */
/* $NetBSD: menus.md.fr,v 1.11 2003/05/07 10:20:22 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.3 2003/05/07 08:45:43 dsl Exp $ */
/* $NetBSD: menus.md.pl,v 1.4 2003/05/07 10:20:22 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.8 2002/03/23 03:24:34 shin Exp */
@ -79,8 +79,7 @@ menu dlgeom, title "Wybierz opcje";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -95,8 +94,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], editpart,-1);
disp_cur_part(&mbr.mbr_parts[0], editpart,-1);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.72 2003/05/03 17:04:09 fvdl Exp $ */
/* $NetBSD: md.c,v 1.73 2003/05/07 10:20:22 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -46,15 +46,17 @@
#include <sys/stat.h>
#include <machine/cpu.h>
#include <stdio.h>
#include <stddef.h>
#include <util.h>
#include <dirent.h>
#include "defs.h"
#include "md.h"
#include "endian.h"
#include "msg_defs.h"
#include "menu_defs.h"
char mbr[512];
mbr_sector_t mbr;
int mbr_len;
int c1024_resp;
struct disklist *disklist = NULL;
@ -63,7 +65,7 @@ struct biosdisk_info *biosdisk = NULL;
int netbsd_mbr_installed = 0;
int netbsd_bootsel_installed = 0;
static int md_read_bootcode (char *, char *, size_t);
static int md_read_bootcode (const char *, mbr_sector_t *);
static int count_mbr_parts (struct mbr_partition *);
static int mbr_part_above_chs (struct mbr_partition *);
static int mbr_partstart_above_chs (struct mbr_partition *);
@ -81,19 +83,18 @@ int defbootselpart, defbootseldisk;
int
md_get_info()
{
read_mbr(diskdev, mbr, sizeof mbr);
if (!valid_mbr(mbr)) {
memset(&mbr[MBR_PARTOFF], 0,
NMBRPART * sizeof (struct mbr_partition));
read_mbr(diskdev, &mbr, sizeof mbr);
if (!valid_mbr(&mbr)) {
memset(&mbr.mbr_parts, 0, sizeof mbr.mbr_parts);
/* XXX check result and give up if < 0 */
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
mbr_len = md_read_bootcode(_PATH_MBR, &mbr);
netbsd_mbr_installed = 1;
} else
mbr_len = MBR_SECSIZE;
md_bios_info(diskdev);
edit:
edit_mbr((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
if (mbr_part_above_chs(part) &&
(biosdisk == NULL || !(biosdisk->bi_flags & BIFLAG_EXTINT13))) {
@ -107,21 +108,19 @@ edit:
msg_display(MSG_installbootsel);
process_menu(MENU_yesno);
if (yesno) {
mbr_len =
md_read_bootcode(_PATH_BOOTSEL, mbr, sizeof mbr);
mbr_len = md_read_bootcode(_PATH_BOOTSEL, &mbr);
configure_bootsel();
netbsd_mbr_installed = netbsd_bootsel_installed = 1;
} else {
msg_display(MSG_installnormalmbr);
process_menu(MENU_yesno);
if (yesno) {
mbr_len = md_read_bootcode(_PATH_MBR, mbr,
sizeof mbr);
mbr_len = md_read_bootcode(_PATH_MBR, &mbr);
netbsd_mbr_installed = 1;
}
}
} else {
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
mbr_len = md_read_bootcode(_PATH_MBR, &mbr);
netbsd_mbr_installed = 1;
}
@ -129,7 +128,7 @@ edit:
msg_display(MSG_installmbr);
process_menu(MENU_yesno);
if (yesno) {
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
mbr_len = md_read_bootcode(_PATH_MBR, &mbr);
netbsd_mbr_installed = 1;
}
}
@ -138,36 +137,37 @@ edit:
}
/*
* Read MBR code from a file. It may be a maximum of "len" bytes
* long. This function skips the partition table. Space for this
* is assumed to be in the file, but a table already in the buffer
* is not overwritten.
* Read MBR code from a file.
* The existing partition table and bootselect configuration is kept.
*/
static int
md_read_bootcode(path, buf, len)
char *path, *buf;
size_t len;
md_read_bootcode(path, mbr)
const char *path;
mbr_sector_t *mbr;
{
int fd, cc;
struct stat st;
size_t len;
fd = open(path, O_RDONLY);
if (fd < 0)
return -1;
if (fstat(fd, &st) < 0 || st.st_size > len || st.st_size < MBR_SECSIZE){
if (fstat(fd, &st) < 0 || st.st_size != sizeof *mbr) {
close(fd);
return -1;
}
if (read(fd, buf, MBR_PARTOFF) != MBR_PARTOFF) {
if (mbr->mbr_bootsel.mbrb_magic != native_to_le16(MBR_MAGIC))
len = offsetof(mbr_sector_t, mbr_parts);
else
len = offsetof(mbr_sector_t, mbr_bootsel);
if (read(fd, mbr, len) != len) {
close(fd);
return -1;
}
if (lseek(fd, (off_t)MBR_MAGICOFF, SEEK_SET) < 0) {
close(fd);
return -1;
}
cc = read(fd, &buf[MBR_MAGICOFF], (size_t)(st.st_size - MBR_MAGICOFF));
mbr->mbr_signature = native_to_le16(MBR_MAGIC);
close(fd);
@ -180,7 +180,7 @@ md_pre_disklabel()
msg_display(MSG_dofdisk);
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);
return 1;
@ -195,12 +195,6 @@ md_post_disklabel(void)
if (rammb <= 32)
set_swap(diskdev, bsdlabel, 1);
/* Sector forwarding / badblocks ... */
if (*doessf) {
msg_display(MSG_dobad144);
return run_prog(RUN_DISPLAY, NULL, "/usr/sbin/bad144 %s 0",
diskdev);
}
return 0;
}
@ -378,7 +372,7 @@ custom:
/* XXX UGH! need arguments to process_menu */
switch (c1024_resp) {
case 1:
edit_mbr((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
/*FALLTHROUGH*/
case 2:
goto editlab;
@ -457,10 +451,10 @@ md_upgrade_mbrtype()
struct mbr_partition *mbrp;
int i, netbsdpart = -1, oldbsdpart = -1, oldbsdcount = 0;
if (read_mbr(diskdev, mbr, sizeof mbr) < 0)
if (read_mbr(diskdev, &mbr, sizeof mbr) < 0)
return;
mbrp = (struct mbr_partition *)(void *)&mbr[MBR_PARTOFF];
mbrp = &mbr.mbr_parts[0];
for (i = 0; i < NMBRPART; i++) {
if (mbrp[i].mbrp_typ == MBR_PTYPE_386BSD) {
@ -472,7 +466,7 @@ md_upgrade_mbrtype()
if (netbsdpart == -1 && oldbsdcount == 1) {
mbrp[oldbsdpart].mbrp_typ = MBR_PTYPE_NETBSD;
write_mbr(diskdev, mbr, sizeof mbr, 0);
write_mbr(diskdev, &mbr, sizeof mbr, 0);
}
}
@ -564,7 +558,7 @@ md_bios_info(dev)
if (nip == NULL || nip->ni_nmatches == 0) {
nogeom:
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else
@ -628,12 +622,10 @@ mbr_partstart_above_chs(pt)
static void
configure_bootsel()
{
struct mbr_partition *parts =
(struct mbr_partition *)(void *)&mbr[MBR_PARTOFF];
struct mbr_partition *parts = &mbr.mbr_parts[0];
int i;
mbs = (struct mbr_bootsel *)(void *)&mbr[MBR_BOOTSELOFF];
mbs = &mbr.mbr_bootsel;
mbs->mbrb_flags = BFL_SELACTIVE;
/* Setup default labels for partitions, since if not done by user */
@ -675,6 +667,7 @@ disp_bootsel(part, mbsp)
char *
get_bootmodel()
{
#if defined(__i386__)
struct utsname ut;
#ifdef DEBUG
char *envstr;
@ -695,6 +688,7 @@ get_bootmodel()
return "laptop";
else if (strstr(ut.version, "PS2") != NULL)
return "ps2";
#endif
return "";
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.h,v 1.35 2003/05/03 17:04:10 fvdl Exp $ */
/* $NetBSD: md.h,v 1.36 2003/05/07 10:20:22 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -142,8 +142,8 @@ extern struct disklist *disklist;
extern struct nativedisk_info *nativedisk;
extern struct biosdisk_info *biosdisk;
#define _PATH_MBR "/usr/mdec/mbr"
#define _PATH_BOOTSEL "/usr/mdec/mbr_bootsel"
#define _PATH_MBR DEFAULT_BOOTDIR "/" DEFAULT_BOOTCODE
#define _PATH_BOOTSEL DEFAULT_BOOTDIR "/" DEFAULT_BOOTSELCODE
extern struct mbr_bootsel *mbs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.41 2003/05/03 17:04:10 fvdl Exp $ */
/* $NetBSD: menus.md.en,v 1.42 2003/05/07 10:20:22 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -89,8 +89,7 @@ menu dlgeom, title "Choose an option";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -105,8 +104,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF
], editpart,-1);
disp_cur_part(&mbr.mbr_parts[0], editpart,-1);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;
@ -295,8 +293,8 @@ menu biosmultmatch;
menu configbootsel, y=16, title "Change a bootmenu item", exit;
display action { msg_display(MSG_configbootsel);
disp_bootsel((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF], mbs);
msg_display_add(MSG_bootseltimeout, (1000 * mbs->mbrb_timeo) / 18200);
disp_bootsel(&mbr.mbr_parts[0], mbs);
msg_display_add(MSG_bootseltimeout, (10 * mbs->mbrb_timeo + 9) / 182);
msg_display_add(MSG_defbootselopt);
if (mbs->mbrb_defkey == SCAN_ENTER)
msg_display_add(MSG_defbootseloptactive);
@ -338,12 +336,12 @@ menu configbootsel, y=16, title "Change a bootmenu item", exit;
do {
snprintf(tstr, 8, "%u",
(1000 * mbs->mbrb_timeo) / 18200);
(10 * mbs->mbrb_timeo + 9) / 182);
msg_prompt(MSG_bootseltimeoutval, tstr, tstr,
8);
timo = (unsigned)atoi(tstr);
} while (timo > 3600);
mbs->mbrb_timeo = (u_int16_t)((timo * 18200) / 1000);
mbs->mbrb_timeo = (u_int16_t)((timo * 182) / 10);
};
option "Set default option", sub menu defaultbootsel;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.35 2003/05/03 17:04:10 fvdl Exp $ */
/* $NetBSD: menus.md.fr,v 1.36 2003/05/07 10:20:22 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -90,8 +90,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -106,8 +105,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "du type de FS", sub menu chooseid;
@ -267,8 +265,8 @@ menu biosmultmatch;
menu configbootsel, title "Changer une entree du menu", exit;
display action { msg_display(MSG_configbootsel);
disp_bootsel((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF], mbs);
msg_display_add(MSG_bootseltimeout, (1000 * mbs->mbrb_timeo) / 18200);
disp_bootsel(&mbr.mbr_parts[0], mbs);
msg_display_add(MSG_bootseltimeout, (10 * mbs->mbrb_timeo + 9) / 182);
msg_display_add(MSG_defbootselopt);
if (mbs->mbrb_defkey == SCAN_ENTER)
msg_display_add(MSG_defbootseloptactive);
@ -310,12 +308,12 @@ menu configbootsel, title "Changer une entree du menu", exit;
do {
snprintf(tstr, 8, "%u",
(1000 * mbs->mbrb_timeo) / 18200);
(10 * mbs->mbrb_timeo + 9) / 182);
msg_prompt(MSG_bootseltimeoutval, tstr, tstr,
8);
timo = (unsigned)atoi(tstr);
} while (timo > 3600);
mbs->mbrb_timeo = (u_int16_t)((timo * 18200) / 1000);
mbs->mbrb_timeo = (u_int16_t)((timo * 182) / 10);
};
option "Changer le choix par defaut", sub menu defaultbootsel;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.6 2003/05/03 17:04:10 fvdl Exp $ */
/* $NetBSD: menus.md.pl,v 1.7 2003/05/07 10:20:23 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.36 2001/11/29 23:20:58 thorpej Exp */
@ -91,8 +91,7 @@ menu dlgeom, title "Wybierz opcje";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -107,8 +106,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF
], editpart,-1);
disp_cur_part(&mbr.mbr_parts[0], editpart,-1);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;
@ -296,8 +294,8 @@ menu biosmultmatch;
menu configbootsel, y=16, title "Zmien bootmenu", exit;
display action { msg_display(MSG_configbootsel);
disp_bootsel((struct mbr_partition *)(void *)&mbr[MBR_PARTOFF], mbs);
msg_display_add(MSG_bootseltimeout, (1000 * mbs->mbrb_timeo) / 18200);
disp_bootsel(&mbr.mbr_parts[0], mbs);
msg_display_add(MSG_bootseltimeout, (10 * mbs->mbrb_timeo + 9) / 182);
msg_display_add(MSG_defbootselopt);
if (mbs->mbrb_defkey == SCAN_ENTER)
msg_display_add(MSG_defbootseloptactive);
@ -339,12 +337,12 @@ menu configbootsel, y=16, title "Zmien bootmenu", exit;
do {
snprintf(tstr, 8, "%u",
(1000 * mbs->mbrb_timeo) / 18200);
(10 * mbs->mbrb_timeo + 9) / 182);
msg_prompt(MSG_bootseltimeoutval, tstr, tstr,
8);
timo = (unsigned)atoi(tstr);
} while (timo > 3600);
mbs->mbrb_timeo = (u_int16_t)((timo * 18200) / 1000);
mbs->mbrb_timeo = (u_int16_t)((timo * 182) / 10);
};
option "Ustaw domyslna opcje", sub menu defaultbootsel;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.1 2002/03/24 22:04:05 scw Exp $ */
/* $NetBSD: menus.md.fr,v 1.2 2003/05/07 10:20:23 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_printf_add ("\n");
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.4 2003/01/11 19:37:49 christos Exp $ */
/* $NetBSD: md.c,v 1.5 2003/05/07 10:20:23 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -49,9 +49,9 @@
#include "bsddisklabel.c"
#ifdef __mips__
extern char mbr[512];
extern mbr_sector_t mbr;
#else
char mbr[512];
mbr_sector_t mbr;
#endif
int
@ -59,17 +59,16 @@ md_get_info()
{
int cyl, head, sec;
read_mbr(diskdev, mbr, sizeof mbr);
read_mbr(diskdev, &mbr, sizeof mbr);
if (!valid_mbr(mbr)) {
memset(&mbr[MBR_PARTOFF], 0,
NMBRPART * sizeof (struct mbr_partition));
*((u_int16_t *)&mbr[MBR_MAGICOFF]) = MBR_MAGIC;
if (!valid_mbr(&mbr)) {
memset(&mbr.mbr_parts, 0, sizeof mbr.mbr_parts);
mbr/mbr_signature = MBR_MAGIC;
}
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else {
@ -79,7 +78,7 @@ md_get_info()
bsize = bcyl * bhead * bsec;
bcylsize = bhead * bsec;
edit_mbr((struct mbr_partition *)&mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
/* Compute minimum NetBSD partition sizes (in sectors). */
minfsdmb = STDNEEDMB * (MEG / sectorsize);
@ -94,7 +93,7 @@ md_pre_disklabel()
msg_display(MSG_dofdisk);
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.5 2003/05/07 08:40:41 dsl Exp $ */
/* $NetBSD: menus.md.en,v 1.6 2003/05/07 10:20:23 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,8 +77,7 @@ menu dlgeom, title "Choose an option";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -93,8 +92,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.6 2003/05/07 08:40:41 dsl Exp $ */
/* $NetBSD: menus.md.fr,v 1.7 2003/05/07 10:20:24 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.4 2003/05/07 08:40:41 dsl Exp $ */
/* $NetBSD: menus.md.pl,v 1.5 2003/05/07 10:20:24 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.2 2001/11/29 23:21:00 thorpej Exp */
@ -79,8 +79,7 @@ menu dlgeom, title "Wybierz opcje";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -95,8 +94,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.6 2003/01/12 21:49:52 christos Exp $ */
/* $NetBSD: md.c,v 1.7 2003/05/07 10:20:24 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -52,7 +52,7 @@
#include "menu_defs.h"
#include "endian.h"
char mbr[512];
mbr_sector_t mbr;
int mbr_present, mbr_len;
int c1024_resp;
@ -69,17 +69,16 @@ int
md_get_info(void)
{
read_mbr(diskdev, mbr, sizeof mbr);
if (!valid_mbr(mbr)) {
memset(&mbr[MBR_PARTOFF], 0,
NMBRPART * sizeof (struct mbr_partition));
read_mbr(diskdev, &mbr, sizeof mbr);
if (!valid_mbr(&mbr)) {
memset(&mbr.mbr_parts, 0, sizeof mbr.mbr_parts);
/* XXX check result and give up if < 0 */
*((u_int16_t *)&mbr[MBR_MAGICOFF]) = le_to_native16(MBR_MAGIC);
mbr.mbr_signature = le_to_native16(MBR_MAGIC);
netbsd_mbr_installed = 1;
} else
mbr_len = MBR_SECSIZE;
edit_mbr((struct mbr_partition *)&mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
/* Compute minimum NetBSD partition sizes (in sectors). */
minfsdmb = STDNEEDMB * (MEG / sectorsize);
@ -94,7 +93,7 @@ md_pre_disklabel(void)
msg_display(MSG_dofdisk);
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);
return 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.3 2002/09/09 10:53:50 grant Exp $ */
/* $NetBSD: menus.md.en,v 1.4 2003/05/07 10:20:24 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -61,8 +61,7 @@ menu wdtype, title "Select type";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -77,8 +76,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.2 2002/04/09 19:48:16 hubertf Exp $ */
/* $NetBSD: menus.md.pl,v 1.3 2003/05/07 10:20:24 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.2 2001/11/29 23:21:01 thorpej Exp */
@ -62,8 +62,7 @@ menu wdtype, title "Wybierz typ";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -78,8 +77,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.6 2003/01/12 21:49:52 christos Exp $ */
/* $NetBSD: md.c,v 1.7 2003/05/07 10:20:24 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -50,7 +50,7 @@
int mbr_present;
int c1024_resp;
char mbr[512];
mbr_sector_t mbr;
/* prototypes */
@ -58,9 +58,9 @@ char mbr[512];
int md_get_info()
{
read_mbr(diskdev, mbr, sizeof mbr);
read_mbr(diskdev, &mbr, sizeof mbr);
md_bios_info(diskdev);
return edit_mbr((struct mbr_partition *) &mbr[MBR_PARTOFF]);
return edit_mbr(&mbr);
}
int md_pre_disklabel()
@ -68,7 +68,7 @@ int md_pre_disklabel()
printf ("%s", msg_string (MSG_dofdisk));
/* write edited MBR onto disk. */
if (write_mbr(diskdev, mbr, sizeof mbr, 1) != 0) {
if (write_mbr(diskdev, &mbr, sizeof mbr, 1) != 0) {
msg_display(MSG_wmbrfail);
process_menu(MENU_ok);
return 1;
@ -280,7 +280,7 @@ editlab:
/* XXX UGH! need arguments to process_menu */
switch (c1024_resp) {
case 1:
edit_mbr((struct mbr_partition *) &mbr[MBR_PARTOFF]);
edit_mbr(&mbr);
/*FALLTHROUGH*/
case 2:
goto editlab;
@ -382,7 +382,7 @@ md_bios_info(dev)
int cyl, head, sec;
msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec);
if (guess_biosgeom_from_mbr(mbr, &cyl, &head, &sec) >= 0) {
if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) {
msg_display_add(MSG_biosguess, cyl, head, sec);
set_bios_geom(cyl, head, sec);
} else

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.en,v 1.3 2002/09/09 10:53:50 grant Exp $ */
/* $NetBSD: menus.md.en,v 1.4 2003/05/07 10:20:25 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -77,7 +77,7 @@ menu dlgeom, title "Choose an option";
menu editparttable, title "Choose your partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edit partition 0", sub menu editpart,
action { editpart = 0; };
@ -92,8 +92,7 @@ menu editparttable, title "Choose your partition", exit;
menu editpart, title "Select to change";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Kind", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.fr,v 1.4 2002/09/27 15:21:54 grant Exp $ */
/* $NetBSD: menus.md.fr,v 1.5 2003/05/07 10:20:25 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -78,8 +78,7 @@ menu dlgeom, title "Choisissez une option";
menu editparttable, title "Choisissez votre partition", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edition de la partition 0", sub menu editpart,
action { editpart = 0; };
@ -94,8 +93,7 @@ menu editparttable, title "Choisissez votre partition", exit;
menu editpart, title "Changement";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "du type de FS", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.md.pl,v 1.2 2002/04/09 19:48:17 hubertf Exp $ */
/* $NetBSD: menus.md.pl,v 1.3 2003/05/07 10:20:25 dsl Exp $ */
/* Based on english version: */
/* NetBSD: menus.md.en,v 1.2 2001/11/29 23:21:01 thorpej Exp */
@ -79,8 +79,7 @@ menu dlgeom, title "Wybierz opcje";
menu editparttable, title "Wybierz swoje partycje", exit;
display action { msg_display (MSG_editparttable);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,-1);
disp_cur_part(&mbr.mbr_parts[0], activepart,-1);
};
option "Edytuj partycje 0", sub menu editpart,
action { editpart = 0; };
@ -95,8 +94,7 @@ menu editparttable, title "Wybierz swoje partycje", exit;
menu editpart, title "Wybierz aby zmienic";
display action { msg_display (MSG_editpart, editpart);
disp_cur_part((struct mbr_partition *)&mbr[MBR_PARTOFF
], activepart,editpart);
disp_cur_part(&mbr.mbr_parts[0], activepart,editpart);
msg_display_add(MSG_newline);
};
option "Rodzaj", sub menu chooseid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbr.c,v 1.31 2003/02/08 09:53:08 shin Exp $ */
/* $NetBSD: mbr.c,v 1.32 2003/05/07 10:20:18 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -181,15 +181,15 @@ ourpart(id)
* Let user change incore Master Boot Record partitions via menu.
*/
int
edit_mbr(partition)
struct mbr_partition *partition;
edit_mbr(mbr)
struct mbr_sector *mbr;
{
int i, j;
/* Ask full/part */
/* XXX this sucks ("part" is used in menus, no param passing there) */
part = partition;
part = &mbr->mbr_parts[0];
msg_display(MSG_fullpart, diskdev);
process_menu(MENU_fullpart);
@ -404,8 +404,9 @@ disp_cur_part(part, sel, disp)
}
int
read_mbr(disk, buf, len)
char *disk, *buf;
read_mbr(disk, mbr, len)
const char *disk;
mbr_sector_t *mbr;
size_t len;
{
char diskpath[MAXPATHLEN];
@ -421,13 +422,13 @@ read_mbr(disk, buf, len)
close(fd);
return -1;
}
if (read(fd, buf, len) < len) {
if (read(fd, mbr, len) < len) {
close(fd);
return -1;
}
if (valid_mbr(buf)) {
mbrp = (struct mbr_partition *)(void *)&buf[MBR_PARTOFF];
if (valid_mbr(mbr)) {
mbrp = &mbr->mbr_parts[0];
for (i = 0; i < NMBRPART; i++) {
if (mbrp[i].mbrp_typ != 0) {
mbrp[i].mbrp_start =
@ -447,8 +448,9 @@ read_mbr(disk, buf, len)
}
int
write_mbr(disk, buf, len, convert)
char *disk, *buf;
write_mbr(disk, mbr, len, convert)
const char *disk;
mbr_sector_t *mbr;
size_t len;
int convert;
{
@ -467,7 +469,7 @@ write_mbr(disk, buf, len, convert)
return -1;
}
mbrp = (struct mbr_partition *)(void *)&buf[MBR_PARTOFF];
mbrp = &mbr->mbr_parts[0];
for (i = 0; i < NMBRPART; i++) {
if (mbrp[i].mbrp_start == 0 &&
mbrp[i].mbrp_size == 0) {
@ -493,7 +495,7 @@ write_mbr(disk, buf, len, convert)
}
}
if (write(fd, buf, len) < 0)
if (write(fd, mbr, len) < 0)
ret = -1;
(void)close(fd);
@ -501,14 +503,11 @@ write_mbr(disk, buf, len, convert)
}
int
valid_mbr(buf)
char *buf;
valid_mbr(mbr)
mbr_sector_t *mbr;
{
u_int16_t magic;
magic = *((u_int16_t *)(void *)&buf[MBR_MAGICOFF]);
return (le_to_native16(magic) == MBR_MAGIC);
return (le_to_native16(mbr->mbr_signature) == MBR_MAGIC);
}
static void
@ -546,11 +545,11 @@ convert_mbr_chs(cyl, head, sec, cylp, headp, secp, relsecs)
* device.
*/
int
guess_biosgeom_from_mbr(buf, cyl, head, sec)
char *buf;
guess_biosgeom_from_mbr(mbr, cyl, head, sec)
mbr_sector_t *mbr;
int *cyl, *head, *sec;
{
struct mbr_partition *parts = (struct mbr_partition *)(void *)&buf[MBR_PARTOFF];
struct mbr_partition *parts = &mbr->mbr_parts[0];
int cylinders = -1, heads = -1, sectors = -1, i, j;
int c1, h1, s1, c2, h2, s2;
long a1, a2;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbr.h,v 1.10 2003/01/10 20:00:28 christos Exp $ */
/* $NetBSD: mbr.h,v 1.11 2003/05/07 10:20:18 dsl Exp $ */
/*
* Copyright 1997, 1988 Piermont Information Systems Inc.
@ -63,7 +63,7 @@ EXTERN int activepart;
EXTERN int bsdpart; /* partition in use by NetBSD */
EXTERN int usefull; /* on install, clobber entire disk */
extern char mbr[];
extern mbr_sector_t mbr;
/* from mbr.c */
@ -72,15 +72,15 @@ void disp_cur_geom (void);
int check_geom (void); /* primitive geometry sanity-check */
void disp_cur_part (struct mbr_partition *, int, int);
int edit_mbr (struct mbr_partition *);
int edit_mbr (mbr_sector_t *);
int partsoverlap (struct mbr_partition *, int, int);
/* from mbr.c */
int read_mbr (char *, char *, size_t);
int write_mbr (char *, char *, size_t, int);
int valid_mbr (char *);
int guess_biosgeom_from_mbr (char *, int *, int *, int *);
int read_mbr (const char *, mbr_sector_t *, size_t);
int write_mbr (const char *, mbr_sector_t *, size_t, int);
int valid_mbr (mbr_sector_t *);
int guess_biosgeom_from_mbr (mbr_sector_t *, int *, int *, int *);
int md_bios_info (char *);
void set_bios_geom (int, int, int);
int otherpart (int);