- Added support for installing boot0 and boot0.5 for PC-98.

- Cosmetic changes.
This commit is contained in:
Yoshihiro Takahashi 2000-08-12 14:20:31 +00:00
parent 3fdc3c548d
commit 552112cadd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64555
12 changed files with 435 additions and 62 deletions

View File

@ -378,7 +378,10 @@ Debug_Disk(struct disk *d)
printf(" bios_geom=%lu/%lu/%lu = %lu\n",
d->bios_cyl,d->bios_hd,d->bios_sect,
d->bios_cyl*d->bios_hd*d->bios_sect);
#if defined(__i386__)
#if defined(PC98)
printf(" boot1=%p, boot2=%p, bootipl=%p, bootmenu=%p\n",
d->boot1,d->boot2,d->bootipl,d->bootmenu);
#elif defined(__i386__)
printf(" boot1=%p, boot2=%p, bootmgr=%p\n",
d->boot1,d->boot2,d->bootmgr);
#elif defined(__alpha__)
@ -393,7 +396,12 @@ Free_Disk(struct disk *d)
{
if(d->chunks) Free_Chunk(d->chunks);
if(d->name) free(d->name);
#ifdef PC98
if(d->bootipl) free(d->bootipl);
if(d->bootmenu) free(d->bootmenu);
#else
if(d->bootmgr) free(d->bootmgr);
#endif
if(d->boot1) free(d->boot1);
#if defined(__i386__)
if(d->boot2) free(d->boot2);
@ -411,10 +419,21 @@ Clone_Disk(struct disk *d)
*d2 = *d;
d2->name = strdup(d2->name);
d2->chunks = Clone_Chunk(d2->chunks);
#ifdef PC98
if(d2->bootipl) {
d2->bootipl = malloc(d2->bootipl_size);
memcpy(d2->bootipl,d->bootipl,d2->bootipl_size);
}
if(d2->bootmenu) {
d2->bootmenu = malloc(d2->bootmenu_size);
memcpy(d2->bootmenu,d->bootmenu,d2->bootmenu_size);
}
#else
if(d2->bootmgr) {
d2->bootmgr = malloc(d2->bootmgr_size);
memcpy(d2->bootmgr,d->bootmgr,d2->bootmgr_size);
}
#endif
#if defined(__i386__)
if(d2->boot1) {
d2->boot1 = malloc(512);
@ -505,10 +524,44 @@ Disk_Names()
return disks;
}
#ifdef PC98
void
Set_Boot_Mgr(struct disk *d, const u_char *bootipl, const size_t bootipl_size,
const u_char *bootmenu, const size_t bootmenu_size)
#else
void
Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s)
#endif
{
#ifndef PC98
#ifdef PC98
/* XXX - assumes sector size of 512 */
if (bootipl_size % 512 != 0)
return;
if (d->bootipl)
free(d->bootipl);
if (!bootipl) {
d->bootipl = NULL;
} else {
d->bootipl_size = bootipl_size;
d->bootipl = malloc(bootipl_size);
if(!d->bootipl) err(1,"malloc failed");
memcpy(d->bootipl,bootipl,bootipl_size);
}
/* XXX - assumes sector size of 512 */
if (bootmenu_size % 512 != 0)
return;
if (d->bootmenu)
free(d->bootmenu);
if (!bootmenu) {
d->bootmenu = NULL;
} else {
d->bootmenu_size = bootmenu_size;
d->bootmenu = malloc(bootmenu_size);
if(!d->bootmenu) err(1,"malloc failed");
memcpy(d->bootmenu,bootmenu,bootmenu_size);
}
#else
/* XXX - assumes sector size of 512 */
if (s % 512 != 0)
return;

View File

@ -31,8 +31,15 @@ struct disk {
u_long bios_cyl;
u_long bios_hd;
u_long bios_sect;
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
u_char *bootmenu;
size_t bootmenu_size;
#else
u_char *bootmgr;
size_t bootmgr_size;
#endif
u_char *boot1;
#if defined(__i386__) /* the alpha only has one boot program */
u_char *boot2;
@ -163,8 +170,14 @@ Disk_Names();
* each pointer, as well as the array by hand
*/
#ifdef PC98
void
Set_Boot_Mgr(struct disk *d, const u_char *bootipl, const size_t bootipl_size,
const u_char *bootmenu, const size_t bootmenu_size);
#else
void
Set_Boot_Mgr(struct disk *d, const u_char *bootmgr, const size_t bootmgr_size);
#endif
/* Use this boot-manager on this disk. Gets written when Write_Disk()
* is called
*/

View File

@ -339,6 +339,9 @@ Write_Disk(struct disk *d1)
#endif
#ifdef PC98
if (d1->bootipl)
write_block(fd,WHERE(0,d1),d1->bootipl);
mbr = read_block(fd,WHERE(1,d1));
memcpy(mbr+DOSPARTOFF,dp,sizeof *dp * NDOSPART);
/* XXX - for entire FreeBSD(98) */
@ -348,6 +351,10 @@ Write_Disk(struct disk *d1)
PC98_EntireDisk = 1;
if (PC98_EntireDisk == 0)
write_block(fd,WHERE(1,d1),mbr);
if (d1->bootmenu)
for (i = 0; i * 512 < d1->bootmenu_size; i++)
write_block(fd,WHERE(2+i,d1),&d1->bootmenu[i * 512]);
#else
mbr = read_block(fd,WHERE(0,d1));
if (d1->bootmgr)

View File

@ -66,6 +66,12 @@ makedevs.c: Makefile rtermcap keymap.h
echo "size_t boot0_size = sizeof(boot0);" >> makedevs.tmp
file2c 'u_char mbr[] = {' '};' < /boot/mbr >> makedevs.tmp
echo "size_t mbr_size = sizeof(mbr);" >> makedevs.tmp
.endif
.if ${MACHINE} == "pc98"
file2c 'u_char boot0[] = {' '};' < /boot/boot0 >> makedevs.tmp
echo "size_t boot0_size = sizeof(boot0);" >> makedevs.tmp
file2c 'u_char boot05[] = {' '};' < /boot/boot0.5 >> makedevs.tmp
echo "size_t boot05_size = sizeof(boot05);" >> makedevs.tmp
.endif
mv makedevs.tmp makedevs.c

View File

@ -163,7 +163,51 @@ print_command_summary()
move(0, 0);
}
#ifndef PC98
#ifdef PC98
static void
getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size,
u_char **bootmenu, size_t *bootmenu_size)
{
extern u_char boot0[];
extern size_t boot0_size;
extern u_char boot05[];
extern size_t boot05_size;
char str[80];
char *cp;
int i = 0;
cp = variable_get(VAR_BOOTMGR);
if (!cp) {
/* Figure out what kind of MBR the user wants */
sprintf(str, "Install Boot Manager for drive %s?", dname);
MenuMBRType.title = str;
i = dmenuOpenSimple(&MenuMBRType, FALSE);
} else {
if (!strncmp(cp, "boot", 4))
BootMgr = 0;
else
BootMgr = 2;
}
if (cp || i) {
switch (BootMgr) {
case 0:
*bootipl = boot0;
*bootipl_size = boot0_size;
*bootmenu = boot05;
*bootmenu_size = boot05_size;
return;
case 2:
default:
break;
}
}
*bootipl = NULL;
*bootipl_size = 0;
*bootmenu = NULL;
*bootmenu_size = 0;
}
#else
static void
getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize)
{
@ -236,7 +280,12 @@ diskPartition(Device *dev)
int rv, key = 0;
Boolean chunking;
char *msg = NULL;
#ifndef PC98
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
u_char *bootmenu;
size_t bootmenu_size;
#else
u_char *mbrContents;
size_t mbrSize;
#endif
@ -505,24 +554,41 @@ diskPartition(Device *dev)
"from this screen, you should do it from the label editor.\n\n"
"Are you absolutely sure you want to do this now?")) {
variable_set2(DISK_PARTITIONED, "yes", 0);
#ifndef PC98
/* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
* disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
* booteasy or a "standard" MBR -- both would be fatal in this case.
/*
* Don't trash the MBR if the first (and therefore only) chunk
* is marked for a truly dedicated disk (i.e., the disklabel
* starts at sector 0), even in cases where the user has
* requested booteasy or a "standard" MBR -- both would be
* fatal in this case.
*/
/*
* Don't offer to update the MBR on this disk if the first "real" chunk looks like
* a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
* Don't offer to update the MBR on this disk if the first
* "real" chunk looks like a FreeBSD "all disk" partition,
* or the disk is entirely FreeBSD.
*/
if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)))
#ifdef PC98
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1))
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
else {
bootipl = NULL;
bootipl_size = 0;
bootmenu = NULL;
bootmenu_size = 0;
}
Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size);
#else
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1))
getBootMgr(d->name, &mbrContents, &mbrSize);
else {
mbrContents = NULL;
mbrSize = 0;
}
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif /* !PC98 */
#endif
if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS)
msgConfirm("Disk partition write returned an error status!");
@ -549,30 +615,47 @@ diskPartition(Device *dev)
case '\033': /* ESC */
case 'Q':
chunking = FALSE;
#ifndef PC98
/* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
* disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
/*
* Don't trash the MBR if the first (and therefore only) chunk
* is marked for a truly dedicated disk (i.e., the disklabel
* starts at sector 0), even in cases where the user has requested
* booteasy or a "standard" MBR -- both would be fatal in this case.
*/
#if 0
if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
if (bootipl != NULL && bootmenu != NULL)
Set_Boot_Mgr(d, bootipl, bootipl_size,
bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
if (mbrContents != NULL)
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif
}
#else
/*
* Don't offer to update the MBR on this disk if the first "real" chunk looks like
* a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
* Don't offer to update the MBR on this disk if the first "real"
* chunk looks like a FreeBSD "all disk" partition, or the disk is
* entirely FreeBSD.
*/
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1)) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
if (bootipl != NULL && bootmenu != NULL)
Set_Boot_Mgr(d, bootipl, bootipl_size,
bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
if (mbrContents != NULL)
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif
}
#endif
#endif /* !PC98 */
break;
case 'Z':
@ -774,7 +857,12 @@ diskPartitionNonInteractive(Device *dev)
{
char *cp;
int i, sz, all_disk = 0;
#ifndef PC98
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
u_char *bootmenu;
size_t bootmenu_size;
#else
u_char *mbrContents;
size_t mbrSize;
#endif
@ -868,12 +956,16 @@ diskPartitionNonInteractive(Device *dev)
msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION);
return;
}
#ifndef PC98
if (!all_disk) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
Set_Boot_Mgr(d, mbrContents, mbrSize);
}
#endif
}
variable_set2(DISK_PARTITIONED, "yes", 0);
}
}

View File

@ -1209,8 +1209,10 @@ DMenu MenuMBRType = {
"drives",
{ { "BootMgr", "Install the FreeBSD Boot Manager",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr },
#ifndef PC98
{ "Standard", "Install a standard MBR (no boot manager)",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
#endif
{ "None", "Leave the Master Boot Record untouched",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
{ NULL } },

View File

@ -66,6 +66,12 @@ makedevs.c: Makefile rtermcap keymap.h
echo "size_t boot0_size = sizeof(boot0);" >> makedevs.tmp
file2c 'u_char mbr[] = {' '};' < /boot/mbr >> makedevs.tmp
echo "size_t mbr_size = sizeof(mbr);" >> makedevs.tmp
.endif
.if ${MACHINE} == "pc98"
file2c 'u_char boot0[] = {' '};' < /boot/boot0 >> makedevs.tmp
echo "size_t boot0_size = sizeof(boot0);" >> makedevs.tmp
file2c 'u_char boot05[] = {' '};' < /boot/boot0.5 >> makedevs.tmp
echo "size_t boot05_size = sizeof(boot05);" >> makedevs.tmp
.endif
mv makedevs.tmp makedevs.c

View File

@ -163,7 +163,51 @@ print_command_summary()
move(0, 0);
}
#ifndef PC98
#ifdef PC98
static void
getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size,
u_char **bootmenu, size_t *bootmenu_size)
{
extern u_char boot0[];
extern size_t boot0_size;
extern u_char boot05[];
extern size_t boot05_size;
char str[80];
char *cp;
int i = 0;
cp = variable_get(VAR_BOOTMGR);
if (!cp) {
/* Figure out what kind of MBR the user wants */
sprintf(str, "Install Boot Manager for drive %s?", dname);
MenuMBRType.title = str;
i = dmenuOpenSimple(&MenuMBRType, FALSE);
} else {
if (!strncmp(cp, "boot", 4))
BootMgr = 0;
else
BootMgr = 2;
}
if (cp || i) {
switch (BootMgr) {
case 0:
*bootipl = boot0;
*bootipl_size = boot0_size;
*bootmenu = boot05;
*bootmenu_size = boot05_size;
return;
case 2:
default:
break;
}
}
*bootipl = NULL;
*bootipl_size = 0;
*bootmenu = NULL;
*bootmenu_size = 0;
}
#else
static void
getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize)
{
@ -236,7 +280,12 @@ diskPartition(Device *dev)
int rv, key = 0;
Boolean chunking;
char *msg = NULL;
#ifndef PC98
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
u_char *bootmenu;
size_t bootmenu_size;
#else
u_char *mbrContents;
size_t mbrSize;
#endif
@ -505,24 +554,41 @@ diskPartition(Device *dev)
"from this screen, you should do it from the label editor.\n\n"
"Are you absolutely sure you want to do this now?")) {
variable_set2(DISK_PARTITIONED, "yes", 0);
#ifndef PC98
/* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
* disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
* booteasy or a "standard" MBR -- both would be fatal in this case.
/*
* Don't trash the MBR if the first (and therefore only) chunk
* is marked for a truly dedicated disk (i.e., the disklabel
* starts at sector 0), even in cases where the user has
* requested booteasy or a "standard" MBR -- both would be
* fatal in this case.
*/
/*
* Don't offer to update the MBR on this disk if the first "real" chunk looks like
* a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
* Don't offer to update the MBR on this disk if the first
* "real" chunk looks like a FreeBSD "all disk" partition,
* or the disk is entirely FreeBSD.
*/
if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)))
#ifdef PC98
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1))
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
else {
bootipl = NULL;
bootipl_size = 0;
bootmenu = NULL;
bootmenu_size = 0;
}
Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size);
#else
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1))
getBootMgr(d->name, &mbrContents, &mbrSize);
else {
mbrContents = NULL;
mbrSize = 0;
}
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif /* !PC98 */
#endif
if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS)
msgConfirm("Disk partition write returned an error status!");
@ -549,30 +615,47 @@ diskPartition(Device *dev)
case '\033': /* ESC */
case 'Q':
chunking = FALSE;
#ifndef PC98
/* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
* disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
/*
* Don't trash the MBR if the first (and therefore only) chunk
* is marked for a truly dedicated disk (i.e., the disklabel
* starts at sector 0), even in cases where the user has requested
* booteasy or a "standard" MBR -- both would be fatal in this case.
*/
#if 0
if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
if (bootipl != NULL && bootmenu != NULL)
Set_Boot_Mgr(d, bootipl, bootipl_size,
bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
if (mbrContents != NULL)
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif
}
#else
/*
* Don't offer to update the MBR on this disk if the first "real" chunk looks like
* a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
* Don't offer to update the MBR on this disk if the first "real"
* chunk looks like a FreeBSD "all disk" partition, or the disk is
* entirely FreeBSD.
*/
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1)) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
if (bootipl != NULL && bootmenu != NULL)
Set_Boot_Mgr(d, bootipl, bootipl_size,
bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
if (mbrContents != NULL)
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif
}
#endif
#endif /* !PC98 */
break;
case 'Z':
@ -774,7 +857,12 @@ diskPartitionNonInteractive(Device *dev)
{
char *cp;
int i, sz, all_disk = 0;
#ifndef PC98
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
u_char *bootmenu;
size_t bootmenu_size;
#else
u_char *mbrContents;
size_t mbrSize;
#endif
@ -868,12 +956,16 @@ diskPartitionNonInteractive(Device *dev)
msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION);
return;
}
#ifndef PC98
if (!all_disk) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
Set_Boot_Mgr(d, mbrContents, mbrSize);
}
#endif
}
variable_set2(DISK_PARTITIONED, "yes", 0);
}
}

View File

@ -1209,8 +1209,10 @@ DMenu MenuMBRType = {
"drives",
{ { "BootMgr", "Install the FreeBSD Boot Manager",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr },
#ifndef PC98
{ "Standard", "Install a standard MBR (no boot manager)",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
#endif
{ "None", "Leave the Master Boot Record untouched",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
{ NULL } },

View File

@ -66,6 +66,12 @@ makedevs.c: Makefile rtermcap keymap.h
echo "size_t boot0_size = sizeof(boot0);" >> makedevs.tmp
file2c 'u_char mbr[] = {' '};' < /boot/mbr >> makedevs.tmp
echo "size_t mbr_size = sizeof(mbr);" >> makedevs.tmp
.endif
.if ${MACHINE} == "pc98"
file2c 'u_char boot0[] = {' '};' < /boot/boot0 >> makedevs.tmp
echo "size_t boot0_size = sizeof(boot0);" >> makedevs.tmp
file2c 'u_char boot05[] = {' '};' < /boot/boot0.5 >> makedevs.tmp
echo "size_t boot05_size = sizeof(boot05);" >> makedevs.tmp
.endif
mv makedevs.tmp makedevs.c

View File

@ -163,7 +163,51 @@ print_command_summary()
move(0, 0);
}
#ifndef PC98
#ifdef PC98
static void
getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size,
u_char **bootmenu, size_t *bootmenu_size)
{
extern u_char boot0[];
extern size_t boot0_size;
extern u_char boot05[];
extern size_t boot05_size;
char str[80];
char *cp;
int i = 0;
cp = variable_get(VAR_BOOTMGR);
if (!cp) {
/* Figure out what kind of MBR the user wants */
sprintf(str, "Install Boot Manager for drive %s?", dname);
MenuMBRType.title = str;
i = dmenuOpenSimple(&MenuMBRType, FALSE);
} else {
if (!strncmp(cp, "boot", 4))
BootMgr = 0;
else
BootMgr = 2;
}
if (cp || i) {
switch (BootMgr) {
case 0:
*bootipl = boot0;
*bootipl_size = boot0_size;
*bootmenu = boot05;
*bootmenu_size = boot05_size;
return;
case 2:
default:
break;
}
}
*bootipl = NULL;
*bootipl_size = 0;
*bootmenu = NULL;
*bootmenu_size = 0;
}
#else
static void
getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize)
{
@ -236,7 +280,12 @@ diskPartition(Device *dev)
int rv, key = 0;
Boolean chunking;
char *msg = NULL;
#ifndef PC98
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
u_char *bootmenu;
size_t bootmenu_size;
#else
u_char *mbrContents;
size_t mbrSize;
#endif
@ -505,24 +554,41 @@ diskPartition(Device *dev)
"from this screen, you should do it from the label editor.\n\n"
"Are you absolutely sure you want to do this now?")) {
variable_set2(DISK_PARTITIONED, "yes", 0);
#ifndef PC98
/* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
* disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
* booteasy or a "standard" MBR -- both would be fatal in this case.
/*
* Don't trash the MBR if the first (and therefore only) chunk
* is marked for a truly dedicated disk (i.e., the disklabel
* starts at sector 0), even in cases where the user has
* requested booteasy or a "standard" MBR -- both would be
* fatal in this case.
*/
/*
* Don't offer to update the MBR on this disk if the first "real" chunk looks like
* a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
* Don't offer to update the MBR on this disk if the first
* "real" chunk looks like a FreeBSD "all disk" partition,
* or the disk is entirely FreeBSD.
*/
if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)))
#ifdef PC98
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1))
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
else {
bootipl = NULL;
bootipl_size = 0;
bootmenu = NULL;
bootmenu_size = 0;
}
Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size);
#else
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1))
getBootMgr(d->name, &mbrContents, &mbrSize);
else {
mbrContents = NULL;
mbrSize = 0;
}
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif /* !PC98 */
#endif
if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS)
msgConfirm("Disk partition write returned an error status!");
@ -549,30 +615,47 @@ diskPartition(Device *dev)
case '\033': /* ESC */
case 'Q':
chunking = FALSE;
#ifndef PC98
/* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
* disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
/*
* Don't trash the MBR if the first (and therefore only) chunk
* is marked for a truly dedicated disk (i.e., the disklabel
* starts at sector 0), even in cases where the user has requested
* booteasy or a "standard" MBR -- both would be fatal in this case.
*/
#if 0
if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
if (bootipl != NULL && bootmenu != NULL)
Set_Boot_Mgr(d, bootipl, bootipl_size,
bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
if (mbrContents != NULL)
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif
}
#else
/*
* Don't offer to update the MBR on this disk if the first "real" chunk looks like
* a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
* Don't offer to update the MBR on this disk if the first "real"
* chunk looks like a FreeBSD "all disk" partition, or the disk is
* entirely FreeBSD.
*/
if ((d->chunks->part->type != freebsd) ||
(d->chunks->part->offset > 1)) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
if (bootipl != NULL && bootmenu != NULL)
Set_Boot_Mgr(d, bootipl, bootipl_size,
bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
if (mbrContents != NULL)
Set_Boot_Mgr(d, mbrContents, mbrSize);
#endif
}
#endif
#endif /* !PC98 */
break;
case 'Z':
@ -774,7 +857,12 @@ diskPartitionNonInteractive(Device *dev)
{
char *cp;
int i, sz, all_disk = 0;
#ifndef PC98
#ifdef PC98
u_char *bootipl;
size_t bootipl_size;
u_char *bootmenu;
size_t bootmenu_size;
#else
u_char *mbrContents;
size_t mbrSize;
#endif
@ -868,12 +956,16 @@ diskPartitionNonInteractive(Device *dev)
msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION);
return;
}
#ifndef PC98
if (!all_disk) {
#ifdef PC98
getBootMgr(d->name, &bootipl, &bootipl_size,
&bootmenu, &bootmenu_size);
Set_Boot_Mgr(d, bootipl, bootipl_size, bootmenu, bootmenu_size);
#else
getBootMgr(d->name, &mbrContents, &mbrSize);
Set_Boot_Mgr(d, mbrContents, mbrSize);
}
#endif
}
variable_set2(DISK_PARTITIONED, "yes", 0);
}
}

View File

@ -1209,8 +1209,10 @@ DMenu MenuMBRType = {
"drives",
{ { "BootMgr", "Install the FreeBSD Boot Manager",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr },
#ifndef PC98
{ "Standard", "Install a standard MBR (no boot manager)",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
#endif
{ "None", "Leave the Master Boot Record untouched",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
{ NULL } },