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.
|
|
|
|
*
|
1996-01-23 21:05:22 +00:00
|
|
|
* $Id: disks.c,v 1.34 1995/12/11 16:32:31 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
|
1995-05-30 08:29:07 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
1995-05-04 23:36:23 +00:00
|
|
|
* 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
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
/* Where we start displaying chunk information on the screen */
|
|
|
|
#define CHUNK_START_ROW 5
|
1995-05-08 00:38:02 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
/* Where we keep track of MBR chunks */
|
1995-12-07 10:34:59 +00:00
|
|
|
static struct chunk *chunk_info[16];
|
1995-05-05 23:47:47 +00:00
|
|
|
static int current_chunk;
|
|
|
|
|
|
|
|
static void
|
1995-05-16 02:53:31 +00:00
|
|
|
record_chunks(Disk *d)
|
1995-05-05 23:47:47 +00:00
|
|
|
{
|
1995-05-16 02:53:31 +00:00
|
|
|
struct chunk *c1;
|
|
|
|
int i = 0;
|
|
|
|
int last_free = 0;
|
|
|
|
if (!d->chunks)
|
|
|
|
msgFatal("No chunk list found for %s!", d->name);
|
|
|
|
current_chunk = 0;
|
1995-12-07 10:34:59 +00:00
|
|
|
for (c1 = d->chunks->part; c1; c1 = c1->next) {
|
1995-05-16 02:53:31 +00:00
|
|
|
if (c1->type == unused && c1->size > last_free) {
|
|
|
|
last_free = c1->size;
|
|
|
|
current_chunk = i;
|
1995-05-05 23:47:47 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
chunk_info[i++] = c1;
|
1995-05-05 23:47:47 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
chunk_info[i] = NULL;
|
1995-05-07 23:37:34 +00:00
|
|
|
}
|
|
|
|
|
1995-05-05 23:47:47 +00:00
|
|
|
static void
|
1995-05-16 02:53:31 +00:00
|
|
|
print_chunks(Disk *d)
|
1995-05-05 23:47:47 +00:00
|
|
|
{
|
1995-05-16 02:53:31 +00:00
|
|
|
int row;
|
|
|
|
int i;
|
1995-05-05 23:47:47 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if ((!d->bios_cyl || d->bios_cyl > 65536) || (!d->bios_hd || d->bios_hd > 256) || (!d->bios_sect || d->bios_sect >= 64)) {
|
|
|
|
int sz;
|
|
|
|
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("WARNING: The current geometry for %s is incorrect. Using\n"
|
|
|
|
"a default geometry of 64 heads and 32 sectors. If this geometry\n"
|
|
|
|
"is incorrect or you are unsure as to whether or not it's correct,\n"
|
|
|
|
"please consult the Hardware Guide in the Documentation submenu\n"
|
|
|
|
"or use the (G)eometry command to change it now.", d->name);
|
|
|
|
d->bios_hd = 64;
|
|
|
|
d->bios_sect = 32;
|
|
|
|
sz = 0;
|
|
|
|
for (i = 0; chunk_info[i]; i++)
|
|
|
|
sz += chunk_info[i]->size;
|
|
|
|
if (sz)
|
|
|
|
d->bios_cyl = sz / ONE_MEG;
|
|
|
|
else
|
|
|
|
msgConfirm("Couldn't set geometry! You'll have to do it by hand.");
|
|
|
|
}
|
1995-05-05 23:47:47 +00:00
|
|
|
attrset(A_NORMAL);
|
1995-05-16 02:53:31 +00:00
|
|
|
mvaddstr(0, 0, "Disk name:\t");
|
1995-05-21 04:34:12 +00:00
|
|
|
clrtobot();
|
1995-05-16 02:53:31 +00:00
|
|
|
attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL);
|
1995-06-11 19:33:05 +00:00
|
|
|
attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL);
|
1995-05-16 02:53:31 +00:00
|
|
|
mvprintw(1, 0,
|
1995-12-07 10:34:59 +00:00
|
|
|
"DISK Geometry:\t%lu cyls/%lu heads/%lu sectors",
|
1995-05-16 02:53:31 +00:00
|
|
|
d->bios_cyl, d->bios_hd, d->bios_sect);
|
|
|
|
mvprintw(3, 1, "%10s %10s %10s %8s %8s %8s %8s %8s",
|
|
|
|
"Offset", "Size", "End", "Name", "PType", "Desc",
|
|
|
|
"Subtype", "Flags");
|
|
|
|
for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) {
|
1995-05-05 23:47:47 +00:00
|
|
|
if (i == current_chunk)
|
1995-05-07 03:38:03 +00:00
|
|
|
attrset(A_REVERSE);
|
1995-06-11 19:33:05 +00:00
|
|
|
mvprintw(row, 2, "%10ld %10lu %10lu %8s %8d %8s %8d\t%-6s",
|
1995-05-16 02:53:31 +00:00
|
|
|
chunk_info[i]->offset, chunk_info[i]->size,
|
|
|
|
chunk_info[i]->end, chunk_info[i]->name,
|
|
|
|
chunk_info[i]->type, chunk_n[chunk_info[i]->type],
|
1995-06-11 19:33:05 +00:00
|
|
|
chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i]));
|
1995-05-05 23:47:47 +00:00
|
|
|
if (i == current_chunk)
|
|
|
|
attrset(A_NORMAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_command_summary()
|
|
|
|
{
|
1995-05-16 02:53:31 +00:00
|
|
|
mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
|
|
|
|
mvprintw(16, 0, "A = Use Entire Disk B = Bad Block Scan C = Create Partition");
|
1995-12-07 10:34:59 +00:00
|
|
|
mvprintw(17, 0, "D = Delete Partition G = Set Drive Geometry S = Set Bootable");
|
1995-09-18 16:53:06 +00:00
|
|
|
mvprintw(18, 0, "U = Undo All Changes Q = Finish W = Write Changes");
|
1995-05-16 02:53:31 +00:00
|
|
|
mvprintw(20, 0, "The currently selected partition is displayed in ");
|
1995-05-25 18:48:33 +00:00
|
|
|
attrset(A_REVERSE); addstr("reverse"); attrset(A_NORMAL); addstr(" video.");
|
1995-05-16 02:53:31 +00:00
|
|
|
mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to move.");
|
1995-05-05 23:47:47 +00:00
|
|
|
move(0, 0);
|
|
|
|
}
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
/* Partition a disk based wholly on which variables are set */
|
|
|
|
static void
|
|
|
|
scriptPartition(Device *dev, Disk *d)
|
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
int i, sz;
|
|
|
|
|
|
|
|
record_chunks(d);
|
|
|
|
cp = variable_get(VAR_GEOMETRY);
|
|
|
|
if (cp) {
|
|
|
|
msgDebug("Setting geometry from script to: %s\n", cp);
|
|
|
|
d->bios_cyl = strtol(cp, &cp, 0);
|
|
|
|
d->bios_hd = strtol(cp + 1, &cp, 0);
|
|
|
|
d->bios_sect = strtol(cp + 1, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
cp = variable_get(VAR_DISKSPACE);
|
|
|
|
if (cp) {
|
|
|
|
if (!strcmp(cp, "free")) {
|
|
|
|
/* Do free disk space case */
|
|
|
|
for (i = 0; chunk_info[i]; i++) {
|
|
|
|
/* If a chunk is at least 10MB in size, use it. */
|
|
|
|
if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) {
|
|
|
|
Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size, freebsd, 3,
|
|
|
|
(chunk_info[i]->flags & CHUNK_ALIGN));
|
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!chunk_info[i]) {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("Unable to find any free space on this disk!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(cp, "all")) {
|
|
|
|
/* Do all disk space case */
|
|
|
|
msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
|
|
|
|
|
|
|
|
All_FreeBSD(d, FALSE);
|
|
|
|
}
|
|
|
|
else if (!strcmp(cp, "exclusive")) {
|
|
|
|
/* Do really-all-the-disk-space case */
|
|
|
|
msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
|
|
|
|
|
|
|
|
All_FreeBSD(d, TRUE);
|
|
|
|
}
|
|
|
|
else if ((sz = strtol(cp, &cp, 0))) {
|
|
|
|
/* Look for sz bytes free */
|
|
|
|
if (*cp && toupper(*cp) == 'M')
|
|
|
|
sz *= ONE_MEG;
|
|
|
|
for (i = 0; chunk_info[i]; i++) {
|
|
|
|
/* If a chunk is at least sz MB, use it. */
|
|
|
|
if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) {
|
|
|
|
Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3, (chunk_info[i]->flags & CHUNK_ALIGN));
|
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!chunk_info[i]) {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("Unable to find %d free blocks on this disk!", sz);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(cp, "existing")) {
|
|
|
|
/* Do existing FreeBSD case */
|
|
|
|
for (i = 0; chunk_info[i]; i++) {
|
|
|
|
if (chunk_info[i]->type == freebsd)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!chunk_info[i]) {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("Unable to find any existing FreeBSD partitions on this disk!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_DISKSPACE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *
|
|
|
|
getBootMgr(char *dname)
|
|
|
|
{
|
|
|
|
extern u_char mbr[], bteasy17[];
|
|
|
|
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;
|
|
|
|
dialog_clear();
|
|
|
|
i = dmenuOpenSimple(&MenuMBRType);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!strncmp(cp, "boot", 4))
|
|
|
|
BootMgr = 0;
|
|
|
|
else if (!strcmp(cp, "standard"))
|
|
|
|
BootMgr = 1;
|
|
|
|
else
|
|
|
|
BootMgr = 2;
|
|
|
|
}
|
|
|
|
if (cp || i) {
|
|
|
|
switch (BootMgr) {
|
|
|
|
case 0:
|
|
|
|
return bteasy17;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
return mbr;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
diskPartition(Device *dev, Disk *d)
|
1995-05-04 23:36:23 +00:00
|
|
|
{
|
1995-05-16 02:53:31 +00:00
|
|
|
char *p;
|
|
|
|
int key = 0;
|
|
|
|
Boolean chunking;
|
1995-05-05 23:47:47 +00:00
|
|
|
char *msg = NULL;
|
1995-12-07 10:34:59 +00:00
|
|
|
u_char *mbrContents;
|
1995-05-05 23:47:47 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
chunking = TRUE;
|
1995-05-05 23:47:47 +00:00
|
|
|
keypad(stdscr, TRUE);
|
|
|
|
|
1995-05-20 19:22:21 +00:00
|
|
|
clear();
|
1995-05-16 02:53:31 +00:00
|
|
|
record_chunks(d);
|
|
|
|
while (chunking) {
|
|
|
|
print_chunks(d);
|
1995-05-05 23:47:47 +00:00
|
|
|
print_command_summary();
|
|
|
|
if (msg) {
|
1995-05-16 02:53:31 +00:00
|
|
|
standout(); mvprintw(23, 0, msg); standend();
|
1995-05-05 23:47:47 +00:00
|
|
|
beep();
|
|
|
|
msg = NULL;
|
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1995-05-05 23:47:47 +00:00
|
|
|
key = toupper(getch());
|
|
|
|
switch (key) {
|
1995-05-25 18:48:33 +00:00
|
|
|
|
|
|
|
case '\014': /* ^L */
|
|
|
|
clear();
|
1995-12-07 10:34:59 +00:00
|
|
|
print_command_summary();
|
1995-05-25 18:48:33 +00:00
|
|
|
continue;
|
|
|
|
|
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':
|
1995-05-16 02:53:31 +00:00
|
|
|
if (chunk_info[current_chunk + 1])
|
1995-05-05 23:47:47 +00:00
|
|
|
++current_chunk;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_HOME:
|
|
|
|
current_chunk = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_END:
|
1995-05-16 02:53:31 +00:00
|
|
|
while (chunk_info[current_chunk + 1])
|
1995-05-05 23:47:47 +00:00
|
|
|
++current_chunk;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_F(1):
|
|
|
|
case '?':
|
1995-12-07 10:34:59 +00:00
|
|
|
systemDisplayHelp("slice");
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
case 'A': {
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
rv = msgYesNo("Do you want to do this with a true partition entry\n"
|
|
|
|
"so as to remain cooperative with any future possible\n"
|
|
|
|
"operating systems on the drive(s)?");
|
|
|
|
if (rv) {
|
|
|
|
rv = !msgYesNo("This is dangerous in that it will make the drive totally\n"
|
|
|
|
"uncooperative with other potential operating systems on the\n"
|
|
|
|
"same disk. It will lead instead to a totally dedicated disk,\n"
|
|
|
|
"starting at the very first sector, bypassing all BIOS geometry\n"
|
1996-01-23 21:05:22 +00:00
|
|
|
"considerations. This precludes the existance of any boot\n"
|
|
|
|
"manager or other stuff in sector 0, since the BSD bootstrap\n"
|
|
|
|
"will live there.\n"
|
1995-12-07 10:34:59 +00:00
|
|
|
"You will run into serious trouble with ST-506 and ESDI drives\n"
|
|
|
|
"and possibly some IDE drives (e.g. drives running under the\n"
|
|
|
|
"control of sort of disk manager). SCSI drives are considerably\n"
|
|
|
|
"less at risk.\n\n"
|
|
|
|
"Do you insist on dedicating the entire disk this way?");
|
|
|
|
}
|
|
|
|
All_FreeBSD(d, rv);
|
|
|
|
if (rv)
|
|
|
|
d->bios_hd = d->bios_sect = d->bios_cyl = 1;
|
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
1995-05-16 02:53:31 +00:00
|
|
|
record_chunks(d);
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'B':
|
|
|
|
if (chunk_info[current_chunk]->type != freebsd)
|
|
|
|
msg = "Can only scan for bad blocks in FreeBSD partition.";
|
1995-12-07 10:34:59 +00:00
|
|
|
else if (strncmp(d->name, "sd", 2) ||
|
|
|
|
!msgYesNo("This typically makes sense only for ESDI, IDE or MFM drives.\n"
|
|
|
|
"Are you sure you want to do this on a SCSI disk?")) {
|
1995-05-18 09:02:06 +00:00
|
|
|
if (chunk_info[current_chunk]->flags & CHUNK_BAD144)
|
|
|
|
chunk_info[current_chunk]->flags &= ~CHUNK_BAD144;
|
|
|
|
else
|
|
|
|
chunk_info[current_chunk]->flags |= CHUNK_BAD144;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1995-05-05 23:47:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
1995-05-16 02:53:31 +00:00
|
|
|
if (chunk_info[current_chunk]->type != unused)
|
|
|
|
msg = "Partition in use, delete it first or move to an unused one.";
|
1995-05-05 23:47:47 +00:00
|
|
|
else {
|
1995-05-16 11:37:27 +00:00
|
|
|
char *val, tmp[20], *cp;
|
1995-05-05 23:47:47 +00:00
|
|
|
int size;
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
|
1995-12-07 10:34:59 +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).");
|
1995-05-16 11:37:27 +00:00
|
|
|
if (val && (size = strtol(val, &cp, 0)) > 0) {
|
|
|
|
if (*cp && toupper(*cp) == 'M')
|
1995-12-07 10:34:59 +00:00
|
|
|
size *= ONE_MEG;
|
1995-09-18 16:53:06 +00:00
|
|
|
Create_Chunk(d, chunk_info[current_chunk]->offset, size, freebsd, 3,
|
|
|
|
(chunk_info[current_chunk]->flags & CHUNK_ALIGN));
|
1995-12-07 10:34:59 +00:00
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
1995-05-16 02:53:31 +00:00
|
|
|
record_chunks(d);
|
1995-05-05 23:47:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1995-05-06 09:34:24 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
case 'D':
|
|
|
|
if (chunk_info[current_chunk]->type == unused)
|
|
|
|
msg = "Partition is already unused!";
|
|
|
|
else {
|
|
|
|
Delete_Chunk(d, chunk_info[current_chunk]);
|
1995-12-07 10:34:59 +00:00
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
1995-05-16 02:53:31 +00:00
|
|
|
record_chunks(d);
|
1995-05-06 09:34:24 +00:00
|
|
|
}
|
|
|
|
break;
|
1995-05-07 05:58:57 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
case 'G': {
|
|
|
|
char *val, geometry[80];
|
|
|
|
|
1995-09-18 16:53:06 +00:00
|
|
|
snprintf(geometry, 80, "%lu/%lu/%lu", d->bios_cyl, d->bios_hd, d->bios_sect);
|
1995-12-07 10:34:59 +00:00
|
|
|
val = msgGetInput(geometry, "Please specify the new geometry in cyl/hd/sect format.\n"
|
|
|
|
"Don't forget to use the two slash (/) separator characters!\n"
|
|
|
|
"It's not possible to parse the field without them.");
|
1995-05-16 02:53:31 +00:00
|
|
|
if (val) {
|
|
|
|
d->bios_cyl = strtol(val, &val, 0);
|
|
|
|
d->bios_hd = strtol(val + 1, &val, 0);
|
|
|
|
d->bios_sect = strtol(val + 1, 0, 0);
|
1995-05-07 05:58:57 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'S':
|
|
|
|
/* Set Bootable */
|
|
|
|
chunk_info[current_chunk]->flags |= CHUNK_ACTIVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'U':
|
|
|
|
clear();
|
|
|
|
if (msgYesNo("Are you SURE you want to Undo everything?"))
|
|
|
|
break;
|
|
|
|
d = Open_Disk(d->name);
|
|
|
|
if (!d) {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", d->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Free_Disk(dev->private);
|
|
|
|
dev->private = d;
|
|
|
|
variable_unset(DISK_PARTITIONED);
|
1995-05-16 02:53:31 +00:00
|
|
|
record_chunks(d);
|
1995-05-07 23:37:34 +00:00
|
|
|
break;
|
|
|
|
|
1995-05-08 00:56:28 +00:00
|
|
|
case 'W':
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!msgYesNo("Are you SURE you want to write this now? You do also\n"
|
|
|
|
"have the option of not modifying the disk until *all*\n"
|
|
|
|
"configuration information has been entered, at which\n"
|
|
|
|
"point you can do it all at once. If you're unsure, then\n"
|
|
|
|
"PLEASE CHOOSE NO at this dialog! This option is DANGEROUS\n"
|
|
|
|
"if you do not know EXACTLY what you are doing!")) {
|
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
|
|
|
clear();
|
|
|
|
|
|
|
|
/* 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 ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL
|
|
|
|
&& (mbrContents = getBootMgr(d->name)) != NULL)
|
|
|
|
Set_Boot_Mgr(d, mbrContents);
|
|
|
|
|
|
|
|
if (diskPartitionWrite(NULL) != RET_SUCCESS) {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("Disk partition write returned an error status!");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msgConfirm("Wrote FDISK partition information out successfully.");
|
|
|
|
}
|
|
|
|
}
|
1995-09-18 16:53:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case '|':
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!msgYesNo("Are you SURE you want to go into Wizard mode?\n"
|
|
|
|
"No seat belts whatsoever are provided!")) {
|
1995-05-08 00:56:28 +00:00
|
|
|
dialog_clear();
|
|
|
|
end_dialog();
|
|
|
|
DialogActive = FALSE;
|
1995-05-16 02:53:31 +00:00
|
|
|
slice_wizard(d);
|
1995-12-07 10:34:59 +00:00
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
1995-05-08 00:56:28 +00:00
|
|
|
dialog_clear();
|
|
|
|
DialogActive = TRUE;
|
1995-05-16 02:53:31 +00:00
|
|
|
record_chunks(d);
|
1995-05-08 00:56:28 +00:00
|
|
|
}
|
|
|
|
else
|
1995-05-16 02:53:31 +00:00
|
|
|
msg = "Wise choice!";
|
1995-05-08 00:56:28 +00:00
|
|
|
break;
|
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
case 'Q':
|
1995-05-16 02:53:31 +00:00
|
|
|
chunking = FALSE;
|
1995-12-07 10:34:59 +00:00
|
|
|
clear();
|
|
|
|
/* 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 ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL
|
|
|
|
&& (mbrContents = getBootMgr(d->name)) != NULL)
|
|
|
|
Set_Boot_Mgr(d, mbrContents);
|
1995-05-05 23:47:47 +00:00
|
|
|
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-16 02:53:31 +00:00
|
|
|
p = CheckRules(d);
|
|
|
|
if (p) {
|
1995-12-07 10:34:59 +00:00
|
|
|
dialog_clear();
|
1995-05-16 02:53:31 +00:00
|
|
|
msgConfirm(p);
|
|
|
|
free(p);
|
|
|
|
}
|
1995-05-17 16:16:10 +00:00
|
|
|
dialog_clear();
|
1995-05-04 23:36:23 +00:00
|
|
|
}
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
static int
|
|
|
|
partitionHook(char *str)
|
1995-05-04 23:36:23 +00:00
|
|
|
{
|
1995-05-16 11:37:27 +00:00
|
|
|
Device **devs = NULL;
|
1995-05-16 02:53:31 +00:00
|
|
|
|
|
|
|
/* Clip garbage off the ends */
|
|
|
|
string_prune(str);
|
|
|
|
str = string_skipwhite(str);
|
|
|
|
/* Try and open all the disks */
|
|
|
|
while (str) {
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
cp = index(str, '\n');
|
|
|
|
if (cp)
|
|
|
|
*cp++ = 0;
|
|
|
|
if (!*str) {
|
|
|
|
beep();
|
|
|
|
return 0;
|
1995-05-08 01:27:07 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
devs = deviceFind(str, DEVICE_TYPE_DISK);
|
|
|
|
if (!devs) {
|
1995-12-07 10:34:59 +00:00
|
|
|
dialog_clear();
|
1995-05-16 02:53:31 +00:00
|
|
|
msgConfirm("Unable to find disk %s!", str);
|
1995-05-08 01:27:07 +00:00
|
|
|
return 0;
|
1995-05-04 23:36:23 +00:00
|
|
|
}
|
1995-05-16 11:37:27 +00:00
|
|
|
devs[0]->enabled = TRUE;
|
1995-12-07 10:34:59 +00:00
|
|
|
diskPartition(devs[0], (Disk *)devs[0]->private);
|
1995-05-16 02:53:31 +00:00
|
|
|
str = cp;
|
|
|
|
}
|
|
|
|
return devs ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
diskPartitionEditor(char *str)
|
|
|
|
{
|
|
|
|
DMenu *menu;
|
1995-06-11 19:33:05 +00:00
|
|
|
Device **devs;
|
1995-12-07 10:34:59 +00:00
|
|
|
int i, cnt;
|
|
|
|
char *cp;
|
1995-06-11 19:33:05 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
cp = variable_get(VAR_DISK);
|
|
|
|
devs = deviceFind(cp, DEVICE_TYPE_DISK);
|
1995-06-11 19:33:05 +00:00
|
|
|
cnt = deviceCount(devs);
|
|
|
|
if (!cnt) {
|
1995-12-07 10:34:59 +00:00
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("No disks found! Please verify that your disk controller is being\n"
|
|
|
|
"properly probed at boot time. See the Hardware Guide on the\n"
|
|
|
|
"Documentation menu for clues on diagnosing this type of problem.");
|
|
|
|
i = RET_FAIL;
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
|
|
|
else if (cnt == 1) {
|
|
|
|
devs[0]->enabled = TRUE;
|
1995-12-07 10:34:59 +00:00
|
|
|
if (str && !strcmp(str, "script"))
|
|
|
|
scriptPartition(devs[0], (Disk *)devs[0]->private);
|
|
|
|
else
|
|
|
|
diskPartition(devs[0], (Disk *)devs[0]->private);
|
|
|
|
i = RET_SUCCESS;
|
|
|
|
variable_set2(DISK_SELECTED, "yes");
|
1995-05-04 23:36:23 +00:00
|
|
|
}
|
1995-05-17 14:40:00 +00:00
|
|
|
else {
|
1995-06-11 19:33:05 +00:00
|
|
|
menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook);
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!menu) {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("No devices suitable for installation found!\n\n"
|
|
|
|
"Please verify that your disk controller (and attached drives)\n"
|
|
|
|
"were detected properly. This can be done by pressing the\n"
|
|
|
|
"[Scroll Lock] key and using the Arrow keys to move back to\n"
|
|
|
|
"the boot messages. Press [Scroll Lock] again to return.");
|
|
|
|
i = RET_FAIL;
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
else {
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!dmenuOpenSimple(menu))
|
|
|
|
i = RET_FAIL;
|
|
|
|
else {
|
|
|
|
i = RET_SUCCESS;
|
|
|
|
variable_set2(DISK_SELECTED, "yes");
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
free(menu);
|
|
|
|
}
|
1995-05-17 14:40:00 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
return i;
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
diskPartitionWrite(char *str)
|
|
|
|
{
|
|
|
|
extern u_char boot1[], boot2[];
|
|
|
|
Device **devs;
|
1995-12-07 10:34:59 +00:00
|
|
|
char *cp;
|
1995-09-18 16:53:06 +00:00
|
|
|
int i;
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if ((cp = variable_get(DISK_PARTITIONED)) && strcmp(cp, "yes"))
|
|
|
|
return RET_SUCCESS;
|
|
|
|
else if (!cp) {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("You must partition the disk(s) before this option can be used.");
|
|
|
|
return RET_FAIL;
|
|
|
|
}
|
|
|
|
|
1995-09-18 16:53:06 +00:00
|
|
|
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
|
|
|
|
if (!devs) {
|
1995-12-07 10:34:59 +00:00
|
|
|
dialog_clear();
|
1995-09-18 16:53:06 +00:00
|
|
|
msgConfirm("Unable to find any disks to write to??");
|
1995-12-07 10:34:59 +00:00
|
|
|
return RET_FAIL;
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; devs[i]; i++) {
|
|
|
|
Chunk *c1;
|
|
|
|
Disk *d = (Disk *)devs[i]->private;
|
|
|
|
|
|
|
|
if (!devs[i]->enabled)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Set_Boot_Blocks(d, boot1, boot2);
|
|
|
|
msgNotify("Writing partition information to drive %s", d->name);
|
1995-12-07 10:34:59 +00:00
|
|
|
if (Write_Disk(d)) {
|
|
|
|
dialog_clear();
|
|
|
|
msgConfirm("ERROR: Unable to write data to disk %s!", d->name);
|
|
|
|
return RET_FAIL;
|
|
|
|
}
|
1995-09-18 16:53:06 +00:00
|
|
|
/* Now scan for bad blocks, if necessary */
|
|
|
|
for (c1 = d->chunks->part; c1; c1 = c1->next) {
|
|
|
|
if (c1->flags & CHUNK_BAD144) {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
msgNotify("Running bad block scan on partition %s", c1->name);
|
|
|
|
ret = vsystem("bad144 -v /dev/r%s 1234", c1->name);
|
1995-12-07 10:34:59 +00:00
|
|
|
if (ret) {
|
|
|
|
dialog_clear();
|
1995-09-18 16:53:06 +00:00
|
|
|
msgConfirm("Bad144 init on %s returned status of %d!", c1->name, ret);
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1995-09-18 16:53:06 +00:00
|
|
|
ret = vsystem("bad144 -v -s /dev/r%s", c1->name);
|
1995-12-07 10:34:59 +00:00
|
|
|
if (ret) {
|
|
|
|
dialog_clear();
|
1995-09-18 16:53:06 +00:00
|
|
|
msgConfirm("Bad144 scan on %s returned status of %d!", c1->name, ret);
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
/* Now it's not "yes", but "written" */
|
|
|
|
variable_set2(DISK_PARTITIONED, "written");
|
|
|
|
return RET_SUCCESS;
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|