summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sade/disks.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1997-06-05 09:48:03 +0000
committerjkh <jkh@FreeBSD.org>1997-06-05 09:48:03 +0000
commit9160ca00b5da185787c84ae5e1b1d848847dd262 (patch)
tree3707fb988b7a0ae5cc4e493af9c486da9892a1dd /usr.sbin/sade/disks.c
parent4caf82f971a9e9d7368fa7667e4e43f98857e620 (diff)
downloadFreeBSD-src-9160ca00b5da185787c84ae5e1b1d848847dd262.zip
FreeBSD-src-9160ca00b5da185787c84ae5e1b1d848847dd262.tar.gz
Resurrect / implement some of the more esoteric scripting features,
such as partitioning a disk or overriding an interactive prompt.
Diffstat (limited to 'usr.sbin/sade/disks.c')
-rw-r--r--usr.sbin/sade/disks.c95
1 files changed, 93 insertions, 2 deletions
diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c
index 34a0c1d..036268d 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.84 1997/05/05 05:16:00 pst Exp $
+ * $Id: disks.c,v 1.85 1997/05/10 17:11:24 pst Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -45,6 +45,8 @@
static struct chunk *chunk_info[16];
static int current_chunk;
+static void diskPartitionNonInteractive(Device *dev, Disk *d);
+
static void
record_chunks(Disk *d)
{
@@ -509,7 +511,10 @@ diskPartitionEditor(dialogMenuItem *self)
}
else if (cnt == 1) {
devs[0]->enabled = TRUE;
- diskPartition(devs[0], (Disk *)devs[0]->private);
+ if (variable_get(VAR_NONINTERACTIVE))
+ diskPartitionNonInteractive(devs[0], (Disk *)devs[0]->private);
+ else
+ diskPartition(devs[0], (Disk *)devs[0]->private);
i = DITEM_SUCCESS;
}
else {
@@ -587,3 +592,89 @@ diskPartitionWrite(dialogMenuItem *self)
variable_set2(DISK_PARTITIONED, "written");
return DITEM_SUCCESS;
}
+
+/* Partition a disk based wholly on which variables are set */
+static void
+diskPartitionNonInteractive(Device *dev, Disk *d)
+{
+ char *cp;
+ int i, sz;
+
+ record_chunks(d);
+ cp = variable_get(VAR_GEOMETRY);
+ if (cp) {
+ msgDebug("Setting geometry from script to: %s\n", cp);
+ d->bios_cyl = strtol(cp, &cp, 0);
+ d->bios_hd = strtol(cp + 1, &cp, 0);
+ d->bios_sect = strtol(cp + 1, 0, 0);
+ }
+
+ cp = variable_get(VAR_PARTITION);
+ if (cp) {
+ if (!strcmp(cp, "free")) {
+ /* Do free disk space case */
+ for (i = 0; chunk_info[i]; i++) {
+ /* If a chunk is at least 10MB in size, use it. */
+ if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) {
+ Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size, freebsd, 3,
+ (chunk_info[i]->flags & CHUNK_ALIGN));
+ variable_set2(DISK_PARTITIONED, "yes");
+ break;
+ }
+ }
+ if (!chunk_info[i]) {
+ dialog_clear();
+ msgConfirm("Unable to find any free space on this disk!");
+ return;
+ }
+ }
+ else if (!strcmp(cp, "all")) {
+ /* Do all disk space case */
+ msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
+
+ All_FreeBSD(d, FALSE);
+ }
+ else if (!strcmp(cp, "exclusive")) {
+ /* Do really-all-the-disk-space case */
+ msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
+
+ All_FreeBSD(d, TRUE);
+ }
+ else if ((sz = strtol(cp, &cp, 0))) {
+ /* Look for sz bytes free */
+ if (*cp && toupper(*cp) == 'M')
+ sz *= ONE_MEG;
+ for (i = 0; chunk_info[i]; i++) {
+ /* If a chunk is at least sz MB, use it. */
+ if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) {
+ Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3, (chunk_info[i]->flags & CHUNK_ALIGN));
+ variable_set2(DISK_PARTITIONED, "yes");
+ break;
+ }
+ }
+ if (!chunk_info[i]) {
+ dialog_clear();
+ msgConfirm("Unable to find %d free blocks on this disk!", sz);
+ return;
+ }
+ }
+ else if (!strcmp(cp, "existing")) {
+ /* Do existing FreeBSD case */
+ for (i = 0; chunk_info[i]; i++) {
+ if (chunk_info[i]->type == freebsd)
+ break;
+ }
+ if (!chunk_info[i]) {
+ dialog_clear();
+ msgConfirm("Unable to find any existing FreeBSD partitions on this disk!");
+ return;
+ }
+ }
+ else {
+ dialog_clear();
+ msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION);
+ return;
+ }
+ variable_set2(DISK_PARTITIONED, "yes");
+ }
+}
OpenPOWER on IntegriCloud