1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

My latest round of changes - make the "slices" editor work.

This commit is contained in:
Jordan K. Hubbard 1995-05-04 03:51:22 +00:00
parent 9b4d8c3412
commit 2e363cad34
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8262
18 changed files with 1011 additions and 312 deletions

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.2 1995/04/27 18:03:53 jkh Exp $
* $Id: devices.c,v 1.1 1995/05/01 21:56:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,6 +44,9 @@
#include "sysinstall.h"
#include "libdisk.h"
/* Where we start displaying chunk information on the screen */
#define CHUNK_START_ROW 5
/* Get all device information for a given device class */
Device *
device_get_all(DeviceType which, int *ndevs)
@ -71,26 +74,78 @@ device_get_all(DeviceType which, int *ndevs)
return devs;
}
void
device_print_chunk(struct chunk *c1, int offset, int *row)
{
CHAR_N
static struct chunk *chunk_info[10];
static int current_chunk;
if (!c1)
return;
mvprintw(*row++, offset, "%10lu %10lu %10lu %-8s %d %-8s %4d %lx",
c1->offset, c1->size, c1->end, c1->name, c1->type,
chunk_n[c1->type], c1->subtype, c1->flags);
device_print_chunk(c1->part, offset + 2, row);
device_print_chunk(c1->next, offset, row);
static void
record_chunks(char *disk, struct disk *d)
{
struct chunk *c1;
int i = 0;
int last_free = 0;
if (!d->chunks)
msgFatal("No chunk list found for %s!", disk);
c1 = d->chunks->part;
while (c1) {
if (c1->type == unused && c1->size > last_free) {
last_free = c1->size;
current_chunk = i;
}
chunk_info[i++] = c1;
c1 = c1->next;
}
chunk_info[i] = NULL;
}
int
static void
print_chunks(char *disk, struct disk *d)
{
int row;
int i;
attrset(A_NORMAL);
mvaddstr(0, 0, "Disk name:\t");
attrset(A_BOLD); addstr(disk); attrset(A_NORMAL);
mvprintw(1, 0,
"BIOS Geometry:\t%lu cyls/%lu heads/%lu sectors",
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");
attrset(A_NORMAL);
for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) {
if (i == current_chunk)
attrset(A_BOLD);
mvprintw(row, 2, "%10lu %10lu %10lu %8s %8d %8s %8d %6lx",
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],
chunk_info[i]->subtype, chunk_info[i]->flags);
if (i == current_chunk)
attrset(A_NORMAL);
}
}
static void
print_command_summary()
{
mvprintw(15, 0, "The following commands are supported (in upper or lower case):");
mvprintw(17, 0, "C = Create New Partition D = Delete Partition");
mvprintw(18, 0, "B = Scan For Bad Blocks U = Undo All Changes");
mvprintw(19, 0, "ESC = Proceed to next screen");
mvprintw(21, 0, "The currently selected partition is displayed in ");
attrset(A_BOLD); addstr("bold"); attrset(A_NORMAL);
move(0, 0);
}
struct disk *
device_slice_disk(char *disk)
{
struct disk *d;
char *p;
int row;
int key = 0;
Boolean chunking;
char *msg = NULL;
d = Open_Disk(disk);
if (!d)
@ -100,23 +155,152 @@ device_slice_disk(char *disk)
msgConfirm(p);
free(p);
}
dialog_clear();
while (1) {
chunking = TRUE;
keypad(stdscr, TRUE);
record_chunks(disk, d);
while (chunking) {
clear();
mvprintw(0, 0, "Disk name: %s, Flags: %lx", disk, d->flags);
mvprintw(1, 0,
"Real Geometry: %lu/%lu/%lu, BIOS Geometry: %lu/%lu/%lu [cyls/heads/sectors]",
d->real_cyl, d->real_hd, d->real_sect,
d->bios_cyl, d->bios_hd, d->bios_sect);
mvprintw(4, 0, "%10s %10s %10s %-8s %4s %-8s %4s %4s",
"Offset", "Size", "End", "Name", "PType", "Desc",
"Subtype", "Flags");
row = 5;
device_print_chunk(d->chunks, 0, &row);
move(23, 0);
addstr("Done!");
if (getch() == 'q')
return 0;
print_chunks(disk, d);
print_command_summary();
if (msg) {
standout(); mvprintw(23, 0, msg); standend();
beep();
msg = NULL;
}
refresh();
key = getch();
switch (key) {
case KEY_UP:
case '-':
if (current_chunk != 0)
--current_chunk;
break;
case KEY_DOWN:
case '+':
case '\r':
case '\n':
if (chunk_info[current_chunk + 1])
++current_chunk;
break;
case KEY_HOME:
current_chunk = 0;
break;
case KEY_END:
while (chunk_info[current_chunk + 1])
++current_chunk;
break;
case KEY_F(1):
case '?':
systemDisplayFile("slice.hlp");
break;
case 'B':
case 'b':
if (chunk_info[current_chunk]->type != freebsd)
msg = "Can only scan for bad blocks in FreeBSD partition.";
else
chunk_info[current_chunk]->flags |= CHUNK_BAD144;
break;
case 'C':
case 'c':
if (chunk_info[current_chunk]->type != unused)
msg = "Partition in use, delete it first or move to an unused one.";
else {
char *val;
char tmp[20];
int size;
snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition");
if (val && (size = atoi(val)) > 0) {
Create_Chunk(d, chunk_info[current_chunk]->offset,
size,
freebsd,
3,
chunk_info[current_chunk]->flags);
record_chunks(disk, d);
}
}
break;
case 'D':
case 'd':
if (chunk_info[current_chunk]->type == unused)
msg = "Partition is already unused!";
else {
Delete_Chunk(d, chunk_info[current_chunk]);
record_chunks(disk, d);
}
break;
case 'U':
case 'u':
Free_Disk(d);
d = Open_Disk(disk);
record_chunks(disk, d);
break;
case 27: /* ESC */
chunking = FALSE;
break;
default:
msg = "Invalid character typed.";
break;
}
}
clear();
refresh();
return d;
}
/*
* Create a menu listing all the devices in the system. The pass-in menu
* is expected to be a "prototype" from which the new menu is cloned.
*/
DMenu *
device_create_disk_menu(DMenu *menu, Device **rdevs, int (*hook)())
{
Device *devices;
int numdevs;
devices = device_get_all(DEVICE_TYPE_DISK, &numdevs);
*rdevs = devices;
if (!devices) {
msgConfirm("No devices suitable for installation found!\n\nPlease verify that your disk controller (and attached drives) were detected properly. This can be done by selecting the ``Bootmsg'' option on the main menu and reviewing the boot messages carefully.");
return NULL;
}
else {
Device *start;
DMenu *tmp;
int i;
tmp = (DMenu *)safe_malloc(sizeof(DMenu) +
(sizeof(DMenuItem) * (numdevs + 1)));
bcopy(menu, tmp, sizeof(DMenu));
for (start = devices, i = 0; start->name[0]; start++, i++) {
tmp->items[i].title = start->name;
if (!strncmp(start->name, "sd", 2))
tmp->items[i].prompt = "SCSI disk";
else if (!strncmp(start->name, "wd", 2))
tmp->items[i].prompt = "IDE/ESDI/MFM/ST506 disk";
else
msgFatal("Unknown disk type: %s!", start->name);
tmp->items[i].type = DMENU_CALL;
tmp->items[i].ptr = hook;
tmp->items[i].disabled = FALSE;
}
tmp->items[i].type = DMENU_NOP;
tmp->items[i].title = NULL;
return tmp;
}
return 0;
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.3 1995/04/29 19:33:01 jkh Exp $
* $Id: install.c,v 1.4 1995/05/01 21:56:22 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -46,60 +46,47 @@
static int
installHook(char *str)
{
int rcode = 0;
int i;
struct disk *disks[100]; /* some ridiculously large number */
i = 0;
/* Clip garbage off the ends */
string_prune(str);
str = string_skipwhite(str);
while (str) {
char *cp;
cp = index(str, ' ');
cp = index(str, '\n');
if (cp)
*cp++ = 0;
rcode = !device_slice_disk(str);
if (!*str) {
beep();
return 0;
}
disks[i++] = device_slice_disk(str);
str = cp;
}
return rcode;
}
/* Create a menu listing all the devices in the system. */
static DMenu *
getAllDisks(DMenu *menu, Device **rdevs)
{
Device *devices;
int numdevs;
devices = device_get_all(DEVICE_TYPE_DISK, &numdevs);
*rdevs = devices;
if (!devices) {
msgConfirm("No devices suitable for installation found!\n\nPlease verify that your disk controller (and attached drives) were detected properly. This can be done by selecting the ``Bootmsg'' option on the main menu and reviewing the boot messages carefully.");
return NULL;
}
disks[i] = NULL;
if (!i)
return 0;
else {
Device *start;
DMenu *tmp;
int i;
tmp = (DMenu *)safe_malloc(sizeof(DMenu) +
(sizeof(DMenuItem) * (numdevs + 1)));
bcopy(menu, tmp, sizeof(DMenu));
for (start = devices, i = 0; start->name[0]; start++, i++) {
tmp->items[i].title = start->name;
if (!strncmp(start->name, "sd", 2))
tmp->items[i].prompt = "SCSI disk";
else if (!strncmp(start->name, "wd", 2))
tmp->items[i].prompt = "IDE/ESDI/MFM/ST506 disk";
else
msgFatal("Unknown disk type: %s!", start->name);
tmp->items[i].type = DMENU_CALL;
tmp->items[i].ptr = installHook;
tmp->items[i].disabled = FALSE;
#ifdef notdoneyet
partition_disks(disks);
if (!confirm_write(disks)) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
return 0;
}
tmp->items[i].type = DMENU_NOP;
tmp->items[i].title = NULL;
return tmp;
else {
make_filesystems(disks);
cpio_extract(disks);
extract_dists(disks);
do_final_setup(disks);
systemShutdown();
}
#endif
}
return 1;
}
int
@ -110,9 +97,8 @@ installCustom(char *str)
DMenu *menu;
Device *devs;
msgInfo("Installating the system custom");
variable_set2("install_type", "custom");
menu = getAllDisks(&MenuDiskDevices, &devs);
menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
if (!menu)
return 0;
choice = scroll = curr = max = 0;
@ -130,9 +116,8 @@ installExpress(char *str)
DMenu *menu;
Device *devs;
msgInfo("Installating the system express");
variable_set2("install_type", "express");
menu = getAllDisks(&MenuDiskDevices, &devs);
menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
if (!menu)
return 0;
choice = scroll = curr = max = 0;

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $Id$
* $Id: main.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -48,6 +48,10 @@ main(int argc, char **argv)
{
int choice, scroll, curr, max;
if (geteuid() != 0) {
fprintf(stderr, "This utility can only be run as root.\n");
return 1;
}
/* Set up whatever things need setting up */
systemInitialize(argc, argv);

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.3 1995/04/29 19:33:03 jkh Exp $
* $Id: menus.c,v 1.4 1995/05/01 21:56:25 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -73,12 +73,8 @@ option by pressing enter.", /* prompt */
DMENU_SUBMENU, (void *)&MenuDocumentation, 0 },
{ "Lang", "Select natural language options.", /* L */
DMENU_SUBMENU, (void *)&MenuLanguage, 0 },
{ "Express", "Express installation (don't ask)", /* E */
DMENU_CALL, (void *)installExpress, 0 },
{ "Custom", "Custom installation (please ask)", /* C */
{ "Install", "Begin installation", /* I */
DMENU_CALL, (void *)installCustom, 0 },
{ "Maint", "Go into maintainance mode (`fix it').", /* M */
DMENU_CALL, (void *)installMaint, 0 },
{ "Bootmsg", "Read the boot messages again.", /* B */
DMENU_SYSTEM_COMMAND_BOX, (void *)"dmesg", 0 },
{ NULL } },
@ -142,6 +138,8 @@ of the english versions.", /* prompt */
DMENU_SET_VARIABLE, (void *)"LANG=ru_SU.KOI8-R", 0 },
{ "Spanish", "Spanish language and character set (ISO-8859-1)", /* S */
DMENU_SET_VARIABLE, (void *)"LANG=es_ES.ISO8859-1", 0 },
{ "Swedish", "Swedish language and character set (ISO-8859-1)", /* S */
DMENU_SET_VARIABLE, (void *)"LANG=sv_SV.ISO8859-1", 0 },
{ NULL } },
};
@ -247,10 +245,11 @@ DMenu MenuDiskDevices = {
FreeBSD. You need to select at least one drive containing some free\n\
space, though FreeBSD can be installed across several drives if you do\n\
not have the required space on a single drive. If you wish to boot\n\
off a drive that's not a `zero drive', you will have the option to install\n\
a boot manager later.",
"drives.hlp",
off a drive that's not a `zero drive', or have multiple operating\n\
systems on your machine, you will have the option to install a boot\n\
manager later.",
"Press F1 for more information on what you see here.",
"drives.hlp",
{ { NULL } },
};

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $
* $Id: msg.c,v 1.2 1995/05/01 21:56:29 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,20 +44,45 @@
#include "sysinstall.h"
#include <stdarg.h>
/* Whack up an informational message on the status line */
/* Whack up an informational message on the status line, in stand-out */
void
msgInfo(char *fmt, ...)
msgYap(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
errstr[0] = '\0';
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
addstr(errstr);
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
/* Whack up an informational message on the status line */
void
msgInfo(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
errstr[0] = '\0';
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
attrs = getattrs(stdscr);
attrset(A_NORMAL);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -67,17 +92,19 @@ msgWarn(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Warning: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
attrs = getattrs(stdscr);
beep();
standout();
addstr(errstr);
standend();
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -87,17 +114,19 @@ msgError(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Error: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
beep();
standout();
addstr(errstr);
standend();
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -107,23 +136,25 @@ msgFatal(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Fatal Error: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
beep();
standout();
addstr(errstr);
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
addstr(" - ");
addstr("PRESS ANY KEY TO ");
if (getpid() == 1)
addstr("REBOOT");
else
addstr("QUIT");
standend();
attrset(attrs);
refresh();
free(errstr);
getch();
systemShutdown();
@ -164,3 +195,29 @@ msgYesNo(char *fmt, ...)
free(errstr);
return ret;
}
/* Put up a message in an input box and return the value */
char *
msgGetInput(char *buf, char *fmt, ...)
{
va_list args;
char *errstr;
char *ret;
static input_buffer[256];
int rval;
errstr = (char *)malloc(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
strcpy(input_buffer, buf);
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
free(errstr);
if (!rval)
return input_buffer;
else
return NULL;
}

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.3 1995/04/29 19:33:05 jkh Exp $
* $Id: sysinstall.h,v 1.4 1995/05/01 21:56:30 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -182,11 +182,13 @@ extern int set_termcap(void);
/* msg.c */
extern void msgInfo(char *fmt, ...);
extern void msgYap(char *fmt, ...);
extern void msgWarn(char *fmt, ...);
extern void msgError(char *fmt, ...);
extern void msgFatal(char *fmt, ...);
extern void msgConfirm(char *fmt, ...);
extern int msgYesNo(char *fmt, ...);
extern char *msgGetInput(char *buf, char *fmt, ...);
/* media.c */
extern int mediaSetCDROM(char *str);
@ -198,7 +200,9 @@ extern int mediaSetFS(char *str);
/* devices.c */
extern Device *device_get_all(DeviceType type, int *ndevs);
extern int device_slice_disk(char *disk);
extern struct disk *device_slice_disk(char *disk);
extern DMenu *device_create_disk_menu(DMenu *menu, Device **rdevs,
int (*func)());
/* variables.c */
extern void variable_set(char *var);

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.2 1995/04/27 18:03:53 jkh Exp $
* $Id: devices.c,v 1.1 1995/05/01 21:56:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,6 +44,9 @@
#include "sysinstall.h"
#include "libdisk.h"
/* Where we start displaying chunk information on the screen */
#define CHUNK_START_ROW 5
/* Get all device information for a given device class */
Device *
device_get_all(DeviceType which, int *ndevs)
@ -71,26 +74,78 @@ device_get_all(DeviceType which, int *ndevs)
return devs;
}
void
device_print_chunk(struct chunk *c1, int offset, int *row)
{
CHAR_N
static struct chunk *chunk_info[10];
static int current_chunk;
if (!c1)
return;
mvprintw(*row++, offset, "%10lu %10lu %10lu %-8s %d %-8s %4d %lx",
c1->offset, c1->size, c1->end, c1->name, c1->type,
chunk_n[c1->type], c1->subtype, c1->flags);
device_print_chunk(c1->part, offset + 2, row);
device_print_chunk(c1->next, offset, row);
static void
record_chunks(char *disk, struct disk *d)
{
struct chunk *c1;
int i = 0;
int last_free = 0;
if (!d->chunks)
msgFatal("No chunk list found for %s!", disk);
c1 = d->chunks->part;
while (c1) {
if (c1->type == unused && c1->size > last_free) {
last_free = c1->size;
current_chunk = i;
}
chunk_info[i++] = c1;
c1 = c1->next;
}
chunk_info[i] = NULL;
}
int
static void
print_chunks(char *disk, struct disk *d)
{
int row;
int i;
attrset(A_NORMAL);
mvaddstr(0, 0, "Disk name:\t");
attrset(A_BOLD); addstr(disk); attrset(A_NORMAL);
mvprintw(1, 0,
"BIOS Geometry:\t%lu cyls/%lu heads/%lu sectors",
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");
attrset(A_NORMAL);
for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) {
if (i == current_chunk)
attrset(A_BOLD);
mvprintw(row, 2, "%10lu %10lu %10lu %8s %8d %8s %8d %6lx",
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],
chunk_info[i]->subtype, chunk_info[i]->flags);
if (i == current_chunk)
attrset(A_NORMAL);
}
}
static void
print_command_summary()
{
mvprintw(15, 0, "The following commands are supported (in upper or lower case):");
mvprintw(17, 0, "C = Create New Partition D = Delete Partition");
mvprintw(18, 0, "B = Scan For Bad Blocks U = Undo All Changes");
mvprintw(19, 0, "ESC = Proceed to next screen");
mvprintw(21, 0, "The currently selected partition is displayed in ");
attrset(A_BOLD); addstr("bold"); attrset(A_NORMAL);
move(0, 0);
}
struct disk *
device_slice_disk(char *disk)
{
struct disk *d;
char *p;
int row;
int key = 0;
Boolean chunking;
char *msg = NULL;
d = Open_Disk(disk);
if (!d)
@ -100,23 +155,152 @@ device_slice_disk(char *disk)
msgConfirm(p);
free(p);
}
dialog_clear();
while (1) {
chunking = TRUE;
keypad(stdscr, TRUE);
record_chunks(disk, d);
while (chunking) {
clear();
mvprintw(0, 0, "Disk name: %s, Flags: %lx", disk, d->flags);
mvprintw(1, 0,
"Real Geometry: %lu/%lu/%lu, BIOS Geometry: %lu/%lu/%lu [cyls/heads/sectors]",
d->real_cyl, d->real_hd, d->real_sect,
d->bios_cyl, d->bios_hd, d->bios_sect);
mvprintw(4, 0, "%10s %10s %10s %-8s %4s %-8s %4s %4s",
"Offset", "Size", "End", "Name", "PType", "Desc",
"Subtype", "Flags");
row = 5;
device_print_chunk(d->chunks, 0, &row);
move(23, 0);
addstr("Done!");
if (getch() == 'q')
return 0;
print_chunks(disk, d);
print_command_summary();
if (msg) {
standout(); mvprintw(23, 0, msg); standend();
beep();
msg = NULL;
}
refresh();
key = getch();
switch (key) {
case KEY_UP:
case '-':
if (current_chunk != 0)
--current_chunk;
break;
case KEY_DOWN:
case '+':
case '\r':
case '\n':
if (chunk_info[current_chunk + 1])
++current_chunk;
break;
case KEY_HOME:
current_chunk = 0;
break;
case KEY_END:
while (chunk_info[current_chunk + 1])
++current_chunk;
break;
case KEY_F(1):
case '?':
systemDisplayFile("slice.hlp");
break;
case 'B':
case 'b':
if (chunk_info[current_chunk]->type != freebsd)
msg = "Can only scan for bad blocks in FreeBSD partition.";
else
chunk_info[current_chunk]->flags |= CHUNK_BAD144;
break;
case 'C':
case 'c':
if (chunk_info[current_chunk]->type != unused)
msg = "Partition in use, delete it first or move to an unused one.";
else {
char *val;
char tmp[20];
int size;
snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition");
if (val && (size = atoi(val)) > 0) {
Create_Chunk(d, chunk_info[current_chunk]->offset,
size,
freebsd,
3,
chunk_info[current_chunk]->flags);
record_chunks(disk, d);
}
}
break;
case 'D':
case 'd':
if (chunk_info[current_chunk]->type == unused)
msg = "Partition is already unused!";
else {
Delete_Chunk(d, chunk_info[current_chunk]);
record_chunks(disk, d);
}
break;
case 'U':
case 'u':
Free_Disk(d);
d = Open_Disk(disk);
record_chunks(disk, d);
break;
case 27: /* ESC */
chunking = FALSE;
break;
default:
msg = "Invalid character typed.";
break;
}
}
clear();
refresh();
return d;
}
/*
* Create a menu listing all the devices in the system. The pass-in menu
* is expected to be a "prototype" from which the new menu is cloned.
*/
DMenu *
device_create_disk_menu(DMenu *menu, Device **rdevs, int (*hook)())
{
Device *devices;
int numdevs;
devices = device_get_all(DEVICE_TYPE_DISK, &numdevs);
*rdevs = devices;
if (!devices) {
msgConfirm("No devices suitable for installation found!\n\nPlease verify that your disk controller (and attached drives) were detected properly. This can be done by selecting the ``Bootmsg'' option on the main menu and reviewing the boot messages carefully.");
return NULL;
}
else {
Device *start;
DMenu *tmp;
int i;
tmp = (DMenu *)safe_malloc(sizeof(DMenu) +
(sizeof(DMenuItem) * (numdevs + 1)));
bcopy(menu, tmp, sizeof(DMenu));
for (start = devices, i = 0; start->name[0]; start++, i++) {
tmp->items[i].title = start->name;
if (!strncmp(start->name, "sd", 2))
tmp->items[i].prompt = "SCSI disk";
else if (!strncmp(start->name, "wd", 2))
tmp->items[i].prompt = "IDE/ESDI/MFM/ST506 disk";
else
msgFatal("Unknown disk type: %s!", start->name);
tmp->items[i].type = DMENU_CALL;
tmp->items[i].ptr = hook;
tmp->items[i].disabled = FALSE;
}
tmp->items[i].type = DMENU_NOP;
tmp->items[i].title = NULL;
return tmp;
}
return 0;
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.3 1995/04/29 19:33:01 jkh Exp $
* $Id: install.c,v 1.4 1995/05/01 21:56:22 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -46,60 +46,47 @@
static int
installHook(char *str)
{
int rcode = 0;
int i;
struct disk *disks[100]; /* some ridiculously large number */
i = 0;
/* Clip garbage off the ends */
string_prune(str);
str = string_skipwhite(str);
while (str) {
char *cp;
cp = index(str, ' ');
cp = index(str, '\n');
if (cp)
*cp++ = 0;
rcode = !device_slice_disk(str);
if (!*str) {
beep();
return 0;
}
disks[i++] = device_slice_disk(str);
str = cp;
}
return rcode;
}
/* Create a menu listing all the devices in the system. */
static DMenu *
getAllDisks(DMenu *menu, Device **rdevs)
{
Device *devices;
int numdevs;
devices = device_get_all(DEVICE_TYPE_DISK, &numdevs);
*rdevs = devices;
if (!devices) {
msgConfirm("No devices suitable for installation found!\n\nPlease verify that your disk controller (and attached drives) were detected properly. This can be done by selecting the ``Bootmsg'' option on the main menu and reviewing the boot messages carefully.");
return NULL;
}
disks[i] = NULL;
if (!i)
return 0;
else {
Device *start;
DMenu *tmp;
int i;
tmp = (DMenu *)safe_malloc(sizeof(DMenu) +
(sizeof(DMenuItem) * (numdevs + 1)));
bcopy(menu, tmp, sizeof(DMenu));
for (start = devices, i = 0; start->name[0]; start++, i++) {
tmp->items[i].title = start->name;
if (!strncmp(start->name, "sd", 2))
tmp->items[i].prompt = "SCSI disk";
else if (!strncmp(start->name, "wd", 2))
tmp->items[i].prompt = "IDE/ESDI/MFM/ST506 disk";
else
msgFatal("Unknown disk type: %s!", start->name);
tmp->items[i].type = DMENU_CALL;
tmp->items[i].ptr = installHook;
tmp->items[i].disabled = FALSE;
#ifdef notdoneyet
partition_disks(disks);
if (!confirm_write(disks)) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
return 0;
}
tmp->items[i].type = DMENU_NOP;
tmp->items[i].title = NULL;
return tmp;
else {
make_filesystems(disks);
cpio_extract(disks);
extract_dists(disks);
do_final_setup(disks);
systemShutdown();
}
#endif
}
return 1;
}
int
@ -110,9 +97,8 @@ installCustom(char *str)
DMenu *menu;
Device *devs;
msgInfo("Installating the system custom");
variable_set2("install_type", "custom");
menu = getAllDisks(&MenuDiskDevices, &devs);
menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
if (!menu)
return 0;
choice = scroll = curr = max = 0;
@ -130,9 +116,8 @@ installExpress(char *str)
DMenu *menu;
Device *devs;
msgInfo("Installating the system express");
variable_set2("install_type", "express");
menu = getAllDisks(&MenuDiskDevices, &devs);
menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
if (!menu)
return 0;
choice = scroll = curr = max = 0;

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $Id$
* $Id: main.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -48,6 +48,10 @@ main(int argc, char **argv)
{
int choice, scroll, curr, max;
if (geteuid() != 0) {
fprintf(stderr, "This utility can only be run as root.\n");
return 1;
}
/* Set up whatever things need setting up */
systemInitialize(argc, argv);

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.3 1995/04/29 19:33:03 jkh Exp $
* $Id: menus.c,v 1.4 1995/05/01 21:56:25 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -73,12 +73,8 @@ option by pressing enter.", /* prompt */
DMENU_SUBMENU, (void *)&MenuDocumentation, 0 },
{ "Lang", "Select natural language options.", /* L */
DMENU_SUBMENU, (void *)&MenuLanguage, 0 },
{ "Express", "Express installation (don't ask)", /* E */
DMENU_CALL, (void *)installExpress, 0 },
{ "Custom", "Custom installation (please ask)", /* C */
{ "Install", "Begin installation", /* I */
DMENU_CALL, (void *)installCustom, 0 },
{ "Maint", "Go into maintainance mode (`fix it').", /* M */
DMENU_CALL, (void *)installMaint, 0 },
{ "Bootmsg", "Read the boot messages again.", /* B */
DMENU_SYSTEM_COMMAND_BOX, (void *)"dmesg", 0 },
{ NULL } },
@ -142,6 +138,8 @@ of the english versions.", /* prompt */
DMENU_SET_VARIABLE, (void *)"LANG=ru_SU.KOI8-R", 0 },
{ "Spanish", "Spanish language and character set (ISO-8859-1)", /* S */
DMENU_SET_VARIABLE, (void *)"LANG=es_ES.ISO8859-1", 0 },
{ "Swedish", "Swedish language and character set (ISO-8859-1)", /* S */
DMENU_SET_VARIABLE, (void *)"LANG=sv_SV.ISO8859-1", 0 },
{ NULL } },
};
@ -247,10 +245,11 @@ DMenu MenuDiskDevices = {
FreeBSD. You need to select at least one drive containing some free\n\
space, though FreeBSD can be installed across several drives if you do\n\
not have the required space on a single drive. If you wish to boot\n\
off a drive that's not a `zero drive', you will have the option to install\n\
a boot manager later.",
"drives.hlp",
off a drive that's not a `zero drive', or have multiple operating\n\
systems on your machine, you will have the option to install a boot\n\
manager later.",
"Press F1 for more information on what you see here.",
"drives.hlp",
{ { NULL } },
};

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $
* $Id: msg.c,v 1.2 1995/05/01 21:56:29 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,20 +44,45 @@
#include "sysinstall.h"
#include <stdarg.h>
/* Whack up an informational message on the status line */
/* Whack up an informational message on the status line, in stand-out */
void
msgInfo(char *fmt, ...)
msgYap(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
errstr[0] = '\0';
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
addstr(errstr);
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
/* Whack up an informational message on the status line */
void
msgInfo(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
errstr[0] = '\0';
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
attrs = getattrs(stdscr);
attrset(A_NORMAL);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -67,17 +92,19 @@ msgWarn(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Warning: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
attrs = getattrs(stdscr);
beep();
standout();
addstr(errstr);
standend();
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -87,17 +114,19 @@ msgError(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Error: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
beep();
standout();
addstr(errstr);
standend();
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -107,23 +136,25 @@ msgFatal(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Fatal Error: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
beep();
standout();
addstr(errstr);
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
addstr(" - ");
addstr("PRESS ANY KEY TO ");
if (getpid() == 1)
addstr("REBOOT");
else
addstr("QUIT");
standend();
attrset(attrs);
refresh();
free(errstr);
getch();
systemShutdown();
@ -164,3 +195,29 @@ msgYesNo(char *fmt, ...)
free(errstr);
return ret;
}
/* Put up a message in an input box and return the value */
char *
msgGetInput(char *buf, char *fmt, ...)
{
va_list args;
char *errstr;
char *ret;
static input_buffer[256];
int rval;
errstr = (char *)malloc(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
strcpy(input_buffer, buf);
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
free(errstr);
if (!rval)
return input_buffer;
else
return NULL;
}

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.3 1995/04/29 19:33:05 jkh Exp $
* $Id: sysinstall.h,v 1.4 1995/05/01 21:56:30 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -182,11 +182,13 @@ extern int set_termcap(void);
/* msg.c */
extern void msgInfo(char *fmt, ...);
extern void msgYap(char *fmt, ...);
extern void msgWarn(char *fmt, ...);
extern void msgError(char *fmt, ...);
extern void msgFatal(char *fmt, ...);
extern void msgConfirm(char *fmt, ...);
extern int msgYesNo(char *fmt, ...);
extern char *msgGetInput(char *buf, char *fmt, ...);
/* media.c */
extern int mediaSetCDROM(char *str);
@ -198,7 +200,9 @@ extern int mediaSetFS(char *str);
/* devices.c */
extern Device *device_get_all(DeviceType type, int *ndevs);
extern int device_slice_disk(char *disk);
extern struct disk *device_slice_disk(char *disk);
extern DMenu *device_create_disk_menu(DMenu *menu, Device **rdevs,
int (*func)());
/* variables.c */
extern void variable_set(char *var);

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.2 1995/04/27 18:03:53 jkh Exp $
* $Id: devices.c,v 1.1 1995/05/01 21:56:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,6 +44,9 @@
#include "sysinstall.h"
#include "libdisk.h"
/* Where we start displaying chunk information on the screen */
#define CHUNK_START_ROW 5
/* Get all device information for a given device class */
Device *
device_get_all(DeviceType which, int *ndevs)
@ -71,26 +74,78 @@ device_get_all(DeviceType which, int *ndevs)
return devs;
}
void
device_print_chunk(struct chunk *c1, int offset, int *row)
{
CHAR_N
static struct chunk *chunk_info[10];
static int current_chunk;
if (!c1)
return;
mvprintw(*row++, offset, "%10lu %10lu %10lu %-8s %d %-8s %4d %lx",
c1->offset, c1->size, c1->end, c1->name, c1->type,
chunk_n[c1->type], c1->subtype, c1->flags);
device_print_chunk(c1->part, offset + 2, row);
device_print_chunk(c1->next, offset, row);
static void
record_chunks(char *disk, struct disk *d)
{
struct chunk *c1;
int i = 0;
int last_free = 0;
if (!d->chunks)
msgFatal("No chunk list found for %s!", disk);
c1 = d->chunks->part;
while (c1) {
if (c1->type == unused && c1->size > last_free) {
last_free = c1->size;
current_chunk = i;
}
chunk_info[i++] = c1;
c1 = c1->next;
}
chunk_info[i] = NULL;
}
int
static void
print_chunks(char *disk, struct disk *d)
{
int row;
int i;
attrset(A_NORMAL);
mvaddstr(0, 0, "Disk name:\t");
attrset(A_BOLD); addstr(disk); attrset(A_NORMAL);
mvprintw(1, 0,
"BIOS Geometry:\t%lu cyls/%lu heads/%lu sectors",
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");
attrset(A_NORMAL);
for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) {
if (i == current_chunk)
attrset(A_BOLD);
mvprintw(row, 2, "%10lu %10lu %10lu %8s %8d %8s %8d %6lx",
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],
chunk_info[i]->subtype, chunk_info[i]->flags);
if (i == current_chunk)
attrset(A_NORMAL);
}
}
static void
print_command_summary()
{
mvprintw(15, 0, "The following commands are supported (in upper or lower case):");
mvprintw(17, 0, "C = Create New Partition D = Delete Partition");
mvprintw(18, 0, "B = Scan For Bad Blocks U = Undo All Changes");
mvprintw(19, 0, "ESC = Proceed to next screen");
mvprintw(21, 0, "The currently selected partition is displayed in ");
attrset(A_BOLD); addstr("bold"); attrset(A_NORMAL);
move(0, 0);
}
struct disk *
device_slice_disk(char *disk)
{
struct disk *d;
char *p;
int row;
int key = 0;
Boolean chunking;
char *msg = NULL;
d = Open_Disk(disk);
if (!d)
@ -100,23 +155,152 @@ device_slice_disk(char *disk)
msgConfirm(p);
free(p);
}
dialog_clear();
while (1) {
chunking = TRUE;
keypad(stdscr, TRUE);
record_chunks(disk, d);
while (chunking) {
clear();
mvprintw(0, 0, "Disk name: %s, Flags: %lx", disk, d->flags);
mvprintw(1, 0,
"Real Geometry: %lu/%lu/%lu, BIOS Geometry: %lu/%lu/%lu [cyls/heads/sectors]",
d->real_cyl, d->real_hd, d->real_sect,
d->bios_cyl, d->bios_hd, d->bios_sect);
mvprintw(4, 0, "%10s %10s %10s %-8s %4s %-8s %4s %4s",
"Offset", "Size", "End", "Name", "PType", "Desc",
"Subtype", "Flags");
row = 5;
device_print_chunk(d->chunks, 0, &row);
move(23, 0);
addstr("Done!");
if (getch() == 'q')
return 0;
print_chunks(disk, d);
print_command_summary();
if (msg) {
standout(); mvprintw(23, 0, msg); standend();
beep();
msg = NULL;
}
refresh();
key = getch();
switch (key) {
case KEY_UP:
case '-':
if (current_chunk != 0)
--current_chunk;
break;
case KEY_DOWN:
case '+':
case '\r':
case '\n':
if (chunk_info[current_chunk + 1])
++current_chunk;
break;
case KEY_HOME:
current_chunk = 0;
break;
case KEY_END:
while (chunk_info[current_chunk + 1])
++current_chunk;
break;
case KEY_F(1):
case '?':
systemDisplayFile("slice.hlp");
break;
case 'B':
case 'b':
if (chunk_info[current_chunk]->type != freebsd)
msg = "Can only scan for bad blocks in FreeBSD partition.";
else
chunk_info[current_chunk]->flags |= CHUNK_BAD144;
break;
case 'C':
case 'c':
if (chunk_info[current_chunk]->type != unused)
msg = "Partition in use, delete it first or move to an unused one.";
else {
char *val;
char tmp[20];
int size;
snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition");
if (val && (size = atoi(val)) > 0) {
Create_Chunk(d, chunk_info[current_chunk]->offset,
size,
freebsd,
3,
chunk_info[current_chunk]->flags);
record_chunks(disk, d);
}
}
break;
case 'D':
case 'd':
if (chunk_info[current_chunk]->type == unused)
msg = "Partition is already unused!";
else {
Delete_Chunk(d, chunk_info[current_chunk]);
record_chunks(disk, d);
}
break;
case 'U':
case 'u':
Free_Disk(d);
d = Open_Disk(disk);
record_chunks(disk, d);
break;
case 27: /* ESC */
chunking = FALSE;
break;
default:
msg = "Invalid character typed.";
break;
}
}
clear();
refresh();
return d;
}
/*
* Create a menu listing all the devices in the system. The pass-in menu
* is expected to be a "prototype" from which the new menu is cloned.
*/
DMenu *
device_create_disk_menu(DMenu *menu, Device **rdevs, int (*hook)())
{
Device *devices;
int numdevs;
devices = device_get_all(DEVICE_TYPE_DISK, &numdevs);
*rdevs = devices;
if (!devices) {
msgConfirm("No devices suitable for installation found!\n\nPlease verify that your disk controller (and attached drives) were detected properly. This can be done by selecting the ``Bootmsg'' option on the main menu and reviewing the boot messages carefully.");
return NULL;
}
else {
Device *start;
DMenu *tmp;
int i;
tmp = (DMenu *)safe_malloc(sizeof(DMenu) +
(sizeof(DMenuItem) * (numdevs + 1)));
bcopy(menu, tmp, sizeof(DMenu));
for (start = devices, i = 0; start->name[0]; start++, i++) {
tmp->items[i].title = start->name;
if (!strncmp(start->name, "sd", 2))
tmp->items[i].prompt = "SCSI disk";
else if (!strncmp(start->name, "wd", 2))
tmp->items[i].prompt = "IDE/ESDI/MFM/ST506 disk";
else
msgFatal("Unknown disk type: %s!", start->name);
tmp->items[i].type = DMENU_CALL;
tmp->items[i].ptr = hook;
tmp->items[i].disabled = FALSE;
}
tmp->items[i].type = DMENU_NOP;
tmp->items[i].title = NULL;
return tmp;
}
return 0;
}

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.3 1995/04/29 19:33:01 jkh Exp $
* $Id: install.c,v 1.4 1995/05/01 21:56:22 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -46,60 +46,47 @@
static int
installHook(char *str)
{
int rcode = 0;
int i;
struct disk *disks[100]; /* some ridiculously large number */
i = 0;
/* Clip garbage off the ends */
string_prune(str);
str = string_skipwhite(str);
while (str) {
char *cp;
cp = index(str, ' ');
cp = index(str, '\n');
if (cp)
*cp++ = 0;
rcode = !device_slice_disk(str);
if (!*str) {
beep();
return 0;
}
disks[i++] = device_slice_disk(str);
str = cp;
}
return rcode;
}
/* Create a menu listing all the devices in the system. */
static DMenu *
getAllDisks(DMenu *menu, Device **rdevs)
{
Device *devices;
int numdevs;
devices = device_get_all(DEVICE_TYPE_DISK, &numdevs);
*rdevs = devices;
if (!devices) {
msgConfirm("No devices suitable for installation found!\n\nPlease verify that your disk controller (and attached drives) were detected properly. This can be done by selecting the ``Bootmsg'' option on the main menu and reviewing the boot messages carefully.");
return NULL;
}
disks[i] = NULL;
if (!i)
return 0;
else {
Device *start;
DMenu *tmp;
int i;
tmp = (DMenu *)safe_malloc(sizeof(DMenu) +
(sizeof(DMenuItem) * (numdevs + 1)));
bcopy(menu, tmp, sizeof(DMenu));
for (start = devices, i = 0; start->name[0]; start++, i++) {
tmp->items[i].title = start->name;
if (!strncmp(start->name, "sd", 2))
tmp->items[i].prompt = "SCSI disk";
else if (!strncmp(start->name, "wd", 2))
tmp->items[i].prompt = "IDE/ESDI/MFM/ST506 disk";
else
msgFatal("Unknown disk type: %s!", start->name);
tmp->items[i].type = DMENU_CALL;
tmp->items[i].ptr = installHook;
tmp->items[i].disabled = FALSE;
#ifdef notdoneyet
partition_disks(disks);
if (!confirm_write(disks)) {
for (i = 0; disks[i]; i++)
Free_Disk(disks[i]);
return 0;
}
tmp->items[i].type = DMENU_NOP;
tmp->items[i].title = NULL;
return tmp;
else {
make_filesystems(disks);
cpio_extract(disks);
extract_dists(disks);
do_final_setup(disks);
systemShutdown();
}
#endif
}
return 1;
}
int
@ -110,9 +97,8 @@ installCustom(char *str)
DMenu *menu;
Device *devs;
msgInfo("Installating the system custom");
variable_set2("install_type", "custom");
menu = getAllDisks(&MenuDiskDevices, &devs);
menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
if (!menu)
return 0;
choice = scroll = curr = max = 0;
@ -130,9 +116,8 @@ installExpress(char *str)
DMenu *menu;
Device *devs;
msgInfo("Installating the system express");
variable_set2("install_type", "express");
menu = getAllDisks(&MenuDiskDevices, &devs);
menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
if (!menu)
return 0;
choice = scroll = curr = max = 0;

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $Id$
* $Id: main.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -48,6 +48,10 @@ main(int argc, char **argv)
{
int choice, scroll, curr, max;
if (geteuid() != 0) {
fprintf(stderr, "This utility can only be run as root.\n");
return 1;
}
/* Set up whatever things need setting up */
systemInitialize(argc, argv);

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.3 1995/04/29 19:33:03 jkh Exp $
* $Id: menus.c,v 1.4 1995/05/01 21:56:25 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -73,12 +73,8 @@ option by pressing enter.", /* prompt */
DMENU_SUBMENU, (void *)&MenuDocumentation, 0 },
{ "Lang", "Select natural language options.", /* L */
DMENU_SUBMENU, (void *)&MenuLanguage, 0 },
{ "Express", "Express installation (don't ask)", /* E */
DMENU_CALL, (void *)installExpress, 0 },
{ "Custom", "Custom installation (please ask)", /* C */
{ "Install", "Begin installation", /* I */
DMENU_CALL, (void *)installCustom, 0 },
{ "Maint", "Go into maintainance mode (`fix it').", /* M */
DMENU_CALL, (void *)installMaint, 0 },
{ "Bootmsg", "Read the boot messages again.", /* B */
DMENU_SYSTEM_COMMAND_BOX, (void *)"dmesg", 0 },
{ NULL } },
@ -142,6 +138,8 @@ of the english versions.", /* prompt */
DMENU_SET_VARIABLE, (void *)"LANG=ru_SU.KOI8-R", 0 },
{ "Spanish", "Spanish language and character set (ISO-8859-1)", /* S */
DMENU_SET_VARIABLE, (void *)"LANG=es_ES.ISO8859-1", 0 },
{ "Swedish", "Swedish language and character set (ISO-8859-1)", /* S */
DMENU_SET_VARIABLE, (void *)"LANG=sv_SV.ISO8859-1", 0 },
{ NULL } },
};
@ -247,10 +245,11 @@ DMenu MenuDiskDevices = {
FreeBSD. You need to select at least one drive containing some free\n\
space, though FreeBSD can be installed across several drives if you do\n\
not have the required space on a single drive. If you wish to boot\n\
off a drive that's not a `zero drive', you will have the option to install\n\
a boot manager later.",
"drives.hlp",
off a drive that's not a `zero drive', or have multiple operating\n\
systems on your machine, you will have the option to install a boot\n\
manager later.",
"Press F1 for more information on what you see here.",
"drives.hlp",
{ { NULL } },
};

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $
* $Id: msg.c,v 1.2 1995/05/01 21:56:29 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,20 +44,45 @@
#include "sysinstall.h"
#include <stdarg.h>
/* Whack up an informational message on the status line */
/* Whack up an informational message on the status line, in stand-out */
void
msgInfo(char *fmt, ...)
msgYap(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
errstr[0] = '\0';
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
addstr(errstr);
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
/* Whack up an informational message on the status line */
void
msgInfo(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
errstr[0] = '\0';
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
attrs = getattrs(stdscr);
attrset(A_NORMAL);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -67,17 +92,19 @@ msgWarn(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Warning: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
attrs = getattrs(stdscr);
beep();
standout();
addstr(errstr);
standend();
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -87,17 +114,19 @@ msgError(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Error: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
beep();
standout();
addstr(errstr);
standend();
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
}
@ -107,23 +136,25 @@ msgFatal(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)malloc(FILENAME_MAX);
strcpy(errstr, "Fatal Error: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
move(25, 0);
beep();
standout();
addstr(errstr);
attrs = getattrs(stdscr);
attrset(A_BOLD);
mvaddstr(23, 0, errstr);
addstr(" - ");
addstr("PRESS ANY KEY TO ");
if (getpid() == 1)
addstr("REBOOT");
else
addstr("QUIT");
standend();
attrset(attrs);
refresh();
free(errstr);
getch();
systemShutdown();
@ -164,3 +195,29 @@ msgYesNo(char *fmt, ...)
free(errstr);
return ret;
}
/* Put up a message in an input box and return the value */
char *
msgGetInput(char *buf, char *fmt, ...)
{
va_list args;
char *errstr;
char *ret;
static input_buffer[256];
int rval;
errstr = (char *)malloc(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
strcpy(input_buffer, buf);
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
free(errstr);
if (!rval)
return input_buffer;
else
return NULL;
}

View File

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.3 1995/04/29 19:33:05 jkh Exp $
* $Id: sysinstall.h,v 1.4 1995/05/01 21:56:30 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -182,11 +182,13 @@ extern int set_termcap(void);
/* msg.c */
extern void msgInfo(char *fmt, ...);
extern void msgYap(char *fmt, ...);
extern void msgWarn(char *fmt, ...);
extern void msgError(char *fmt, ...);
extern void msgFatal(char *fmt, ...);
extern void msgConfirm(char *fmt, ...);
extern int msgYesNo(char *fmt, ...);
extern char *msgGetInput(char *buf, char *fmt, ...);
/* media.c */
extern int mediaSetCDROM(char *str);
@ -198,7 +200,9 @@ extern int mediaSetFS(char *str);
/* devices.c */
extern Device *device_get_all(DeviceType type, int *ndevs);
extern int device_slice_disk(char *disk);
extern struct disk *device_slice_disk(char *disk);
extern DMenu *device_create_disk_menu(DMenu *menu, Device **rdevs,
int (*func)());
/* variables.c */
extern void variable_set(char *var);