Subject: Re: port-shark/35576 - Make sysinst clear MBR
To: None <gnats-bugs@NetBSD.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: port-arm
Date: 03/11/2007 21:02:49
--Apple-Mail-2--84842333
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed

Hi,

The attached patch for sysinst asks the user if he wants to clear the  
MBR and does so.  It also tells him how to configure the firmware to  
boot from the on-disk kernel.

But... I feel the question is useless.  Is it there any reason not to  
clear the MBR?  If there is not, I'll change the code to  
unconditionally clear it and only add a message at the end of the  
installation to tell the user what to do on the firmware.

Thanks.


--Apple-Mail-2--84842333
Content-Transfer-Encoding: quoted-printable
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name=sysinst.diff
Content-Disposition: attachment;
	filename=sysinst.diff

Index:=20arch/shark/md.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0ARCS=20file:=20=
/cvsroot/src/distrib/utils/sysinst/arch/shark/md.c,v=0Aretrieving=20=
revision=201.19=0Adiff=20-u=20-p=20-u=20-r1.19=20md.c=0A---=20=
arch/shark/md.c=095=20Apr=202006=2016:55:07=20-0000=091.19=0A+++=20=
arch/shark/md.c=0911=20Mar=202007=2020:00:06=20-0000=0A@@=20-53,6=20=
+53,31=20@@=0A=20#include=20"msg_defs.h"=0A=20#include=20"menu_defs.h"=0A=
=20=0A+/*=0A+=20*=20Clears=20the=20disk's=20first=20sector=20by=20=
writing=20all=20zeros=20over=20it.=0A+=20*=20Returns=200=20on=20success,=20=
-1=20on=20failure.=20=20Leaves=20the=20disk's=20path=20in=0A+=20*=20the=20=
output=20diskpath=20buffer=20for=20further=20usage=20in=20error=20=
messages.=0A+=20*/=0A+static=20int=0A+clear_mbr(const=20char=20*disk,=20=
char=20*diskpath,=20size_t=20diskpathlen)=0A+{=0A+=09int=20fd;=0A+=09=
char=20sector[512];=0A+=0A+=09fd=20=3D=20opendisk(disk,=20O_WRONLY,=20=
diskpath,=20diskpathlen,=200);=0A+=09if=20(fd=20<=200)=0A+=09=09return=20=
-1;=0A+=0A+=09memset(sector,=200,=20sizeof(sector));=0A+=09if=20=
(pwrite(fd,=20&sector,=20sizeof(sector),=200)=20<=200)=20{=0A+=09=09=
close(fd);=0A+=09=09return=20-1;=0A+=09}=0A+=0A+=09close(fd);=0A+=09=
return=200;=0A+}=0A+=0A=20int=0A=20md_get_info(void)=0A=20{=0A@@=20=
-109,6=20+134,18=20@@=20md_pre_disklabel(void)=0A=20int=0A=20=
md_post_disklabel(void)=0A=20{=0A+=0A+=09msg_display(MSG_clearmbr);=0A+=09=
process_menu(MENU_yesno,=20NULL);=0A+=09if=20(yesno)=20{=0A+=09=09char=20=
diskpath[MAXPATHLEN];=0A+=0A+=09=09if=20(clear_mbr(diskdev,=20diskpath,=20=
sizeof(diskpath))=20=3D=3D=20-1)=20{=0A+=09=09=09=
msg_display(MSG_badclearmbr,=20diskpath);=0A+=09=09=09=
process_menu(MENU_ok,=20NULL);=0A+=09=09}=0A+=09}=0A+=0A=20=09return=20=
0;=0A=20}=0A=20=0AIndex:=20arch/shark/msg.md.de=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0ARCS=20file:=20=
/cvsroot/src/distrib/utils/sysinst/arch/shark/msg.md.de,v=0Aretrieving=20=
revision=201.4=0Adiff=20-u=20-p=20-u=20-r1.4=20msg.md.de=0A---=20=
arch/shark/msg.md.de=0921=20Oct=202004=2012:14:22=20-0000=091.4=0A+++=20=
arch/shark/msg.md.de=0911=20Mar=202007=2020:00:06=20-0000=0A@@=20-81,3=20=
+81,28=20@@=20message=20arm32fspart=0A=20=0A=20message=20set_kernel_1=0A=20=
{Kernel=20(GENERIC)}=0A+=0A+message=20clearmbr=0A+{The=20DNARD's=20=
firmware=20can=20load=20a=20NetBSD=20kernel=20straight=20from=20a=20FFS=20=
partition=0A+on=20the=20local=20hard=20disk.=20=20However,=20it=20will=20=
not=20recognize=20the=20disk=20as=20bootable=0A+if=20it=20has=20an=20=
i386-like=20MBR=20on=20the=20first=20sector.=0A+=0A+Furthermore,=20to=20=
automatically=20boot=20the=20system=20from=20the=20disk=20you=20will=20=
need=20to=0A+manually=20run=20the=20following=20command=20from=20=
OpenFirmare's=20shell,=20unless=20it=20is=0A+already=20configured=20=
appropriately:=0A+=0A+setenv=20boot-device=20disk:\\netbsd.aout=0A+=0A=
+Do=20you=20want=20me=20to=20clear=20the=20first=20sector=20to=20ensure=20=
the=20disk=20is=20bootable?=0A+Note=20that=20the=20firmware's=20=
configuration=20will=20be=20left=20untouched.=0A+=0A+}=0A+=0A+message=20=
badclearmbr=0A+{Failed=20to=20clear=20the=20disk's=20first=20sector.=20=20=
If=20the=20firmware=20cannot=20see=20the=0A+disk,=20try=20to=20run=20the=20=
following=20command=20manually=20from=20the=20installer's=20shell=0A=
+utility:=0A+=0A+dd=20if=3D/dev/zero=20of=3D%s=20bs=3D512=20count=3D1=0A=
+=0A+}=0AIndex:=20arch/shark/msg.md.en=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0ARCS=20file:=20=
/cvsroot/src/distrib/utils/sysinst/arch/shark/msg.md.en,v=0Aretrieving=20=
revision=201.6=0Adiff=20-u=20-p=20-u=20-r1.6=20msg.md.en=0A---=20=
arch/shark/msg.md.en=0912=20Jun=202003=2011:20:13=20-0000=091.6=0A+++=20=
arch/shark/msg.md.en=0911=20Mar=202007=2020:00:06=20-0000=0A@@=20-77,3=20=
+77,28=20@@=20message=20arm32fspart=0A=20=0A=20message=20set_kernel_1=0A=20=
{Kernel=20(GENERIC)}=0A+=0A+message=20clearmbr=0A+{The=20DNARD's=20=
firmware=20can=20load=20a=20NetBSD=20kernel=20straight=20from=20a=20FFS=20=
partition=0A+on=20the=20local=20hard=20disk.=20=20However,=20it=20will=20=
not=20recognize=20the=20disk=20as=20bootable=0A+if=20it=20has=20an=20=
i386-like=20MBR=20on=20the=20first=20sector.=0A+=0A+Furthermore,=20to=20=
automatically=20boot=20the=20system=20from=20the=20disk=20you=20will=20=
need=20to=0A+manually=20run=20the=20following=20command=20from=20=
OpenFirmare's=20shell,=20unless=20it=20is=0A+already=20configured=20=
appropriately:=0A+=0A+setenv=20boot-device=20disk:\\netbsd.aout=0A+=0A=
+Do=20you=20want=20me=20to=20clear=20the=20first=20sector=20to=20ensure=20=
the=20disk=20is=20bootable?=0A+Note=20that=20the=20firmware's=20=
configuration=20will=20be=20left=20untouched.=0A+=0A+}=0A+=0A+message=20=
badclearmbr=0A+{Failed=20to=20clear=20the=20disk's=20first=20sector.=20=20=
If=20the=20firmware=20cannot=20see=20the=0A+disk,=20try=20to=20run=20the=20=
following=20command=20manually=20from=20the=20installer's=20shell=0A=
+utility:=0A+=0A+dd=20if=3D/dev/zero=20of=3D%s=20bs=3D512=20count=3D1=0A=
+=0A+}=0AIndex:=20arch/shark/msg.md.es=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0ARCS=20file:=20=
/cvsroot/src/distrib/utils/sysinst/arch/shark/msg.md.es,v=0Aretrieving=20=
revision=201.2=0Adiff=20-u=20-p=20-u=20-r1.2=20msg.md.es=0A---=20=
arch/shark/msg.md.es=0926=20Aug=202005=2016:32:33=20-0000=091.2=0A+++=20=
arch/shark/msg.md.es=0911=20Mar=202007=2020:00:06=20-0000=0A@@=20-80,3=20=
+80,29=20@@=20Compensaci=F3n=20en=20%s):=0A=20=0A=20message=20=
set_kernel_1=0A=20{N=FAcleo=20(GENERIC)}=0A+=0A+message=20clearmbr=0A=
+{El=20firmware=20del=20DNARD=20puede=20cargar=20el=20n=FAcleo=20de=20=
NetBSD=20directamente=20desde=0A+una=20partici=F3n=20FFS=20del=20disco=20=
local.=20=20A=FAn=20as=ED,=20no=20reconocer=E1=20el=20disco=20como=0A=
+arrancable=20si=20=E9ste=20tiene=20un=20MBR=20del=20estilo=20de=20las=20=
m=E1quinas=20i386=20en=20el=20primer=0A+sector=20del=20disco.=0A+=0A=
+Adem=E1s,=20para=20conseguir=20que=20el=20sistema=20arranque=20desde=20=
disco=20deber=E1=20ejecutar=0A+manualmente=20el=20siguiente=20comando=20=
desde=20la=20interfaz=20de=20OpenFirmware,=20a=20no=20ser=0A+que=20ya=20=
se=20encuentre=20configurado=20de=20la=20forma=20adecuada:=0A+=0A+setenv=20=
boot-device=20disk:\\netbsd.aout=0A+=0A+Desea=20que=20borre=20el=20=
primer=20sector=20del=20disco=20para=20asegurarse=20de=20que=20ser=E1=0A=
+arrancable?=20=20Recuerde=20que=20no=20se=20modificar=E1=20la=20=
configuraci=F3n=20del=20firmware.=0A+=0A+}=0A+=0A+message=20badclearmbr=0A=
+{Ha=20ocurrido=20un=20error=20al=20intentar=20borrar=20el=20primer=20=
sector=20del=20disco.=20=20Si=20el=0A+firmware=20no=20puede=20verlo,=20=
pruebe=20a=20ejecutar=20el=20siguiente=20comando=20manualmente=0A+desde=20=
la=20linea=20de=20comandos=20de=20la=20utilidad=20de=20instalaci=F3n:=0A=
+=0A+dd=20if=3D/dev/zero=20of=3D%s=20bs=3D512=20count=3D1=0A+=0A+}=0A=
Index:=20arch/shark/msg.md.fr=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0ARCS=20file:=20=
/cvsroot/src/distrib/utils/sysinst/arch/shark/msg.md.fr,v=0Aretrieving=20=
revision=201.6=0Adiff=20-u=20-p=20-u=20-r1.6=20msg.md.fr=0A---=20=
arch/shark/msg.md.fr=0912=20Jun=202003=2011:20:13=20-0000=091.6=0A+++=20=
arch/shark/msg.md.fr=0911=20Mar=202007=2020:00:06=20-0000=0A@@=20-82,3=20=
+82,27=20@@=20message=20arm32fspart=0A=20message=20set_kernel_1=0A=20=
{Kernel=20(GENERIC)}=0A=20=0A+message=20clearmbr=0A+{The=20DNARD's=20=
firmware=20can=20load=20a=20NetBSD=20kernel=20straight=20from=20a=20FFS=20=
partition=0A+on=20the=20local=20hard=20disk.=20=20However,=20it=20will=20=
not=20recognize=20the=20disk=20as=20bootable=0A+if=20it=20has=20an=20=
i386-like=20MBR=20on=20the=20first=20sector.=0A+=0A+Furthermore,=20to=20=
automatically=20boot=20the=20system=20from=20the=20disk=20you=20will=20=
need=20to=0A+manually=20run=20the=20following=20command=20from=20=
OpenFirmare's=20shell,=20unless=20it=20is=0A+already=20configured=20=
appropriately:=0A+=0A+setenv=20boot-device=20disk:\\netbsd.aout=0A+=0A=
+Do=20you=20want=20me=20to=20clear=20the=20first=20sector=20to=20ensure=20=
the=20disk=20is=20bootable?=0A+Note=20that=20the=20firmware's=20=
configuration=20will=20be=20left=20untouched.=0A+=0A+}=0A+=0A+message=20=
badclearmbr=0A+{Failed=20to=20clear=20the=20disk's=20first=20sector.=20=20=
If=20the=20firmware=20cannot=20see=20the=0A+disk,=20try=20to=20run=20the=20=
following=20command=20manually=20from=20the=20installer's=20shell=0A=
+utility:=0A+=0A+dd=20if=3D/dev/zero=20of=3D%s=20bs=3D512=20count=3D1=0A=
+=0A+}=0AIndex:=20arch/shark/msg.md.pl=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0ARCS=20file:=20=
/cvsroot/src/distrib/utils/sysinst/arch/shark/msg.md.pl,v=0Aretrieving=20=
revision=201.5=0Adiff=20-u=20-p=20-u=20-r1.5=20msg.md.pl=0A---=20=
arch/shark/msg.md.pl=0912=20Jun=202003=2011:20:13=20-0000=091.5=0A+++=20=
arch/shark/msg.md.pl=0911=20Mar=202007=2020:00:06=20-0000=0A@@=20-80,3=20=
+80,27=20@@=20message=20arm32fspart=0A=20message=20set_kernel_1=0A=20=
{Kernel=20(GENERIC)}=0A=20=0A+message=20clearmbr=0A+{The=20DNARD's=20=
firmware=20can=20load=20a=20NetBSD=20kernel=20straight=20from=20a=20FFS=20=
partition=0A+on=20the=20local=20hard=20disk.=20=20However,=20it=20will=20=
not=20recognize=20the=20disk=20as=20bootable=0A+if=20it=20has=20an=20=
i386-like=20MBR=20on=20the=20first=20sector.=0A+=0A+Furthermore,=20to=20=
automatically=20boot=20the=20system=20from=20the=20disk=20you=20will=20=
need=20to=0A+manually=20run=20the=20following=20command=20from=20=
OpenFirmare's=20shell,=20unless=20it=20is=0A+already=20configured=20=
appropriately:=0A+=0A+setenv=20boot-device=20disk:\\netbsd.aout=0A+=0A=
+Do=20you=20want=20me=20to=20clear=20the=20first=20sector=20to=20ensure=20=
the=20disk=20is=20bootable?=0A+Note=20that=20the=20firmware's=20=
configuration=20will=20be=20left=20untouched.=0A+=0A+}=0A+=0A+message=20=
badclearmbr=0A+{Failed=20to=20clear=20the=20disk's=20first=20sector.=20=20=
If=20the=20firmware=20cannot=20see=20the=0A+disk,=20try=20to=20run=20the=20=
following=20command=20manually=20from=20the=20installer's=20shell=0A=
+utility:=0A+=0A+dd=20if=3D/dev/zero=20of=3D%s=20bs=3D512=20count=3D1=0A=
+=0A+}=0A=

--Apple-Mail-2--84842333
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed



-- 
Julio M. Merino Vidal <jmmv84@gmail.com>



--Apple-Mail-2--84842333--