1995-05-16 02:53:31 +00:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last program in the `sysinstall' line - the next
|
|
|
|
* generation being essentially a complete rewrite.
|
|
|
|
*
|
1997-06-05 09:48:03 +00:00
|
|
|
* $Id: label.c,v 1.70 1997/03/11 17:51:01 jkh Exp $
|
1995-05-16 02:53:31 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Jordan Hubbard. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1995-05-30 08:29:07 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
1995-05-16 02:53:31 +00:00
|
|
|
* point in the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysinstall.h"
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/disklabel.h>
|
1995-09-18 16:53:06 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/sysctl.h>
|
1995-05-16 02:53:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Everything to do with editing the contents of disk labels.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* A nice message we use a lot in the disklabel editor */
|
|
|
|
#define MSG_NOT_APPLICABLE "That option is not applicable here"
|
|
|
|
|
|
|
|
/* Where to start printing the freebsd slices */
|
|
|
|
#define CHUNK_SLICE_START_ROW 2
|
1995-05-19 02:19:15 +00:00
|
|
|
#define CHUNK_PART_START_ROW 11
|
1995-05-16 02:53:31 +00:00
|
|
|
|
|
|
|
/* The smallest filesystem we're willing to create */
|
1995-05-22 14:10:25 +00:00
|
|
|
#define FS_MIN_SIZE ONE_MEG
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1995-05-21 10:16:10 +00:00
|
|
|
/* The smallest root filesystem we're willing to create */
|
1995-12-07 10:34:59 +00:00
|
|
|
#define ROOT_MIN_SIZE 20
|
|
|
|
|
|
|
|
/* The smallest swap partition we want to create by default */
|
|
|
|
#define SWAP_MIN_SIZE 16
|
|
|
|
|
|
|
|
/* The smallest /usr partition we're willing to create by default */
|
|
|
|
#define USR_MIN_SIZE 80
|
|
|
|
|
|
|
|
/* The smallest /var partition we're willing to create by default */
|
|
|
|
#define VAR_MIN_SIZE 30
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1996-04-28 22:54:21 +00:00
|
|
|
/* The bottom-most row we're allowed to scribble on */
|
|
|
|
#define CHUNK_ROW_MAX 16
|
|
|
|
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
/* All the chunks currently displayed on the screen */
|
|
|
|
static struct {
|
|
|
|
struct chunk *c;
|
|
|
|
PartType type;
|
|
|
|
} label_chunk_info[MAX_CHUNKS + 1];
|
|
|
|
static int here;
|
|
|
|
|
1996-04-28 22:54:21 +00:00
|
|
|
static int ChunkPartStartRow;
|
|
|
|
static WINDOW *ChunkWin;
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
static int diskLabel(char *str);
|
1997-06-05 09:48:03 +00:00
|
|
|
static int diskLabelNonInteractive(char *str);
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
diskLabelEditor(dialogMenuItem *self)
|
1995-12-07 10:34:59 +00:00
|
|
|
{
|
|
|
|
Device **devs;
|
1996-04-13 13:32:15 +00:00
|
|
|
int i, cnt, enabled;
|
|
|
|
char *cp;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
cp = variable_get(VAR_DISK);
|
|
|
|
devs = deviceFind(cp, DEVICE_TYPE_DISK);
|
|
|
|
cnt = deviceCount(devs);
|
|
|
|
if (!cnt) {
|
|
|
|
msgConfirm("No disks found! Please verify that your disk controller is being\n"
|
|
|
|
"properly probed at boot time. See the Hardware Guide on the\n"
|
|
|
|
"Documentation menu for clues on diagnosing this type of problem.");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1996-04-13 13:32:15 +00:00
|
|
|
for (i = 0, enabled = 0; i < cnt; i++) {
|
|
|
|
if (devs[i]->enabled)
|
|
|
|
++enabled;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1996-04-13 13:32:15 +00:00
|
|
|
if (!enabled) {
|
1996-05-09 09:42:17 +00:00
|
|
|
msgConfirm("No disks have been selected. Please visit the Partition\n"
|
|
|
|
"editor first to specify which disks you wish to operate on.");
|
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1997-06-05 09:48:03 +00:00
|
|
|
if (variable_get(VAR_NONINTERACTIVE))
|
|
|
|
i = diskLabelNonInteractive(devs[0]->name);
|
|
|
|
else
|
|
|
|
i = diskLabel(devs[0]->name);
|
1996-10-06 11:40:31 +00:00
|
|
|
if (DITEM_STATUS(i) != DITEM_FAILURE) {
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
|
|
|
|
variable_set2(DISK_LABELLED, "yes");
|
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
diskLabelCommit(dialogMenuItem *self)
|
1995-12-07 10:34:59 +00:00
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Already done? */
|
1996-07-09 03:07:51 +00:00
|
|
|
if ((cp = variable_get(DISK_LABELLED)) && strcmp(cp, "yes"))
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_SUCCESS;
|
1995-12-07 10:34:59 +00:00
|
|
|
else if (!cp) {
|
|
|
|
msgConfirm("You must assign disk labels before this option can be used.");
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
/* The routine will guard against redundant writes, just as this one does */
|
1996-04-28 03:27:26 +00:00
|
|
|
else if (DITEM_STATUS(diskPartitionWrite(self)) != DITEM_SUCCESS)
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1996-04-28 03:27:26 +00:00
|
|
|
else if (DITEM_STATUS(installFilesystems(self)) != DITEM_SUCCESS)
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
else {
|
|
|
|
msgInfo("All filesystem information written successfully.");
|
|
|
|
variable_set2(DISK_LABELLED, "written");
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_SUCCESS;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
/* See if we're already using a desired partition name */
|
|
|
|
static Boolean
|
|
|
|
check_conflict(char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1995-05-25 18:48:33 +00:00
|
|
|
for (i = 0; label_chunk_info[i].c; i++)
|
1997-03-11 17:51:01 +00:00
|
|
|
if ((label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT)
|
|
|
|
&& label_chunk_info[i].c->private_data
|
1996-03-24 18:57:37 +00:00
|
|
|
&& !strcmp(((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint, name))
|
1995-05-16 02:53:31 +00:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* How much space is in this FreeBSD slice? */
|
|
|
|
static int
|
|
|
|
space_free(struct chunk *c)
|
|
|
|
{
|
1995-12-07 10:34:59 +00:00
|
|
|
struct chunk *c1;
|
1995-05-16 02:53:31 +00:00
|
|
|
int sz = c->size;
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
for (c1 = c->part; c1; c1 = c1->next) {
|
1995-05-16 02:53:31 +00:00
|
|
|
if (c1->type != unused)
|
|
|
|
sz -= c1->size;
|
|
|
|
}
|
|
|
|
if (sz < 0)
|
|
|
|
msgFatal("Partitions are larger than actual chunk??");
|
|
|
|
return sz;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Snapshot the current situation into the displayed chunks structure */
|
|
|
|
static void
|
1995-12-07 10:34:59 +00:00
|
|
|
record_label_chunks(Device **devs)
|
1995-05-16 02:53:31 +00:00
|
|
|
{
|
|
|
|
int i, j, p;
|
|
|
|
struct chunk *c1, *c2;
|
1995-05-16 11:37:27 +00:00
|
|
|
Disk *d;
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1996-04-28 22:54:21 +00:00
|
|
|
ChunkPartStartRow = CHUNK_SLICE_START_ROW + 3;
|
1995-05-16 02:53:31 +00:00
|
|
|
j = p = 0;
|
1995-05-16 11:37:27 +00:00
|
|
|
/* First buzz through and pick up the FreeBSD slices */
|
1995-05-16 02:53:31 +00:00
|
|
|
for (i = 0; devs[i]; i++) {
|
1995-05-16 11:37:27 +00:00
|
|
|
if (!devs[i]->enabled)
|
|
|
|
continue;
|
|
|
|
d = (Disk *)devs[i]->private;
|
|
|
|
if (!d->chunks)
|
|
|
|
msgFatal("No chunk list found for %s!", d->name);
|
|
|
|
|
|
|
|
/* Put the slice entries first */
|
|
|
|
for (c1 = d->chunks->part; c1; c1 = c1->next) {
|
1995-05-16 02:53:31 +00:00
|
|
|
if (c1->type == freebsd) {
|
|
|
|
label_chunk_info[j].type = PART_SLICE;
|
|
|
|
label_chunk_info[j].c = c1;
|
|
|
|
++j;
|
1996-04-28 22:54:21 +00:00
|
|
|
++ChunkPartStartRow;
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1995-05-16 11:37:27 +00:00
|
|
|
/* Now run through again and get the FreeBSD partition entries */
|
|
|
|
for (i = 0; devs[i]; i++) {
|
|
|
|
if (!devs[i]->enabled)
|
|
|
|
continue;
|
|
|
|
d = (Disk *)devs[i]->private;
|
1995-05-16 02:53:31 +00:00
|
|
|
/* Then buzz through and pick up the partitions */
|
1995-05-16 11:37:27 +00:00
|
|
|
for (c1 = d->chunks->part; c1; c1 = c1->next) {
|
1995-05-16 02:53:31 +00:00
|
|
|
if (c1->type == freebsd) {
|
|
|
|
for (c2 = c1->part; c2; c2 = c2->next) {
|
|
|
|
if (c2->type == part) {
|
|
|
|
if (c2->subtype == FS_SWAP)
|
|
|
|
label_chunk_info[j].type = PART_SWAP;
|
|
|
|
else
|
|
|
|
label_chunk_info[j].type = PART_FILESYSTEM;
|
|
|
|
label_chunk_info[j].c = c2;
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (c1->type == fat) {
|
|
|
|
label_chunk_info[j].type = PART_FAT;
|
|
|
|
label_chunk_info[j].c = c1;
|
1995-05-22 14:10:25 +00:00
|
|
|
++j;
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
label_chunk_info[j].c = NULL;
|
|
|
|
if (here >= j)
|
|
|
|
here = j ? j - 1 : 0;
|
1996-04-29 05:09:23 +00:00
|
|
|
if (ChunkWin) {
|
1996-04-28 22:54:21 +00:00
|
|
|
wclear(ChunkWin);
|
1996-04-29 05:09:23 +00:00
|
|
|
wrefresh(ChunkWin);
|
|
|
|
}
|
1996-04-28 22:54:21 +00:00
|
|
|
else
|
|
|
|
ChunkWin = newwin(CHUNK_ROW_MAX - ChunkPartStartRow, 76, ChunkPartStartRow, 0);
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* A new partition entry */
|
|
|
|
static PartInfo *
|
1995-05-21 01:56:03 +00:00
|
|
|
new_part(char *mpoint, Boolean newfs, u_long size)
|
1995-05-16 02:53:31 +00:00
|
|
|
{
|
|
|
|
PartInfo *ret;
|
1995-06-11 19:33:05 +00:00
|
|
|
|
|
|
|
if (!mpoint)
|
|
|
|
mpoint = "/change_me";
|
1995-05-16 02:53:31 +00:00
|
|
|
|
|
|
|
ret = (PartInfo *)safe_malloc(sizeof(PartInfo));
|
1996-12-09 08:22:19 +00:00
|
|
|
sstrncpy(ret->mountpoint, mpoint, FILENAME_MAX);
|
1996-03-02 20:02:13 +00:00
|
|
|
strcpy(ret->newfs_cmd, "newfs -b 8192 -f 1024");
|
1995-05-21 03:20:05 +00:00
|
|
|
ret->newfs = newfs;
|
1995-05-21 06:12:44 +00:00
|
|
|
if (!size)
|
|
|
|
return ret;
|
1995-05-16 02:53:31 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the mountpoint for a partition and save it away */
|
1995-12-07 10:34:59 +00:00
|
|
|
static PartInfo *
|
1995-05-18 09:02:06 +00:00
|
|
|
get_mountpoint(struct chunk *old)
|
1995-05-16 02:53:31 +00:00
|
|
|
{
|
|
|
|
char *val;
|
|
|
|
PartInfo *tmp;
|
|
|
|
|
1996-03-24 18:57:37 +00:00
|
|
|
if (old && old->private_data)
|
|
|
|
tmp = old->private_data;
|
1995-05-28 09:31:44 +00:00
|
|
|
else
|
|
|
|
tmp = NULL;
|
1996-10-01 12:13:29 +00:00
|
|
|
if (!old) {
|
1996-10-01 14:08:28 +00:00
|
|
|
DialogX = 14;
|
|
|
|
DialogY = 16;
|
1996-10-01 12:13:29 +00:00
|
|
|
}
|
1995-05-28 09:31:44 +00:00
|
|
|
val = msgGetInput(tmp ? tmp->mountpoint : NULL, "Please specify a mount point for the partition");
|
1996-10-01 12:13:29 +00:00
|
|
|
DialogX = DialogY = 0;
|
1995-05-26 11:21:53 +00:00
|
|
|
if (!val || !*val) {
|
1995-05-25 18:48:33 +00:00
|
|
|
if (!old)
|
|
|
|
return NULL;
|
|
|
|
else {
|
1996-03-24 18:57:37 +00:00
|
|
|
free(old->private_data);
|
|
|
|
old->private_data = NULL;
|
1995-05-25 18:48:33 +00:00
|
|
|
}
|
1995-05-21 06:12:44 +00:00
|
|
|
return NULL;
|
1995-05-25 18:48:33 +00:00
|
|
|
}
|
1995-05-21 06:12:44 +00:00
|
|
|
|
|
|
|
/* Is it just the same value? */
|
1995-05-28 09:31:44 +00:00
|
|
|
if (tmp && !strcmp(tmp->mountpoint, val))
|
1995-05-21 06:12:44 +00:00
|
|
|
return NULL;
|
1995-05-28 09:31:44 +00:00
|
|
|
|
|
|
|
/* Did we use it already? */
|
1995-05-21 06:12:44 +00:00
|
|
|
if (check_conflict(val)) {
|
|
|
|
msgConfirm("You already have a mount point for %s assigned!", val);
|
|
|
|
return NULL;
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
1995-05-28 09:31:44 +00:00
|
|
|
|
|
|
|
/* Is it bogus? */
|
1995-05-21 06:12:44 +00:00
|
|
|
if (*val != '/') {
|
|
|
|
msgConfirm("Mount point must start with a / character");
|
|
|
|
return NULL;
|
|
|
|
}
|
1995-05-28 09:31:44 +00:00
|
|
|
|
|
|
|
/* Is it going to be mounted on root? */
|
1995-05-21 06:12:44 +00:00
|
|
|
if (!strcmp(val, "/")) {
|
|
|
|
if (old)
|
|
|
|
old->flags |= CHUNK_IS_ROOT;
|
1995-05-28 09:31:44 +00:00
|
|
|
}
|
|
|
|
else if (old)
|
1995-05-21 06:12:44 +00:00
|
|
|
old->flags &= ~CHUNK_IS_ROOT;
|
1995-05-28 09:31:44 +00:00
|
|
|
|
|
|
|
safe_free(tmp);
|
1995-05-21 06:12:44 +00:00
|
|
|
tmp = new_part(val, TRUE, 0);
|
|
|
|
if (old) {
|
1996-03-24 18:57:37 +00:00
|
|
|
old->private_data = tmp;
|
1995-05-21 06:12:44 +00:00
|
|
|
old->private_free = safe_free;
|
|
|
|
}
|
|
|
|
return tmp;
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the type of the new partiton */
|
|
|
|
static PartType
|
|
|
|
get_partition_type(void)
|
|
|
|
{
|
|
|
|
char selection[20];
|
1995-05-21 06:12:44 +00:00
|
|
|
int i;
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
static unsigned char *fs_types[] = {
|
|
|
|
"FS",
|
|
|
|
"A file system",
|
|
|
|
"Swap",
|
|
|
|
"A swap partition.",
|
|
|
|
};
|
1996-10-01 12:13:29 +00:00
|
|
|
DialogX = 7;
|
1996-10-01 14:08:28 +00:00
|
|
|
DialogY = 8;
|
1995-05-21 06:12:44 +00:00
|
|
|
i = dialog_menu("Please choose a partition type",
|
1995-12-07 10:34:59 +00:00
|
|
|
"If you want to use this partition for swap space, select Swap.\n"
|
|
|
|
"If you want to put a filesystem on it, choose FS.",
|
|
|
|
-1, -1, 2, 2, fs_types, selection, NULL, NULL);
|
1996-10-01 12:13:29 +00:00
|
|
|
DialogX = DialogY = 0;
|
1995-05-21 06:12:44 +00:00
|
|
|
if (!i) {
|
1995-05-16 02:53:31 +00:00
|
|
|
if (!strcmp(selection, "FS"))
|
|
|
|
return PART_FILESYSTEM;
|
|
|
|
else if (!strcmp(selection, "Swap"))
|
|
|
|
return PART_SWAP;
|
|
|
|
}
|
|
|
|
return PART_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the user wants a special newfs command for this, set it */
|
|
|
|
static void
|
|
|
|
getNewfsCmd(PartInfo *p)
|
|
|
|
{
|
|
|
|
char *val;
|
|
|
|
|
|
|
|
val = msgGetInput(p->newfs_cmd,
|
1995-12-07 10:34:59 +00:00
|
|
|
"Please enter the newfs command and options you'd like to use in\n"
|
|
|
|
"creating this file system.");
|
1995-05-16 02:53:31 +00:00
|
|
|
if (val)
|
1996-12-09 08:22:19 +00:00
|
|
|
sstrncpy(p->newfs_cmd, val, NEWFS_CMD_MAX);
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_MOUNT_NAME 12
|
|
|
|
|
|
|
|
#define PART_PART_COL 0
|
|
|
|
#define PART_MOUNT_COL 8
|
|
|
|
#define PART_SIZE_COL (PART_MOUNT_COL + MAX_MOUNT_NAME + 3)
|
|
|
|
#define PART_NEWFS_COL (PART_SIZE_COL + 7)
|
|
|
|
#define PART_OFF 38
|
|
|
|
|
|
|
|
/* stick this all up on the screen */
|
|
|
|
static void
|
|
|
|
print_label_chunks(void)
|
|
|
|
{
|
|
|
|
int i, j, srow, prow, pcol;
|
|
|
|
int sz;
|
|
|
|
|
|
|
|
attrset(A_REVERSE);
|
|
|
|
mvaddstr(0, 25, "FreeBSD Disklabel Editor");
|
|
|
|
attrset(A_NORMAL);
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
1996-04-28 22:54:21 +00:00
|
|
|
mvaddstr(ChunkPartStartRow - 2, PART_PART_COL + (i * PART_OFF), "Part");
|
|
|
|
mvaddstr(ChunkPartStartRow - 1, PART_PART_COL + (i * PART_OFF), "----");
|
1995-05-19 02:19:15 +00:00
|
|
|
|
1996-04-28 22:54:21 +00:00
|
|
|
mvaddstr(ChunkPartStartRow - 2, PART_MOUNT_COL + (i * PART_OFF), "Mount");
|
|
|
|
mvaddstr(ChunkPartStartRow - 1, PART_MOUNT_COL + (i * PART_OFF), "-----");
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1996-04-28 22:54:21 +00:00
|
|
|
mvaddstr(ChunkPartStartRow - 2, PART_SIZE_COL + (i * PART_OFF) + 2, "Size");
|
|
|
|
mvaddstr(ChunkPartStartRow - 1, PART_SIZE_COL + (i * PART_OFF) + 2, "----");
|
1995-05-19 02:19:15 +00:00
|
|
|
|
1996-04-28 22:54:21 +00:00
|
|
|
mvaddstr(ChunkPartStartRow - 2, PART_NEWFS_COL + (i * PART_OFF), "Newfs");
|
|
|
|
mvaddstr(ChunkPartStartRow - 1, PART_NEWFS_COL + (i * PART_OFF), "-----");
|
1995-05-19 02:19:15 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
srow = CHUNK_SLICE_START_ROW;
|
1996-04-28 22:54:21 +00:00
|
|
|
prow = 0;
|
1995-05-16 02:53:31 +00:00
|
|
|
pcol = 0;
|
|
|
|
|
1995-05-25 18:48:33 +00:00
|
|
|
for (i = 0; label_chunk_info[i].c; i++) {
|
1995-05-16 02:53:31 +00:00
|
|
|
/* Is it a slice entry displayed at the top? */
|
|
|
|
if (label_chunk_info[i].type == PART_SLICE) {
|
|
|
|
sz = space_free(label_chunk_info[i].c);
|
1996-04-28 22:54:21 +00:00
|
|
|
if (i == here)
|
1996-06-08 09:08:51 +00:00
|
|
|
attrset(ATTR_SELECTED);
|
1995-05-25 18:48:33 +00:00
|
|
|
mvprintw(srow++, 0, "Disk: %s\tPartition name: %s\tFree: %d blocks (%dMB)",
|
|
|
|
label_chunk_info[i].c->disk->name, label_chunk_info[i].c->name, sz, (sz / ONE_MEG));
|
1996-04-28 22:54:21 +00:00
|
|
|
attrset(A_NORMAL);
|
|
|
|
clrtoeol();
|
|
|
|
move(0, 0);
|
|
|
|
refresh();
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
1996-04-28 22:54:21 +00:00
|
|
|
/* Otherwise it's a DOS, swap or filesystem entry in the Chunk window */
|
1995-05-16 02:53:31 +00:00
|
|
|
else {
|
|
|
|
char onestr[PART_OFF], num[10], *mountpoint, *newfs;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We copy this into a blank-padded string so that it looks like
|
|
|
|
* a solid bar in reverse-video
|
|
|
|
*/
|
|
|
|
memset(onestr, ' ', PART_OFF - 1);
|
|
|
|
onestr[PART_OFF - 1] = '\0';
|
1996-04-28 22:54:21 +00:00
|
|
|
/* Go for two columns if we've written one full columns worth */
|
|
|
|
if (prow == (CHUNK_ROW_MAX - ChunkPartStartRow)) {
|
1995-05-16 02:53:31 +00:00
|
|
|
pcol = PART_OFF;
|
1996-04-28 22:54:21 +00:00
|
|
|
prow = 0;
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
1995-05-23 02:41:18 +00:00
|
|
|
memcpy(onestr + PART_PART_COL, label_chunk_info[i].c->name, strlen(label_chunk_info[i].c->name));
|
1995-05-16 02:53:31 +00:00
|
|
|
/* If it's a filesystem, display the mountpoint */
|
1996-03-24 18:57:37 +00:00
|
|
|
if (label_chunk_info[i].c->private_data
|
1995-09-18 16:53:06 +00:00
|
|
|
&& (label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT))
|
1996-03-24 18:57:37 +00:00
|
|
|
mountpoint = ((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint;
|
1997-03-08 16:17:49 +00:00
|
|
|
else if (label_chunk_info[i].type == PART_SWAP)
|
|
|
|
mountpoint = "swap";
|
1995-09-18 16:53:06 +00:00
|
|
|
else
|
|
|
|
mountpoint = "<none>";
|
|
|
|
|
|
|
|
/* Now display the newfs field */
|
|
|
|
if (label_chunk_info[i].type == PART_FAT)
|
|
|
|
newfs = "DOS";
|
1996-03-24 18:57:37 +00:00
|
|
|
else if (label_chunk_info[i].c->private_data && label_chunk_info[i].type == PART_FILESYSTEM)
|
|
|
|
newfs = ((PartInfo *)label_chunk_info[i].c->private_data)->newfs ? "UFS Y" : "UFS N";
|
1995-09-18 16:53:06 +00:00
|
|
|
else if (label_chunk_info[i].type == PART_SWAP)
|
|
|
|
newfs = "SWAP";
|
|
|
|
else
|
1995-05-16 02:53:31 +00:00
|
|
|
newfs = "*";
|
|
|
|
for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++)
|
|
|
|
onestr[PART_MOUNT_COL + j] = mountpoint[j];
|
1995-05-26 11:21:53 +00:00
|
|
|
snprintf(num, 10, "%4ldMB", label_chunk_info[i].c->size ? label_chunk_info[i].c->size / ONE_MEG : 0);
|
1995-05-16 02:53:31 +00:00
|
|
|
memcpy(onestr + PART_SIZE_COL, num, strlen(num));
|
|
|
|
memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs));
|
|
|
|
onestr[PART_NEWFS_COL + strlen(newfs)] = '\0';
|
1996-04-28 22:54:21 +00:00
|
|
|
if (i == here)
|
1996-06-08 09:08:51 +00:00
|
|
|
wattrset(ChunkWin, ATTR_SELECTED);
|
1996-04-28 22:54:21 +00:00
|
|
|
mvwaddstr(ChunkWin, prow, pcol, onestr);
|
|
|
|
wattrset(ChunkWin, A_NORMAL);
|
|
|
|
wrefresh(ChunkWin);
|
|
|
|
move(0, 0);
|
1995-05-16 02:53:31 +00:00
|
|
|
++prow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1996-10-01 12:13:29 +00:00
|
|
|
print_command_summary(void)
|
1995-05-16 02:53:31 +00:00
|
|
|
{
|
1995-05-28 20:28:15 +00:00
|
|
|
mvprintw(17, 0, "The following commands are valid here (upper or lower case):");
|
1997-01-24 07:47:17 +00:00
|
|
|
mvprintw(18, 0, "C = Create D = Delete M = Mount pt.");
|
1996-04-28 22:54:21 +00:00
|
|
|
if (!RunningAsInit)
|
1996-05-09 09:42:17 +00:00
|
|
|
mvprintw(18, 47, "W = Write");
|
1995-09-18 16:53:06 +00:00
|
|
|
mvprintw(19, 0, "N = Newfs Opts T = Newfs Toggle U = Undo Q = Finish");
|
|
|
|
mvprintw(20, 0, "A = Auto Defaults for all!");
|
1996-05-09 09:42:17 +00:00
|
|
|
mvprintw(22, 0, "Use F1 or ? to get more help, arrow keys to select.");
|
1995-05-16 02:53:31 +00:00
|
|
|
move(0, 0);
|
|
|
|
}
|
|
|
|
|
1996-10-01 12:13:29 +00:00
|
|
|
static void
|
|
|
|
clear_wins(void)
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
wclear(ChunkWin);
|
|
|
|
}
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
static int
|
|
|
|
diskLabel(char *str)
|
1995-05-16 02:53:31 +00:00
|
|
|
{
|
1996-10-01 12:13:29 +00:00
|
|
|
int sz, key = 0;
|
1995-05-16 02:53:31 +00:00
|
|
|
Boolean labeling;
|
|
|
|
char *msg = NULL;
|
1995-06-11 19:33:05 +00:00
|
|
|
PartInfo *p, *oldp;
|
1995-05-16 02:53:31 +00:00
|
|
|
PartType type;
|
1995-05-28 23:12:09 +00:00
|
|
|
Device **devs;
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
|
|
|
|
if (!devs) {
|
|
|
|
msgConfirm("No disks found!");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
labeling = TRUE;
|
|
|
|
keypad(stdscr, TRUE);
|
1995-12-07 10:34:59 +00:00
|
|
|
record_label_chunks(devs);
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1996-10-01 12:13:29 +00:00
|
|
|
clear();
|
1995-05-16 02:53:31 +00:00
|
|
|
while (labeling) {
|
1996-10-06 11:40:31 +00:00
|
|
|
char *cp;
|
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
print_label_chunks();
|
1996-10-01 12:13:29 +00:00
|
|
|
print_command_summary();
|
1995-05-16 02:53:31 +00:00
|
|
|
if (msg) {
|
1996-05-09 09:42:17 +00:00
|
|
|
attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
|
1995-12-07 10:34:59 +00:00
|
|
|
clrtoeol();
|
1995-05-16 02:53:31 +00:00
|
|
|
beep();
|
|
|
|
msg = NULL;
|
|
|
|
}
|
1996-04-29 05:09:23 +00:00
|
|
|
else {
|
|
|
|
move(23, 0);
|
|
|
|
clrtoeol();
|
|
|
|
}
|
1996-10-06 11:40:31 +00:00
|
|
|
|
1996-10-01 12:13:29 +00:00
|
|
|
refresh();
|
1996-08-03 05:25:56 +00:00
|
|
|
key = getch();
|
|
|
|
switch (toupper(key)) {
|
1996-04-28 22:54:21 +00:00
|
|
|
int i;
|
1996-07-31 06:20:59 +00:00
|
|
|
static char _msg[40];
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1995-05-25 18:48:33 +00:00
|
|
|
case '\014': /* ^L */
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
|
|
|
break;
|
1995-05-25 18:48:33 +00:00
|
|
|
|
1997-01-15 02:52:00 +00:00
|
|
|
case '\020': /* ^P */
|
1995-05-16 02:53:31 +00:00
|
|
|
case KEY_UP:
|
|
|
|
case '-':
|
|
|
|
if (here != 0)
|
|
|
|
--here;
|
1995-05-25 18:48:33 +00:00
|
|
|
else
|
|
|
|
while (label_chunk_info[here + 1].c)
|
|
|
|
++here;
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
|
1997-01-15 02:52:00 +00:00
|
|
|
case '\016': /* ^N */
|
1995-05-16 02:53:31 +00:00
|
|
|
case KEY_DOWN:
|
|
|
|
case '+':
|
|
|
|
case '\r':
|
|
|
|
case '\n':
|
1995-05-25 18:48:33 +00:00
|
|
|
if (label_chunk_info[here + 1].c)
|
1995-05-16 02:53:31 +00:00
|
|
|
++here;
|
1995-05-25 18:48:33 +00:00
|
|
|
else
|
|
|
|
here = 0;
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_HOME:
|
|
|
|
here = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_END:
|
1995-05-25 18:48:33 +00:00
|
|
|
while (label_chunk_info[here + 1].c)
|
1995-05-16 02:53:31 +00:00
|
|
|
++here;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_F(1):
|
|
|
|
case '?':
|
1995-12-07 10:34:59 +00:00
|
|
|
systemDisplayHelp("partition");
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
|
1995-09-18 16:53:06 +00:00
|
|
|
case 'A':
|
|
|
|
if (label_chunk_info[here].type != PART_SLICE) {
|
1996-04-28 22:54:21 +00:00
|
|
|
msg = "You can only do this in a disk slice (at top of screen)";
|
1995-09-18 16:53:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sz = space_free(label_chunk_info[here].c);
|
1996-07-31 06:20:59 +00:00
|
|
|
if (sz <= FS_MIN_SIZE)
|
1996-04-28 22:54:21 +00:00
|
|
|
msg = "Not enough free space to create a new partition in the slice";
|
1995-12-07 10:34:59 +00:00
|
|
|
else {
|
1996-04-28 22:54:21 +00:00
|
|
|
struct chunk *tmp;
|
|
|
|
int mib[2];
|
|
|
|
int physmem;
|
|
|
|
size_t size, swsize;
|
|
|
|
char *cp;
|
1996-07-31 06:20:59 +00:00
|
|
|
Chunk *rootdev, *swapdev, *usrdev, *vardev;
|
|
|
|
|
1996-07-31 09:29:35 +00:00
|
|
|
(void)checkLabels(FALSE, &rootdev, &swapdev, &usrdev, &vardev);
|
1996-07-31 06:20:59 +00:00
|
|
|
if (!rootdev) {
|
|
|
|
cp = variable_get(VAR_ROOT_SIZE);
|
|
|
|
tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
|
|
|
|
(cp ? atoi(cp) : 32) * ONE_MEG, part, FS_BSDFFS, CHUNK_IS_ROOT);
|
|
|
|
if (!tmp) {
|
|
|
|
msgConfirm("Unable to create the root partition. Too big?");
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1996-07-31 06:20:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp->private_data = new_part("/", TRUE, tmp->size);
|
|
|
|
tmp->private_free = safe_free;
|
|
|
|
record_label_chunks(devs);
|
1996-04-28 22:54:21 +00:00
|
|
|
}
|
1996-07-31 06:20:59 +00:00
|
|
|
|
|
|
|
if (!swapdev) {
|
|
|
|
cp = variable_get(VAR_SWAP_SIZE);
|
|
|
|
if (cp)
|
|
|
|
swsize = atoi(cp) * ONE_MEG;
|
|
|
|
else {
|
|
|
|
mib[0] = CTL_HW;
|
|
|
|
mib[1] = HW_PHYSMEM;
|
|
|
|
size = sizeof physmem;
|
|
|
|
sysctl(mib, 2, &physmem, &size, (void *)0, (size_t)0);
|
|
|
|
swsize = 16 * ONE_MEG + (physmem * 2 / 512);
|
|
|
|
}
|
|
|
|
tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
|
|
|
|
swsize, part, FS_SWAP, 0);
|
|
|
|
if (!tmp) {
|
|
|
|
msgConfirm("Unable to create the swap partition. Too big?");
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1996-07-31 06:20:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp->private_data = 0;
|
|
|
|
tmp->private_free = safe_free;
|
|
|
|
record_label_chunks(devs);
|
1996-04-28 22:54:21 +00:00
|
|
|
}
|
1996-07-31 06:20:59 +00:00
|
|
|
|
|
|
|
if (!vardev) {
|
|
|
|
cp = variable_get(VAR_VAR_SIZE);
|
|
|
|
tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
|
|
|
|
(cp ? atoi(cp) : VAR_MIN_SIZE) * ONE_MEG, part, FS_BSDFFS, 0);
|
|
|
|
if (!tmp) {
|
|
|
|
msgConfirm("Less than %dMB free for /var - you will need to\n"
|
|
|
|
"partition your disk manually with a custom install!",
|
|
|
|
(cp ? atoi(cp) : VAR_MIN_SIZE));
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1996-07-31 06:20:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp->private_data = new_part("/var", TRUE, tmp->size);
|
|
|
|
tmp->private_free = safe_free;
|
|
|
|
record_label_chunks(devs);
|
1996-04-28 22:54:21 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1996-07-31 06:20:59 +00:00
|
|
|
if (!usrdev) {
|
|
|
|
cp = variable_get(VAR_USR_SIZE);
|
|
|
|
if (cp)
|
|
|
|
sz = atoi(cp) * ONE_MEG;
|
|
|
|
else
|
|
|
|
sz = space_free(label_chunk_info[here].c);
|
|
|
|
if (!sz || sz < (USR_MIN_SIZE * ONE_MEG)) {
|
|
|
|
msgConfirm("Less than %dMB free for /usr - you will need to\n"
|
|
|
|
"partition your disk manually with a custom install!", USR_MIN_SIZE);
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1996-07-31 06:20:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
|
|
|
|
label_chunk_info[here].c,
|
|
|
|
sz, part, FS_BSDFFS, 0);
|
|
|
|
if (!tmp) {
|
|
|
|
msgConfirm("Unable to create the /usr partition. Not enough space?\n"
|
|
|
|
"You will need to partition your disk manually with a custom install!");
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1996-07-31 06:20:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp->private_data = new_part("/usr", TRUE, tmp->size);
|
|
|
|
tmp->private_free = safe_free;
|
|
|
|
record_label_chunks(devs);
|
1996-04-28 22:54:21 +00:00
|
|
|
}
|
|
|
|
/* At this point, we're reasonably "labelled" */
|
1996-10-06 11:40:31 +00:00
|
|
|
if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
|
|
|
|
variable_set2(DISK_LABELLED, "yes");
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|
1996-04-28 22:54:21 +00:00
|
|
|
break;
|
1995-09-18 16:53:06 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
case 'C':
|
|
|
|
if (label_chunk_info[here].type != PART_SLICE) {
|
|
|
|
msg = "You can only do this in a master partition (see top of screen)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sz = space_free(label_chunk_info[here].c);
|
1995-05-21 06:12:44 +00:00
|
|
|
if (sz <= FS_MIN_SIZE) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msg = "Not enough space to create an additional FreeBSD partition";
|
1995-05-21 06:12:44 +00:00
|
|
|
break;
|
|
|
|
}
|
1996-04-28 22:54:21 +00:00
|
|
|
else {
|
1996-10-06 11:40:31 +00:00
|
|
|
char *val;
|
1995-05-22 14:10:25 +00:00
|
|
|
int size;
|
|
|
|
struct chunk *tmp;
|
1995-05-28 20:28:15 +00:00
|
|
|
char osize[80];
|
1995-05-22 14:10:25 +00:00
|
|
|
u_long flags = 0;
|
|
|
|
|
1995-05-28 20:28:15 +00:00
|
|
|
sprintf(osize, "%d", sz);
|
1996-10-01 12:13:29 +00:00
|
|
|
DialogX = 3;
|
1996-10-01 14:08:28 +00:00
|
|
|
DialogY = 2;
|
1996-10-01 12:13:29 +00:00
|
|
|
val = msgGetInput(osize,
|
|
|
|
"Please specify the partition size in blocks or append a trailing M for\n"
|
|
|
|
"megabytes or C for cylinders. %d blocks (%dMB) are free.",
|
|
|
|
sz, sz / ONE_MEG);
|
|
|
|
DialogX = DialogY = 0;
|
|
|
|
if (!val || (size = strtol(val, &cp, 0)) <= 0) {
|
|
|
|
clear_wins();
|
1995-05-22 14:10:25 +00:00
|
|
|
break;
|
1996-10-01 12:13:29 +00:00
|
|
|
}
|
1995-05-21 06:12:44 +00:00
|
|
|
|
1995-05-25 18:48:33 +00:00
|
|
|
if (*cp) {
|
|
|
|
if (toupper(*cp) == 'M')
|
|
|
|
size *= ONE_MEG;
|
|
|
|
else if (toupper(*cp) == 'C')
|
|
|
|
size *= (label_chunk_info[here].c->disk->bios_hd * label_chunk_info[here].c->disk->bios_sect);
|
1995-05-28 20:28:15 +00:00
|
|
|
}
|
|
|
|
if (size <= FS_MIN_SIZE) {
|
|
|
|
msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG);
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1995-05-28 20:28:15 +00:00
|
|
|
break;
|
1995-05-25 18:48:33 +00:00
|
|
|
}
|
1995-05-22 14:10:25 +00:00
|
|
|
type = get_partition_type();
|
1996-10-01 12:13:29 +00:00
|
|
|
if (type == PART_NONE) {
|
|
|
|
clear_wins();
|
|
|
|
beep();
|
1995-05-21 10:16:10 +00:00
|
|
|
break;
|
1996-10-01 12:13:29 +00:00
|
|
|
}
|
1995-05-22 14:10:25 +00:00
|
|
|
|
|
|
|
if (type == PART_FILESYSTEM) {
|
1996-10-01 12:13:29 +00:00
|
|
|
if ((p = get_mountpoint(NULL)) == NULL) {
|
|
|
|
clear_wins();
|
|
|
|
beep();
|
1995-05-22 14:10:25 +00:00
|
|
|
break;
|
1996-10-01 12:13:29 +00:00
|
|
|
}
|
1995-05-22 14:10:25 +00:00
|
|
|
else if (!strcmp(p->mountpoint, "/"))
|
|
|
|
flags |= CHUNK_IS_ROOT;
|
|
|
|
else
|
|
|
|
flags &= ~CHUNK_IS_ROOT;
|
1996-10-01 12:13:29 +00:00
|
|
|
}
|
|
|
|
else
|
1995-05-22 14:10:25 +00:00
|
|
|
p = NULL;
|
|
|
|
|
|
|
|
if ((flags & CHUNK_IS_ROOT)) {
|
|
|
|
if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("This region cannot be used for your root partition as the\n"
|
|
|
|
"FreeBSD boot code cannot deal with a root partition created\n"
|
|
|
|
"in that location. Please choose another location or smaller\n"
|
|
|
|
"size for your root partition and try again!");
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1995-05-22 14:10:25 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
if (size < (ROOT_MIN_SIZE * ONE_MEG)) {
|
|
|
|
msgConfirm("Warning: This is smaller than the recommended size for a\n"
|
|
|
|
"root partition. For a variety of reasons, root\n"
|
|
|
|
"partitions should usually be at least %dMB in size", ROOT_MIN_SIZE);
|
|
|
|
}
|
1995-05-21 10:16:10 +00:00
|
|
|
}
|
1995-05-25 18:48:33 +00:00
|
|
|
tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
|
1995-05-22 14:10:25 +00:00
|
|
|
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?");
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1995-05-21 10:16:10 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-05-22 14:10:25 +00:00
|
|
|
if ((flags & CHUNK_IS_ROOT) && (tmp->flags & CHUNK_PAST_1024)) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("This region cannot be used for your root partition as it starts\n"
|
|
|
|
"or extends past the 1024'th cylinder mark and is thus a\n"
|
|
|
|
"poor location to boot from. Please choose another\n"
|
|
|
|
"location (or smaller size) for your root partition and try again!");
|
1995-05-25 18:48:33 +00:00
|
|
|
Delete_Chunk(label_chunk_info[here].c->disk, tmp);
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1995-05-21 06:12:44 +00:00
|
|
|
break;
|
1995-05-22 14:10:25 +00:00
|
|
|
}
|
|
|
|
if (type != PART_SWAP) {
|
1995-05-21 06:12:44 +00:00
|
|
|
/* This is needed to tell the newfs -u about the size */
|
1996-03-24 18:57:37 +00:00
|
|
|
tmp->private_data = new_part(p->mountpoint, p->newfs, tmp->size);
|
1995-05-21 06:12:44 +00:00
|
|
|
safe_free(p);
|
1995-05-30 08:29:07 +00:00
|
|
|
}
|
1996-04-23 01:29:35 +00:00
|
|
|
else
|
|
|
|
tmp->private_data = p;
|
1995-05-22 14:10:25 +00:00
|
|
|
tmp->private_free = safe_free;
|
1996-10-06 11:40:31 +00:00
|
|
|
if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
|
|
|
|
variable_set2(DISK_LABELLED, "yes");
|
1995-12-07 10:34:59 +00:00
|
|
|
record_label_chunks(devs);
|
1996-10-01 12:13:29 +00:00
|
|
|
clear_wins();
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-08-03 05:25:56 +00:00
|
|
|
case KEY_DC:
|
1995-05-16 02:53:31 +00:00
|
|
|
case 'D': /* delete */
|
|
|
|
if (label_chunk_info[here].type == PART_SLICE) {
|
|
|
|
msg = MSG_NOT_APPLICABLE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (label_chunk_info[here].type == PART_FAT) {
|
1995-05-23 02:41:18 +00:00
|
|
|
msg = "Use the Disk Partition Editor to delete DOS partitions";
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-05-25 18:48:33 +00:00
|
|
|
Delete_Chunk(label_chunk_info[here].c->disk, label_chunk_info[here].c);
|
1996-10-06 11:40:31 +00:00
|
|
|
if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
|
|
|
|
variable_set2(DISK_LABELLED, "yes");
|
1995-12-07 10:34:59 +00:00
|
|
|
record_label_chunks(devs);
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'M': /* mount */
|
|
|
|
switch(label_chunk_info[here].type) {
|
|
|
|
case PART_SLICE:
|
|
|
|
msg = MSG_NOT_APPLICABLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PART_SWAP:
|
|
|
|
msg = "You don't need to specify a mountpoint for a swap partition.";
|
|
|
|
break;
|
|
|
|
|
1995-05-16 11:37:27 +00:00
|
|
|
case PART_FAT:
|
1995-05-16 02:53:31 +00:00
|
|
|
case PART_FILESYSTEM:
|
1996-03-24 18:57:37 +00:00
|
|
|
oldp = label_chunk_info[here].c->private_data;
|
1995-05-18 09:02:06 +00:00
|
|
|
p = get_mountpoint(label_chunk_info[here].c);
|
1995-05-16 02:53:31 +00:00
|
|
|
if (p) {
|
1995-06-11 19:33:05 +00:00
|
|
|
if (!oldp)
|
|
|
|
p->newfs = FALSE;
|
1995-05-24 09:00:58 +00:00
|
|
|
if (label_chunk_info[here].type == PART_FAT
|
|
|
|
&& (!strcmp(p->mountpoint, "/") || !strcmp(p->mountpoint, "/usr")
|
|
|
|
|| !strcmp(p->mountpoint, "/var"))) {
|
|
|
|
msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint);
|
|
|
|
strcpy(p->mountpoint, "/bogus");
|
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
1996-10-06 11:40:31 +00:00
|
|
|
if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
|
|
|
|
variable_set2(DISK_LABELLED, "yes");
|
1995-12-07 10:34:59 +00:00
|
|
|
record_label_chunks(devs);
|
1996-10-02 02:19:35 +00:00
|
|
|
clear_wins();
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
msgFatal("Bogus partition under cursor???");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'N': /* Set newfs options */
|
1996-03-24 18:57:37 +00:00
|
|
|
if (label_chunk_info[here].c->private_data &&
|
|
|
|
((PartInfo *)label_chunk_info[here].c->private_data)->newfs)
|
|
|
|
getNewfsCmd(label_chunk_info[here].c->private_data);
|
1995-05-16 02:53:31 +00:00
|
|
|
else
|
|
|
|
msg = MSG_NOT_APPLICABLE;
|
1996-10-02 02:19:35 +00:00
|
|
|
clear_wins();
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T': /* Toggle newfs state */
|
1995-06-11 19:33:05 +00:00
|
|
|
if (label_chunk_info[here].type == PART_FILESYSTEM) {
|
1997-03-11 17:51:01 +00:00
|
|
|
PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data);
|
|
|
|
label_chunk_info[here].c->private_data =
|
|
|
|
new_part(pi ? pi->mountpoint : NULL, pi ? !pi->newfs : TRUE, label_chunk_info[here].c->size);
|
|
|
|
safe_free(pi);
|
|
|
|
label_chunk_info[here].c->private_free = safe_free;
|
|
|
|
if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
|
|
|
|
variable_set2(DISK_LABELLED, "yes");
|
1996-10-01 12:13:29 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
else
|
|
|
|
msg = MSG_NOT_APPLICABLE;
|
|
|
|
break;
|
|
|
|
|
1995-05-28 20:28:15 +00:00
|
|
|
case 'U':
|
1995-12-07 10:34:59 +00:00
|
|
|
clear();
|
1996-10-06 11:40:31 +00:00
|
|
|
if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) {
|
|
|
|
msgConfirm("You've already written out your changes -\n"
|
|
|
|
"it's too late to undo!");
|
|
|
|
}
|
|
|
|
else if (!msgYesNo("Are you SURE you want to Undo everything?")) {
|
|
|
|
variable_unset(DISK_PARTITIONED);
|
|
|
|
variable_unset(DISK_LABELLED);
|
|
|
|
for (i = 0; devs[i]; i++) {
|
|
|
|
Disk *d;
|
|
|
|
|
|
|
|
if (!devs[i]->enabled)
|
|
|
|
continue;
|
|
|
|
else if ((d = Open_Disk(devs[i]->name)) != NULL) {
|
|
|
|
Free_Disk(devs[i]->private);
|
|
|
|
devs[i]->private = d;
|
|
|
|
diskPartition(devs[i], d);
|
|
|
|
}
|
1995-05-28 23:12:09 +00:00
|
|
|
}
|
1996-10-06 11:40:31 +00:00
|
|
|
record_label_chunks(devs);
|
1995-05-28 23:12:09 +00:00
|
|
|
}
|
1996-10-02 02:19:35 +00:00
|
|
|
clear_wins();
|
1995-05-28 23:12:09 +00:00
|
|
|
break;
|
1995-05-28 20:28:15 +00:00
|
|
|
|
1995-05-16 02:53:31 +00:00
|
|
|
case 'W':
|
1996-10-06 11:40:31 +00:00
|
|
|
if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) {
|
|
|
|
msgConfirm("You've already written out your changes - if you\n"
|
|
|
|
"wish to overwrite them, you'll have to start this\n"
|
|
|
|
"procedure again from the beginning.");
|
|
|
|
}
|
|
|
|
else if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n"
|
1996-10-04 14:53:52 +00:00
|
|
|
"installation. If you are installing FreeBSD for the first time\n"
|
|
|
|
"then you should simply type Q when you're finished here and your\n"
|
|
|
|
"changes will be committed in one batch automatically at the end of\n"
|
|
|
|
"these questions.\n\n"
|
|
|
|
"Are you absolutely sure you want to do this now?")) {
|
1995-12-07 10:34:59 +00:00
|
|
|
variable_set2(DISK_LABELLED, "yes");
|
|
|
|
diskLabelCommit(NULL);
|
|
|
|
}
|
1996-10-02 02:19:35 +00:00
|
|
|
clear_wins();
|
1995-09-18 16:53:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case '|':
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!msgYesNo("Are you sure you want to go into Wizard mode?\n\n"
|
|
|
|
"This is an entirely undocumented feature which you are not\n"
|
|
|
|
"expected to understand!")) {
|
1995-05-16 02:53:31 +00:00
|
|
|
int i;
|
|
|
|
Device **devs;
|
|
|
|
|
|
|
|
dialog_clear();
|
|
|
|
end_dialog();
|
|
|
|
DialogActive = FALSE;
|
|
|
|
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
|
|
|
|
if (!devs) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Can't find any disk devices!");
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-05-21 04:34:12 +00:00
|
|
|
for (i = 0; devs[i] && ((Disk *)devs[i]->private); i++) {
|
1995-05-18 18:02:31 +00:00
|
|
|
if (devs[i]->enabled)
|
|
|
|
slice_wizard(((Disk *)devs[i]->private));
|
|
|
|
}
|
1996-10-06 11:40:31 +00:00
|
|
|
if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
|
|
|
|
variable_set2(DISK_LABELLED, "yes");
|
1995-05-16 02:53:31 +00:00
|
|
|
DialogActive = TRUE;
|
1995-12-07 10:34:59 +00:00
|
|
|
record_label_chunks(devs);
|
1996-10-02 02:19:35 +00:00
|
|
|
clear_wins();
|
1995-05-16 02:53:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
msg = "A most prudent choice!";
|
|
|
|
break;
|
|
|
|
|
1997-01-15 02:52:00 +00:00
|
|
|
case '\033': /* ESC */
|
1995-06-11 19:33:05 +00:00
|
|
|
case 'Q':
|
1995-05-16 02:53:31 +00:00
|
|
|
labeling = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
beep();
|
1996-07-31 06:20:59 +00:00
|
|
|
sprintf(_msg, "Invalid key %d - Type F1 or ? for help", key);
|
|
|
|
msg = _msg;
|
1995-05-16 02:53:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1996-07-31 06:20:59 +00:00
|
|
|
return DITEM_SUCCESS | DITEM_RESTORE;
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|
1997-06-05 09:48:03 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|