summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sade
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-12-11 09:35:06 +0000
committerjkh <jkh@FreeBSD.org>1996-12-11 09:35:06 +0000
commit3727883bddbc2a8ead72a97011cf4763fe5c7ede (patch)
tree3e96d1a8c70e76ad8e35ec46e4c61b3f0ab3295c /usr.sbin/sade
parent90d182874d165b16fcb0758a86668941f1ddda01 (diff)
downloadFreeBSD-src-3727883bddbc2a8ead72a97011cf4763fe5c7ede.zip
FreeBSD-src-3727883bddbc2a8ead72a97011cf4763fe5c7ede.tar.gz
Do a few things I've been threatening to do for a long time:
1. Don't use the MSDOSFS code for accessing FreeBSD distribution data. Use Robert Nordier's stand-alone DOS I/O library for the purpose. It this works as well as Robert says it does, it should drastically reduce (or even eliminate) our "I can't install from my DOS partition!" calls. 2. As a result of the above, go to stdio file descriptors for all media types. 3. Taking advantage of #2, start using libftpio for FTP transfers instead of maintaining our own parallel version of the FTP transfer code. Yay! I ripped something out for a change! #1 Submitted-By: Robert Nordier <rnordier@iafrica.com>
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r--usr.sbin/sade/Makefile10
-rw-r--r--usr.sbin/sade/config.c14
-rw-r--r--usr.sbin/sade/devices.c35
-rw-r--r--usr.sbin/sade/main.c20
-rw-r--r--usr.sbin/sade/sade.h37
5 files changed, 54 insertions, 62 deletions
diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile
index 10abd4c..d4b3e13 100644
--- a/usr.sbin/sade/Makefile
+++ b/usr.sbin/sade/Makefile
@@ -7,21 +7,21 @@ CLEANFILES+= keymap.tmp keymap.h
.PATH: ${.CURDIR}/../disklabel ${.CURDIR}/../../usr.bin/cksum
SRCS= anonFTP.c apache.c attr.c cdrom.c command.c config.c devices.c \
- disks.c dispatch.c dist.c dmenu.c doc.c dos.c floppy.c ftp.c \
- ftp_strat.c globals.c index.c install.c installUpgrade.c \
+ disks.c dispatch.c dist.c dmenu.c doc.c dos.c dosio.c floppy.c ftp.c \
+ globals.c index.c install.c installUpgrade.c \
keymap.c label.c lndir.c main.c makedevs.c media.c menus.c misc.c \
msg.c network.c nfs.c options.c package.c samba.c system.c \
tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \
uc_eisa.c uc_isa.c uc_kmem.c uc_list.c uc_main.c uc_pci.c \
- uc_scsi.c
+ uc_scsi.c keymap.h
CFLAGS+= -Wall -I${.CURDIR}/../../gnu/lib/libdialog -I${.OBJDIR} -I/sys
CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS -DSAVE_USERCONFIG
#CFLAGS+= -DLOAD_CONFIG_FILE=\"install.cfg\"
-DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK}
-LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk
+DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
+LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk -lftpio
makedevs.c: Makefile rtermcap keymap.h
rm -f makedevs.tmp
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c
index ab4f062..aa15e2a 100644
--- a/usr.sbin/sade/config.c
+++ b/usr.sbin/sade/config.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: config.c,v 1.61 1996/12/02 05:01:00 jkh Exp $
+ * $Id: config.c,v 1.62 1996/12/09 08:22:11 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -467,7 +467,7 @@ configPackages(dialogMenuItem *self)
static PkgNode top, plist;
static Boolean index_initted = FALSE;
PkgNodePtr tmp;
- int fd;
+ FILE *fp;
if (!mediaVerify())
return DITEM_FAILURE;
@@ -477,8 +477,8 @@ configPackages(dialogMenuItem *self)
if (!index_initted) {
msgNotify("Attempting to fetch packages/INDEX file from selected media.");
- fd = mediaDevice->get(mediaDevice, "packages/INDEX", TRUE);
- if (fd < 0) {
+ fp = mediaDevice->get(mediaDevice, "packages/INDEX", TRUE);
+ if (!fp) {
dialog_clear_norefresh();
msgConfirm("Unable to get packages/INDEX file from selected media.\n"
"This may be because the packages collection is not available at\n"
@@ -491,13 +491,13 @@ configPackages(dialogMenuItem *self)
}
msgNotify("Got INDEX successfully, now building packages menu..");
index_init(&top, &plist);
- if (index_read(fd, &top)) {
+ if (index_read(fp, &top)) {
msgConfirm("I/O or format error on packages/INDEX file.\n"
"Please verify media (or path to media) and try again.");
- mediaDevice->close(mediaDevice, fd);
+ fclose(fp);
return DITEM_FAILURE | DITEM_RESTORE;
}
- mediaDevice->close(mediaDevice, fd);
+ fclose(fp);
index_sort(&top);
index_initted = TRUE;
}
diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c
index 8965f6c..35ae6e8 100644
--- a/usr.sbin/sade/devices.c
+++ b/usr.sbin/sade/devices.c
@@ -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.52 1996/12/08 12:27:53 jkh Exp $
+ * $Id: devices.c,v 1.53 1996/12/09 08:22:11 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -113,18 +113,10 @@ dummyInit(Device *dev)
return TRUE;
}
-int
+FILE *
dummyGet(Device *dev, char *dist, Boolean probe)
{
- return -1;
-}
-
-Boolean
-dummyClose(Device *dev, int fd)
-{
- if (!close(fd))
- return TRUE;
- return FALSE;
+ return NULL;
}
void
@@ -152,8 +144,8 @@ deviceTry(char *name, char *try)
/* Register a new device in the devices array */
Device *
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
- Boolean (*init)(Device *), int (*get)(Device *, char *, Boolean),
- Boolean (*close)(Device *, int), void (*shutdown)(Device *), void *private)
+ Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean),
+ void (*shutdown)(Device *), void *private)
{
Device *newdev = NULL;
@@ -167,7 +159,6 @@ deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean e
newdev->enabled = enabled;
newdev->init = init ? init : dummyInit;
newdev->get = get ? get : dummyGet;
- newdev->close = close ? close : dummyClose;
newdev->shutdown = shutdown ? shutdown : dummyShutdown;
newdev->private = private;
Devices[numDevs] = newdev;
@@ -199,7 +190,7 @@ deviceGetAll(void)
if (!d)
msgFatal("Unable to open disk %s", names[i]);
- (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, NULL, d);
+ (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, d);
msgDebug("Found a disk device named %s\n", names[i]);
/* Look for existing DOS partitions to register */
@@ -211,7 +202,7 @@ deviceGetAll(void)
/* Got one! */
sprintf(devname, "/dev/%s", c1->name);
dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
- mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL);
+ mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
dev->private = c1;
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
}
@@ -259,7 +250,7 @@ deviceGetAll(void)
descr = "<unknown network interface type>";
deviceRegister(ifptr->ifr_name, descr, strdup(ifptr->ifr_name), DEVICE_TYPE_NETWORK, TRUE,
- mediaInitNetwork, NULL, NULL, mediaShutdownNetwork, NULL);
+ mediaInitNetwork, NULL, mediaShutdownNetwork, NULL);
msgDebug("Found a network device named %s\n", ifptr->ifr_name);
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
@@ -284,7 +275,7 @@ skipif:
if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
if (fd >= 0) close(fd);
(void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, NULL,
+ DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
mediaShutdownCDROM, NULL);
msgDebug("Found a CDROM device named %s\n", device_names[i].name);
}
@@ -295,7 +286,7 @@ skipif:
if (fd >= 0) {
if (fd) close(fd);
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, NULL, mediaShutdownTape, NULL);
+ DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
msgDebug("Found a TAPE device named %s\n", device_names[i].name);
}
break;
@@ -305,7 +296,7 @@ skipif:
if (fd >= 0) {
if (fd) close(fd);
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
- DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, NULL,
+ DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
mediaShutdownFloppy, NULL);
msgDebug("Found a floppy device named %s\n", device_names[i].name);
}
@@ -325,11 +316,11 @@ skipif:
newdesc = safe_malloc(strlen(cp) + 40);
sprintf(newdesc, cp, "SLIP interface");
deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, NULL, mediaShutdownNetwork, NULL);
+ NULL, mediaShutdownNetwork, NULL);
newdesc = safe_malloc(strlen(cp) + 50);
sprintf(newdesc, cp, "PPP interface");
deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, NULL, mediaShutdownNetwork, NULL);
+ NULL, mediaShutdownNetwork, NULL);
msgDebug("Found a serial network device named %s on %s\n", device_names[i].name, try);
}
break;
diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c
index 2328c70..d61d0c1 100644
--- a/usr.sbin/sade/main.c
+++ b/usr.sbin/sade/main.c
@@ -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: main.c,v 1.27 1996/09/15 23:55:23 jkh Exp $
+ * $Id: main.c,v 1.28 1996/09/26 21:03:35 pst Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -112,21 +112,21 @@ main(int argc, char **argv)
}
{
- int fd;
+ FILE *fp;
Attribs attrs[512];
bzero(attrs, sizeof(attrs));
- fd = open("install.cfg", O_RDONLY);
- if (fd >= 0) {
+ fp = fopen("install.cfg", "r");
+ if (fp) {
msgNotify("Loading pre-configuration file");
- if (DITEM_STATUS(attr_parse(attrs, fd)) == DITEM_SUCCESS) {
+ if (DITEM_STATUS(attr_parse(attrs, fp)) == DITEM_SUCCESS) {
int i;
for (i = 0; *attrs[i].name; i++)
variable_set2(attrs[i].name, attrs[i].value);
}
- close(fd);
+ fclose(fp);
}
#if defined(LOAD_CONFIG_FILE)
@@ -143,17 +143,17 @@ main(int argc, char **argv)
mediaDevice->init(mediaDevice)) {
int fd;
- fd = mediaDevice->get(mediaDevice, LOAD_CONFIG_FILE, TRUE);
- if (fd > 0) {
+ fp = mediaDevice->get(mediaDevice, LOAD_CONFIG_FILE, TRUE);
+ if (fp) {
msgNotify("Loading %s pre-configuration file",
LOAD_CONFIG_FILE);
- if (DITEM_STATUS(attr_parse(attrs, fd)) == DITEM_SUCCESS) {
+ if (DITEM_STATUS(attr_parse(attrs, fp)) == DITEM_SUCCESS) {
int i;
for (i = 0; *attrs[i].name; i++)
variable_set2(attrs[i].name, attrs[i].value);
}
- mediaDevice->close(mediaDevice, fd);
+ fclose(fp);
}
mediaDevice->shutdown(mediaDevice);
}
diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h
index dab2d63..3ebcecf 100644
--- a/usr.sbin/sade/sade.h
+++ b/usr.sbin/sade/sade.h
@@ -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.89 1996/12/09 06:37:45 jkh Exp $
+ * $Id: sysinstall.h,v 1.90 1996/12/09 08:22:17 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -214,8 +214,8 @@ typedef struct _device {
DeviceType type;
Boolean enabled;
Boolean (*init)(struct _device *dev);
- int (*get)(struct _device *dev, char *file, Boolean probe);
- Boolean (*close)(struct _device *dev, int fd);
+ FILE * (*get)(struct _device *dev, char *file, Boolean probe);
+ Boolean (*close)(struct _device *dev, FILE *fp);
void (*shutdown)(struct _device *dev);
void *private;
unsigned int flags;
@@ -358,11 +358,11 @@ extern int configAnonFTP(dialogMenuItem *self);
/* attrs.c */
extern char *attr_match(Attribs *attr, char *name);
extern int attr_parse_file(Attribs *attr, char *file);
-extern int attr_parse(Attribs *attr, int fd);
+extern int attr_parse(Attribs *attr, FILE *fp);
/* cdrom.c */
extern Boolean mediaInitCDROM(Device *dev);
-extern int mediaGetCDROM(Device *dev, char *file, Boolean probe);
+extern FILE *mediaGetCDROM(Device *dev, char *file, Boolean probe);
extern void mediaShutdownCDROM(Device *dev);
/* command.c */
@@ -401,12 +401,12 @@ 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), int (*get)(Device *dev, char *file, Boolean probe),
- Boolean (*close)(Device *mediadev, int fd), void (*shutDown)(Device *mediadev),
+ Boolean (*init)(Device *mediadev),
+ FILE * (*get)(Device *dev, char *file, Boolean probe),
+ void (*shutDown)(Device *mediadev),
void *private);
extern Boolean dummyInit(Device *dev);
-extern int dummyGet(Device *dev, char *dist, Boolean probe);
-extern Boolean dummyClose(Device *dev, int fd);
+extern FILE *dummyGet(Device *dev, char *dist, Boolean probe);
extern void dummyShutdown(Device *dev);
/* disks.c */
@@ -455,20 +455,21 @@ extern int docBrowser(dialogMenuItem *self);
extern int docShowDocument(dialogMenuItem *self);
/* dos.c */
+extern Boolean mediaCloseDOS(Device *dev, FILE *fp);
extern Boolean mediaInitDOS(Device *dev);
-extern int mediaGetDOS(Device *dev, char *file, Boolean probe);
+extern FILE *mediaGetDOS(Device *dev, char *file, Boolean probe);
extern void mediaShutdownDOS(Device *dev);
/* floppy.c */
extern int getRootFloppy(void);
extern Boolean mediaInitFloppy(Device *dev);
-extern int mediaGetFloppy(Device *dev, char *file, Boolean probe);
+extern FILE *mediaGetFloppy(Device *dev, char *file, Boolean probe);
extern void mediaShutdownFloppy(Device *dev);
/* ftp_strat.c */
-extern Boolean mediaCloseFTP(Device *dev, int fd);
+extern Boolean mediaCloseFTP(Device *dev, FILE *fp);
extern Boolean mediaInitFTP(Device *dev);
-extern int mediaGetFTP(Device *dev, char *file, Boolean probe);
+extern FILE *mediaGetFTP(Device *dev, char *file, Boolean probe);
extern void mediaShutdownFTP(Device *dev);
/* globals.c */
@@ -476,7 +477,7 @@ extern void globalsInit(void);
/* index.c */
int index_get(char *fname, PkgNodePtr papa);
-int index_read(int fd, PkgNodePtr papa);
+int index_read(FILE *fp, PkgNodePtr papa);
int index_menu(PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll);
void index_init(PkgNodePtr top, PkgNodePtr plist);
void index_node_free(PkgNodePtr top, PkgNodePtr plist);
@@ -536,7 +537,7 @@ extern int mediaSetNFS(dialogMenuItem *self);
extern int mediaSetFTPUserPass(dialogMenuItem *self);
extern int mediaSetCPIOVerbosity(dialogMenuItem *self);
extern int mediaGetType(dialogMenuItem *self);
-extern Boolean mediaExtractDist(char *dir, int fd);
+extern Boolean mediaExtractDist(char *dir, FILE *fp);
extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic);
extern Boolean mediaExtractDistEnd(int zpid, int cpid);
extern Boolean mediaVerify(void);
@@ -590,7 +591,7 @@ extern void mediaShutdownNetwork(Device *dev);
/* nfs.c */
extern Boolean mediaInitNFS(Device *dev);
-extern int mediaGetNFS(Device *dev, char *file, Boolean probe);
+extern FILE *mediaGetNFS(Device *dev, char *file, Boolean probe);
extern void mediaShutdownNFS(Device *dev);
/* options.c */
@@ -618,7 +619,7 @@ extern int vsystem(char *fmt, ...);
/* tape.c */
extern char *mediaTapeBlocksize(void);
extern Boolean mediaInitTape(Device *dev);
-extern int mediaGetTape(Device *dev, char *file, Boolean probe);
+extern FILE *mediaGetTape(Device *dev, char *file, Boolean probe);
extern void mediaShutdownTape(Device *dev);
/* tcpip.c */
@@ -632,7 +633,7 @@ extern int set_termcap(void);
/* ufs.c */
extern void mediaShutdownUFS(Device *dev);
extern Boolean mediaInitUFS(Device *dev);
-extern int mediaGetUFS(Device *dev, char *file, Boolean probe);
+extern FILE *mediaGetUFS(Device *dev, char *file, Boolean probe);
/* user.c */
extern int userAddGroup(dialogMenuItem *self);
OpenPOWER on IntegriCloud