Commit parts of reorg that were diffs. Substantially re-engineer the

extraction and mediaGetFTP() handshaking to solve some unexpected complexities.
This commit is contained in:
Jordan K. Hubbard 1995-05-27 10:47:44 +00:00
parent ba5d6a864b
commit 8e98d776c0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8792
19 changed files with 513 additions and 152 deletions

View File

@ -4,15 +4,11 @@ CLEANFILES= makedevs.c rtermcap
.PATH: ${.CURDIR}/../disklabel ${.CURDIR}/../../usr.bin/cksum
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 ftp.c config.c \
crc.c
SRCS= attr.c cdrom.c command.c config.c crc.c decode.c devices.c disks.c dist.c \
dmenu.c dos.c floppy.c ftp.c ftp_strat.c globals.c install.c label.c lang.c \
main.c makedevs.c media.c menus.c misc.c msg.c network.c nfs.c system.c tape.c \
tcpip.c termcap.c ufs.c variable.c wizard.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: dist.c,v 1.24 1995/05/26 10:58:50 jkh Exp $
* $Id: dist.c,v 1.25 1995/05/26 22:22:20 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -226,7 +226,7 @@ distExtract(char *parent, Distribution *me)
status = 0;
if (mediaDevice->init)
if ((*mediaDevice->init)(mediaDevice) == FALSE)
if (!(*mediaDevice->init)(mediaDevice))
return 0;
for (i = 0; me[i].my_name; i++) {
if (me[i].my_bit & *(me[i].my_mask)) {
@ -257,9 +257,10 @@ distExtract(char *parent, Distribution *me)
}
}
}
if (mediaDevice->shutdown)
if (mediaDevice->shutdown && parent == NULL) {
(*mediaDevice->shutdown)(mediaDevice);
mediaDevice = NULL;
mediaDevice = NULL;
}
return status;
}

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.59 1995/05/26 10:32:28 jkh Exp $
* $Id: install.c,v 1.60 1995/05/26 20:45:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -386,11 +386,11 @@ static void loop_on_root_floppy();
static void
root_extract(void)
{
int fd, status;
int fd;
if (OnCDROM) {
fd = open("/floppies/root.flp", O_RDONLY);
mediaExtractDist("root.flp", "/", fd);
(void)mediaExtractDist("root.flp", "/", fd);
return;
}
if (mediaDevice) {
@ -407,12 +407,14 @@ root_extract(void)
fd = (*mediaDevice->get)("root.flp", "floppies/");
if (fd != -1) {
msgNotify("Loading root floppy from %s", mediaDevice->name);
status = mediaExtractDist("root.flp", "/", fd);
(void)mediaExtractDist("root.flp", "/", fd);
if (mediaDevice->close)
(*mediaDevice->close)(mediaDevice, fd);
else
close(fd);
}
if (mediaDevice->shutdown)
(*mediaDevice->shutdown)(mediaDevice);
break;
case DEVICE_TYPE_FLOPPY:
@ -430,9 +432,7 @@ loop_on_root_floppy(void)
{
int fd;
mediaDevice = NULL;
fd = genericGetDist("root.flp", NULL, TRUE);
if (fd == -1)
return;
mediaExtractDist("root.flp", "/", fd);
fd = getRootFloppy();
if (fd != -1)
mediaExtractDist("root.flp", "/", fd);
}

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.17 1995/05/26 08:41:41 jkh Exp $
* $Id: media.c,v 1.18 1995/05/26 20:30:58 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,10 +44,153 @@
#include <stdio.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <unistd.h>
#include "sysinstall.h"
pid_t getDistpid = 0;
/*
* This is the generic distribution opening routine. It returns
* a file descriptor that refers to a stream of bytes coming from
* _somewhere_ that can be extracted as a gzip'd tar file.
*/
int
genericGetDist(char *path, Attribs *dist_attrib, Boolean prompt)
{
int fd;
char buf[512];
struct stat sb;
int pfd[2], numchunks;
const char *tmp;
/* reap any previous child corpse - yuck! */
if (getDistpid) {
int i, j;
i = waitpid(getDistpid, &j, 0);
if (i < 0 || WEXITSTATUS(j))
msgNotify("Warning: Previous extraction returned status code %d.", WEXITSTATUS(j));
getDistpid = 0;
}
/* How try to figure out how many pieces to expect */
if (dist_attrib) {
tmp = attr_match(dist_attrib, "pieces");
numchunks = atoi(tmp);
}
else
numchunks = 1;
if (!path)
return -1;
if (stat(path, &sb) == 0) {
fd = open(path, O_RDONLY, 0);
return(fd);
}
snprintf(buf, 512, "%s.tgz", path);
if (stat(buf, &sb) == 0) {
fd = open(buf, O_RDONLY, 0);
return(fd);
}
snprintf(buf, 512, "%s.aa", path);
if (stat(buf, &sb) == 0 && numchunks == 1) {
fd = open(buf, O_RDONLY, 0);
if (fd != -1)
return fd;
else if (!prompt) {
}
}
if (numchunks < 2 && !prompt) {
if (!getenv(NO_CONFIRMATION))
msgConfirm("Cannot find file(s) for distribution in ``%s''!", path);
else
msgDebug("Cannot find file(s) for distribution in ``%s''!\n", path);
return -1;
}
msgDebug("Attempting to concatenate %u chunks\n", numchunks);
pipe(pfd);
getDistpid = fork();
if (!getDistpid) {
caddr_t memory;
int chunk;
int retval;
dup2(pfd[1], 1); close(pfd[1]);
close(pfd[0]);
for (chunk = 0; chunk < numchunks; chunk++) {
int fd;
unsigned long len, val;
retval = stat(buf, &sb);
if ((retval != 0) && (prompt != TRUE))
{
msgConfirm("Cannot find file(s) for distribution in ``%s''!\n", path);
return -1;
} else {
char *tmp = index(buf, '/');
tmp++;
while (retval != 0)
{
if (mediaDevice->shutdown)
(*mediaDevice->shutdown)(mediaDevice);
msgConfirm("Please insert the media with the `%s' file on it\n", tmp);
if (mediaDevice->init)
if (!mediaDevice->init(mediaDevice))
return -1;
retval = stat(buf, &sb);
}
}
snprintf(buf, 512, "%s.%c%c", path, (chunk / 26) + 'a', (chunk % 26) + 'a');
if ((fd = open(buf, O_RDONLY)) == -1)
msgFatal("Cannot find file `%s'!", buf);
if (prompt == TRUE) {
extern int crc(int, unsigned long *, unsigned long *);
crc(fd, &val, &len);
msgDebug("crc for %s is %lu %lu\n", buf, val, len);
}
fstat(fd, &sb);
msgDebug("mmap()ing %s (%d)\n", buf, fd);
memory = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t) 0);
if (memory == (caddr_t) -1)
msgFatal("mmap error: %s\n", strerror(errno));
retval = write(1, memory, sb.st_size);
if (retval != sb.st_size)
{
msgConfirm("write didn't write out the complete file!\n(wrote %d bytes of %d bytes)", retval,
sb.st_size);
exit(1);
}
retval = munmap(memory, sb.st_size);
if (retval != 0)
{
msgConfirm("munmap() returned %d", retval);
exit(1);
}
close(fd);
}
close(1);
msgDebug("Extract of %s finished!!!\n", path);
exit(0);
}
close(pfd[1]);
return(pfd[0]);
}
static int
genericHook(char *str, DeviceType type)
{
@ -196,6 +339,7 @@ mediaSetDOS(char *str)
/* Got one! */
mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE,
mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL);
mediaDevice->private = c1;
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
break;
}
@ -270,6 +414,7 @@ mediaSetFTP(char *str)
ftpDevice.type = DEVICE_TYPE_NETWORK;
ftpDevice.init = mediaInitFTP;
ftpDevice.get = mediaGetFTP;
ftpDevice.close = mediaCloseFTP;
ftpDevice.shutdown = mediaShutdownFTP;
ftpDevice.private = mediaDevice;
mediaDevice = &ftpDevice;
@ -336,13 +481,13 @@ mediaExtractDist(char *distname, char *dir, int fd)
i = waitpid(zpid, &j, 0);
if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */
dialog_clear();
msgConfirm("wait for gunzip returned status of %d!", i);
msgDebug("wait for gunzip returned status of %d!\n", i);
return FALSE;
}
i = waitpid(cpid, &j, 0);
if (i < 0 || WEXITSTATUS(j)) {
dialog_clear();
msgConfirm("cpio returned error status of %d!", WEXITSTATUS(j));
msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
return FALSE;
}
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.32 1995/05/26 11:21:53 jkh Exp $
* $Id: menus.c,v 1.33 1995/05/26 19:28:03 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -554,6 +554,8 @@ When you're done setting options, select Cancel",
DMENU_SET_VARIABLE, "debug=yes", 0, 0 },
{ "No Debugging", "Turn the extra debugging flag off",
DMENU_SET_VARIABLE, "debug=no", 0, 0 },
{ "Yes To All", "Assume \"Yes\" answers to all non-critical dialogs",
DMENU_SET_VARIABLE, "noConfirmation=Yes", 0, 0 },
{ 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.34 1995/05/26 08:41:48 jkh Exp $
* $Id: sysinstall.h,v 1.35 1995/05/26 19:28:04 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -85,7 +85,7 @@
#define DISK_LABELLED "_diskLabelled"
#define RUNNING_ON_ROOT "_runningOnRoot"
#define TCP_CONFIGURED "_tcpConfigured"
#define NO_CONFIRMATION "_noConfirmation"
#define NO_CONFIRMATION "noConfirmation"
#define VAR_HOSTNAME "hostname"
#define VAR_DOMAINNAME "domainname"
@ -142,6 +142,15 @@ typedef struct _variable {
char value[VAR_VALUE_MAX];
} Variable;
#define MAX_ATTRIBS 200
#define MAX_NAME 511
#define MAX_VALUE 4095
typedef struct _attribs {
char *name;
char *value;
} Attribs;
typedef enum {
DEVICE_TYPE_NONE,
DEVICE_TYPE_DISK,
@ -235,6 +244,15 @@ extern DMenu MenuDiskDevices; /* Disk devices menu */
/*** Prototypes ***/
/* attrs.c */
extern const char *attr_match(Attribs *attr, char *name);
extern int attr_parse(Attribs **attr, char *file);
/* cdrom.c */
extern Boolean mediaInitCDROM(Device *dev);
extern int mediaGetCDROM(char *dist, char *path);
extern void mediaShutdownCDROM(Device *dev);
/* command.c */
extern void command_clear(void);
extern void command_sort(void);
@ -285,6 +303,23 @@ extern void dmenuOpen(DMenu *menu, int *choice, int *scroll,
int *curr, int *max);
extern void dmenuOpenSimple(DMenu *menu);
/* dos.c */
extern Boolean mediaInitDOS(Device *dev);
extern int mediaGetDOS(char *dist, char *path);
extern void mediaShutdownDOS(Device *dev);
/* floppy.c */
extern int getRootFloppy(void);
extern Boolean mediaInitFloppy(Device *dev);
extern int mediaGetFloppy(char *dist, char *path);
extern void mediaShutdownFloppy(Device *dev);
/* ftp_strat.c */
extern Boolean mediaCloseFTP(Device *dev, int fd);
extern Boolean mediaInitFTP(Device *dev);
extern int mediaGetFTP(char *dist, char *path);
extern void mediaShutdownFTP(Device *dev);
/* globals.c */
extern void globalsInit(void);
@ -322,6 +357,7 @@ extern const u_char koi8_r2cp866[];
extern u_char default_scrnmap[];
/* media.c */
extern int genericGetDist(char *path, Attribs *dist_attrib, Boolean prompt);
extern int mediaSetCDROM(char *str);
extern int mediaSetFloppy(char *str);
extern int mediaSetDOS(char *str);
@ -332,28 +368,6 @@ extern Boolean mediaGetType(void);
extern Boolean mediaExtractDist(char *distname, char *dir, int fd);
extern Boolean mediaVerify(void);
/* media_strategy.c */
extern int genericGetDist(char *path, void *dist_attrib, Boolean prompt);
extern Boolean mediaInitCDROM(Device *dev);
extern Boolean mediaInitDOS(Device *dev);
extern Boolean mediaInitFloppy(Device *dev);
extern Boolean mediaInitFTP(Device *dev);
extern Boolean mediaInitNetwork(Device *dev);
extern Boolean mediaInitTape(Device *dev);
extern Boolean mediaInitUFS(Device *dev);
extern int mediaGetCDROM(char *dist, char *path);
extern int mediaGetDOS(char *dist, char *path);
extern int mediaGetFloppy(char *dist, char *path);
extern int mediaGetFTP(char *dist, char *path);
extern int mediaGetTape(char *dist, char *path);
extern int mediaGetUFS(char *dist, char *path);
extern void mediaShutdownCDROM(Device *dev);
extern void mediaShutdownDOS(Device *dev);
extern void mediaShutdownFTP(Device *dev);
extern void mediaShutdownFloppy(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
extern void mediaShutdownTape(Device *dev);
/* misc.c */
extern Boolean file_readable(char *fname);
extern Boolean file_executable(char *fname);
@ -384,6 +398,10 @@ extern void msgWeHaveOutput(char *fmt, ...);
extern int msgYesNo(char *fmt, ...);
extern char *msgGetInput(char *buf, char *fmt, ...);
/* network.c */
extern Boolean mediaInitNetwork(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
/* system.c */
extern void systemInitialize(int argc, char **argv);
extern void systemShutdown(void);
@ -399,6 +417,11 @@ extern void systemChangeTerminal(char *color, const u_char c_termcap[],
extern void systemChangeScreenmap(const u_char newmap[]);
extern int vsystem(char *fmt, ...);
/* tape.c */
extern Boolean mediaInitTape(Device *dev);
extern int mediaGetTape(char *dist, char *path);
extern void mediaShutdownTape(Device *dev);
/* tcpip.c */
extern int tcpOpenDialog(Device *dev);
extern int tcpDeviceSelect(char *str);
@ -407,6 +430,10 @@ extern Boolean tcpStartPPP(Device *dev);
/* termcap.c */
extern int set_termcap(void);
/* ufs.c */
extern Boolean mediaInitUFS(Device *dev);
extern int mediaGetUFS(char *dist, char *path);
/* variables.c */
extern void variable_set(char *var);
extern void variable_set2(char *name, char *value);

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: variable.c,v 1.2 1995/05/20 10:33:13 jkh Exp $
* $Id: variable.c,v 1.3 1995/05/26 20:45:20 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -75,8 +75,6 @@ variable_set(char *var)
void
variable_set2(char *var, char *value)
{
Variable *newvar;
if (!var || !value)
msgFatal("Null name or value passed to set_variable2!");
make_variable(var, value);

View File

@ -4,15 +4,11 @@ CLEANFILES= makedevs.c rtermcap
.PATH: ${.CURDIR}/../disklabel ${.CURDIR}/../../usr.bin/cksum
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 ftp.c config.c \
crc.c
SRCS= attr.c cdrom.c command.c config.c crc.c decode.c devices.c disks.c dist.c \
dmenu.c dos.c floppy.c ftp.c ftp_strat.c globals.c install.c label.c lang.c \
main.c makedevs.c media.c menus.c misc.c msg.c network.c nfs.c system.c tape.c \
tcpip.c termcap.c ufs.c variable.c wizard.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: install.c,v 1.59 1995/05/26 10:32:28 jkh Exp $
* $Id: install.c,v 1.60 1995/05/26 20:45:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -386,11 +386,11 @@ static void loop_on_root_floppy();
static void
root_extract(void)
{
int fd, status;
int fd;
if (OnCDROM) {
fd = open("/floppies/root.flp", O_RDONLY);
mediaExtractDist("root.flp", "/", fd);
(void)mediaExtractDist("root.flp", "/", fd);
return;
}
if (mediaDevice) {
@ -407,12 +407,14 @@ root_extract(void)
fd = (*mediaDevice->get)("root.flp", "floppies/");
if (fd != -1) {
msgNotify("Loading root floppy from %s", mediaDevice->name);
status = mediaExtractDist("root.flp", "/", fd);
(void)mediaExtractDist("root.flp", "/", fd);
if (mediaDevice->close)
(*mediaDevice->close)(mediaDevice, fd);
else
close(fd);
}
if (mediaDevice->shutdown)
(*mediaDevice->shutdown)(mediaDevice);
break;
case DEVICE_TYPE_FLOPPY:
@ -430,9 +432,7 @@ loop_on_root_floppy(void)
{
int fd;
mediaDevice = NULL;
fd = genericGetDist("root.flp", NULL, TRUE);
if (fd == -1)
return;
mediaExtractDist("root.flp", "/", fd);
fd = getRootFloppy();
if (fd != -1)
mediaExtractDist("root.flp", "/", fd);
}

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.32 1995/05/26 11:21:53 jkh Exp $
* $Id: menus.c,v 1.33 1995/05/26 19:28:03 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -554,6 +554,8 @@ When you're done setting options, select Cancel",
DMENU_SET_VARIABLE, "debug=yes", 0, 0 },
{ "No Debugging", "Turn the extra debugging flag off",
DMENU_SET_VARIABLE, "debug=no", 0, 0 },
{ "Yes To All", "Assume \"Yes\" answers to all non-critical dialogs",
DMENU_SET_VARIABLE, "noConfirmation=Yes", 0, 0 },
{ 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.34 1995/05/26 08:41:48 jkh Exp $
* $Id: sysinstall.h,v 1.35 1995/05/26 19:28:04 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -85,7 +85,7 @@
#define DISK_LABELLED "_diskLabelled"
#define RUNNING_ON_ROOT "_runningOnRoot"
#define TCP_CONFIGURED "_tcpConfigured"
#define NO_CONFIRMATION "_noConfirmation"
#define NO_CONFIRMATION "noConfirmation"
#define VAR_HOSTNAME "hostname"
#define VAR_DOMAINNAME "domainname"
@ -142,6 +142,15 @@ typedef struct _variable {
char value[VAR_VALUE_MAX];
} Variable;
#define MAX_ATTRIBS 200
#define MAX_NAME 511
#define MAX_VALUE 4095
typedef struct _attribs {
char *name;
char *value;
} Attribs;
typedef enum {
DEVICE_TYPE_NONE,
DEVICE_TYPE_DISK,
@ -235,6 +244,15 @@ extern DMenu MenuDiskDevices; /* Disk devices menu */
/*** Prototypes ***/
/* attrs.c */
extern const char *attr_match(Attribs *attr, char *name);
extern int attr_parse(Attribs **attr, char *file);
/* cdrom.c */
extern Boolean mediaInitCDROM(Device *dev);
extern int mediaGetCDROM(char *dist, char *path);
extern void mediaShutdownCDROM(Device *dev);
/* command.c */
extern void command_clear(void);
extern void command_sort(void);
@ -285,6 +303,23 @@ extern void dmenuOpen(DMenu *menu, int *choice, int *scroll,
int *curr, int *max);
extern void dmenuOpenSimple(DMenu *menu);
/* dos.c */
extern Boolean mediaInitDOS(Device *dev);
extern int mediaGetDOS(char *dist, char *path);
extern void mediaShutdownDOS(Device *dev);
/* floppy.c */
extern int getRootFloppy(void);
extern Boolean mediaInitFloppy(Device *dev);
extern int mediaGetFloppy(char *dist, char *path);
extern void mediaShutdownFloppy(Device *dev);
/* ftp_strat.c */
extern Boolean mediaCloseFTP(Device *dev, int fd);
extern Boolean mediaInitFTP(Device *dev);
extern int mediaGetFTP(char *dist, char *path);
extern void mediaShutdownFTP(Device *dev);
/* globals.c */
extern void globalsInit(void);
@ -322,6 +357,7 @@ extern const u_char koi8_r2cp866[];
extern u_char default_scrnmap[];
/* media.c */
extern int genericGetDist(char *path, Attribs *dist_attrib, Boolean prompt);
extern int mediaSetCDROM(char *str);
extern int mediaSetFloppy(char *str);
extern int mediaSetDOS(char *str);
@ -332,28 +368,6 @@ extern Boolean mediaGetType(void);
extern Boolean mediaExtractDist(char *distname, char *dir, int fd);
extern Boolean mediaVerify(void);
/* media_strategy.c */
extern int genericGetDist(char *path, void *dist_attrib, Boolean prompt);
extern Boolean mediaInitCDROM(Device *dev);
extern Boolean mediaInitDOS(Device *dev);
extern Boolean mediaInitFloppy(Device *dev);
extern Boolean mediaInitFTP(Device *dev);
extern Boolean mediaInitNetwork(Device *dev);
extern Boolean mediaInitTape(Device *dev);
extern Boolean mediaInitUFS(Device *dev);
extern int mediaGetCDROM(char *dist, char *path);
extern int mediaGetDOS(char *dist, char *path);
extern int mediaGetFloppy(char *dist, char *path);
extern int mediaGetFTP(char *dist, char *path);
extern int mediaGetTape(char *dist, char *path);
extern int mediaGetUFS(char *dist, char *path);
extern void mediaShutdownCDROM(Device *dev);
extern void mediaShutdownDOS(Device *dev);
extern void mediaShutdownFTP(Device *dev);
extern void mediaShutdownFloppy(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
extern void mediaShutdownTape(Device *dev);
/* misc.c */
extern Boolean file_readable(char *fname);
extern Boolean file_executable(char *fname);
@ -384,6 +398,10 @@ extern void msgWeHaveOutput(char *fmt, ...);
extern int msgYesNo(char *fmt, ...);
extern char *msgGetInput(char *buf, char *fmt, ...);
/* network.c */
extern Boolean mediaInitNetwork(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
/* system.c */
extern void systemInitialize(int argc, char **argv);
extern void systemShutdown(void);
@ -399,6 +417,11 @@ extern void systemChangeTerminal(char *color, const u_char c_termcap[],
extern void systemChangeScreenmap(const u_char newmap[]);
extern int vsystem(char *fmt, ...);
/* tape.c */
extern Boolean mediaInitTape(Device *dev);
extern int mediaGetTape(char *dist, char *path);
extern void mediaShutdownTape(Device *dev);
/* tcpip.c */
extern int tcpOpenDialog(Device *dev);
extern int tcpDeviceSelect(char *str);
@ -407,6 +430,10 @@ extern Boolean tcpStartPPP(Device *dev);
/* termcap.c */
extern int set_termcap(void);
/* ufs.c */
extern Boolean mediaInitUFS(Device *dev);
extern int mediaGetUFS(char *dist, char *path);
/* variables.c */
extern void variable_set(char *var);
extern void variable_set2(char *name, char *value);

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: variable.c,v 1.2 1995/05/20 10:33:13 jkh Exp $
* $Id: variable.c,v 1.3 1995/05/26 20:45:20 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -75,8 +75,6 @@ variable_set(char *var)
void
variable_set2(char *var, char *value)
{
Variable *newvar;
if (!var || !value)
msgFatal("Null name or value passed to set_variable2!");
make_variable(var, value);

View File

@ -4,15 +4,11 @@ CLEANFILES= makedevs.c rtermcap
.PATH: ${.CURDIR}/../disklabel ${.CURDIR}/../../usr.bin/cksum
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 ftp.c config.c \
crc.c
SRCS= attr.c cdrom.c command.c config.c crc.c decode.c devices.c disks.c dist.c \
dmenu.c dos.c floppy.c ftp.c ftp_strat.c globals.c install.c label.c lang.c \
main.c makedevs.c media.c menus.c misc.c msg.c network.c nfs.c system.c tape.c \
tcpip.c termcap.c ufs.c variable.c wizard.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: dist.c,v 1.24 1995/05/26 10:58:50 jkh Exp $
* $Id: dist.c,v 1.25 1995/05/26 22:22:20 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -226,7 +226,7 @@ distExtract(char *parent, Distribution *me)
status = 0;
if (mediaDevice->init)
if ((*mediaDevice->init)(mediaDevice) == FALSE)
if (!(*mediaDevice->init)(mediaDevice))
return 0;
for (i = 0; me[i].my_name; i++) {
if (me[i].my_bit & *(me[i].my_mask)) {
@ -257,9 +257,10 @@ distExtract(char *parent, Distribution *me)
}
}
}
if (mediaDevice->shutdown)
if (mediaDevice->shutdown && parent == NULL) {
(*mediaDevice->shutdown)(mediaDevice);
mediaDevice = NULL;
mediaDevice = NULL;
}
return status;
}

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.59 1995/05/26 10:32:28 jkh Exp $
* $Id: install.c,v 1.60 1995/05/26 20:45:19 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -386,11 +386,11 @@ static void loop_on_root_floppy();
static void
root_extract(void)
{
int fd, status;
int fd;
if (OnCDROM) {
fd = open("/floppies/root.flp", O_RDONLY);
mediaExtractDist("root.flp", "/", fd);
(void)mediaExtractDist("root.flp", "/", fd);
return;
}
if (mediaDevice) {
@ -407,12 +407,14 @@ root_extract(void)
fd = (*mediaDevice->get)("root.flp", "floppies/");
if (fd != -1) {
msgNotify("Loading root floppy from %s", mediaDevice->name);
status = mediaExtractDist("root.flp", "/", fd);
(void)mediaExtractDist("root.flp", "/", fd);
if (mediaDevice->close)
(*mediaDevice->close)(mediaDevice, fd);
else
close(fd);
}
if (mediaDevice->shutdown)
(*mediaDevice->shutdown)(mediaDevice);
break;
case DEVICE_TYPE_FLOPPY:
@ -430,9 +432,7 @@ loop_on_root_floppy(void)
{
int fd;
mediaDevice = NULL;
fd = genericGetDist("root.flp", NULL, TRUE);
if (fd == -1)
return;
mediaExtractDist("root.flp", "/", fd);
fd = getRootFloppy();
if (fd != -1)
mediaExtractDist("root.flp", "/", fd);
}

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.17 1995/05/26 08:41:41 jkh Exp $
* $Id: media.c,v 1.18 1995/05/26 20:30:58 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -44,10 +44,153 @@
#include <stdio.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <unistd.h>
#include "sysinstall.h"
pid_t getDistpid = 0;
/*
* This is the generic distribution opening routine. It returns
* a file descriptor that refers to a stream of bytes coming from
* _somewhere_ that can be extracted as a gzip'd tar file.
*/
int
genericGetDist(char *path, Attribs *dist_attrib, Boolean prompt)
{
int fd;
char buf[512];
struct stat sb;
int pfd[2], numchunks;
const char *tmp;
/* reap any previous child corpse - yuck! */
if (getDistpid) {
int i, j;
i = waitpid(getDistpid, &j, 0);
if (i < 0 || WEXITSTATUS(j))
msgNotify("Warning: Previous extraction returned status code %d.", WEXITSTATUS(j));
getDistpid = 0;
}
/* How try to figure out how many pieces to expect */
if (dist_attrib) {
tmp = attr_match(dist_attrib, "pieces");
numchunks = atoi(tmp);
}
else
numchunks = 1;
if (!path)
return -1;
if (stat(path, &sb) == 0) {
fd = open(path, O_RDONLY, 0);
return(fd);
}
snprintf(buf, 512, "%s.tgz", path);
if (stat(buf, &sb) == 0) {
fd = open(buf, O_RDONLY, 0);
return(fd);
}
snprintf(buf, 512, "%s.aa", path);
if (stat(buf, &sb) == 0 && numchunks == 1) {
fd = open(buf, O_RDONLY, 0);
if (fd != -1)
return fd;
else if (!prompt) {
}
}
if (numchunks < 2 && !prompt) {
if (!getenv(NO_CONFIRMATION))
msgConfirm("Cannot find file(s) for distribution in ``%s''!", path);
else
msgDebug("Cannot find file(s) for distribution in ``%s''!\n", path);
return -1;
}
msgDebug("Attempting to concatenate %u chunks\n", numchunks);
pipe(pfd);
getDistpid = fork();
if (!getDistpid) {
caddr_t memory;
int chunk;
int retval;
dup2(pfd[1], 1); close(pfd[1]);
close(pfd[0]);
for (chunk = 0; chunk < numchunks; chunk++) {
int fd;
unsigned long len, val;
retval = stat(buf, &sb);
if ((retval != 0) && (prompt != TRUE))
{
msgConfirm("Cannot find file(s) for distribution in ``%s''!\n", path);
return -1;
} else {
char *tmp = index(buf, '/');
tmp++;
while (retval != 0)
{
if (mediaDevice->shutdown)
(*mediaDevice->shutdown)(mediaDevice);
msgConfirm("Please insert the media with the `%s' file on it\n", tmp);
if (mediaDevice->init)
if (!mediaDevice->init(mediaDevice))
return -1;
retval = stat(buf, &sb);
}
}
snprintf(buf, 512, "%s.%c%c", path, (chunk / 26) + 'a', (chunk % 26) + 'a');
if ((fd = open(buf, O_RDONLY)) == -1)
msgFatal("Cannot find file `%s'!", buf);
if (prompt == TRUE) {
extern int crc(int, unsigned long *, unsigned long *);
crc(fd, &val, &len);
msgDebug("crc for %s is %lu %lu\n", buf, val, len);
}
fstat(fd, &sb);
msgDebug("mmap()ing %s (%d)\n", buf, fd);
memory = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t) 0);
if (memory == (caddr_t) -1)
msgFatal("mmap error: %s\n", strerror(errno));
retval = write(1, memory, sb.st_size);
if (retval != sb.st_size)
{
msgConfirm("write didn't write out the complete file!\n(wrote %d bytes of %d bytes)", retval,
sb.st_size);
exit(1);
}
retval = munmap(memory, sb.st_size);
if (retval != 0)
{
msgConfirm("munmap() returned %d", retval);
exit(1);
}
close(fd);
}
close(1);
msgDebug("Extract of %s finished!!!\n", path);
exit(0);
}
close(pfd[1]);
return(pfd[0]);
}
static int
genericHook(char *str, DeviceType type)
{
@ -196,6 +339,7 @@ mediaSetDOS(char *str)
/* Got one! */
mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE,
mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL);
mediaDevice->private = c1;
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
break;
}
@ -270,6 +414,7 @@ mediaSetFTP(char *str)
ftpDevice.type = DEVICE_TYPE_NETWORK;
ftpDevice.init = mediaInitFTP;
ftpDevice.get = mediaGetFTP;
ftpDevice.close = mediaCloseFTP;
ftpDevice.shutdown = mediaShutdownFTP;
ftpDevice.private = mediaDevice;
mediaDevice = &ftpDevice;
@ -336,13 +481,13 @@ mediaExtractDist(char *distname, char *dir, int fd)
i = waitpid(zpid, &j, 0);
if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */
dialog_clear();
msgConfirm("wait for gunzip returned status of %d!", i);
msgDebug("wait for gunzip returned status of %d!\n", i);
return FALSE;
}
i = waitpid(cpid, &j, 0);
if (i < 0 || WEXITSTATUS(j)) {
dialog_clear();
msgConfirm("cpio returned error status of %d!", WEXITSTATUS(j));
msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
return FALSE;
}
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.32 1995/05/26 11:21:53 jkh Exp $
* $Id: menus.c,v 1.33 1995/05/26 19:28:03 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -554,6 +554,8 @@ When you're done setting options, select Cancel",
DMENU_SET_VARIABLE, "debug=yes", 0, 0 },
{ "No Debugging", "Turn the extra debugging flag off",
DMENU_SET_VARIABLE, "debug=no", 0, 0 },
{ "Yes To All", "Assume \"Yes\" answers to all non-critical dialogs",
DMENU_SET_VARIABLE, "noConfirmation=Yes", 0, 0 },
{ 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.34 1995/05/26 08:41:48 jkh Exp $
* $Id: sysinstall.h,v 1.35 1995/05/26 19:28:04 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -85,7 +85,7 @@
#define DISK_LABELLED "_diskLabelled"
#define RUNNING_ON_ROOT "_runningOnRoot"
#define TCP_CONFIGURED "_tcpConfigured"
#define NO_CONFIRMATION "_noConfirmation"
#define NO_CONFIRMATION "noConfirmation"
#define VAR_HOSTNAME "hostname"
#define VAR_DOMAINNAME "domainname"
@ -142,6 +142,15 @@ typedef struct _variable {
char value[VAR_VALUE_MAX];
} Variable;
#define MAX_ATTRIBS 200
#define MAX_NAME 511
#define MAX_VALUE 4095
typedef struct _attribs {
char *name;
char *value;
} Attribs;
typedef enum {
DEVICE_TYPE_NONE,
DEVICE_TYPE_DISK,
@ -235,6 +244,15 @@ extern DMenu MenuDiskDevices; /* Disk devices menu */
/*** Prototypes ***/
/* attrs.c */
extern const char *attr_match(Attribs *attr, char *name);
extern int attr_parse(Attribs **attr, char *file);
/* cdrom.c */
extern Boolean mediaInitCDROM(Device *dev);
extern int mediaGetCDROM(char *dist, char *path);
extern void mediaShutdownCDROM(Device *dev);
/* command.c */
extern void command_clear(void);
extern void command_sort(void);
@ -285,6 +303,23 @@ extern void dmenuOpen(DMenu *menu, int *choice, int *scroll,
int *curr, int *max);
extern void dmenuOpenSimple(DMenu *menu);
/* dos.c */
extern Boolean mediaInitDOS(Device *dev);
extern int mediaGetDOS(char *dist, char *path);
extern void mediaShutdownDOS(Device *dev);
/* floppy.c */
extern int getRootFloppy(void);
extern Boolean mediaInitFloppy(Device *dev);
extern int mediaGetFloppy(char *dist, char *path);
extern void mediaShutdownFloppy(Device *dev);
/* ftp_strat.c */
extern Boolean mediaCloseFTP(Device *dev, int fd);
extern Boolean mediaInitFTP(Device *dev);
extern int mediaGetFTP(char *dist, char *path);
extern void mediaShutdownFTP(Device *dev);
/* globals.c */
extern void globalsInit(void);
@ -322,6 +357,7 @@ extern const u_char koi8_r2cp866[];
extern u_char default_scrnmap[];
/* media.c */
extern int genericGetDist(char *path, Attribs *dist_attrib, Boolean prompt);
extern int mediaSetCDROM(char *str);
extern int mediaSetFloppy(char *str);
extern int mediaSetDOS(char *str);
@ -332,28 +368,6 @@ extern Boolean mediaGetType(void);
extern Boolean mediaExtractDist(char *distname, char *dir, int fd);
extern Boolean mediaVerify(void);
/* media_strategy.c */
extern int genericGetDist(char *path, void *dist_attrib, Boolean prompt);
extern Boolean mediaInitCDROM(Device *dev);
extern Boolean mediaInitDOS(Device *dev);
extern Boolean mediaInitFloppy(Device *dev);
extern Boolean mediaInitFTP(Device *dev);
extern Boolean mediaInitNetwork(Device *dev);
extern Boolean mediaInitTape(Device *dev);
extern Boolean mediaInitUFS(Device *dev);
extern int mediaGetCDROM(char *dist, char *path);
extern int mediaGetDOS(char *dist, char *path);
extern int mediaGetFloppy(char *dist, char *path);
extern int mediaGetFTP(char *dist, char *path);
extern int mediaGetTape(char *dist, char *path);
extern int mediaGetUFS(char *dist, char *path);
extern void mediaShutdownCDROM(Device *dev);
extern void mediaShutdownDOS(Device *dev);
extern void mediaShutdownFTP(Device *dev);
extern void mediaShutdownFloppy(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
extern void mediaShutdownTape(Device *dev);
/* misc.c */
extern Boolean file_readable(char *fname);
extern Boolean file_executable(char *fname);
@ -384,6 +398,10 @@ extern void msgWeHaveOutput(char *fmt, ...);
extern int msgYesNo(char *fmt, ...);
extern char *msgGetInput(char *buf, char *fmt, ...);
/* network.c */
extern Boolean mediaInitNetwork(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
/* system.c */
extern void systemInitialize(int argc, char **argv);
extern void systemShutdown(void);
@ -399,6 +417,11 @@ extern void systemChangeTerminal(char *color, const u_char c_termcap[],
extern void systemChangeScreenmap(const u_char newmap[]);
extern int vsystem(char *fmt, ...);
/* tape.c */
extern Boolean mediaInitTape(Device *dev);
extern int mediaGetTape(char *dist, char *path);
extern void mediaShutdownTape(Device *dev);
/* tcpip.c */
extern int tcpOpenDialog(Device *dev);
extern int tcpDeviceSelect(char *str);
@ -407,6 +430,10 @@ extern Boolean tcpStartPPP(Device *dev);
/* termcap.c */
extern int set_termcap(void);
/* ufs.c */
extern Boolean mediaInitUFS(Device *dev);
extern int mediaGetUFS(char *dist, char *path);
/* variables.c */
extern void variable_set(char *var);
extern void variable_set2(char *name, char *value);

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: variable.c,v 1.2 1995/05/20 10:33:13 jkh Exp $
* $Id: variable.c,v 1.3 1995/05/26 20:45:20 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -75,8 +75,6 @@ variable_set(char *var)
void
variable_set2(char *var, char *value)
{
Variable *newvar;
if (!var || !value)
msgFatal("Null name or value passed to set_variable2!");
make_variable(var, value);