1. Fix a pathological bug I introduced in msgInfo(). Right idea, wrong

implementation.

2. Totally rework device registration.  It's about half the size and
   more powerful now.

3. Add DOS discovery.

4. Start filling in some of the strategy routines.

5. Another clean-up pass over the menus.

6. Make wizard code use Disk typedef.

If I can get the first strategy routine finished tonite, we should have a working
install (from ftp, at least) this weekend.
This commit is contained in:
Jordan K. Hubbard 1995-05-20 10:33:14 +00:00
parent 2cf252e087
commit f10eb488f6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8641
33 changed files with 461 additions and 360 deletions

View file

@ -4,12 +4,14 @@ CLEANFILES= makedevs.c rtermcap
.PATH: ${.CURDIR}/../disklabel
SRCS= globals.c main.c dmenu.c menus.c \
misc.c msg.c system.c install.c \
termcap.c makedevs.c media.c variable.c \
devices.c dist.c lang.c wizard.c \
disks.c command.c decode.c label.c \
tcpip.c media_strategy.c
SRCS= globals.c main.c dmenu.c \
menus.c misc.c msg.c \
system.c install.c termcap.c \
media.c variable.c devices.c \
dist.c lang.c wizard.c \
disks.c command.c decode.c \
label.c tcpip.c media_strategy.c \
makedevs.c
CFLAGS+= -Wall -g -I${.CURDIR}/../libdisk \
-I${.CURDIR}/../../gnu/lib/libdialog

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: devices.c,v 1.19 1995/05/19 02:31:13 jkh Exp $
* $Id: devices.c,v 1.20 1995/05/20 00:13:06 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -69,9 +69,6 @@
static Device *Devices[DEV_MAX];
static int numDevs;
#define CHECK_DEVS \
if (numDevs == DEV_MAX) msgFatal("Too many devices found!")
static struct {
DeviceType type;
char *name;
@ -110,7 +107,7 @@ static struct {
{ NULL },
};
static Device *
Device *
new_device(char *name)
{
Device *dev;
@ -143,6 +140,29 @@ deviceDiskFree(Device *dev)
Free_Disk(dev->private);
}
/* Register a new device in the devices array */
Device *
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *), Boolean (*get)(char *), void (*close)(Device *), void *private)
{
Device *newdev;
if (numDevs == DEV_MAX)
msgFatal("Too many devices found!");
newdev = new_device(name);
newdev->description = desc;
newdev->devname = devname;
newdev->type = type;
newdev->enabled = enabled;
newdev->init = init;
newdev->get = get;
newdev->close = close;
newdev->private = private;
Devices[numDevs] = newdev;
Devices[++numDevs] = NULL;
return newdev;
}
/* Get all device information for devices we have attached */
void
deviceGetAll(void)
@ -159,18 +179,15 @@ deviceGetAll(void)
int i;
for (i = 0; names[i]; i++) {
CHECK_DEVS;
Devices[numDevs] = new_device(names[i]);
Devices[numDevs]->type = DEVICE_TYPE_DISK;
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitUFS;
Devices[numDevs]->get = mediaGetUFS;
Devices[numDevs]->close = deviceDiskFree;
Devices[numDevs]->private = Open_Disk(names[i]);
if (!Devices[numDevs]->private)
msgFatal("Unable to open device for %s!", names[i]);
Disk *d;
d = Open_Disk(names[i]);
if (!d)
msgFatal("Unable to open disk %s", names[i]);
(void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
mediaInitUFS, mediaGetUFS, deviceDiskFree, d);
msgDebug("Found a device of type disk named: %s\n", names[i]);
++numDevs;
}
free(names);
}
@ -187,19 +204,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_CDROM;
Devices[numDevs]->description = device_names[i].description;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE; /* XXX check for FreeBSD disk later XXX */
Devices[numDevs]->init = mediaInitCDROM;
Devices[numDevs]->get = mediaGetCDROM;
Devices[numDevs]->close = NULL;
Devices[numDevs]->private = NULL;
msgDebug("Found a device of type CDROM named: %s\n",
device_names[i].name);
++numDevs;
(void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, mediaCloseCDROM, NULL);
msgDebug("Found a device of type CDROM named: %s\n", device_names[i].name);
}
break;
@ -207,17 +214,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_TAPE;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE;
Devices[numDevs]->init = mediaInitTape;
Devices[numDevs]->get = mediaGetTape;
Devices[numDevs]->close = mediaCloseTape;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaCloseTape, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -225,17 +224,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_FLOPPY;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE;
Devices[numDevs]->init = mediaInitFloppy;
Devices[numDevs]->get = mediaGetFloppy;
Devices[numDevs]->close = mediaCloseFloppy;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, mediaCloseFloppy, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -243,17 +234,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_NETWORK;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitNetwork;
Devices[numDevs]->get = mediaGetNetwork;
Devices[numDevs]->close = mediaCloseNetwork;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, mediaGetNetwork, mediaCloseNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -285,33 +268,23 @@ deviceGetAll(void)
if (!strncmp(ifptr->ifr_name, "tun", 3)
|| !strncmp(ifptr->ifr_name, "lo0", 3))
continue;
CHECK_DEVS;
Devices[numDevs] = new_device(ifptr->ifr_name);
Devices[numDevs]->type = DEVICE_TYPE_NETWORK;
Devices[numDevs]->devname = NULL;
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitNetwork;
Devices[numDevs]->get = mediaGetNetwork;
Devices[numDevs]->close = mediaCloseNetwork;
Devices[numDevs]->private = NULL;
deviceRegister(ifptr->ifr_name, ifptr->ifr_name, ifptr->ifr_name,
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, mediaGetNetwork, mediaCloseNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", ifptr->ifr_name);
++numDevs;
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
msgConfirm("ifconfig: socket");
continue;
}
if (ifptr->ifr_addr.sa_len) /* Dohw! */
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len
- sizeof(struct sockaddr));
if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr));
}
/* Terminate the devices array */
Devices[numDevs] = NULL;
}
/*
* Find all devices that match the criteria, allowing "wildcarding" as well
* by allowing NULL or ANY values to match all.
* by allowing NULL or ANY values to match all. The array returned is static
* and may be used until the next invocation of deviceFind().
*/
Device **
deviceFind(char *name, DeviceType class)

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: disks.c,v 1.21 1995/05/17 16:16:07 jkh Exp $
* $Id: disks.c,v 1.22 1995/05/18 09:01:50 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -316,7 +316,6 @@ partitionHook(char *str)
int
diskPartitionEditor(char *str)
{
int scroll, choice, curr, max;
DMenu *menu;
menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook);
@ -324,8 +323,7 @@ diskPartitionEditor(char *str)
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.");
}
else {
choice = scroll = curr = max = 0;
dmenuOpen(menu, &choice, &scroll, &curr, &max);
dmenuOpenSimple(menu);
free(menu);
}
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.32 1995/05/20 00:13:10 jkh Exp $
* $Id: install.c,v 1.33 1995/05/20 08:31:40 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -45,6 +45,7 @@
#include <sys/disklabel.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/wait.h>
#include <unistd.h>
Boolean SystemWasInstalled;
@ -92,7 +93,7 @@ installInitial(void)
/* If things aren't kosher, or we refuse to proceed, bail. */
if (!preInstallCheck()
|| msgYesNo("Last Chance! Are you SURE you want continue the installation?\n\nIf you're running this on an existing system, we STRONGLY\nencourage you to make proper backups before proceeding.\nWe take no responsibility for lost disk contents!"))
return 0;
return;
mbrContents = NULL;
if (!msgYesNo("Would you like to install a boot manager?\n\nThis will allow you to easily select between other operating systems\non the first disk, or boot from a disk other than the first."))
@ -272,7 +273,6 @@ static void
cpio_extract(void)
{
int i, j, zpid, cpid, pfd[2];
extern int wait(int *status);
tryagain:
j = fork();
@ -319,7 +319,7 @@ cpio_extract(void)
msgConfirm("gunzip returned status of %d, error was: %s (%d)! Help!", j, strerror(errno), errno);
exit(1);
}
i = waitpid(cpid, &j);
i = waitpid(cpid, &j, 0);
if (i < 0 || j) {
msgConfirm("cpio returned status of %d, error was: %s (%d)! Help!", j, strerror(errno), errno);
exit(2);

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: label.c,v 1.9 1995/05/19 02:09:02 jkh Exp $
* $Id: label.c,v 1.10 1995/05/19 02:19:15 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -279,7 +279,6 @@ print_label_chunks(void)
{
int i, j, srow, prow, pcol;
int sz;
int label_attr;
clear();
attrset(A_REVERSE);

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: media.c,v 1.7 1995/05/20 00:13:11 jkh Exp $
* $Id: media.c,v 1.8 1995/05/20 03:49:09 gpalmer Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,6 +44,28 @@
#include <stdio.h>
#include "sysinstall.h"
static int
genericHook(char *str, DeviceType type)
{
Device **devs;
/* Clip garbage off the ends */
string_prune(str);
str = string_skipwhite(str);
if (!*str)
return 0;
devs = deviceFind(str, type);
if (devs)
mediaDevice = devs[0];
return devs ? 1 : 0;
}
static int
cdromHook(char *str)
{
return genericHook(str, DEVICE_TYPE_CDROM);
}
/*
* Return 1 if we successfully found and set the installation type to
* be a CD.
@ -54,8 +76,10 @@ mediaSetCDROM(char *str)
Device **devs;
int cnt;
if (OnCDROM == TRUE)
if (OnCDROM == TRUE) {
/* XXX point mediaDevice at something meaningful here - perhaps a static device structure */
return 1;
}
else {
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
cnt = deviceCount(devs);
@ -64,13 +88,24 @@ mediaSetCDROM(char *str)
return 0;
}
else if (cnt > 1) {
/* put up a menu */
DMenu *menu;
menu = deviceCreateMenu(&MenuMediaCDROM, DEVICE_TYPE_CDROM, cdromHook);
if (!menu)
msgFatal("Unable to create CDROM menu! Something is seriously wrong.");
dmenuOpenSimple(menu);
free(menu);
}
else {
else
mediaDevice = devs[0];
}
}
return 0;
return mediaDevice ? 1 : 0;
}
static int
floppyHook(char *str)
{
return genericHook(str, DEVICE_TYPE_FLOPPY);
}
/*
@ -80,8 +115,27 @@ mediaSetCDROM(char *str)
int
mediaSetFloppy(char *str)
{
dmenuOpenSimple(&MenuMediaFloppy);
return 0;
Device **devs;
int cnt;
devs = deviceFind(NULL, DEVICE_TYPE_FLOPPY);
cnt = deviceCount(devs);
if (!cnt) {
msgConfirm("No floppy devices found! Please check that your system's\nconfiguration is correct. For more information, consult the hardware guide\nin the Doc menu.");
return 0;
}
else if (cnt > 1) {
DMenu *menu;
menu = deviceCreateMenu(&MenuMediaFloppy, DEVICE_TYPE_FLOPPY, floppyHook);
if (!menu)
msgFatal("Unable to create Floppy menu! Something is seriously wrong.");
dmenuOpenSimple(menu);
free(menu);
}
else
mediaDevice = devs[0];
return mediaDevice ? 1 : 0;
}
/*
@ -92,11 +146,31 @@ int
mediaSetDOS(char *str)
{
Device **devs;
Disk *d;
Chunk *c1;
int i;
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
if (!devs)
msgConfirm("No disk devices found!");
return 0;
for (i = 0; devs[i]; i++) {
if (!devs[i]->enabled)
continue;
d = (Disk *)devs[i]->private;
/* Now try to find a DOS partition */
for (c1 = d->chunks->part; c1; c1 = c1->next) {
if (c1->type == fat) {
/* Got one! */
mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DISK, TRUE,
mediaInitDOS, mediaGetDOS, mediaCloseDOS, NULL);
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
break;
}
}
}
if (!mediaDevice)
msgConfirm("No DOS primary partitions found! This installation method is unavailable");
return mediaDevice ? 1 : 0;
}
/*
@ -158,14 +232,7 @@ mediaExtractDist(FILE *fp)
Boolean
mediaGetType(void)
{
char *cp;
dmenuOpenSimple(&MenuMedia);
#if 0
cp = getenv(MEDIA_TYPE);
if (!cp)
return FALSE;
#endif
return TRUE;
}

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: media_strategy.c,v 1.1 1995/05/17 14:39:53 jkh Exp $
* $Id: media_strategy.c,v 1.2 1995/05/20 03:49:09 gpalmer Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -134,6 +134,24 @@ mediaCloseFloppy(Device *dev)
return;
}
Boolean
mediaInitDOS(Device *dev)
{
return TRUE;
}
Boolean
mediaGetDOS(char *dist)
{
return TRUE;
}
void
mediaCloseDOS(Device *dev)
{
return;
}
Boolean
mediaInitTape(Device *dev)
{

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.18 1995/05/20 00:13:12 jkh Exp $
* $Id: menus.c,v 1.19 1995/05/20 07:50:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -168,13 +168,9 @@ procedure (available on the FreeBSD CDROM or the net under the\n\
tools/dos directory) or have otherwise prepared a set of diskettes\n\
for each distribution that properly contains all the components of\n\
the distribution plus the extraction and checksumming scripts.",
"Please select the floppy drive you want to use",
"Please select which floppy drive you want to use",
NULL,
{ { "A", "Floppy drive A", /* M */
DMENU_SET_VARIABLE, (void *)"mediaDevice=fd0a", 0, 0 },
{ "B", "Floppy drive B", /* M */
DMENU_SET_VARIABLE, (void *)"mediaDevice=fd1a", 0, 0 },
{ NULL } },
{ { NULL } },
};
DMenu MenuMediaFTP = {

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.16 1995/05/20 07:50:20 jkh Exp $
* $Id: msg.c,v 1.17 1995/05/20 08:31:42 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -72,6 +72,12 @@ msgInfo(char *fmt, ...)
char *errstr;
int attrs;
/* NULL is a special convention meaning "erase the old stuff" */
if (!fmt) {
move(23, 0);
clrtoeol();
return;
}
errstr = (char *)safe_malloc(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
@ -83,7 +89,7 @@ msgInfo(char *fmt, ...)
refresh();
if (OnVTY) {
msgDebug("Informational message `%s'\n", errstr);
msgInfo("");
msgInfo(NULL);
}
free(errstr);
}
@ -183,7 +189,7 @@ msgConfirm(char *fmt, ...)
use_helpfile(NULL);
if (OnVTY) {
msgDebug("User confirmation requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
dialog_notify(errstr);
free(errstr);
@ -225,7 +231,7 @@ msgYesNo(char *fmt, ...)
w = dupwin(newscr);
if (OnVTY) {
msgDebug("User decision requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
touchwin(w);
@ -258,7 +264,7 @@ msgGetInput(char *buf, char *fmt, ...)
w = dupwin(newscr);
if (OnVTY) {
msgDebug("User input requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
touchwin(w);

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.21 1995/05/20 00:13:14 jkh Exp $
* $Id: sysinstall.h,v 1.22 1995/05/20 03:49:10 gpalmer Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -231,6 +231,10 @@ extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)());
extern void deviceGetAll(void);
extern Device **deviceFind(char *name, DeviceType type);
extern int deviceCount(Device **devs);
extern Device *new_device(char *name);
extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *mediadev), Boolean (*get)(char *distname),
void (*close)(Device *mediadev), void *private);
/* disks.c */
extern int diskPartitionEditor(char *unused);
@ -303,15 +307,18 @@ extern void mediaClose(void);
extern Boolean mediaInitUFS(Device *dev);
extern Boolean mediaGetUFS(char *dist);
extern Boolean mediaInitCDROM(Device *dev);
extern Boolean mediaInitDOS(Device *dev);
extern Boolean mediaGetFloppy(char *dist);
extern Boolean mediaInitFloppy(Device *dev);
extern Boolean mediaGetCDROM(char *dist);
extern Boolean mediaGetDOS(char *dist);
extern Boolean mediaInitTape(Device *dev);
extern Boolean mediaGetTape(char *dist);
extern Boolean mediaInitNetwork(Device *dev);
extern Boolean mediaGetNetwork(char *dist);
extern void mediaCloseTape(Device *dev);
extern void mediaCloseCDROM(Device *dev);
extern void mediaCloseDOS(Device *dev);
extern void mediaCloseNetwork(Device *dev);
extern void mediaCloseFloppy(Device *dev);

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: variable.c,v 1.1 1995/05/01 21:56:32 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -61,6 +61,7 @@ variable_set(char *var)
newvar->next = VarHead;
VarHead = newvar;
setenv(newvar->name, newvar->value, 1);
msgInfo("Set %s to %s", newvar->name, newvar->value);
}
void
@ -77,4 +78,5 @@ variable_set2(char *var, char *value)
newvar->next = VarHead;
VarHead = newvar;
setenv(newvar->name, newvar->value, 1);
msgInfo("Set %s to %s", newvar->name, newvar->value);
}

View file

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: wizard.c,v 1.2 1995/05/16 02:53:31 jkh Exp $
* $Id: wizard.c,v 1.3 1995/05/17 14:40:00 jkh Exp $
*
*/
@ -81,7 +81,7 @@ scan_block(int fd, daddr_t block)
}
void
Scan_Disk(struct disk *d)
Scan_Disk(Disk *d)
{
char device[64];
u_long l;
@ -115,9 +115,9 @@ Scan_Disk(struct disk *d)
}
void
slice_wizard(struct disk *d)
slice_wizard(Disk *d)
{
struct disk *db;
Disk *db;
char myprompt[BUFSIZ];
char input[BUFSIZ];
char *p,*q=0;

View file

@ -4,12 +4,14 @@ CLEANFILES= makedevs.c rtermcap
.PATH: ${.CURDIR}/../disklabel
SRCS= globals.c main.c dmenu.c menus.c \
misc.c msg.c system.c install.c \
termcap.c makedevs.c media.c variable.c \
devices.c dist.c lang.c wizard.c \
disks.c command.c decode.c label.c \
tcpip.c media_strategy.c
SRCS= globals.c main.c dmenu.c \
menus.c misc.c msg.c \
system.c install.c termcap.c \
media.c variable.c devices.c \
dist.c lang.c wizard.c \
disks.c command.c decode.c \
label.c tcpip.c media_strategy.c \
makedevs.c
CFLAGS+= -Wall -g -I${.CURDIR}/../libdisk \
-I${.CURDIR}/../../gnu/lib/libdialog

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: devices.c,v 1.19 1995/05/19 02:31:13 jkh Exp $
* $Id: devices.c,v 1.20 1995/05/20 00:13:06 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -69,9 +69,6 @@
static Device *Devices[DEV_MAX];
static int numDevs;
#define CHECK_DEVS \
if (numDevs == DEV_MAX) msgFatal("Too many devices found!")
static struct {
DeviceType type;
char *name;
@ -110,7 +107,7 @@ static struct {
{ NULL },
};
static Device *
Device *
new_device(char *name)
{
Device *dev;
@ -143,6 +140,29 @@ deviceDiskFree(Device *dev)
Free_Disk(dev->private);
}
/* Register a new device in the devices array */
Device *
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *), Boolean (*get)(char *), void (*close)(Device *), void *private)
{
Device *newdev;
if (numDevs == DEV_MAX)
msgFatal("Too many devices found!");
newdev = new_device(name);
newdev->description = desc;
newdev->devname = devname;
newdev->type = type;
newdev->enabled = enabled;
newdev->init = init;
newdev->get = get;
newdev->close = close;
newdev->private = private;
Devices[numDevs] = newdev;
Devices[++numDevs] = NULL;
return newdev;
}
/* Get all device information for devices we have attached */
void
deviceGetAll(void)
@ -159,18 +179,15 @@ deviceGetAll(void)
int i;
for (i = 0; names[i]; i++) {
CHECK_DEVS;
Devices[numDevs] = new_device(names[i]);
Devices[numDevs]->type = DEVICE_TYPE_DISK;
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitUFS;
Devices[numDevs]->get = mediaGetUFS;
Devices[numDevs]->close = deviceDiskFree;
Devices[numDevs]->private = Open_Disk(names[i]);
if (!Devices[numDevs]->private)
msgFatal("Unable to open device for %s!", names[i]);
Disk *d;
d = Open_Disk(names[i]);
if (!d)
msgFatal("Unable to open disk %s", names[i]);
(void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
mediaInitUFS, mediaGetUFS, deviceDiskFree, d);
msgDebug("Found a device of type disk named: %s\n", names[i]);
++numDevs;
}
free(names);
}
@ -187,19 +204,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_CDROM;
Devices[numDevs]->description = device_names[i].description;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE; /* XXX check for FreeBSD disk later XXX */
Devices[numDevs]->init = mediaInitCDROM;
Devices[numDevs]->get = mediaGetCDROM;
Devices[numDevs]->close = NULL;
Devices[numDevs]->private = NULL;
msgDebug("Found a device of type CDROM named: %s\n",
device_names[i].name);
++numDevs;
(void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, mediaCloseCDROM, NULL);
msgDebug("Found a device of type CDROM named: %s\n", device_names[i].name);
}
break;
@ -207,17 +214,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_TAPE;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE;
Devices[numDevs]->init = mediaInitTape;
Devices[numDevs]->get = mediaGetTape;
Devices[numDevs]->close = mediaCloseTape;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaCloseTape, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -225,17 +224,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_FLOPPY;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE;
Devices[numDevs]->init = mediaInitFloppy;
Devices[numDevs]->get = mediaGetFloppy;
Devices[numDevs]->close = mediaCloseFloppy;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, mediaCloseFloppy, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -243,17 +234,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_NETWORK;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitNetwork;
Devices[numDevs]->get = mediaGetNetwork;
Devices[numDevs]->close = mediaCloseNetwork;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, mediaGetNetwork, mediaCloseNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -285,33 +268,23 @@ deviceGetAll(void)
if (!strncmp(ifptr->ifr_name, "tun", 3)
|| !strncmp(ifptr->ifr_name, "lo0", 3))
continue;
CHECK_DEVS;
Devices[numDevs] = new_device(ifptr->ifr_name);
Devices[numDevs]->type = DEVICE_TYPE_NETWORK;
Devices[numDevs]->devname = NULL;
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitNetwork;
Devices[numDevs]->get = mediaGetNetwork;
Devices[numDevs]->close = mediaCloseNetwork;
Devices[numDevs]->private = NULL;
deviceRegister(ifptr->ifr_name, ifptr->ifr_name, ifptr->ifr_name,
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, mediaGetNetwork, mediaCloseNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", ifptr->ifr_name);
++numDevs;
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
msgConfirm("ifconfig: socket");
continue;
}
if (ifptr->ifr_addr.sa_len) /* Dohw! */
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len
- sizeof(struct sockaddr));
if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr));
}
/* Terminate the devices array */
Devices[numDevs] = NULL;
}
/*
* Find all devices that match the criteria, allowing "wildcarding" as well
* by allowing NULL or ANY values to match all.
* by allowing NULL or ANY values to match all. The array returned is static
* and may be used until the next invocation of deviceFind().
*/
Device **
deviceFind(char *name, DeviceType class)

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: disks.c,v 1.21 1995/05/17 16:16:07 jkh Exp $
* $Id: disks.c,v 1.22 1995/05/18 09:01:50 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -316,7 +316,6 @@ partitionHook(char *str)
int
diskPartitionEditor(char *str)
{
int scroll, choice, curr, max;
DMenu *menu;
menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook);
@ -324,8 +323,7 @@ diskPartitionEditor(char *str)
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.");
}
else {
choice = scroll = curr = max = 0;
dmenuOpen(menu, &choice, &scroll, &curr, &max);
dmenuOpenSimple(menu);
free(menu);
}
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.32 1995/05/20 00:13:10 jkh Exp $
* $Id: install.c,v 1.33 1995/05/20 08:31:40 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -45,6 +45,7 @@
#include <sys/disklabel.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/wait.h>
#include <unistd.h>
Boolean SystemWasInstalled;
@ -92,7 +93,7 @@ installInitial(void)
/* If things aren't kosher, or we refuse to proceed, bail. */
if (!preInstallCheck()
|| msgYesNo("Last Chance! Are you SURE you want continue the installation?\n\nIf you're running this on an existing system, we STRONGLY\nencourage you to make proper backups before proceeding.\nWe take no responsibility for lost disk contents!"))
return 0;
return;
mbrContents = NULL;
if (!msgYesNo("Would you like to install a boot manager?\n\nThis will allow you to easily select between other operating systems\non the first disk, or boot from a disk other than the first."))
@ -272,7 +273,6 @@ static void
cpio_extract(void)
{
int i, j, zpid, cpid, pfd[2];
extern int wait(int *status);
tryagain:
j = fork();
@ -319,7 +319,7 @@ cpio_extract(void)
msgConfirm("gunzip returned status of %d, error was: %s (%d)! Help!", j, strerror(errno), errno);
exit(1);
}
i = waitpid(cpid, &j);
i = waitpid(cpid, &j, 0);
if (i < 0 || j) {
msgConfirm("cpio returned status of %d, error was: %s (%d)! Help!", j, strerror(errno), errno);
exit(2);

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: label.c,v 1.9 1995/05/19 02:09:02 jkh Exp $
* $Id: label.c,v 1.10 1995/05/19 02:19:15 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -279,7 +279,6 @@ print_label_chunks(void)
{
int i, j, srow, prow, pcol;
int sz;
int label_attr;
clear();
attrset(A_REVERSE);

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.18 1995/05/20 00:13:12 jkh Exp $
* $Id: menus.c,v 1.19 1995/05/20 07:50:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -168,13 +168,9 @@ procedure (available on the FreeBSD CDROM or the net under the\n\
tools/dos directory) or have otherwise prepared a set of diskettes\n\
for each distribution that properly contains all the components of\n\
the distribution plus the extraction and checksumming scripts.",
"Please select the floppy drive you want to use",
"Please select which floppy drive you want to use",
NULL,
{ { "A", "Floppy drive A", /* M */
DMENU_SET_VARIABLE, (void *)"mediaDevice=fd0a", 0, 0 },
{ "B", "Floppy drive B", /* M */
DMENU_SET_VARIABLE, (void *)"mediaDevice=fd1a", 0, 0 },
{ NULL } },
{ { NULL } },
};
DMenu MenuMediaFTP = {

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.16 1995/05/20 07:50:20 jkh Exp $
* $Id: msg.c,v 1.17 1995/05/20 08:31:42 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -72,6 +72,12 @@ msgInfo(char *fmt, ...)
char *errstr;
int attrs;
/* NULL is a special convention meaning "erase the old stuff" */
if (!fmt) {
move(23, 0);
clrtoeol();
return;
}
errstr = (char *)safe_malloc(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
@ -83,7 +89,7 @@ msgInfo(char *fmt, ...)
refresh();
if (OnVTY) {
msgDebug("Informational message `%s'\n", errstr);
msgInfo("");
msgInfo(NULL);
}
free(errstr);
}
@ -183,7 +189,7 @@ msgConfirm(char *fmt, ...)
use_helpfile(NULL);
if (OnVTY) {
msgDebug("User confirmation requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
dialog_notify(errstr);
free(errstr);
@ -225,7 +231,7 @@ msgYesNo(char *fmt, ...)
w = dupwin(newscr);
if (OnVTY) {
msgDebug("User decision requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
touchwin(w);
@ -258,7 +264,7 @@ msgGetInput(char *buf, char *fmt, ...)
w = dupwin(newscr);
if (OnVTY) {
msgDebug("User input requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
touchwin(w);

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.21 1995/05/20 00:13:14 jkh Exp $
* $Id: sysinstall.h,v 1.22 1995/05/20 03:49:10 gpalmer Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -231,6 +231,10 @@ extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)());
extern void deviceGetAll(void);
extern Device **deviceFind(char *name, DeviceType type);
extern int deviceCount(Device **devs);
extern Device *new_device(char *name);
extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *mediadev), Boolean (*get)(char *distname),
void (*close)(Device *mediadev), void *private);
/* disks.c */
extern int diskPartitionEditor(char *unused);
@ -303,15 +307,18 @@ extern void mediaClose(void);
extern Boolean mediaInitUFS(Device *dev);
extern Boolean mediaGetUFS(char *dist);
extern Boolean mediaInitCDROM(Device *dev);
extern Boolean mediaInitDOS(Device *dev);
extern Boolean mediaGetFloppy(char *dist);
extern Boolean mediaInitFloppy(Device *dev);
extern Boolean mediaGetCDROM(char *dist);
extern Boolean mediaGetDOS(char *dist);
extern Boolean mediaInitTape(Device *dev);
extern Boolean mediaGetTape(char *dist);
extern Boolean mediaInitNetwork(Device *dev);
extern Boolean mediaGetNetwork(char *dist);
extern void mediaCloseTape(Device *dev);
extern void mediaCloseCDROM(Device *dev);
extern void mediaCloseDOS(Device *dev);
extern void mediaCloseNetwork(Device *dev);
extern void mediaCloseFloppy(Device *dev);

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: variable.c,v 1.1 1995/05/01 21:56:32 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -61,6 +61,7 @@ variable_set(char *var)
newvar->next = VarHead;
VarHead = newvar;
setenv(newvar->name, newvar->value, 1);
msgInfo("Set %s to %s", newvar->name, newvar->value);
}
void
@ -77,4 +78,5 @@ variable_set2(char *var, char *value)
newvar->next = VarHead;
VarHead = newvar;
setenv(newvar->name, newvar->value, 1);
msgInfo("Set %s to %s", newvar->name, newvar->value);
}

View file

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: wizard.c,v 1.2 1995/05/16 02:53:31 jkh Exp $
* $Id: wizard.c,v 1.3 1995/05/17 14:40:00 jkh Exp $
*
*/
@ -81,7 +81,7 @@ scan_block(int fd, daddr_t block)
}
void
Scan_Disk(struct disk *d)
Scan_Disk(Disk *d)
{
char device[64];
u_long l;
@ -115,9 +115,9 @@ Scan_Disk(struct disk *d)
}
void
slice_wizard(struct disk *d)
slice_wizard(Disk *d)
{
struct disk *db;
Disk *db;
char myprompt[BUFSIZ];
char input[BUFSIZ];
char *p,*q=0;

View file

@ -4,12 +4,14 @@ CLEANFILES= makedevs.c rtermcap
.PATH: ${.CURDIR}/../disklabel
SRCS= globals.c main.c dmenu.c menus.c \
misc.c msg.c system.c install.c \
termcap.c makedevs.c media.c variable.c \
devices.c dist.c lang.c wizard.c \
disks.c command.c decode.c label.c \
tcpip.c media_strategy.c
SRCS= globals.c main.c dmenu.c \
menus.c misc.c msg.c \
system.c install.c termcap.c \
media.c variable.c devices.c \
dist.c lang.c wizard.c \
disks.c command.c decode.c \
label.c tcpip.c media_strategy.c \
makedevs.c
CFLAGS+= -Wall -g -I${.CURDIR}/../libdisk \
-I${.CURDIR}/../../gnu/lib/libdialog

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: devices.c,v 1.19 1995/05/19 02:31:13 jkh Exp $
* $Id: devices.c,v 1.20 1995/05/20 00:13:06 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -69,9 +69,6 @@
static Device *Devices[DEV_MAX];
static int numDevs;
#define CHECK_DEVS \
if (numDevs == DEV_MAX) msgFatal("Too many devices found!")
static struct {
DeviceType type;
char *name;
@ -110,7 +107,7 @@ static struct {
{ NULL },
};
static Device *
Device *
new_device(char *name)
{
Device *dev;
@ -143,6 +140,29 @@ deviceDiskFree(Device *dev)
Free_Disk(dev->private);
}
/* Register a new device in the devices array */
Device *
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *), Boolean (*get)(char *), void (*close)(Device *), void *private)
{
Device *newdev;
if (numDevs == DEV_MAX)
msgFatal("Too many devices found!");
newdev = new_device(name);
newdev->description = desc;
newdev->devname = devname;
newdev->type = type;
newdev->enabled = enabled;
newdev->init = init;
newdev->get = get;
newdev->close = close;
newdev->private = private;
Devices[numDevs] = newdev;
Devices[++numDevs] = NULL;
return newdev;
}
/* Get all device information for devices we have attached */
void
deviceGetAll(void)
@ -159,18 +179,15 @@ deviceGetAll(void)
int i;
for (i = 0; names[i]; i++) {
CHECK_DEVS;
Devices[numDevs] = new_device(names[i]);
Devices[numDevs]->type = DEVICE_TYPE_DISK;
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitUFS;
Devices[numDevs]->get = mediaGetUFS;
Devices[numDevs]->close = deviceDiskFree;
Devices[numDevs]->private = Open_Disk(names[i]);
if (!Devices[numDevs]->private)
msgFatal("Unable to open device for %s!", names[i]);
Disk *d;
d = Open_Disk(names[i]);
if (!d)
msgFatal("Unable to open disk %s", names[i]);
(void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
mediaInitUFS, mediaGetUFS, deviceDiskFree, d);
msgDebug("Found a device of type disk named: %s\n", names[i]);
++numDevs;
}
free(names);
}
@ -187,19 +204,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_CDROM;
Devices[numDevs]->description = device_names[i].description;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE; /* XXX check for FreeBSD disk later XXX */
Devices[numDevs]->init = mediaInitCDROM;
Devices[numDevs]->get = mediaGetCDROM;
Devices[numDevs]->close = NULL;
Devices[numDevs]->private = NULL;
msgDebug("Found a device of type CDROM named: %s\n",
device_names[i].name);
++numDevs;
(void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, mediaCloseCDROM, NULL);
msgDebug("Found a device of type CDROM named: %s\n", device_names[i].name);
}
break;
@ -207,17 +214,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_TAPE;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE;
Devices[numDevs]->init = mediaInitTape;
Devices[numDevs]->get = mediaGetTape;
Devices[numDevs]->close = mediaCloseTape;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaCloseTape, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -225,17 +224,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_FLOPPY;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = TRUE;
Devices[numDevs]->init = mediaInitFloppy;
Devices[numDevs]->get = mediaGetFloppy;
Devices[numDevs]->close = mediaCloseFloppy;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, mediaCloseFloppy, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -243,17 +234,9 @@ deviceGetAll(void)
fd = deviceTry(device_names[i].name, try);
if (fd >= 0) {
close(fd);
CHECK_DEVS;
Devices[numDevs] = new_device(device_names[i].name);
Devices[numDevs]->type = DEVICE_TYPE_NETWORK;
Devices[numDevs]->devname = strdup(try);
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitNetwork;
Devices[numDevs]->get = mediaGetNetwork;
Devices[numDevs]->close = mediaCloseNetwork;
Devices[numDevs]->private = NULL;
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, mediaGetNetwork, mediaCloseNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", device_names[i].name);
++numDevs;
}
break;
@ -285,33 +268,23 @@ deviceGetAll(void)
if (!strncmp(ifptr->ifr_name, "tun", 3)
|| !strncmp(ifptr->ifr_name, "lo0", 3))
continue;
CHECK_DEVS;
Devices[numDevs] = new_device(ifptr->ifr_name);
Devices[numDevs]->type = DEVICE_TYPE_NETWORK;
Devices[numDevs]->devname = NULL;
Devices[numDevs]->enabled = FALSE;
Devices[numDevs]->init = mediaInitNetwork;
Devices[numDevs]->get = mediaGetNetwork;
Devices[numDevs]->close = mediaCloseNetwork;
Devices[numDevs]->private = NULL;
deviceRegister(ifptr->ifr_name, ifptr->ifr_name, ifptr->ifr_name,
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, mediaGetNetwork, mediaCloseNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", ifptr->ifr_name);
++numDevs;
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
msgConfirm("ifconfig: socket");
continue;
}
if (ifptr->ifr_addr.sa_len) /* Dohw! */
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len
- sizeof(struct sockaddr));
if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr));
}
/* Terminate the devices array */
Devices[numDevs] = NULL;
}
/*
* Find all devices that match the criteria, allowing "wildcarding" as well
* by allowing NULL or ANY values to match all.
* by allowing NULL or ANY values to match all. The array returned is static
* and may be used until the next invocation of deviceFind().
*/
Device **
deviceFind(char *name, DeviceType class)

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: disks.c,v 1.21 1995/05/17 16:16:07 jkh Exp $
* $Id: disks.c,v 1.22 1995/05/18 09:01:50 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -316,7 +316,6 @@ partitionHook(char *str)
int
diskPartitionEditor(char *str)
{
int scroll, choice, curr, max;
DMenu *menu;
menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook);
@ -324,8 +323,7 @@ diskPartitionEditor(char *str)
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.");
}
else {
choice = scroll = curr = max = 0;
dmenuOpen(menu, &choice, &scroll, &curr, &max);
dmenuOpenSimple(menu);
free(menu);
}
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.32 1995/05/20 00:13:10 jkh Exp $
* $Id: install.c,v 1.33 1995/05/20 08:31:40 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -45,6 +45,7 @@
#include <sys/disklabel.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/wait.h>
#include <unistd.h>
Boolean SystemWasInstalled;
@ -92,7 +93,7 @@ installInitial(void)
/* If things aren't kosher, or we refuse to proceed, bail. */
if (!preInstallCheck()
|| msgYesNo("Last Chance! Are you SURE you want continue the installation?\n\nIf you're running this on an existing system, we STRONGLY\nencourage you to make proper backups before proceeding.\nWe take no responsibility for lost disk contents!"))
return 0;
return;
mbrContents = NULL;
if (!msgYesNo("Would you like to install a boot manager?\n\nThis will allow you to easily select between other operating systems\non the first disk, or boot from a disk other than the first."))
@ -272,7 +273,6 @@ static void
cpio_extract(void)
{
int i, j, zpid, cpid, pfd[2];
extern int wait(int *status);
tryagain:
j = fork();
@ -319,7 +319,7 @@ cpio_extract(void)
msgConfirm("gunzip returned status of %d, error was: %s (%d)! Help!", j, strerror(errno), errno);
exit(1);
}
i = waitpid(cpid, &j);
i = waitpid(cpid, &j, 0);
if (i < 0 || j) {
msgConfirm("cpio returned status of %d, error was: %s (%d)! Help!", j, strerror(errno), errno);
exit(2);

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: label.c,v 1.9 1995/05/19 02:09:02 jkh Exp $
* $Id: label.c,v 1.10 1995/05/19 02:19:15 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -279,7 +279,6 @@ print_label_chunks(void)
{
int i, j, srow, prow, pcol;
int sz;
int label_attr;
clear();
attrset(A_REVERSE);

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: media.c,v 1.7 1995/05/20 00:13:11 jkh Exp $
* $Id: media.c,v 1.8 1995/05/20 03:49:09 gpalmer Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,6 +44,28 @@
#include <stdio.h>
#include "sysinstall.h"
static int
genericHook(char *str, DeviceType type)
{
Device **devs;
/* Clip garbage off the ends */
string_prune(str);
str = string_skipwhite(str);
if (!*str)
return 0;
devs = deviceFind(str, type);
if (devs)
mediaDevice = devs[0];
return devs ? 1 : 0;
}
static int
cdromHook(char *str)
{
return genericHook(str, DEVICE_TYPE_CDROM);
}
/*
* Return 1 if we successfully found and set the installation type to
* be a CD.
@ -54,8 +76,10 @@ mediaSetCDROM(char *str)
Device **devs;
int cnt;
if (OnCDROM == TRUE)
if (OnCDROM == TRUE) {
/* XXX point mediaDevice at something meaningful here - perhaps a static device structure */
return 1;
}
else {
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
cnt = deviceCount(devs);
@ -64,13 +88,24 @@ mediaSetCDROM(char *str)
return 0;
}
else if (cnt > 1) {
/* put up a menu */
DMenu *menu;
menu = deviceCreateMenu(&MenuMediaCDROM, DEVICE_TYPE_CDROM, cdromHook);
if (!menu)
msgFatal("Unable to create CDROM menu! Something is seriously wrong.");
dmenuOpenSimple(menu);
free(menu);
}
else {
else
mediaDevice = devs[0];
}
}
return 0;
return mediaDevice ? 1 : 0;
}
static int
floppyHook(char *str)
{
return genericHook(str, DEVICE_TYPE_FLOPPY);
}
/*
@ -80,8 +115,27 @@ mediaSetCDROM(char *str)
int
mediaSetFloppy(char *str)
{
dmenuOpenSimple(&MenuMediaFloppy);
return 0;
Device **devs;
int cnt;
devs = deviceFind(NULL, DEVICE_TYPE_FLOPPY);
cnt = deviceCount(devs);
if (!cnt) {
msgConfirm("No floppy devices found! Please check that your system's\nconfiguration is correct. For more information, consult the hardware guide\nin the Doc menu.");
return 0;
}
else if (cnt > 1) {
DMenu *menu;
menu = deviceCreateMenu(&MenuMediaFloppy, DEVICE_TYPE_FLOPPY, floppyHook);
if (!menu)
msgFatal("Unable to create Floppy menu! Something is seriously wrong.");
dmenuOpenSimple(menu);
free(menu);
}
else
mediaDevice = devs[0];
return mediaDevice ? 1 : 0;
}
/*
@ -92,11 +146,31 @@ int
mediaSetDOS(char *str)
{
Device **devs;
Disk *d;
Chunk *c1;
int i;
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
if (!devs)
msgConfirm("No disk devices found!");
return 0;
for (i = 0; devs[i]; i++) {
if (!devs[i]->enabled)
continue;
d = (Disk *)devs[i]->private;
/* Now try to find a DOS partition */
for (c1 = d->chunks->part; c1; c1 = c1->next) {
if (c1->type == fat) {
/* Got one! */
mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DISK, TRUE,
mediaInitDOS, mediaGetDOS, mediaCloseDOS, NULL);
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
break;
}
}
}
if (!mediaDevice)
msgConfirm("No DOS primary partitions found! This installation method is unavailable");
return mediaDevice ? 1 : 0;
}
/*
@ -158,14 +232,7 @@ mediaExtractDist(FILE *fp)
Boolean
mediaGetType(void)
{
char *cp;
dmenuOpenSimple(&MenuMedia);
#if 0
cp = getenv(MEDIA_TYPE);
if (!cp)
return FALSE;
#endif
return TRUE;
}

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.18 1995/05/20 00:13:12 jkh Exp $
* $Id: menus.c,v 1.19 1995/05/20 07:50:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -168,13 +168,9 @@ procedure (available on the FreeBSD CDROM or the net under the\n\
tools/dos directory) or have otherwise prepared a set of diskettes\n\
for each distribution that properly contains all the components of\n\
the distribution plus the extraction and checksumming scripts.",
"Please select the floppy drive you want to use",
"Please select which floppy drive you want to use",
NULL,
{ { "A", "Floppy drive A", /* M */
DMENU_SET_VARIABLE, (void *)"mediaDevice=fd0a", 0, 0 },
{ "B", "Floppy drive B", /* M */
DMENU_SET_VARIABLE, (void *)"mediaDevice=fd1a", 0, 0 },
{ NULL } },
{ { NULL } },
};
DMenu MenuMediaFTP = {

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.16 1995/05/20 07:50:20 jkh Exp $
* $Id: msg.c,v 1.17 1995/05/20 08:31:42 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -72,6 +72,12 @@ msgInfo(char *fmt, ...)
char *errstr;
int attrs;
/* NULL is a special convention meaning "erase the old stuff" */
if (!fmt) {
move(23, 0);
clrtoeol();
return;
}
errstr = (char *)safe_malloc(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
@ -83,7 +89,7 @@ msgInfo(char *fmt, ...)
refresh();
if (OnVTY) {
msgDebug("Informational message `%s'\n", errstr);
msgInfo("");
msgInfo(NULL);
}
free(errstr);
}
@ -183,7 +189,7 @@ msgConfirm(char *fmt, ...)
use_helpfile(NULL);
if (OnVTY) {
msgDebug("User confirmation requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
dialog_notify(errstr);
free(errstr);
@ -225,7 +231,7 @@ msgYesNo(char *fmt, ...)
w = dupwin(newscr);
if (OnVTY) {
msgDebug("User decision requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
touchwin(w);
@ -258,7 +264,7 @@ msgGetInput(char *buf, char *fmt, ...)
w = dupwin(newscr);
if (OnVTY) {
msgDebug("User input requested (type ALT-F1)\n");
msgInfo("");
msgInfo(NULL);
}
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
touchwin(w);

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.21 1995/05/20 00:13:14 jkh Exp $
* $Id: sysinstall.h,v 1.22 1995/05/20 03:49:10 gpalmer Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -231,6 +231,10 @@ extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)());
extern void deviceGetAll(void);
extern Device **deviceFind(char *name, DeviceType type);
extern int deviceCount(Device **devs);
extern Device *new_device(char *name);
extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *mediadev), Boolean (*get)(char *distname),
void (*close)(Device *mediadev), void *private);
/* disks.c */
extern int diskPartitionEditor(char *unused);
@ -303,15 +307,18 @@ extern void mediaClose(void);
extern Boolean mediaInitUFS(Device *dev);
extern Boolean mediaGetUFS(char *dist);
extern Boolean mediaInitCDROM(Device *dev);
extern Boolean mediaInitDOS(Device *dev);
extern Boolean mediaGetFloppy(char *dist);
extern Boolean mediaInitFloppy(Device *dev);
extern Boolean mediaGetCDROM(char *dist);
extern Boolean mediaGetDOS(char *dist);
extern Boolean mediaInitTape(Device *dev);
extern Boolean mediaGetTape(char *dist);
extern Boolean mediaInitNetwork(Device *dev);
extern Boolean mediaGetNetwork(char *dist);
extern void mediaCloseTape(Device *dev);
extern void mediaCloseCDROM(Device *dev);
extern void mediaCloseDOS(Device *dev);
extern void mediaCloseNetwork(Device *dev);
extern void mediaCloseFloppy(Device *dev);

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: variable.c,v 1.1 1995/05/01 21:56:32 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -61,6 +61,7 @@ variable_set(char *var)
newvar->next = VarHead;
VarHead = newvar;
setenv(newvar->name, newvar->value, 1);
msgInfo("Set %s to %s", newvar->name, newvar->value);
}
void
@ -77,4 +78,5 @@ variable_set2(char *var, char *value)
newvar->next = VarHead;
VarHead = newvar;
setenv(newvar->name, newvar->value, 1);
msgInfo("Set %s to %s", newvar->name, newvar->value);
}

View file

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: wizard.c,v 1.2 1995/05/16 02:53:31 jkh Exp $
* $Id: wizard.c,v 1.3 1995/05/17 14:40:00 jkh Exp $
*
*/
@ -81,7 +81,7 @@ scan_block(int fd, daddr_t block)
}
void
Scan_Disk(struct disk *d)
Scan_Disk(Disk *d)
{
char device[64];
u_long l;
@ -115,9 +115,9 @@ Scan_Disk(struct disk *d)
}
void
slice_wizard(struct disk *d)
slice_wizard(Disk *d)
{
struct disk *db;
Disk *db;
char myprompt[BUFSIZ];
char input[BUFSIZ];
char *p,*q=0;