1995-05-04 23:36:23 +00:00
/*
* The new sysinstall program .
*
* This is probably the last program in the ` sysinstall ' line - the next
* generation being essentially a complete rewrite .
*
1995-05-11 09:01:35 +00:00
* $ Id : disks . c , v 1.16 1995 / 05 / 11 06 : 10 : 48 jkh Exp $
1995-05-04 23:36:23 +00:00
*
* Copyright ( c ) 1995
* Jordan Hubbard . All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* 1. Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer ,
* verbatim and that no modifications are made prior to this
* point in the file .
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement :
* This product includes software developed by Jordan Hubbard
* for the FreeBSD Project .
* 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
* endorse or promote products derived from this software without specific
* prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ` ` AS IS ' ' AND
* ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED . IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
* FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL
* DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES ; LOSS OF USE , DATA , LIFE OR PROFITS ; OR BUSINESS INTERRUPTION )
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT
* LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE .
*
*/
# include "sysinstall.h"
1995-05-05 23:47:47 +00:00
# include <ctype.h>
1995-05-06 09:34:24 +00:00
# include <sys/disklabel.h>
1995-05-05 23:47:47 +00:00
/*
* I make some pretty gross assumptions about having a max of 50 chunks
* total - 8 slices and 42 partitions . I can ' t easily display many more
* than that on the screen at once !
*
* For 2.1 I ' ll revisit this and try to make it more dynamic , but since
* this will catch 99.99 % of all possible cases , I ' m not too worried .
*/
# define MAX_CHUNKS 50
/* Where to start printing the freebsd slices */
# define CHUNK_SLICE_START_ROW 2
# define CHUNK_PART_START_ROW 10
/* The smallest filesystem we're willing to create */
# define FS_MIN_SIZE 2048
1995-05-08 00:38:02 +00:00
# define MSG_NOT_APPLICABLE "That option is not applicable here"
1995-05-05 23:47:47 +00:00
static struct {
struct disk * d ;
struct chunk * c ;
1995-05-06 09:34:24 +00:00
PartType type ;
1995-05-05 23:47:47 +00:00
} fbsd_chunk_info [ MAX_CHUNKS + 1 ] ;
static int current_chunk ;
1995-05-04 23:36:23 +00:00
1995-05-05 23:47:47 +00:00
static Boolean
check_conflict ( char * name )
{
int i ;
for ( i = 0 ; fbsd_chunk_info [ i ] . d ; i + + )
if ( fbsd_chunk_info [ i ] . type = = PART_FILESYSTEM & &
1995-05-08 00:38:02 +00:00
fbsd_chunk_info [ i ] . c - > private & &
! strcmp ( ( ( PartInfo * ) fbsd_chunk_info [ i ] . c - > private ) - > mountpoint ,
name ) )
1995-05-05 23:47:47 +00:00
return TRUE ;
1995-05-04 23:36:23 +00:00
return FALSE ;
}
1995-05-05 23:47:47 +00:00
static int
space_free ( struct chunk * c )
{
struct chunk * c1 = c - > part ;
int sz = c - > size ;
while ( c1 ) {
if ( c1 - > type ! = unused )
sz - = c1 - > size ;
c1 = c1 - > next ;
}
if ( sz < 0 )
msgFatal ( " Partitions are larger than actual chunk?? " ) ;
return sz ;
}
static void
1995-05-08 10:20:56 +00:00
record_fbsd_chunks ( )
1995-05-05 23:47:47 +00:00
{
int i , j , p ;
1995-05-07 05:58:57 +00:00
struct chunk * c1 , * c2 ;
1995-05-05 23:47:47 +00:00
1995-05-07 22:07:53 +00:00
j = p = 0 ;
1995-05-08 10:20:56 +00:00
for ( i = 0 ; Disks [ i ] ; i + + ) {
if ( ! Disks [ i ] - > chunks )
msgFatal ( " No chunk list found for %s! " , Disks [ i ] - > name ) ;
1995-05-05 23:47:47 +00:00
1995-05-07 03:38:03 +00:00
/* Put the freebsd chunks first */
1995-05-08 10:20:56 +00:00
for ( c1 = Disks [ i ] - > chunks - > part ; c1 ; c1 = c1 - > next ) {
1995-05-07 03:38:03 +00:00
if ( c1 - > type = = freebsd ) {
1995-05-05 23:47:47 +00:00
fbsd_chunk_info [ j ] . type = PART_SLICE ;
1995-05-08 10:20:56 +00:00
fbsd_chunk_info [ j ] . d = Disks [ i ] ;
1995-05-05 23:47:47 +00:00
fbsd_chunk_info [ j ] . c = c1 ;
1995-05-07 05:58:57 +00:00
+ + j ;
1995-05-07 03:38:03 +00:00
}
}
1995-05-07 05:58:57 +00:00
}
1995-05-08 10:20:56 +00:00
for ( i = 0 ; Disks [ i ] ; i + + ) {
1995-05-07 03:38:03 +00:00
/* Then buzz through and pick up the partitions */
1995-05-08 10:20:56 +00:00
for ( c1 = Disks [ i ] - > chunks - > part ; c1 ; c1 = c1 - > next ) {
1995-05-07 03:38:03 +00:00
if ( c1 - > type = = freebsd ) {
1995-05-07 05:58:57 +00:00
for ( c2 = c1 - > part ; c2 ; c2 = c2 - > next ) {
1995-05-05 23:47:47 +00:00
if ( c2 - > type = = part ) {
if ( c2 - > subtype = = FS_SWAP )
fbsd_chunk_info [ j ] . type = PART_SWAP ;
else
fbsd_chunk_info [ j ] . type = PART_FILESYSTEM ;
1995-05-08 10:20:56 +00:00
fbsd_chunk_info [ j ] . d = Disks [ i ] ;
1995-05-05 23:47:47 +00:00
fbsd_chunk_info [ j ] . c = c2 ;
1995-05-07 05:58:57 +00:00
+ + j ;
1995-05-05 23:47:47 +00:00
}
}
}
}
}
fbsd_chunk_info [ j ] . d = NULL ;
fbsd_chunk_info [ j ] . c = NULL ;
1995-05-07 22:07:53 +00:00
if ( current_chunk > = j )
current_chunk = j ? j - 1 : 0 ;
1995-05-05 23:47:47 +00:00
}
1995-05-07 05:58:57 +00:00
static PartInfo *
new_part ( char * mpoint , Boolean newfs )
{
PartInfo * ret ;
ret = ( PartInfo * ) safe_malloc ( sizeof ( PartInfo ) ) ;
strncpy ( ret - > mountpoint , mpoint , FILENAME_MAX ) ;
1995-05-07 23:37:34 +00:00
strcpy ( ret - > newfs_cmd , " newfs " ) ;
1995-05-07 05:58:57 +00:00
ret - > newfs = newfs ;
return ret ;
}
1995-05-07 22:07:53 +00:00
PartInfo *
get_mountpoint ( struct chunk * c )
1995-05-05 23:47:47 +00:00
{
char * val ;
1995-05-07 22:07:53 +00:00
PartInfo * tmp ;
1995-05-05 23:47:47 +00:00
1995-05-07 22:07:53 +00:00
val = msgGetInput ( c & & c - > private ?
( ( PartInfo * ) c - > private ) - > mountpoint : NULL ,
" Please specify a mount point for the partition " ) ;
1995-05-05 23:47:47 +00:00
if ( val ) {
1995-05-07 22:07:53 +00:00
if ( check_conflict ( val ) ) {
1995-05-10 08:03:21 +00:00
msgConfirm ( " You already have a mount point for %s assigned! " , val ) ;
return NULL ;
}
else if ( * val ! = ' / ' ) {
msgConfirm ( " Mount point must start with a / character " ) ;
1995-05-07 22:07:53 +00:00
return NULL ;
}
else if ( ! strcmp ( val , " / " ) ) {
1995-05-11 06:10:56 +00:00
if ( c ) {
if ( c - > flags & CHUNK_PAST_1024 ) {
msgConfirm ( " This region cannot be used for your root partition as \n it is past the 1024'th cylinder mark and the system would not be \n able to boot from it. Please pick another location for your \n root partition and try again! " ) ;
return NULL ;
}
1995-05-11 09:01:35 +00:00
#if 0 /* This never seems to be set */
1995-05-11 06:10:56 +00:00
else if ( ! ( c - > flags & CHUNK_BSD_COMPAT ) ) {
msgConfirm ( " This region cannot be used for your root partition as \n the FreeBSD boot code cannot deal with a root partition created in \n such a region. Please choose another partition for this. " ) ;
return NULL ;
}
1995-05-11 09:01:35 +00:00
# endif
1995-05-11 06:10:56 +00:00
else
c - > flags | = CHUNK_IS_ROOT ;
1995-05-05 23:47:47 +00:00
}
}
1995-05-07 22:07:53 +00:00
else if ( c )
c - > flags & = ~ CHUNK_IS_ROOT ;
safe_free ( c ? c - > private : NULL ) ;
tmp = new_part ( val , TRUE ) ;
if ( c ) {
c - > private = tmp ;
c - > private_free = safe_free ;
1995-05-05 23:47:47 +00:00
}
1995-05-07 22:07:53 +00:00
return tmp ;
1995-05-05 23:47:47 +00:00
}
1995-05-07 22:07:53 +00:00
return NULL ;
1995-05-05 23:47:47 +00:00
}
1995-05-06 09:34:24 +00:00
static PartType
1995-05-07 05:58:57 +00:00
get_partition_type ( void )
1995-05-05 23:47:47 +00:00
{
char selection [ 20 ] ;
static unsigned char * fs_types [ ] = {
" FS " ,
" A file system " ,
1995-05-06 09:34:24 +00:00
" Swap " ,
" A swap partition. " ,
1995-05-05 23:47:47 +00:00
} ;
if ( ! dialog_menu ( " Please choose a partition type " ,
" If you want to use this partition for swap space, select Swap. \n If you want to put a filesystem on it, choose FS. " , - 1 , - 1 , 2 , 2 , fs_types , selection , NULL , NULL ) ) {
if ( ! strcmp ( selection , " FS " ) )
return PART_FILESYSTEM ;
else if ( ! strcmp ( selection , " Swap " ) )
return PART_SWAP ;
}
return PART_NONE ;
}
1995-05-07 23:37:34 +00:00
static void
getNewfsCmd ( PartInfo * p )
{
char * val ;
val = msgGetInput ( p - > newfs_cmd ,
" Please enter the newfs command and options you'd like to use in \n creating this file system. " ) ;
if ( val )
strncpy ( p - > newfs_cmd , val , NEWFS_CMD_MAX ) ;
}
1995-05-07 02:04:29 +00:00
# define MAX_MOUNT_NAME 12
1995-05-05 23:47:47 +00:00
# define PART_PART_COL 0
# define PART_MOUNT_COL 8
1995-05-08 00:38:02 +00:00
# define PART_SIZE_COL (PART_MOUNT_COL + MAX_MOUNT_NAME + 3)
# define PART_NEWFS_COL (PART_SIZE_COL + 7)
# define PART_OFF 38
1995-05-05 23:47:47 +00:00
1995-05-07 22:07:53 +00:00
/* How many mounted partitions to display in column before going to next */
# define CHUNK_COLUMN_MAX 6
1995-05-05 23:47:47 +00:00
static void
print_fbsd_chunks ( void )
{
1995-05-07 03:38:03 +00:00
int i , j , srow , prow , pcol ;
1995-05-05 23:47:47 +00:00
int sz ;
attrset ( A_REVERSE ) ;
mvaddstr ( 0 , 25 , " FreeBSD Partition Editor " ) ;
attrset ( A_NORMAL ) ;
for ( i = 0 ; i < 2 ; i + + ) {
attrset ( A_UNDERLINE ) ;
mvaddstr ( CHUNK_PART_START_ROW - 1 , PART_PART_COL + ( i * PART_OFF ) ,
" Part " ) ;
attrset ( A_NORMAL ) ;
attrset ( A_UNDERLINE ) ;
mvaddstr ( CHUNK_PART_START_ROW - 1 , PART_MOUNT_COL + ( i * PART_OFF ) ,
" Mount " ) ;
attrset ( A_NORMAL ) ;
1995-05-07 02:04:29 +00:00
attrset ( A_UNDERLINE ) ;
1995-05-07 03:38:03 +00:00
mvaddstr ( CHUNK_PART_START_ROW - 1 , PART_SIZE_COL + ( i * PART_OFF ) + 2 ,
1995-05-07 02:04:29 +00:00
" Size " ) ;
1995-05-07 03:38:03 +00:00
attrset ( A_NORMAL ) ;
1995-05-07 02:04:29 +00:00
1995-05-05 23:47:47 +00:00
attrset ( A_UNDERLINE ) ;
mvaddstr ( CHUNK_PART_START_ROW - 1 , PART_NEWFS_COL + ( i * PART_OFF ) ,
" Newfs " ) ;
attrset ( A_NORMAL ) ;
}
1995-05-11 06:10:56 +00:00
1995-05-05 23:47:47 +00:00
srow = CHUNK_SLICE_START_ROW ;
prow = CHUNK_PART_START_ROW ;
1995-05-08 00:38:02 +00:00
pcol = 0 ;
1995-05-05 23:47:47 +00:00
for ( i = 0 ; fbsd_chunk_info [ i ] . d ; i + + ) {
if ( i = = current_chunk )
1995-05-07 03:38:03 +00:00
attrset ( A_REVERSE ) ;
1995-05-07 02:04:29 +00:00
/* Is it a slice entry displayed at the top? */
1995-05-05 23:47:47 +00:00
if ( fbsd_chunk_info [ i ] . type = = PART_SLICE ) {
sz = space_free ( fbsd_chunk_info [ i ] . c ) ;
mvprintw ( srow + + , 0 ,
" Disk: %s \t Partition name: %s \t Free: %d blocks (%dMB) " ,
fbsd_chunk_info [ i ] . d - > name ,
fbsd_chunk_info [ i ] . c - > name , sz , ( sz / 2048 ) ) ;
}
1995-05-07 02:04:29 +00:00
/* Otherwise it's a swap or filesystem entry, at the bottom */
1995-05-05 23:47:47 +00:00
else {
1995-05-07 05:58:57 +00:00
char onestr [ PART_OFF ] , num [ 10 ] , * mountpoint , * newfs ;
1995-05-07 02:04:29 +00:00
1995-05-07 05:58:57 +00:00
memset ( onestr , ' ' , PART_OFF - 1 ) ;
onestr [ PART_OFF - 1 ] = ' \0 ' ;
1995-05-05 23:47:47 +00:00
/* Go for two columns */
1995-05-07 23:37:34 +00:00
if ( prow = = ( CHUNK_PART_START_ROW + CHUNK_COLUMN_MAX ) ) {
1995-05-05 23:47:47 +00:00
pcol = PART_OFF ;
1995-05-07 23:37:34 +00:00
prow = CHUNK_PART_START_ROW ;
}
1995-05-07 05:58:57 +00:00
memcpy ( onestr + PART_PART_COL , fbsd_chunk_info [ i ] . c - > name ,
strlen ( fbsd_chunk_info [ i ] . c - > name ) ) ;
1995-05-05 23:47:47 +00:00
if ( fbsd_chunk_info [ i ] . type = = PART_FILESYSTEM ) {
1995-05-07 22:07:53 +00:00
if ( fbsd_chunk_info [ i ] . c - > private ) {
mountpoint = ( ( PartInfo * ) fbsd_chunk_info [ i ] . c - > private ) - > mountpoint ;
newfs = ( ( PartInfo * ) fbsd_chunk_info [ i ] . c - > private ) - > newfs ? " Y " : " N " ;
1995-05-05 23:47:47 +00:00
}
else {
1995-05-07 05:58:57 +00:00
fbsd_chunk_info [ i ] . c - > private = new_part ( " " , FALSE ) ;
1995-05-07 22:07:53 +00:00
fbsd_chunk_info [ i ] . c - > private_free = safe_free ;
1995-05-07 02:04:29 +00:00
mountpoint = " " ;
1995-05-07 05:58:57 +00:00
newfs = " N " ;
1995-05-05 23:47:47 +00:00
}
}
1995-05-07 02:04:29 +00:00
else {
mountpoint = " swap " ;
newfs = " " ;
}
1995-05-07 03:38:03 +00:00
for ( j = 0 ; j < MAX_MOUNT_NAME & & mountpoint [ j ] ; j + + )
1995-05-07 05:58:57 +00:00
onestr [ PART_MOUNT_COL + j ] = mountpoint [ j ] ;
1995-05-11 06:10:56 +00:00
snprintf ( num , 10 , " %4ldMB " , fbsd_chunk_info [ i ] . c - > size ?
1995-05-07 05:58:57 +00:00
fbsd_chunk_info [ i ] . c - > size / 2048 : 0 ) ;
memcpy ( onestr + PART_SIZE_COL , num , strlen ( num ) ) ;
memcpy ( onestr + PART_NEWFS_COL , newfs , strlen ( newfs ) ) ;
1995-05-11 06:10:56 +00:00
onestr [ PART_NEWFS_COL + strlen ( newfs ) ] = ' \0 ' ;
1995-05-07 05:58:57 +00:00
mvaddstr ( prow , pcol , onestr ) ;
1995-05-05 23:47:47 +00:00
+ + prow ;
}
if ( i = = current_chunk )
attrset ( A_NORMAL ) ;
}
}
static void
print_command_summary ( )
{
1995-05-07 22:07:53 +00:00
mvprintw ( 17 , 0 ,
1995-05-05 23:47:47 +00:00
" The following commands are valid here (upper or lower case): " ) ;
1995-05-07 22:07:53 +00:00
mvprintw ( 19 , 0 , " C = Create Partition D = Delete Partition M = Mount Partition " ) ;
mvprintw ( 20 , 0 , " N = Newfs Options T = Toggle Newfs ESC = Finish Partitioning " ) ;
mvprintw ( 21 , 0 , " The default target will be displayed in " ) ;
1995-05-05 23:47:47 +00:00
1995-05-07 03:38:03 +00:00
attrset ( A_REVERSE ) ;
1995-05-11 06:10:56 +00:00
addstr ( " reverse video. " ) ;
1995-05-05 23:47:47 +00:00
attrset ( A_NORMAL ) ;
1995-05-11 06:10:56 +00:00
mvprintw ( 22 , 0 , " Use F1 or ? to get more help, arrow keys to move. " ) ;
1995-05-05 23:47:47 +00:00
move ( 0 , 0 ) ;
}
1995-05-04 23:36:23 +00:00
void
1995-05-08 10:20:56 +00:00
partition_disks ( void )
1995-05-04 23:36:23 +00:00
{
1995-05-05 23:47:47 +00:00
int sz , key = 0 ;
Boolean partitioning ;
char * msg = NULL ;
1995-05-07 22:07:53 +00:00
PartInfo * p ;
PartType type ;
1995-05-05 23:47:47 +00:00
dialog_clear ( ) ;
partitioning = TRUE ;
keypad ( stdscr , TRUE ) ;
1995-05-08 10:20:56 +00:00
record_fbsd_chunks ( ) ;
1995-05-05 23:47:47 +00:00
while ( partitioning ) {
clear ( ) ;
print_fbsd_chunks ( ) ;
print_command_summary ( ) ;
if ( msg ) {
1995-05-07 05:58:57 +00:00
attrset ( A_REVERSE ) ; mvprintw ( 23 , 0 , msg ) ; attrset ( A_NORMAL ) ;
1995-05-05 23:47:47 +00:00
beep ( ) ;
msg = NULL ;
}
refresh ( ) ;
key = toupper ( getch ( ) ) ;
switch ( key ) {
1995-05-07 05:58:57 +00:00
1995-05-05 23:47:47 +00:00
case KEY_UP :
case ' - ' :
if ( current_chunk ! = 0 )
- - current_chunk ;
break ;
case KEY_DOWN :
case ' + ' :
case ' \r ' :
case ' \n ' :
if ( fbsd_chunk_info [ current_chunk + 1 ] . d )
+ + current_chunk ;
break ;
case KEY_HOME :
current_chunk = 0 ;
break ;
case KEY_END :
while ( fbsd_chunk_info [ current_chunk + 1 ] . d )
+ + current_chunk ;
break ;
case KEY_F ( 1 ) :
case ' ? ' :
systemDisplayFile ( " partitioning.hlp " ) ;
break ;
case ' C ' :
if ( fbsd_chunk_info [ current_chunk ] . type ! = PART_SLICE ) {
1995-05-08 00:38:02 +00:00
msg = " You can only do this in a master partition (see top of screen) " ;
1995-05-05 23:47:47 +00:00
break ;
}
sz = space_free ( fbsd_chunk_info [ current_chunk ] . c ) ;
if ( sz < = FS_MIN_SIZE )
msg = " Not enough space to create additional FreeBSD partition " ;
else {
1995-05-07 22:07:53 +00:00
char * val , * cp , tmp [ 20 ] ;
1995-05-05 23:47:47 +00:00
int size ;
snprintf ( tmp , 20 , " %d " , sz ) ;
1995-05-07 22:07:53 +00:00
val = msgGetInput ( tmp , " Please specify the size for new FreeBSD partition in blocks, or append \n a trailing `M' for megabytes (e.g. 20M). " ) ;
if ( val & & ( size = strtol ( val , & cp , 0 ) ) > 0 ) {
struct chunk * tmp ;
u_long flags = 0 ;
if ( * cp & & toupper ( * cp ) = = ' M ' )
size * = 2048 ;
1995-05-07 05:58:57 +00:00
type = get_partition_type ( ) ;
1995-05-05 23:47:47 +00:00
if ( type = = PART_NONE )
break ;
1995-05-07 22:07:53 +00:00
else if ( type = = PART_FILESYSTEM ) {
if ( ( p = get_mountpoint ( NULL ) ) = = NULL )
break ;
else if ( ! strcmp ( p - > mountpoint , " / " ) )
flags | = CHUNK_IS_ROOT ;
else
flags & = ~ CHUNK_IS_ROOT ;
}
else
p = NULL ;
1995-05-10 09:25:49 +00:00
tmp = Create_Chunk_DWIM ( fbsd_chunk_info [ current_chunk ] . d ,
fbsd_chunk_info [ current_chunk ] . c ,
size ,
part ,
( type = = PART_SWAP ) ?
FS_SWAP : FS_BSDFFS ,
flags ) ;
1995-05-07 22:07:53 +00:00
if ( ! tmp )
msgConfirm ( " Unable to create the partition. Too big? " ) ;
else {
tmp - > private = p ;
tmp - > private_free = safe_free ;
1995-05-08 10:20:56 +00:00
record_fbsd_chunks ( ) ;
1995-05-07 22:07:53 +00:00
}
1995-05-05 23:47:47 +00:00
}
}
break ;
1995-05-06 09:34:24 +00:00
1995-05-07 05:58:57 +00:00
case ' D ' : /* delete */
1995-05-06 09:34:24 +00:00
if ( fbsd_chunk_info [ current_chunk ] . type = = PART_SLICE ) {
1995-05-08 00:38:02 +00:00
msg = MSG_NOT_APPLICABLE ;
1995-05-06 09:34:24 +00:00
break ;
}
Delete_Chunk ( fbsd_chunk_info [ current_chunk ] . d ,
fbsd_chunk_info [ current_chunk ] . c ) ;
1995-05-08 10:20:56 +00:00
record_fbsd_chunks ( ) ;
1995-05-06 09:34:24 +00:00
break ;
1995-05-07 05:58:57 +00:00
case ' M ' : /* mount */
1995-05-07 22:07:53 +00:00
switch ( fbsd_chunk_info [ current_chunk ] . type ) {
case PART_SLICE :
1995-05-08 00:38:02 +00:00
msg = MSG_NOT_APPLICABLE ;
1995-05-07 05:58:57 +00:00
break ;
1995-05-07 22:07:53 +00:00
case PART_SWAP :
msg = " You don't need to specify a mountpoint for a swap partition. " ;
break ;
case PART_FILESYSTEM :
p = get_mountpoint ( fbsd_chunk_info [ current_chunk ] . c ) ;
if ( p ) {
p - > newfs = FALSE ;
1995-05-08 10:20:56 +00:00
record_fbsd_chunks ( ) ;
1995-05-07 22:07:53 +00:00
}
break ;
default :
msgFatal ( " Bogus partition under cursor??? " ) ;
break ;
1995-05-07 05:58:57 +00:00
}
break ;
1995-05-07 23:37:34 +00:00
case ' N ' : /* Set newfs options */
if ( fbsd_chunk_info [ current_chunk ] . c - > private & &
( ( PartInfo * ) fbsd_chunk_info [ current_chunk ] . c - > private ) - > newfs )
getNewfsCmd ( fbsd_chunk_info [ current_chunk ] . c - > private ) ;
else
1995-05-08 00:38:02 +00:00
msg = MSG_NOT_APPLICABLE ;
1995-05-07 23:37:34 +00:00
break ;
case ' T ' : /* Toggle newfs state */
if ( fbsd_chunk_info [ current_chunk ] . c - > private )
( ( PartInfo * ) fbsd_chunk_info [ current_chunk ] . c - > private ) - > newfs = ! ( ( PartInfo * ) fbsd_chunk_info [ current_chunk ] . c - > private ) - > newfs ;
else
1995-05-08 00:38:02 +00:00
msg = MSG_NOT_APPLICABLE ;
1995-05-07 23:37:34 +00:00
break ;
1995-05-08 00:56:28 +00:00
case ' W ' :
1995-05-08 01:27:07 +00:00
if ( ! msgYesNo ( " Are you sure you want to go into Wizard mode? \n \n This is an entirely undocumented feature which you are not \n expected to understand! " ) ) {
1995-05-08 00:56:28 +00:00
int i ;
clear ( ) ;
dialog_clear ( ) ;
end_dialog ( ) ;
DialogActive = FALSE ;
1995-05-08 10:20:56 +00:00
for ( i = 0 ; Disks [ i ] ; i + + )
slice_wizard ( Disks [ i ] ) ;
1995-05-08 00:56:28 +00:00
clear ( ) ;
dialog_clear ( ) ;
DialogActive = TRUE ;
1995-05-08 10:20:56 +00:00
record_fbsd_chunks ( ) ;
1995-05-08 00:56:28 +00:00
}
else
msg = " A most prudent choice! " ;
break ;
1995-05-05 23:47:47 +00:00
case 27 : /* ESC */
partitioning = FALSE ;
break ;
1995-05-07 23:37:34 +00:00
default :
beep ( ) ;
msg = " Type F1 or ? for help " ;
break ;
1995-05-05 23:47:47 +00:00
}
}
1995-05-04 23:36:23 +00:00
}
int
1995-05-08 10:20:56 +00:00
write_disks ( void )
1995-05-04 23:36:23 +00:00
{
int i ;
extern u_char boot1 [ ] , boot2 [ ] ;
extern u_char mbr [ ] , bteasy17 [ ] ;
dialog_clear ( ) ;
1995-05-08 10:20:56 +00:00
for ( i = 0 ; Disks [ i ] ; i + + ) {
1995-05-10 09:25:49 +00:00
Set_Boot_Blocks ( Disks [ i ] , boot1 , boot2 ) ;
1995-05-08 01:27:07 +00:00
dialog_clear ( ) ;
1995-05-08 00:38:02 +00:00
if ( i = = 0 & & ! msgYesNo ( " Would you like to install a boot manager? \n \n This will allow you to easily select between other operating systems \n on the first disk, or boot from a disk other than the first. " ) )
1995-05-08 10:20:56 +00:00
Set_Boot_Mgr ( Disks [ i ] , bteasy17 ) ;
1995-05-08 01:27:07 +00:00
else {
dialog_clear ( ) ;
if ( i = = 0 & & ! msgYesNo ( " Would you like to remove an existing boot manager? " ) )
1995-05-08 10:20:56 +00:00
Set_Boot_Mgr ( Disks [ i ] , mbr ) ;
1995-05-08 01:27:07 +00:00
}
dialog_clear ( ) ;
1995-05-08 00:38:02 +00:00
if ( ! msgYesNo ( " Last Chance! Are you sure you want to write out \n all these changes to disk? " ) ) {
1995-05-08 18:41:37 +00:00
Write_Disk ( Disks [ i ] ) ;
1995-05-08 01:27:07 +00:00
return 0 ;
1995-05-04 23:36:23 +00:00
}
}
return 1 ;
}