summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sade
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1995-05-22 14:10:25 +0000
committerjkh <jkh@FreeBSD.org>1995-05-22 14:10:25 +0000
commit102ea06d3bd47d7b7dcdaa9f1121ba3e26b1a3e7 (patch)
tree9229dd261cca0b9bdfdd8d28254004226a5b7505 /usr.sbin/sade
parenta93f9fc13537d35520b293f7dda9f8361a782400 (diff)
downloadFreeBSD-src-102ea06d3bd47d7b7dcdaa9f1121ba3e26b1a3e7.zip
FreeBSD-src-102ea06d3bd47d7b7dcdaa9f1121ba3e26b1a3e7.tar.gz
Implement most of the CD extract code.
Clean up a few last display bugs. Add sanity checking that makes sure user creates root and swap partitions. Add swap partitions with swapon().
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r--usr.sbin/sade/disks.c3
-rw-r--r--usr.sbin/sade/install.c182
-rw-r--r--usr.sbin/sade/label.c118
-rw-r--r--usr.sbin/sade/msg.c17
4 files changed, 199 insertions, 121 deletions
diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c
index 399c812..ba0b190 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.24 1995/05/20 19:22:18 jkh Exp $
+ * $Id: disks.c,v 1.26 1995/05/21 06:12:42 phk Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -276,7 +276,6 @@ diskPartition(Disk *d)
free(p);
}
dialog_clear();
- refresh();
variable_set2(DISK_PARTITIONED, "yes");
return d;
}
diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c
index db8ecf1..a00431a 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.45 1995/05/21 01:56:01 phk Exp $
+ * $Id: install.c,v 1.46 1995/05/21 15:40:48 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -56,6 +56,69 @@ static void cpio_extract(void);
static void install_configuration_files(void);
static void do_final_setup(void);
+static Disk *rootdisk;
+static Chunk *rootdev;
+
+static Boolean
+checkLabels(void)
+{
+ Device **devs;
+ Disk *disk;
+ Chunk *c1, *c2, *swapdev = NULL;
+ int i;
+
+ devs = deviceFind(NULL, DEVICE_TYPE_DISK);
+ /* First verify that we have a root device */
+ for (i = 0; devs[i]; i++) {
+ if (!devs[i]->enabled)
+ continue;
+ disk = (Disk *)devs[i]->private;
+ msgDebug("Scanning disk %s for root filesystem\n", disk->name);
+ if (!disk->chunks)
+ msgFatal("No chunk list found for %s!", disk->name);
+ for (c1 = disk->chunks->part; c1; c1 = c1->next) {
+ if (c1->type == freebsd) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
+ if (c2->type == part && c2->subtype != FS_SWAP &&
+ c2->private && c2->flags & CHUNK_IS_ROOT) {
+ rootdisk = disk;
+ rootdev = c2;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /* Now register the swap devices */
+ for (i = 0; devs[i]; i++) {
+ disk = (Disk *)devs[i]->private;
+ msgDebug("Scanning disk %s for swap partitions\n", disk->name);
+ if (!disk->chunks)
+ msgFatal("No chunk list found for %s!", disk->name);
+ for (c1 = disk->chunks->part; c1; c1 = c1->next) {
+ if (c1->type == freebsd) {
+ for (c2 = c1->part; c2; c2 = c2->next) {
+ if (c2->type == part && c2->subtype == FS_SWAP) {
+ swapdev = c2;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!rootdev) {
+ msgConfirm("No root device found - you must label a partition as /\n in the label editor.");
+ return FALSE;
+ }
+ if (!swapdev) {
+ msgConfirm("No swap devices found - you must create at least one\nswap partition.");
+ return FALSE;
+ }
+ return TRUE;
+}
+
static void
installInitial(void)
{
@@ -78,6 +141,8 @@ installInitial(void)
msgConfirm("You need to assign disk labels before you can proceed with\nthe installation.");
return;
}
+ if (!checkLabels())
+ return;
/* Figure out what kind of MBR the user wants */
dmenuOpenSimple(&MenuMBRType);
@@ -96,8 +161,8 @@ installInitial(void)
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
for (i = 0; devs[i]; i++) {
- Disk *d = (Disk *)devs[i]->private;
Chunk *c1;
+ Disk *d = (Disk *)devs[i]->private;
if (!devs[i]->enabled)
continue;
@@ -178,63 +243,45 @@ make_filesystems(void)
Disk *disk;
Chunk *c1, *c2;
Device **devs;
+ char dname[40];
+ PartInfo *p = (PartInfo *)rootdev->private;
command_clear();
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- /* First look for the root device and mount it */
- for (i = 0; devs[i]; i++) {
- disk = (Disk *)devs[i]->private;
- msgDebug("Scanning disk %s for root filesystem\n", disk->name);
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && c2->subtype != FS_SWAP &&
- c2->private && c2->flags & CHUNK_IS_ROOT) {
- char dname[40];
- PartInfo *p = (PartInfo *)c2->private;
+ /* First, create and mount the root device */
+ if (strcmp(p->mountpoint, "/"))
+ msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, p->mountpoint);
- if (strcmp(p->mountpoint, "/")) {
- msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", c2->name, p->mountpoint);
- continue;
- }
- if (p->newfs) {
- int i;
-
- sprintf(dname, "/dev/r%sa", disk->name);
- msgNotify("Making a new root filesystem on %s", dname);
- i = vsystem("%s %s", p->newfs_cmd,dname);
- if (i) {
- msgConfirm("Unable to make new root filesystem! Command returned status %d", i);
- return;
- }
- }
- else
- msgConfirm("Warning: You have selected a Read-Only root device\nand may be unable to find the appropriate device entries on it\nif it is from an older pre-slice version of FreeBSD.");
- sprintf(dname, "/dev/%sa", disk->name);
- if (Mount("/mnt", dname)) {
- msgConfirm("Unable to mount the root file system! Giving up.");
- return;
- }
- else {
- extern int makedevs(void);
-
- msgNotify("Making device files");
- if (Mkdir("/mnt/dev", NULL)
- || chdir("/mnt/dev")
- || makedevs())
- msgConfirm("Failed to make some of the devices in /mnt!");
- if (Mkdir("/mnt/stand", NULL))
- msgConfirm("Unable to make /mnt/stand directory!");
- chdir("/");
- break;
- }
- }
- }
- }
+ if (p->newfs) {
+ int i;
+
+ sprintf(dname, "/dev/r%sa", rootdisk->name);
+ msgNotify("Making a new root filesystem on %s", dname);
+ i = vsystem("%s %s", p->newfs_cmd, dname);
+ if (i) {
+ msgConfirm("Unable to make new root filesystem! Command returned status %d", i);
+ return;
+ }
+ }
+ else
+ msgConfirm("Warning: You have selected a Read-Only root device\nand may be unable to find the appropriate device entries on it\nif it is from an older pre-slice version of FreeBSD.");
+ sprintf(dname, "/dev/%sa", rootdisk->name);
+ if (Mount("/mnt", dname)) {
+ msgConfirm("Unable to mount the root file system! Giving up.");
+ return;
+ }
+ else {
+ extern int makedevs(void);
+
+ msgNotify("Making device files");
+ if (Mkdir("/mnt/dev", NULL) || chdir("/mnt/dev") || makedevs())
+ msgConfirm("Failed to make some of the devices in /mnt!");
+ if (Mkdir("/mnt/stand", NULL)) {
+ msgConfirm("Unable to make /mnt/stand directory!");
+ return;
}
+ chdir("/");
}
/* Now buzz through the rest of the partitions and mount them too */
@@ -256,10 +303,20 @@ make_filesystems(void)
continue;
if (tmp->newfs)
- command_shell_add(tmp->mountpoint,
- "%s /mnt/dev/r%s", tmp->newfs_cmd, c2->name);
+ command_shell_add(tmp->mountpoint, "%s /mnt/dev/r%s", tmp->newfs_cmd, c2->name);
command_func_add(tmp->mountpoint, Mount, c2->name);
}
+ else if (c2->type == part && c2->subtype == FS_SWAP) {
+ char fname[80];
+ int i;
+
+ sprintf(fname, "/mnt/dev/%s", c2->name);
+ i = swapon(fname);
+ if (!i)
+ msgNotify("Added %s as a swap device", fname);
+ else
+ msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
+ }
}
}
}
@@ -285,10 +342,21 @@ cpio_extract(void)
{
int i, j, zpid, cpid, pfd[2];
+#if 0
+ if (mediaDevice && mediaDevice->type == DEVICE_TYPE_CDROM) {
+ if (mediaDevice->init) {
+ if ((*mediaDevice->init)(mediaDevice)) {
+ CpioFD = open("/cdrom/floppies/cpio.flp", O_RDONLY);
+ if (CpioFD != -1)
+ msgNotify("Loading CPIO floppy from CDROM");
+ }
+ }
+ }
+#endif
tryagain:
while (CpioFD == -1) {
msgConfirm("Please Insert CPIO floppy in floppy drive 0");
- CpioFD = open("/dev/rfd0", O_RDWR);
+ CpioFD = open("/dev/rfd0", O_RDONLY);
if (CpioFD >= 0)
break;
msgDebug("Error on open of cpio floppy: %s (%d)\n", strerror(errno), errno);
@@ -302,6 +370,8 @@ cpio_extract(void)
if (!zpid) {
dup2(CpioFD, 0); close(CpioFD);
dup2(pfd[1], 1); close(pfd[1]);
+ if (DebugFD != -1)
+ dup2(DebugFD, 2);
close(pfd[0]);
i = execl("/stand/gunzip", "/stand/gunzip", 0);
msgDebug("/stand/gunzip command returns %d status\n", i);
diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c
index 5395e1c..a5d811a 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.19 1995/05/21 17:53:27 jkh Exp $
+ * $Id: label.c,v 1.20 1995/05/21 18:24:33 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -66,11 +66,14 @@
#define CHUNK_SLICE_START_ROW 2
#define CHUNK_PART_START_ROW 11
+/* One MB worth of blocks */
+#define ONE_MEG 2048
+
/* The smallest filesystem we're willing to create */
-#define FS_MIN_SIZE 2048
+#define FS_MIN_SIZE ONE_MEG
/* The smallest root filesystem we're willing to create */
-#define ROOT_MIN_SIZE 40960 /* 20MB */
+#define ROOT_MIN_SIZE (20 * ONE_MEG)
/* All the chunks currently displayed on the screen */
static struct {
@@ -169,6 +172,7 @@ record_label_chunks()
label_chunk_info[j].type = PART_FAT;
label_chunk_info[j].d = d;
label_chunk_info[j].c = c1;
+ ++j;
}
}
}
@@ -210,7 +214,6 @@ get_mountpoint(struct chunk *old)
char *val;
PartInfo *tmp;
- dialog_clear(); clear();
val = msgGetInput(old && old->private ? ((PartInfo *)old->private)->mountpoint : NULL,
"Please specify a mount point for the partition");
if (!val)
@@ -255,7 +258,6 @@ get_partition_type(void)
"Swap",
"A swap partition.",
};
- dialog_clear(); clear();
i = dialog_menu("Please choose a partition type",
"If you want to use this partition for swap space, select Swap.\nIf you want to put a filesystem on it, choose FS.", -1, -1, 2, 2, fs_types, selection, NULL, NULL);
if (!i) {
@@ -329,7 +331,7 @@ print_label_chunks(void)
mvprintw(srow++, 0,
"Disk: %s\tPartition name: %s\tFree: %d blocks (%dMB)",
label_chunk_info[i].d->name,
- label_chunk_info[i].c->name, sz, (sz / 2048));
+ label_chunk_info[i].c->name, sz, (sz / ONE_MEG));
}
/* Otherwise it's a DOS, swap or filesystem entry, at the bottom */
else {
@@ -381,7 +383,7 @@ print_label_chunks(void)
for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++)
onestr[PART_MOUNT_COL + j] = mountpoint[j];
snprintf(num, 10, "%4ldMB", label_chunk_info[i].c->size ?
- label_chunk_info[i].c->size / 2048 : 0);
+ label_chunk_info[i].c->size / ONE_MEG : 0);
memcpy(onestr + PART_SIZE_COL, num, strlen(num));
memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs));
onestr[PART_NEWFS_COL + strlen(newfs)] = '\0';
@@ -426,8 +428,9 @@ diskLabelEditor(char *str)
msgConfirm("You need to partition your disk(s) before you can assign disk labels.");
return 0;
}
- clear();
+ dialog_clear(); clear();
while (labeling) {
+ clear();
print_label_chunks();
print_command_summary();
if (msg) {
@@ -478,66 +481,70 @@ diskLabelEditor(char *str)
break;
}
{
- char *val, *cp, tmpb[20];
- int size;
- struct chunk *tmp;
- u_long flags = 0;
-
- snprintf(tmpb, 20, "%d", sz);
- val = msgGetInput(tmpb, "Please specify the size for new FreeBSD partition in blocks, or append\na trailing `M' for megabytes (e.g. 20M).");
- if (!val || (size = strtol(val, &cp, 0)) <= 0)
- break;
-
- if (*cp && toupper(*cp) == 'M')
- size *= 2048;
-
- type = get_partition_type();
- if (type == PART_NONE)
- break;
+ char *val, *cp, tmpb[20];
+ int size;
+ struct chunk *tmp;
+ u_long flags = 0;
+
+ snprintf(tmpb, 20, "%d", sz);
+ val = msgGetInput(tmpb, "Please specify the size for new FreeBSD partition in blocks, or append\na trailing `M' for megabytes (e.g. 20M).");
+ if (!val || (size = strtol(val, &cp, 0)) <= 0)
+ break;
- if (type == PART_FILESYSTEM) {
- if ((p = get_mountpoint(NULL)) == NULL)
+ if (sz <= FS_MIN_SIZE) {
+ msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG);
break;
- else if (!strcmp(p->mountpoint, "/"))
- flags |= CHUNK_IS_ROOT;
- else
- flags &= ~CHUNK_IS_ROOT;
- } else
- p = NULL;
-
- if ((flags & CHUNK_IS_ROOT)) {
- if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) {
- msgConfirm("This region cannot be used for your root partition as\nthe FreeBSD boot code cannot deal with a root partition created in\nsuch a location. Please choose another location for your root\npartition and try again!");
+ }
+ if (*cp && toupper(*cp) == 'M')
+ size *= ONE_MEG;
+
+ type = get_partition_type();
+ if (type == PART_NONE)
break;
+
+ if (type == PART_FILESYSTEM) {
+ if ((p = get_mountpoint(NULL)) == NULL)
+ break;
+ else if (!strcmp(p->mountpoint, "/"))
+ flags |= CHUNK_IS_ROOT;
+ else
+ flags &= ~CHUNK_IS_ROOT;
+ } else
+ p = NULL;
+
+ if ((flags & CHUNK_IS_ROOT)) {
+ if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) {
+ msgConfirm("This region cannot be used for your root partition as\nthe FreeBSD boot code cannot deal with a root partition created in\nsuch a location. Please choose another location for your root\npartition and try again!");
+ break;
+ }
+ if (size < ROOT_MIN_SIZE) {
+ msgConfirm("This is too small a size for a root partition. For a variety of\nreasons, root partitions should be at least %dMB in size", ROOT_MIN_SIZE / ONE_MEG);
+ break;
+ }
}
- if (size < ROOT_MIN_SIZE) {
- msgConfirm("This is too small a size for a root partition. For a variety of\nreasons, root partitions should be at least %dMB in size", ROOT_MIN_SIZE / 2048);
+ tmp = Create_Chunk_DWIM(label_chunk_info[here].d,
+ label_chunk_info[here].c,
+ size, part,
+ (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS,
+ flags);
+ if (!tmp) {
+ msgConfirm("Unable to create the partition. Too big?");
break;
}
- }
- tmp = Create_Chunk_DWIM(label_chunk_info[here].d,
- label_chunk_info[here].c,
- size, part,
- (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS,
- flags);
- if (!tmp) {
- msgConfirm("Unable to create the partition. Too big?");
- break;
- }
- if ((flags & CHUNK_IS_ROOT) && (tmp->flags & CHUNK_PAST_1024)) {
+ if ((flags & CHUNK_IS_ROOT) && (tmp->flags & CHUNK_PAST_1024)) {
msgConfirm("This region cannot be used for your root partition as it starts\nor extends past the 1024'th cylinder mark and is thus a\npoor location to boot from. Please choose another\nlocation for your root partition and try again!");
Delete_Chunk(label_chunk_info[here].d, tmp);
break;
- }
- if (type != PART_SWAP) {
+ }
+ if (type != PART_SWAP) {
/* This is needed to tell the newfs -u about the size */
tmp->private = new_part(p->mountpoint,p->newfs,tmp->size);
safe_free(p);
- } else {
+ } else {
tmp->private = p;
- }
- tmp->private_free = safe_free;
- record_label_chunks();
+ }
+ tmp->private_free = safe_free;
+ record_label_chunks();
}
break;
@@ -639,7 +646,6 @@ diskLabelEditor(char *str)
}
variable_set2(DISK_LABELLED, "yes");
dialog_clear();
- refresh();
return 0;
}
diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c
index c9b3e20..c78621d 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.20 1995/05/20 14:05:31 jkh Exp $
+ * $Id: msg.c,v 1.21 1995/05/20 19:12:12 phk Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -44,6 +44,9 @@
#include "sysinstall.h"
#include <stdarg.h>
+#define VTY_STATLINE 24
+#define TTY_STATLINE 23
+
/* Whack up an informational message on the status line, in stand-out */
void
msgYap(char *fmt, ...)
@@ -58,7 +61,7 @@ msgYap(char *fmt, ...)
va_end(args);
attrs = getattrs(stdscr);
attrset(A_REVERSE);
- mvaddstr(23, 0, errstr);
+ mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr);
attrset(attrs);
refresh();
free(errstr);
@@ -74,7 +77,7 @@ msgInfo(char *fmt, ...)
/* NULL is a special convention meaning "erase the old stuff" */
if (!fmt) {
- move(23, 0);
+ move(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0);
clrtoeol();
return;
}
@@ -84,7 +87,7 @@ msgInfo(char *fmt, ...)
va_end(args);
attrs = getattrs(stdscr);
attrset(A_NORMAL);
- mvaddstr(23, 0, errstr);
+ mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr);
attrset(attrs);
refresh();
if (OnVTY) {
@@ -110,7 +113,7 @@ msgWarn(char *fmt, ...)
attrs = getattrs(stdscr);
beep();
attrset(A_REVERSE);
- mvaddstr(23, 0, errstr);
+ mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr);
attrset(attrs);
refresh();
if (OnVTY)
@@ -134,7 +137,7 @@ msgError(char *fmt, ...)
beep();
attrs = getattrs(stdscr);
attrset(A_REVERSE);
- mvaddstr(23, 0, errstr);
+ mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr);
attrset(attrs);
refresh();
if (OnVTY)
@@ -158,7 +161,7 @@ msgFatal(char *fmt, ...)
beep();
attrs = getattrs(stdscr);
attrset(A_REVERSE);
- mvaddstr(23, 0, errstr);
+ mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr);
addstr(" - ");
addstr("PRESS ANY KEY TO ");
if (getpid() == 1)
OpenPOWER on IntegriCloud