summaryrefslogtreecommitdiffstats
path: root/release/sysinstall/label.c
diff options
context:
space:
mode:
Diffstat (limited to 'release/sysinstall/label.c')
-rw-r--r--release/sysinstall/label.c117
1 files changed, 115 insertions, 2 deletions
diff --git a/release/sysinstall/label.c b/release/sysinstall/label.c
index c57abf1..582e561 100644
--- a/release/sysinstall/label.c
+++ b/release/sysinstall/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.69 1997/03/08 16:17:49 jkh Exp $
+ * $Id: label.c,v 1.70 1997/03/11 17:51:01 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -81,6 +81,7 @@ static int ChunkPartStartRow;
static WINDOW *ChunkWin;
static int diskLabel(char *str);
+static int diskLabelNonInteractive(char *str);
int
diskLabelEditor(dialogMenuItem *self)
@@ -107,7 +108,10 @@ diskLabelEditor(dialogMenuItem *self)
"editor first to specify which disks you wish to operate on.");
return DITEM_FAILURE;
}
- i = diskLabel(devs[0]->name);
+ if (variable_get(VAR_NONINTERACTIVE))
+ i = diskLabelNonInteractive(devs[0]->name);
+ else
+ i = diskLabel(devs[0]->name);
if (DITEM_STATUS(i) != DITEM_FAILURE) {
char *cp;
@@ -936,3 +940,112 @@ diskLabel(char *str)
}
return DITEM_SUCCESS | DITEM_RESTORE;
}
+
+static int
+diskLabelNonInteractive(char *str)
+{
+ char *cp;
+ PartType type;
+ PartInfo *p;
+ u_long flags = 0;
+ int i, status;
+ Device **devs;
+ Disk *d;
+
+ status = DITEM_SUCCESS;
+ cp = variable_get(VAR_DISK);
+ if (!cp) {
+ dialog_clear();
+ msgConfirm("diskLabel: No disk selected - can't label automatically.");
+ return DITEM_FAILURE;
+ }
+
+ devs = deviceFind(cp, DEVICE_TYPE_DISK);
+ if (!devs) {
+ msgConfirm("diskLabel: No disk device %s found!", cp);
+ return DITEM_FAILURE;
+ }
+ d = devs[0]->private;
+
+ record_label_chunks(devs);
+ for (i = 0; label_chunk_info[i].c; i++) {
+ Chunk *c1 = label_chunk_info[i].c;
+
+ if (label_chunk_info[i].type == PART_SLICE) {
+ if ((cp = variable_get(c1->name)) != NULL) {
+ int sz;
+ char typ[10], mpoint[50];
+
+ if (sscanf(cp, "%s %d %s", typ, &sz, mpoint) != 3) {
+ msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
+ status = DITEM_FAILURE;
+ continue;
+ }
+ else {
+ Chunk *tmp;
+
+ if (!strcmp(typ, "swap")) {
+ type = PART_SWAP;
+ strcpy(mpoint, "SWAP");
+ }
+ else {
+ type = PART_FILESYSTEM;
+ if (!strcmp(mpoint, "/"))
+ flags |= CHUNK_IS_ROOT;
+ }
+ if (!sz)
+ sz = space_free(c1);
+ if (sz > space_free(c1)) {
+ msgConfirm("Not enough free space to create partition: %s", mpoint);
+ status = DITEM_FAILURE;
+ continue;
+ }
+ if (!(tmp = Create_Chunk_DWIM(d, c1, sz, part,
+ (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, flags))) {
+ msgConfirm("Unable to create from partition spec: %s. Too big?", cp);
+ status = DITEM_FAILURE;
+ break;
+ }
+ else {
+ tmp->private_data = new_part(mpoint, TRUE, sz);
+ tmp->private_free = safe_free;
+ status = DITEM_SUCCESS;
+ }
+ }
+ }
+ }
+ else {
+ /* Must be something we can set a mountpoint */
+ cp = variable_get(c1->name);
+ if (cp) {
+ char mpoint[50], nwfs[8];
+ Boolean newfs = FALSE;
+
+ nwfs[0] = '\0';
+ if (sscanf(cp, "%s %s", mpoint, nwfs) != 2) {
+ dialog_clear();
+ msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
+ status = DITEM_FAILURE;
+ continue;
+ }
+ newfs = toupper(nwfs[0]) == 'Y' ? TRUE : FALSE;
+ if (c1->private_data) {
+ p = c1->private_data;
+ p->newfs = newfs;
+ strcpy(p->mountpoint, mpoint);
+ }
+ else {
+ c1->private_data = new_part(mpoint, newfs, 0);
+ c1->private_free = safe_free;
+ }
+ if (!strcmp(mpoint, "/"))
+ c1->flags |= CHUNK_IS_ROOT;
+ else
+ c1->flags &= ~CHUNK_IS_ROOT;
+ }
+ }
+ }
+ if (status == DITEM_SUCCESS)
+ variable_set2(DISK_LABELLED, "yes");
+ return status;
+}
OpenPOWER on IntegriCloud