diff options
author | jkh <jkh@FreeBSD.org> | 1995-05-20 10:33:14 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-05-20 10:33:14 +0000 |
commit | 3b6a142d8de0c7c6fc16424823c1c574c26a6019 (patch) | |
tree | fe34e20c28206a242583f4afa84e1c0ce9c247b8 /usr.sbin/sade | |
parent | b00009a29ac9fc1ba5f3ce41b8d992a4c9b88e5e (diff) | |
download | FreeBSD-src-3b6a142d8de0c7c6fc16424823c1c574c26a6019.zip FreeBSD-src-3b6a142d8de0c7c6fc16424823c1c574c26a6019.tar.gz |
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.
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r-- | usr.sbin/sade/Makefile | 14 | ||||
-rw-r--r-- | usr.sbin/sade/devices.c | 123 | ||||
-rw-r--r-- | usr.sbin/sade/disks.c | 6 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 8 | ||||
-rw-r--r-- | usr.sbin/sade/label.c | 3 | ||||
-rw-r--r-- | usr.sbin/sade/menus.c | 10 | ||||
-rw-r--r-- | usr.sbin/sade/msg.c | 16 | ||||
-rw-r--r-- | usr.sbin/sade/sade.h | 9 | ||||
-rw-r--r-- | usr.sbin/sade/variable.c | 4 | ||||
-rw-r--r-- | usr.sbin/sade/wizard.c | 8 |
10 files changed, 92 insertions, 109 deletions
diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile index f013b7d..15a5197 100644 --- a/usr.sbin/sade/Makefile +++ b/usr.sbin/sade/Makefile @@ -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 diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c index dffe69e..113b1d8 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.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) diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c index 20f9f11..f1f1693 100644 --- a/usr.sbin/sade/disks.c +++ b/usr.sbin/sade/disks.c @@ -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; diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 3602d3c..1b880aa 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -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); diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c index a86f394..a501013 100644 --- a/usr.sbin/sade/label.c +++ b/usr.sbin/sade/label.c @@ -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); diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c index c6c54e1..07c33c9 100644 --- a/usr.sbin/sade/menus.c +++ b/usr.sbin/sade/menus.c @@ -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 = { diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c index 5213ced..5acd662 100644 --- a/usr.sbin/sade/msg.c +++ b/usr.sbin/sade/msg.c @@ -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); diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index ad1cd39..b4b9463 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.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); diff --git a/usr.sbin/sade/variable.c b/usr.sbin/sade/variable.c index 5a64f91..993828c 100644 --- a/usr.sbin/sade/variable.c +++ b/usr.sbin/sade/variable.c @@ -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); } diff --git a/usr.sbin/sade/wizard.c b/usr.sbin/sade/wizard.c index aa4fc34..a3f9285 100644 --- a/usr.sbin/sade/wizard.c +++ b/usr.sbin/sade/wizard.c @@ -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; |