1994-10-19 23:58:03 +00:00
/*
* Copyright ( c ) 1994 , Paul Richards .
*
* All rights reserved .
*
* This software may be used , modified , copied , distributed , and
* sold , in both source and binary form provided that the above
* copyright and these terms are retained , verbatim , as the first
* lines of this file . Under no circumstances is the author
* responsible for the proper functioning of this software , nor does
* the author assume any responsibility for damages incurred with
* its use .
*/
# include <stdio.h>
1994-10-21 18:08:33 +00:00
# include <unistd.h>
# include <dialog.h>
# include <fcntl.h>
1994-11-18 18:13:13 +00:00
# include <fstab.h>
1994-10-21 18:08:33 +00:00
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
# ifdef __i386__ /* temp measure delete nov 15 1994 */
# define i386 1
# else
# warning FOO
# endif
1994-10-19 23:58:03 +00:00
# include <sys/types.h>
1994-11-18 18:13:13 +00:00
# include <sys/devconf.h>
1994-10-19 23:58:03 +00:00
# include <sys/disklabel.h>
# include <sys/uio.h>
1994-10-21 18:08:33 +00:00
# include "sysinstall.h"
1994-11-18 18:13:13 +00:00
# include "disk.h"
# include "editor.h"
# include "mbr.h"
1994-10-19 23:58:03 +00:00
1994-11-18 18:13:13 +00:00
char * part_type ( int ) ;
int write_mbr ( char * , struct mbr * ) ;
int read_mbr ( char * , struct mbr * ) ;
void show_mbr ( struct mbr * ) ;
int clear_mbr ( struct mbr * , char * ) ;
int build_mbr ( struct mbr * , char * , struct disklabel * ) ;
extern char boot1 [ ] ;
extern struct disk disk_list [ ] ;
1994-10-19 23:58:03 +00:00
struct part_type part_types [ ] = PARTITION_TYPES
1994-11-18 18:13:13 +00:00
struct field * last_field ;
1994-10-19 23:58:03 +00:00
char *
part_type ( int type )
{
1994-11-02 08:15:46 +00:00
int num_types = ( sizeof ( part_types ) / sizeof ( struct part_type ) ) ;
int next_type = 0 ;
struct part_type * ptr = part_types ;
while ( next_type < num_types ) {
if ( ptr - > type = = type )
return ( ptr - > name ) ;
ptr + + ;
next_type + + ;
}
return ( " Unknown " ) ;
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
}
1994-11-18 18:13:13 +00:00
int
read_mbr ( char * device , struct mbr * mbr )
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
{
1994-11-18 18:13:13 +00:00
int fd ;
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
1994-11-18 18:13:13 +00:00
if ( ( fd = open ( device , O_RDONLY ) ) = = - 1 ) {
sprintf ( errmsg ,
" Couldn't open device %s to read master boot record \n " ,
device ) ;
return ( - 1 ) ;
}
1994-11-08 10:14:19 +00:00
1994-11-18 18:13:13 +00:00
if ( lseek ( fd , 0 , SEEK_SET ) = = - 1 ) {
sprintf ( errmsg ,
" Couldn't seek to track 0 of device %s to read master boot record \n " ,
device ) ;
return ( - 1 ) ;
}
1994-10-19 23:58:03 +00:00
1994-11-18 18:13:13 +00:00
if ( read ( fd , & ( mbr - > bootcode ) , MBRSIZE ) = = - 1 ) {
sprintf ( errmsg , " Failed to read master boot record from device %s \n " ,
device ) ;
return ( - 1 ) ;
}
1994-11-18 11:30:04 +00:00
1994-11-18 18:13:13 +00:00
if ( close ( fd ) = = - 1 ) {
sprintf ( errmsg ,
" Couldn't close device %s after reading master boot record \n " ,
device ) ;
return ( - 1 ) ;
}
return ( 0 ) ;
1994-11-18 11:30:04 +00:00
}
1994-10-19 23:58:03 +00:00
int
1994-11-18 18:13:13 +00:00
write_mbr ( char * device , struct mbr * mbr )
1994-10-19 23:58:03 +00:00
{
1994-11-18 18:13:13 +00:00
int fd ;
1994-10-19 23:58:03 +00:00
1994-11-18 18:13:13 +00:00
if ( ( fd = open ( device , O_WRONLY ) ) = = - 1 ) {
sprintf ( errmsg ,
" Couldn't open device %s to write master boot record \n " ,
device ) ;
return ( - 1 ) ;
}
1994-10-19 23:58:03 +00:00
1994-11-18 18:13:13 +00:00
if ( lseek ( fd , 0 , SEEK_SET ) = = - 1 ) {
sprintf ( errmsg ,
" Couldn't seek to track 0 of device %s to write master boot record \n " ,
device ) ;
return ( - 1 ) ;
1994-10-19 23:58:03 +00:00
}
1994-11-02 08:15:46 +00:00
1994-11-18 18:13:13 +00:00
if ( enable_label ( fd ) = = - 1 ) {
sprintf ( errmsg ,
" Couldn't write enable MBR area of device %s \n " ,
device ) ;
return ( - 1 ) ;
}
if ( write ( fd , mbr - > bootcode , MBRSIZE ) = = - 1 ) {
sprintf ( errmsg , " Failed to write master boot record to device %s \n " ,
device ) ;
return ( - 1 ) ;
}
if ( disable_label ( fd ) = = - 1 ) {
sprintf ( errmsg ,
" Couldn't write disable MBR area of device %s \n " ,
device ) ;
return ( - 1 ) ;
}
if ( close ( fd ) = = - 1 ) {
sprintf ( errmsg ,
" Couldn't close device %s after reading master boot record \n " ,
device ) ;
return ( - 1 ) ;
}
return ( 0 ) ;
1994-10-19 23:58:03 +00:00
}
1994-10-21 18:08:33 +00:00
int
clear_mbr ( struct mbr * mbr , char * bootcode )
1994-10-19 23:58:03 +00:00
{
1994-11-02 08:15:46 +00:00
int i ;
int fd ;
/*
1994-11-19 05:20:13 +00:00
* Must replace any old bootcode that was read
* from disk with our bootblocks .
1994-11-02 08:15:46 +00:00
*/
1994-11-19 05:20:13 +00:00
TellEm ( " Loading MBR code from %s " , bootcode ) ;
fd = open ( bootcode , O_RDONLY ) ;
if ( fd < 0 ) {
sprintf ( errmsg , " Couldn't open boot file %s \n " , bootcode ) ;
return ( - 1 ) ;
}
1994-11-02 08:15:46 +00:00
1994-11-19 05:20:13 +00:00
if ( read ( fd , mbr - > bootcode , MBRSIZE ) < 0 ) {
sprintf ( errmsg , " Couldn't read from boot file %s \n " , bootcode ) ;
return ( - 1 ) ;
}
1994-11-02 08:15:46 +00:00
1994-11-19 05:20:13 +00:00
if ( close ( fd ) = = - 1 ) {
sprintf ( errmsg , " Couldn't close boot file %s \n " , bootcode ) ;
return ( - 1 ) ;
}
1994-11-02 08:15:46 +00:00
1994-11-19 05:20:13 +00:00
/* Create an empty partition table */
for ( i = 0 ; i < NDOSPART ; i + + ) {
mbr - > dospart [ i ] . dp_flag = 0 ;
mbr - > dospart [ i ] . dp_shd = 0 ;
mbr - > dospart [ i ] . dp_ssect = 0 ;
mbr - > dospart [ i ] . dp_scyl = 0 ;
mbr - > dospart [ i ] . dp_typ = 0 ;
mbr - > dospart [ i ] . dp_ehd = 0 ;
mbr - > dospart [ i ] . dp_esect = 0 ;
mbr - > dospart [ i ] . dp_ecyl = 0 ;
mbr - > dospart [ i ] . dp_start = 0 ;
mbr - > dospart [ i ] . dp_size = 0 ;
}
1994-11-18 18:13:13 +00:00
1994-11-19 05:20:13 +00:00
mbr - > magic = MBR_MAGIC ;
dialog_clear ( ) ;
return ( 0 ) ;
1994-10-19 23:58:03 +00:00
}
int
1994-11-18 18:13:13 +00:00
dedicated_mbr ( struct mbr * mbr , char * bootcode , struct disklabel * lbl )
1994-10-19 23:58:03 +00:00
{
1994-11-18 18:13:13 +00:00
struct dos_partition * dp = & mbr - > dospart [ 0 ] ;
1994-11-02 08:15:46 +00:00
if ( clear_mbr ( mbr , bootcode ) = = - 1 )
1994-11-18 18:13:13 +00:00
return ( - 1 ) ;
1994-11-02 08:15:46 +00:00
dp - > dp_scyl = 0 ;
dp - > dp_shd = 1 ;
dp - > dp_ssect = 1 ;
1994-11-18 18:13:13 +00:00
dp - > dp_ecyl = lbl - > d_ncylinders - 1 ;
dp - > dp_ehd = lbl - > d_ntracks - 1 ;
dp - > dp_esect = lbl - > d_nsectors ;
dp - > dp_start = ( dp - > dp_scyl * lbl - > d_ntracks * lbl - > d_nsectors ) +
( dp - > dp_shd * lbl - > d_nsectors ) +
dp - > dp_ssect - 1 ;
1994-11-02 08:15:46 +00:00
dp - > dp_size =
1994-11-18 18:13:13 +00:00
( lbl - > d_nsectors * lbl - > d_ntracks * lbl - > d_ncylinders ) - dp - > dp_start ;
1994-11-02 08:15:46 +00:00
1994-11-19 05:20:13 +00:00
dp - > dp_typ = MBR_PTYPE_FreeBSD ;
1994-11-18 18:13:13 +00:00
dp - > dp_flag = ACTIVE ;
return ( 0 ) ;
1994-10-19 23:58:03 +00:00
}
1994-11-18 18:13:13 +00:00
int
get_geom_values ( int disk )
1994-10-19 23:58:03 +00:00
{
1994-11-18 18:13:13 +00:00
WINDOW * window ;
struct disklabel * lbl = & disk_list [ disk ] . lbl ;
int key = 0 ;
int cur_field = 0 ;
int next = 0 ;
struct field field [ ] = {
1994-11-18 19:29:01 +00:00
{ 2 , 28 , 06 , 10 , 01 , 02 , 01 , - 1 , 01 , " Unset " } ,
{ 4 , 28 , 06 , 10 , 02 , 00 , 02 , - 1 , 02 , " Unset " } ,
{ 6 , 28 , 06 , 10 , 00 , 01 , 00 , - 1 , 00 , " Unset " } ,
{ 0 , 07 , 24 , 24 , - 1 , - 1 , - 1 , - 1 , - 1 , " BIOS geometry parameters " } ,
{ 2 , 02 , 20 , 20 , - 1 , - 1 , - 1 , - 1 , - 1 , " Number of cylinders: " } ,
{ 4 , 02 , 25 , 25 , - 1 , - 1 , - 1 , - 1 , - 1 , " Number of tracks (heads): " } ,
{ 6 , 02 , 18 , 18 , - 1 , - 1 , - 1 , - 1 , - 1 , " Number of sectors: " }
1994-11-18 18:13:13 +00:00
} ;
if ( ! ( window = newwin ( 10 , 40 , 5 , 20 ) ) ) {
sprintf ( errmsg , " Failed to open window for geometry editor " ) ;
return ( - 1 ) ;
} ;
keypad ( window , TRUE ) ;
1994-11-19 00:09:00 +00:00
dialog_clear_norefresh ( ) ;
1994-11-18 18:13:13 +00:00
draw_box ( window , 0 , 0 , 9 , 40 , dialog_attr , border_attr ) ;
while ( key ! = ESC ) {
sprintf ( field [ 0 ] . field , " %ld " , lbl - > d_ncylinders ) ;
sprintf ( field [ 1 ] . field , " %ld " , lbl - > d_ntracks ) ;
sprintf ( field [ 2 ] . field , " %ld " , lbl - > d_nsectors ) ;
disp_fields ( window , field , sizeof ( field ) / sizeof ( struct field ) ) ;
1994-11-19 05:20:13 +00:00
key = edit_line ( window , field [ cur_field ] . y , field [ cur_field ] . x ,
field [ cur_field ] . field , field [ cur_field ] . width ,
field [ cur_field ] . maxlen ) ;
1994-11-18 18:13:13 +00:00
next = change_field ( field [ cur_field ] , key ) ;
if ( next = = - 1 )
beep ( ) ;
else
cur_field = next ;
lbl - > d_ncylinders = atoi ( field [ 0 ] . field ) ;
lbl - > d_ntracks = atoi ( field [ 1 ] . field ) ;
lbl - > d_nsectors = atoi ( field [ 2 ] . field ) ;
}
delwin ( window ) ;
refresh ( ) ;
return ( 0 ) ;
1994-10-19 23:58:03 +00:00
}
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
1994-11-18 18:13:13 +00:00
int
edit_mbr ( int disk )
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
{
1994-11-18 18:13:13 +00:00
WINDOW * window ;
int cur_field ;
int i ;
int ok ;
int next ;
int key = 0 ;
struct mbr * mbr = & disk_list [ disk ] . mbr ;
/* Confirm disk parameters */
1994-11-18 19:29:01 +00:00
# ifdef 0
1994-11-19 05:20:13 +00:00
dialog_msgbox ( " \n BIOS disk geometry values " , " In order to setup the boot area of the disk it is necessary to know the BIOS values for the disk geometry i.e. the number of cylinders, heads and sectors. These values may be different form the real geometry of the disk, depending on whether or not your system uses geometry translation. At this stage it is the entries from the BIOS that are needed. If you do not know these they can be found by rebooting the machine and entering th BIOS setup routine. See you BIOS manual for details. \n " , - 1 , - 1 , 1 )
1994-11-18 19:29:01 +00:00
# endif
1994-11-18 18:13:13 +00:00
if ( get_geom_values ( disk ) = = - 1 )
return ( - 1 ) ;
/* Read MBR from disk */
sprintf ( scratch , " /dev/r%s%dd " , disk_list [ disk ] . devconf - > dc_name ,
disk_list [ disk ] . devconf - > dc_unit ) ;
if ( read_mbr ( scratch , & disk_list [ disk ] . mbr ) = = - 1 ) {
sprintf ( scratch , " The following error occured while trying \n to read the master boot record: \n \n %s \n In order to install FreeBSD a new master boot record \n will have to be written which will mean all current \n data on the hard disk will be lost. " , errmsg ) ;
ok = 0 ;
while ( ! ok ) {
AskAbort ( scratch ) ;
if ( ! dialog_yesno ( TITLE ,
1994-11-19 05:20:13 +00:00
" \n Are you sure you wish to proceed ? \n " ,
- 1 , - 1 ) ) {
dialog_clear ( ) ;
1994-11-18 18:13:13 +00:00
if ( dedicated_mbr ( mbr , boot1 , & disk_list [ disk ] . lbl ) = = - 1 ) {
1994-11-19 05:20:13 +00:00
sprintf ( scratch , " \n Couldn't create new master boot record. \n \n %s " , errmsg ) ;
1994-11-18 18:13:13 +00:00
return ( - 1 ) ;
}
ok = 1 ;
}
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
}
}
1994-11-18 18:13:13 +00:00
1994-11-19 05:20:13 +00:00
sprintf ( scratch , " \n Do you wish to dedicate the whole disk to FreeBSD? \n \n Doing so will overwrite any existing data on the disk. \n " ) ;
1994-11-19 00:09:00 +00:00
dialog_clear_norefresh ( ) ;
if ( ! dialog_yesno ( TITLE , scratch , - 1 , - 1 ) )
1994-11-18 18:13:13 +00:00
if ( dedicated_mbr ( mbr , boot1 , & disk_list [ disk ] . lbl ) = = - 1 ) {
1994-11-19 05:20:13 +00:00
sprintf ( scratch , " \n Couldn't dedicate disk to FreeBSD. \n \n %s " , errmsg ) ;
1994-11-18 18:13:13 +00:00
return ( - 1 ) ;
}
if ( ! ( window = newwin ( 24 , 79 , 0 , 0 ) ) ) {
sprintf ( errmsg , " Failed to open window for MBR editor \n " ) ;
return ( - 1 ) ;
} ;
keypad ( window , TRUE ) ;
1994-11-19 00:09:00 +00:00
dialog_clear_norefresh ( ) ;
1994-11-18 18:13:13 +00:00
draw_box ( window , 0 , 0 , 24 , 79 , dialog_attr , border_attr ) ;
cur_field = 1 ;
while ( key ! = ESC ) {
for ( i = 0 ; i < NDOSPART ; i + + ) {
sprintf ( mbr_field [ ( i * 12 ) + 1 ] . field , " %s " , part_type ( mbr - > dospart [ i ] . dp_typ ) ) ;
sprintf ( mbr_field [ ( i * 12 ) + 2 ] . field , " %ld " , mbr - > dospart [ i ] . dp_start ) ;
sprintf ( mbr_field [ ( i * 12 ) + 3 ] . field , " %d " , mbr - > dospart [ i ] . dp_scyl ) ;
sprintf ( mbr_field [ ( i * 12 ) + 4 ] . field , " %d " , mbr - > dospart [ i ] . dp_shd ) ;
sprintf ( mbr_field [ ( i * 12 ) + 5 ] . field , " %d " , mbr - > dospart [ i ] . dp_ssect ) ;
sprintf ( mbr_field [ ( i * 12 ) + 6 ] . field , " %d " , 0 ) ;
sprintf ( mbr_field [ ( i * 12 ) + 7 ] . field , " %d " , mbr - > dospart [ i ] . dp_ecyl ) ;
sprintf ( mbr_field [ ( i * 12 ) + 8 ] . field , " %d " , mbr - > dospart [ i ] . dp_ehd ) ;
sprintf ( mbr_field [ ( i * 12 ) + 9 ] . field , " %d " , mbr - > dospart [ i ] . dp_esect ) ;
sprintf ( mbr_field [ ( i * 12 ) + 10 ] . field , " %ld " , mbr - > dospart [ i ] . dp_size ) ;
sprintf ( mbr_field [ ( i * 12 ) + 11 ] . field , " %d " , sectstoMb ( mbr - > dospart [ i ] . dp_size , 512 ) ) ;
sprintf ( mbr_field [ ( i * 12 ) + 12 ] . field , " %d " , mbr - > dospart [ i ] . dp_flag ) ;
}
disp_fields ( window , mbr_field , sizeof ( mbr_field ) / sizeof ( struct field ) ) ;
1994-11-19 05:20:13 +00:00
switch ( mbr_field [ cur_field ] . type ) {
case F_EDIT :
key = edit_line ( window , mbr_field [ cur_field ] . y ,
mbr_field [ cur_field ] . x ,
mbr_field [ cur_field ] . field , mbr_field [ cur_field ] . width ,
mbr_field [ cur_field ] . maxlen ) ;
/* Propagate changes to MBR */
for ( i = 0 ; i < NDOSPART ; i + + ) {
mbr - > dospart [ i ] . dp_start = atoi ( mbr_field [ ( i * 12 ) + 2 ] . field ) ;
mbr - > dospart [ i ] . dp_scyl = atoi ( mbr_field [ ( i * 12 ) + 3 ] . field ) ;
mbr - > dospart [ i ] . dp_shd = atoi ( mbr_field [ ( i * 12 ) + 4 ] . field ) ;
mbr - > dospart [ i ] . dp_ssect = atoi ( mbr_field [ ( i * 12 ) + 5 ] . field ) ;
mbr - > dospart [ i ] . dp_ecyl = atoi ( mbr_field [ ( i * 12 ) + 7 ] . field ) ;
mbr - > dospart [ i ] . dp_ehd = atoi ( mbr_field [ ( i * 12 ) + 8 ] . field ) ;
mbr - > dospart [ i ] . dp_esect = atoi ( mbr_field [ ( i * 12 ) + 9 ] . field ) ;
mbr - > dospart [ i ] . dp_size = atoi ( mbr_field [ ( i * 12 ) + 10 ] . field ) ;
}
next = change_field ( mbr_field [ cur_field ] , key ) ;
if ( next = = - 1 )
beep ( ) ;
else
cur_field = next ;
break ;
case F_TITLE :
default :
break ;
1994-11-18 18:13:13 +00:00
}
1994-11-19 05:20:13 +00:00
}
1994-11-18 18:13:13 +00:00
1994-11-19 05:20:13 +00:00
sprintf ( scratch , " \n Writing a new master boot record can erase the current disk contents. \n \n Are you sure you want to write the new MBR? \n " ) ;
1994-11-19 00:09:00 +00:00
dialog_clear_norefresh ( ) ;
if ( ! dialog_yesno ( " Write new MBR? " , scratch , - 1 , - 1 ) ) {
1994-11-18 18:13:13 +00:00
sprintf ( scratch , " /dev/r%s%dd " , disk_list [ disk ] . devconf - > dc_name ,
disk_list [ disk ] . devconf - > dc_unit ) ;
if ( write_mbr ( scratch , mbr ) = = - 1 ) {
1994-11-19 05:20:13 +00:00
sprintf ( scratch , " \n The following error occured while trying to write the new MBR. \n \n %s " , errmsg ) ;
1994-11-18 18:13:13 +00:00
return ( - 1 ) ;
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
}
}
1994-11-18 19:29:01 +00:00
1994-11-19 05:20:13 +00:00
/* Find first FreeBSD partition, as kernel would upon boot */
disk_list [ disk ] . inst_part = - 1 ;
for ( i = 0 ; i < NDOSPART ; i + + )
if ( mbr - > dospart [ i ] . dp_typ = = MBR_PTYPE_FreeBSD ) {
disk_list [ disk ] . inst_part = i ;
break ;
}
if ( disk_list [ disk ] . inst_part = = - 1 ) {
sprintf ( errmsg , " \n There is no space allocated to FreeBSD on %s \n " ,
diskname ( disk ) ) ;
return ( - 1 ) ;
}
1994-11-18 19:29:01 +00:00
delwin ( window ) ;
1994-11-18 18:13:13 +00:00
dialog_clear ( ) ;
return ( 0 ) ;
Public apology:
I have walked all over Paul Richards code again, and severely lobotomized
some of his stuff, in order to cut some corners for the 2.0-Alpha release.
I belive that we can now manipulate fdisk and disklabel-stuff sufficiently
for the release to actually be produced.
It's not that I don't like Paul and his code, I just need something I
can kick out of the door RSN.
Sysinstall is now under absolute code-freeze, only Jordan has my permission
to commit to this code (stage0 & 5). I would appreciate if everybody
else would finds problems in sysinstall send patches to me, and I will
commit them. THANKYOU.
The fdisk/disklabel editors are made in pure ncurses, and follow a model
"a`la spreadsheet".
There are some important functions which are missing still, and I would
appreciate if somebody would look at them.
The FDISK part needs a "whole-disk" option, and it needs a "rewrite
MBR-boot code" option.
The DISKLABEL part needs to be able to "import DOS-partition".
Both need a "HELP" function, (display a file "/HELP" using dialog is OK).
It seems to me like the wd.c and sd.c should reread the physical record
when a DIOCGDINFO is made, so that they can pick up changes in the
MBR-data. Otherwise there will be a couple of weird cases where we
cannot avoid replicating code from the kernel.
If you want to play with this, look at src/release/Makefile. You may need
to step back to version 1.38 of sys/i386/isa/fd.c to make "rootable"
floppies, it is not clear at this time if that indeed is the problem I
have been having.
Sleep well, my friends, and expect the real Alpha in 24H, if the tree is
still solid.
1994-11-01 10:10:43 +00:00
}