Implement a work-around for Create_Chunk providing no pointer to the

new chunk.  The partition editor now works as well as the underlying
libdisk can support it - have at it, Poul!
This commit is contained in:
Jordan K. Hubbard 1995-05-07 22:07:53 +00:00
parent 09d9aeaab3
commit 51f0ec8415
9 changed files with 357 additions and 150 deletions

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next * This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite. * generation being essentially a complete rewrite.
* *
* $Id: devices.c,v 1.7 1995/05/07 03:37:58 jkh Exp $ * $Id: devices.c,v 1.8 1995/05/07 05:58:55 jkh Exp $
* *
* Copyright (c) 1995 * Copyright (c) 1995
* Jordan Hubbard. All rights reserved. * Jordan Hubbard. All rights reserved.
@ -136,6 +136,7 @@ print_command_summary()
mvprintw(18, 0, "U = Undo All Changes W = `Wizard' Mode ESC = Proceed to next screen"); mvprintw(18, 0, "U = Undo All Changes W = `Wizard' Mode ESC = Proceed to next screen");
mvprintw(20, 0, "The currently selected partition is displayed in "); mvprintw(20, 0, "The currently selected partition is displayed in ");
attrset(A_REVERSE); addstr("reverse video"); attrset(A_NORMAL); attrset(A_REVERSE); addstr("reverse video"); attrset(A_NORMAL);
mvprintw(21, 0, "Use F1 or ? to get more help");
move(0, 0); move(0, 0);
} }
@ -244,6 +245,7 @@ device_slice_disk(struct disk *d)
case 'S': case 'S':
/* Set Bootable */ /* Set Bootable */
chunk_info[current_chunk]->flags |= CHUNK_ACTIVE;
break; break;
case 'U': case 'U':

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next * This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite. * generation being essentially a complete rewrite.
* *
* $Id: disks.c,v 1.5 1995/05/07 03:37:59 jkh Exp $ * $Id: disks.c,v 1.6 1995/05/07 05:58:56 jkh Exp $
* *
* Copyright (c) 1995 * Copyright (c) 1995
* Jordan Hubbard. All rights reserved. * Jordan Hubbard. All rights reserved.
@ -66,7 +66,6 @@
static struct { static struct {
struct disk *d; struct disk *d;
struct chunk *c; struct chunk *c;
PartInfo *p;
PartType type; PartType type;
} fbsd_chunk_info[MAX_CHUNKS + 1]; } fbsd_chunk_info[MAX_CHUNKS + 1];
static int current_chunk; static int current_chunk;
@ -96,6 +95,29 @@ contains_root_partition(struct disk *d)
return FALSE; return FALSE;
} }
/* Locate a chunk by position on a specific disk somewhere */
static struct chunk *
find_chunk_by_loc(struct disk *d, u_long offset, u_long size)
{
struct chunk *c1, *c2;
if (!d->chunks)
msgFatal("No chunk list for %s!", d->name);
for (c1 = d->chunks->part; c1; c1 = c1->next) {
if (c1->type == freebsd) {
if (c1->offset == offset && c1->size == size)
return c1;
for (c2 = c1->part; c2; c2 = c2->next) {
if (c2->type == part && c2->offset == offset &&
c2->size == size)
return c2;
}
}
}
return NULL;
}
static Boolean static Boolean
check_conflict(char *name) check_conflict(char *name)
{ {
@ -130,7 +152,7 @@ record_fbsd_chunks(struct disk **disks)
int i, j, p; int i, j, p;
struct chunk *c1, *c2; struct chunk *c1, *c2;
j = p = current_chunk = 0; j = p = 0;
for (i = 0; disks[i]; i++) { for (i = 0; disks[i]; i++) {
if (!disks[i]->chunks) if (!disks[i]->chunks)
msgFatal("No chunk list found for %s!", disks[i]->name); msgFatal("No chunk list found for %s!", disks[i]->name);
@ -141,7 +163,6 @@ record_fbsd_chunks(struct disk **disks)
fbsd_chunk_info[j].type = PART_SLICE; fbsd_chunk_info[j].type = PART_SLICE;
fbsd_chunk_info[j].d = disks[i]; fbsd_chunk_info[j].d = disks[i];
fbsd_chunk_info[j].c = c1; fbsd_chunk_info[j].c = c1;
fbsd_chunk_info[j].p = NULL;
++j; ++j;
} }
} }
@ -158,7 +179,6 @@ record_fbsd_chunks(struct disk **disks)
fbsd_chunk_info[j].type = PART_FILESYSTEM; fbsd_chunk_info[j].type = PART_FILESYSTEM;
fbsd_chunk_info[j].d = disks[i]; fbsd_chunk_info[j].d = disks[i];
fbsd_chunk_info[j].c = c2; fbsd_chunk_info[j].c = c2;
fbsd_chunk_info[j].p = c2->private;
++j; ++j;
} }
} }
@ -167,6 +187,8 @@ record_fbsd_chunks(struct disk **disks)
} }
fbsd_chunk_info[j].d = NULL; fbsd_chunk_info[j].d = NULL;
fbsd_chunk_info[j].c = NULL; fbsd_chunk_info[j].c = NULL;
if (current_chunk >= j)
current_chunk = j ? j - 1 : 0;
} }
static PartInfo * static PartInfo *
@ -180,33 +202,39 @@ new_part(char *mpoint, Boolean newfs)
return ret; return ret;
} }
int PartInfo *
get_mountpoint(int i) get_mountpoint(struct chunk *c)
{ {
char *val; char *val;
PartInfo *tmp;
val = msgGetInput(fbsd_chunk_info[i].p ? val = msgGetInput(c && c->private ?
fbsd_chunk_info[i].p->mountpoint : NULL, ((PartInfo *)c->private)->mountpoint : NULL,
"Please specify a mount point for the new partition"); "Please specify a mount point for the partition");
if (val) { if (val) {
if (!strcmp(val, "/")) {
if (fbsd_chunk_info[i].c->flags & CHUNK_PAST_1024) {
msgConfirm("This region cannot be used for your root partition as\nit is past the 1024'th cylinder mark and the system would not be\nable to boot from it. Please pick another location for your\nroot partition and try again!");
return 1;
}
fbsd_chunk_info[i].c->flags |= CHUNK_IS_ROOT;
}
if (check_conflict(val)) { if (check_conflict(val)) {
msgConfirm("You already have a mountpoint for %s assigned!", val); msgConfirm("You already have a mountpoint for %s assigned!", val);
return 1; return NULL;
} }
safe_free(fbsd_chunk_info[i].c->private); else if (!strcmp(val, "/")) {
fbsd_chunk_info[i].c->private = new_part(val, TRUE); if (c && c->flags & CHUNK_PAST_1024) {
fbsd_chunk_info[i].c->private_free = free; msgConfirm("This region cannot be used for your root partition as\nit is past the 1024'th cylinder mark and the system would not be\nable to boot from it. Please pick another location for your\nroot partition and try again!");
fbsd_chunk_info[i].p = fbsd_chunk_info[i].c->private; return NULL;
return 0; }
else if (c)
c->flags |= CHUNK_IS_ROOT;
}
else if (c)
c->flags &= ~CHUNK_IS_ROOT;
safe_free(c ? c->private : NULL);
tmp = new_part(val, TRUE);
if (c) {
c->private = tmp;
c->private_free = safe_free;
}
return tmp;
} }
return 1; return NULL;
} }
static PartType static PartType
@ -238,6 +266,9 @@ get_partition_type(void)
#define PART_NEWFS_COL (PART_SIZE_COL + 8) #define PART_NEWFS_COL (PART_SIZE_COL + 8)
#define PART_OFF 42 #define PART_OFF 42
/* How many mounted partitions to display in column before going to next */
#define CHUNK_COLUMN_MAX 6
static void static void
print_fbsd_chunks(void) print_fbsd_chunks(void)
{ {
@ -291,21 +322,20 @@ print_fbsd_chunks(void)
memset(onestr, ' ', PART_OFF - 1); memset(onestr, ' ', PART_OFF - 1);
onestr[PART_OFF - 1] = '\0'; onestr[PART_OFF - 1] = '\0';
/* Go for two columns */ /* Go for two columns */
if (prow == (CHUNK_PART_START_ROW + 8)) if (prow == (CHUNK_PART_START_ROW + CHUNK_COLUMN_MAX))
pcol = PART_OFF; pcol = PART_OFF;
else else
pcol = 0; pcol = 0;
memcpy(onestr + PART_PART_COL, fbsd_chunk_info[i].c->name, memcpy(onestr + PART_PART_COL, fbsd_chunk_info[i].c->name,
strlen(fbsd_chunk_info[i].c->name)); strlen(fbsd_chunk_info[i].c->name));
if (fbsd_chunk_info[i].type == PART_FILESYSTEM) { if (fbsd_chunk_info[i].type == PART_FILESYSTEM) {
if (fbsd_chunk_info[i].p) { if (fbsd_chunk_info[i].c->private) {
mountpoint = fbsd_chunk_info[i].p->mountpoint; mountpoint = ((PartInfo *)fbsd_chunk_info[i].c->private)->mountpoint;
newfs = fbsd_chunk_info[i].p->newfs ? "Y" : "N"; newfs = ((PartInfo *)fbsd_chunk_info[i].c->private)->newfs ? "Y" : "N";
} }
else { else {
fbsd_chunk_info[i].c->private = new_part("", FALSE); fbsd_chunk_info[i].c->private = new_part("", FALSE);
fbsd_chunk_info[i].c->private_free = free; fbsd_chunk_info[i].c->private_free = safe_free;
fbsd_chunk_info[i].p = fbsd_chunk_info[i].c->private;
mountpoint = " "; mountpoint = " ";
newfs = "N"; newfs = "N";
} }
@ -331,15 +361,16 @@ print_fbsd_chunks(void)
static void static void
print_command_summary() print_command_summary()
{ {
mvprintw(19, 0, mvprintw(17, 0,
"The following commands are valid here (upper or lower case):"); "The following commands are valid here (upper or lower case):");
mvprintw(20, 0, "C = Create FreeBSD Partition D = Delete Partition"); mvprintw(19, 0, "C = Create Partition D = Delete Partition M = Mount Partition");
mvprintw(21, 0, "M = Mount Partition (no newfs) ESC = Proceed to summary screen"); mvprintw(20, 0, "N = Newfs Options T = Toggle Newfs ESC = Finish Partitioning");
mvprintw(22, 0, "The default target will be displayed in "); mvprintw(21, 0, "The default target will be displayed in ");
attrset(A_REVERSE); attrset(A_REVERSE);
addstr("reverse video"); addstr("reverse video");
attrset(A_NORMAL); attrset(A_NORMAL);
mvprintw(22, 0, "Use F1 or ? to get more help");
move(0, 0); move(0, 0);
} }
@ -349,6 +380,8 @@ partition_disks(struct disk **disks)
int sz, key = 0; int sz, key = 0;
Boolean partitioning; Boolean partitioning;
char *msg = NULL; char *msg = NULL;
PartInfo *p;
PartType type;
dialog_clear(); dialog_clear();
partitioning = TRUE; partitioning = TRUE;
@ -405,27 +438,47 @@ partition_disks(struct disk **disks)
if (sz <= FS_MIN_SIZE) if (sz <= FS_MIN_SIZE)
msg = "Not enough space to create additional FreeBSD partition"; msg = "Not enough space to create additional FreeBSD partition";
else { else {
char *val, tmp[20]; char *val, *cp, tmp[20];
int size; int size;
snprintf(tmp, 20, "%d", sz); snprintf(tmp, 20, "%d", sz);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition"); val = msgGetInput(tmp, "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, 0, 0)) > 0) { if (val && (size = strtol(val, &cp, 0)) > 0) {
PartType type; struct chunk *tmp;
u_long flags = 0;
if (*cp && toupper(*cp) == 'M')
size *= 2048;
type = get_partition_type(); type = get_partition_type();
if (type == PART_NONE) if (type == PART_NONE)
break; break;
else 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;
Create_Chunk(fbsd_chunk_info[current_chunk].d, Create_Chunk(fbsd_chunk_info[current_chunk].d,
fbsd_chunk_info[current_chunk].c->offset + fbsd_chunk_info[current_chunk].c->offset +
sz - size, sz - size,
size, size,
part, part,
type == PART_SWAP ? FS_SWAP : freebsd, (type == PART_SWAP) ? FS_SWAP : freebsd,
fbsd_chunk_info[current_chunk].c->flags); flags);
if (get_mountpoint(current_chunk)) tmp = find_chunk_by_loc(fbsd_chunk_info[current_chunk].d,
break; fbsd_chunk_info[current_chunk].c->offset + sz - size, size);
record_fbsd_chunks(disks); if (!tmp)
msgConfirm("Unable to create the partition. Too big?");
else {
tmp->private = p;
tmp->private_free = safe_free;
record_fbsd_chunks(disks);
}
} }
} }
break; break;
@ -441,12 +494,27 @@ partition_disks(struct disk **disks)
break; break;
case 'M': /* mount */ case 'M': /* mount */
if (fbsd_chunk_info[current_chunk].type == PART_SLICE) { switch(fbsd_chunk_info[current_chunk].type) {
case PART_SLICE:
msg = "You can't mount one of these directly!"; msg = "You can't mount one of these directly!";
break; break;
case PART_SWAP:
msg = "You don't need to specify a mountpoint for a swap partition.";
break;
case PART_FILESYSTEM:
p = get_mountpoint(fbsd_chunk_info[current_chunk].c);
if (p) {
p->newfs = FALSE;
record_fbsd_chunks(disks);
}
break;
default:
msgFatal("Bogus partition under cursor???");
break;
} }
if (get_mountpoint(current_chunk))
record_fbsd_chunks(disks);
break; break;
case 27: /* ESC */ case 27: /* ESC */
@ -472,9 +540,7 @@ write_disks(struct disk **disks)
Set_Boot_Mgr(disks[i], bteasy17); Set_Boot_Mgr(disks[i], bteasy17);
else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?")) else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?"))
Set_Boot_Mgr(disks[i], mbr); Set_Boot_Mgr(disks[i], mbr);
#if 0
Write_Disk(disks[i]); Write_Disk(disks[i]);
#endif
} }
return 0; return 0;
} }

View File

@ -7,8 +7,9 @@ main(int argc, char **argv)
char buf[4096]; char buf[4096];
int i; int i;
if (argc < 2)
return 1;
i = tgetent(buf, argv[1]); i = tgetent(buf, argv[1]);
printf("%s",buf); printf("%s",buf);
return 0; return 0;
} }

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next * This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite. * generation being essentially a complete rewrite.
* *
* $Id: devices.c,v 1.7 1995/05/07 03:37:58 jkh Exp $ * $Id: devices.c,v 1.8 1995/05/07 05:58:55 jkh Exp $
* *
* Copyright (c) 1995 * Copyright (c) 1995
* Jordan Hubbard. All rights reserved. * Jordan Hubbard. All rights reserved.
@ -136,6 +136,7 @@ print_command_summary()
mvprintw(18, 0, "U = Undo All Changes W = `Wizard' Mode ESC = Proceed to next screen"); mvprintw(18, 0, "U = Undo All Changes W = `Wizard' Mode ESC = Proceed to next screen");
mvprintw(20, 0, "The currently selected partition is displayed in "); mvprintw(20, 0, "The currently selected partition is displayed in ");
attrset(A_REVERSE); addstr("reverse video"); attrset(A_NORMAL); attrset(A_REVERSE); addstr("reverse video"); attrset(A_NORMAL);
mvprintw(21, 0, "Use F1 or ? to get more help");
move(0, 0); move(0, 0);
} }
@ -244,6 +245,7 @@ device_slice_disk(struct disk *d)
case 'S': case 'S':
/* Set Bootable */ /* Set Bootable */
chunk_info[current_chunk]->flags |= CHUNK_ACTIVE;
break; break;
case 'U': case 'U':

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next * This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite. * generation being essentially a complete rewrite.
* *
* $Id: disks.c,v 1.5 1995/05/07 03:37:59 jkh Exp $ * $Id: disks.c,v 1.6 1995/05/07 05:58:56 jkh Exp $
* *
* Copyright (c) 1995 * Copyright (c) 1995
* Jordan Hubbard. All rights reserved. * Jordan Hubbard. All rights reserved.
@ -66,7 +66,6 @@
static struct { static struct {
struct disk *d; struct disk *d;
struct chunk *c; struct chunk *c;
PartInfo *p;
PartType type; PartType type;
} fbsd_chunk_info[MAX_CHUNKS + 1]; } fbsd_chunk_info[MAX_CHUNKS + 1];
static int current_chunk; static int current_chunk;
@ -96,6 +95,29 @@ contains_root_partition(struct disk *d)
return FALSE; return FALSE;
} }
/* Locate a chunk by position on a specific disk somewhere */
static struct chunk *
find_chunk_by_loc(struct disk *d, u_long offset, u_long size)
{
struct chunk *c1, *c2;
if (!d->chunks)
msgFatal("No chunk list for %s!", d->name);
for (c1 = d->chunks->part; c1; c1 = c1->next) {
if (c1->type == freebsd) {
if (c1->offset == offset && c1->size == size)
return c1;
for (c2 = c1->part; c2; c2 = c2->next) {
if (c2->type == part && c2->offset == offset &&
c2->size == size)
return c2;
}
}
}
return NULL;
}
static Boolean static Boolean
check_conflict(char *name) check_conflict(char *name)
{ {
@ -130,7 +152,7 @@ record_fbsd_chunks(struct disk **disks)
int i, j, p; int i, j, p;
struct chunk *c1, *c2; struct chunk *c1, *c2;
j = p = current_chunk = 0; j = p = 0;
for (i = 0; disks[i]; i++) { for (i = 0; disks[i]; i++) {
if (!disks[i]->chunks) if (!disks[i]->chunks)
msgFatal("No chunk list found for %s!", disks[i]->name); msgFatal("No chunk list found for %s!", disks[i]->name);
@ -141,7 +163,6 @@ record_fbsd_chunks(struct disk **disks)
fbsd_chunk_info[j].type = PART_SLICE; fbsd_chunk_info[j].type = PART_SLICE;
fbsd_chunk_info[j].d = disks[i]; fbsd_chunk_info[j].d = disks[i];
fbsd_chunk_info[j].c = c1; fbsd_chunk_info[j].c = c1;
fbsd_chunk_info[j].p = NULL;
++j; ++j;
} }
} }
@ -158,7 +179,6 @@ record_fbsd_chunks(struct disk **disks)
fbsd_chunk_info[j].type = PART_FILESYSTEM; fbsd_chunk_info[j].type = PART_FILESYSTEM;
fbsd_chunk_info[j].d = disks[i]; fbsd_chunk_info[j].d = disks[i];
fbsd_chunk_info[j].c = c2; fbsd_chunk_info[j].c = c2;
fbsd_chunk_info[j].p = c2->private;
++j; ++j;
} }
} }
@ -167,6 +187,8 @@ record_fbsd_chunks(struct disk **disks)
} }
fbsd_chunk_info[j].d = NULL; fbsd_chunk_info[j].d = NULL;
fbsd_chunk_info[j].c = NULL; fbsd_chunk_info[j].c = NULL;
if (current_chunk >= j)
current_chunk = j ? j - 1 : 0;
} }
static PartInfo * static PartInfo *
@ -180,33 +202,39 @@ new_part(char *mpoint, Boolean newfs)
return ret; return ret;
} }
int PartInfo *
get_mountpoint(int i) get_mountpoint(struct chunk *c)
{ {
char *val; char *val;
PartInfo *tmp;
val = msgGetInput(fbsd_chunk_info[i].p ? val = msgGetInput(c && c->private ?
fbsd_chunk_info[i].p->mountpoint : NULL, ((PartInfo *)c->private)->mountpoint : NULL,
"Please specify a mount point for the new partition"); "Please specify a mount point for the partition");
if (val) { if (val) {
if (!strcmp(val, "/")) {
if (fbsd_chunk_info[i].c->flags & CHUNK_PAST_1024) {
msgConfirm("This region cannot be used for your root partition as\nit is past the 1024'th cylinder mark and the system would not be\nable to boot from it. Please pick another location for your\nroot partition and try again!");
return 1;
}
fbsd_chunk_info[i].c->flags |= CHUNK_IS_ROOT;
}
if (check_conflict(val)) { if (check_conflict(val)) {
msgConfirm("You already have a mountpoint for %s assigned!", val); msgConfirm("You already have a mountpoint for %s assigned!", val);
return 1; return NULL;
} }
safe_free(fbsd_chunk_info[i].c->private); else if (!strcmp(val, "/")) {
fbsd_chunk_info[i].c->private = new_part(val, TRUE); if (c && c->flags & CHUNK_PAST_1024) {
fbsd_chunk_info[i].c->private_free = free; msgConfirm("This region cannot be used for your root partition as\nit is past the 1024'th cylinder mark and the system would not be\nable to boot from it. Please pick another location for your\nroot partition and try again!");
fbsd_chunk_info[i].p = fbsd_chunk_info[i].c->private; return NULL;
return 0; }
else if (c)
c->flags |= CHUNK_IS_ROOT;
}
else if (c)
c->flags &= ~CHUNK_IS_ROOT;
safe_free(c ? c->private : NULL);
tmp = new_part(val, TRUE);
if (c) {
c->private = tmp;
c->private_free = safe_free;
}
return tmp;
} }
return 1; return NULL;
} }
static PartType static PartType
@ -238,6 +266,9 @@ get_partition_type(void)
#define PART_NEWFS_COL (PART_SIZE_COL + 8) #define PART_NEWFS_COL (PART_SIZE_COL + 8)
#define PART_OFF 42 #define PART_OFF 42
/* How many mounted partitions to display in column before going to next */
#define CHUNK_COLUMN_MAX 6
static void static void
print_fbsd_chunks(void) print_fbsd_chunks(void)
{ {
@ -291,21 +322,20 @@ print_fbsd_chunks(void)
memset(onestr, ' ', PART_OFF - 1); memset(onestr, ' ', PART_OFF - 1);
onestr[PART_OFF - 1] = '\0'; onestr[PART_OFF - 1] = '\0';
/* Go for two columns */ /* Go for two columns */
if (prow == (CHUNK_PART_START_ROW + 8)) if (prow == (CHUNK_PART_START_ROW + CHUNK_COLUMN_MAX))
pcol = PART_OFF; pcol = PART_OFF;
else else
pcol = 0; pcol = 0;
memcpy(onestr + PART_PART_COL, fbsd_chunk_info[i].c->name, memcpy(onestr + PART_PART_COL, fbsd_chunk_info[i].c->name,
strlen(fbsd_chunk_info[i].c->name)); strlen(fbsd_chunk_info[i].c->name));
if (fbsd_chunk_info[i].type == PART_FILESYSTEM) { if (fbsd_chunk_info[i].type == PART_FILESYSTEM) {
if (fbsd_chunk_info[i].p) { if (fbsd_chunk_info[i].c->private) {
mountpoint = fbsd_chunk_info[i].p->mountpoint; mountpoint = ((PartInfo *)fbsd_chunk_info[i].c->private)->mountpoint;
newfs = fbsd_chunk_info[i].p->newfs ? "Y" : "N"; newfs = ((PartInfo *)fbsd_chunk_info[i].c->private)->newfs ? "Y" : "N";
} }
else { else {
fbsd_chunk_info[i].c->private = new_part("", FALSE); fbsd_chunk_info[i].c->private = new_part("", FALSE);
fbsd_chunk_info[i].c->private_free = free; fbsd_chunk_info[i].c->private_free = safe_free;
fbsd_chunk_info[i].p = fbsd_chunk_info[i].c->private;
mountpoint = " "; mountpoint = " ";
newfs = "N"; newfs = "N";
} }
@ -331,15 +361,16 @@ print_fbsd_chunks(void)
static void static void
print_command_summary() print_command_summary()
{ {
mvprintw(19, 0, mvprintw(17, 0,
"The following commands are valid here (upper or lower case):"); "The following commands are valid here (upper or lower case):");
mvprintw(20, 0, "C = Create FreeBSD Partition D = Delete Partition"); mvprintw(19, 0, "C = Create Partition D = Delete Partition M = Mount Partition");
mvprintw(21, 0, "M = Mount Partition (no newfs) ESC = Proceed to summary screen"); mvprintw(20, 0, "N = Newfs Options T = Toggle Newfs ESC = Finish Partitioning");
mvprintw(22, 0, "The default target will be displayed in "); mvprintw(21, 0, "The default target will be displayed in ");
attrset(A_REVERSE); attrset(A_REVERSE);
addstr("reverse video"); addstr("reverse video");
attrset(A_NORMAL); attrset(A_NORMAL);
mvprintw(22, 0, "Use F1 or ? to get more help");
move(0, 0); move(0, 0);
} }
@ -349,6 +380,8 @@ partition_disks(struct disk **disks)
int sz, key = 0; int sz, key = 0;
Boolean partitioning; Boolean partitioning;
char *msg = NULL; char *msg = NULL;
PartInfo *p;
PartType type;
dialog_clear(); dialog_clear();
partitioning = TRUE; partitioning = TRUE;
@ -405,27 +438,47 @@ partition_disks(struct disk **disks)
if (sz <= FS_MIN_SIZE) if (sz <= FS_MIN_SIZE)
msg = "Not enough space to create additional FreeBSD partition"; msg = "Not enough space to create additional FreeBSD partition";
else { else {
char *val, tmp[20]; char *val, *cp, tmp[20];
int size; int size;
snprintf(tmp, 20, "%d", sz); snprintf(tmp, 20, "%d", sz);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition"); val = msgGetInput(tmp, "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, 0, 0)) > 0) { if (val && (size = strtol(val, &cp, 0)) > 0) {
PartType type; struct chunk *tmp;
u_long flags = 0;
if (*cp && toupper(*cp) == 'M')
size *= 2048;
type = get_partition_type(); type = get_partition_type();
if (type == PART_NONE) if (type == PART_NONE)
break; break;
else 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;
Create_Chunk(fbsd_chunk_info[current_chunk].d, Create_Chunk(fbsd_chunk_info[current_chunk].d,
fbsd_chunk_info[current_chunk].c->offset + fbsd_chunk_info[current_chunk].c->offset +
sz - size, sz - size,
size, size,
part, part,
type == PART_SWAP ? FS_SWAP : freebsd, (type == PART_SWAP) ? FS_SWAP : freebsd,
fbsd_chunk_info[current_chunk].c->flags); flags);
if (get_mountpoint(current_chunk)) tmp = find_chunk_by_loc(fbsd_chunk_info[current_chunk].d,
break; fbsd_chunk_info[current_chunk].c->offset + sz - size, size);
record_fbsd_chunks(disks); if (!tmp)
msgConfirm("Unable to create the partition. Too big?");
else {
tmp->private = p;
tmp->private_free = safe_free;
record_fbsd_chunks(disks);
}
} }
} }
break; break;
@ -441,12 +494,27 @@ partition_disks(struct disk **disks)
break; break;
case 'M': /* mount */ case 'M': /* mount */
if (fbsd_chunk_info[current_chunk].type == PART_SLICE) { switch(fbsd_chunk_info[current_chunk].type) {
case PART_SLICE:
msg = "You can't mount one of these directly!"; msg = "You can't mount one of these directly!";
break; break;
case PART_SWAP:
msg = "You don't need to specify a mountpoint for a swap partition.";
break;
case PART_FILESYSTEM:
p = get_mountpoint(fbsd_chunk_info[current_chunk].c);
if (p) {
p->newfs = FALSE;
record_fbsd_chunks(disks);
}
break;
default:
msgFatal("Bogus partition under cursor???");
break;
} }
if (get_mountpoint(current_chunk))
record_fbsd_chunks(disks);
break; break;
case 27: /* ESC */ case 27: /* ESC */
@ -472,9 +540,7 @@ write_disks(struct disk **disks)
Set_Boot_Mgr(disks[i], bteasy17); Set_Boot_Mgr(disks[i], bteasy17);
else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?")) else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?"))
Set_Boot_Mgr(disks[i], mbr); Set_Boot_Mgr(disks[i], mbr);
#if 0
Write_Disk(disks[i]); Write_Disk(disks[i]);
#endif
} }
return 0; return 0;
} }

View File

@ -7,8 +7,9 @@ main(int argc, char **argv)
char buf[4096]; char buf[4096];
int i; int i;
if (argc < 2)
return 1;
i = tgetent(buf, argv[1]); i = tgetent(buf, argv[1]);
printf("%s",buf); printf("%s",buf);
return 0; return 0;
} }

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next * This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite. * generation being essentially a complete rewrite.
* *
* $Id: devices.c,v 1.7 1995/05/07 03:37:58 jkh Exp $ * $Id: devices.c,v 1.8 1995/05/07 05:58:55 jkh Exp $
* *
* Copyright (c) 1995 * Copyright (c) 1995
* Jordan Hubbard. All rights reserved. * Jordan Hubbard. All rights reserved.
@ -136,6 +136,7 @@ print_command_summary()
mvprintw(18, 0, "U = Undo All Changes W = `Wizard' Mode ESC = Proceed to next screen"); mvprintw(18, 0, "U = Undo All Changes W = `Wizard' Mode ESC = Proceed to next screen");
mvprintw(20, 0, "The currently selected partition is displayed in "); mvprintw(20, 0, "The currently selected partition is displayed in ");
attrset(A_REVERSE); addstr("reverse video"); attrset(A_NORMAL); attrset(A_REVERSE); addstr("reverse video"); attrset(A_NORMAL);
mvprintw(21, 0, "Use F1 or ? to get more help");
move(0, 0); move(0, 0);
} }
@ -244,6 +245,7 @@ device_slice_disk(struct disk *d)
case 'S': case 'S':
/* Set Bootable */ /* Set Bootable */
chunk_info[current_chunk]->flags |= CHUNK_ACTIVE;
break; break;
case 'U': case 'U':

View File

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next * This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite. * generation being essentially a complete rewrite.
* *
* $Id: disks.c,v 1.5 1995/05/07 03:37:59 jkh Exp $ * $Id: disks.c,v 1.6 1995/05/07 05:58:56 jkh Exp $
* *
* Copyright (c) 1995 * Copyright (c) 1995
* Jordan Hubbard. All rights reserved. * Jordan Hubbard. All rights reserved.
@ -66,7 +66,6 @@
static struct { static struct {
struct disk *d; struct disk *d;
struct chunk *c; struct chunk *c;
PartInfo *p;
PartType type; PartType type;
} fbsd_chunk_info[MAX_CHUNKS + 1]; } fbsd_chunk_info[MAX_CHUNKS + 1];
static int current_chunk; static int current_chunk;
@ -96,6 +95,29 @@ contains_root_partition(struct disk *d)
return FALSE; return FALSE;
} }
/* Locate a chunk by position on a specific disk somewhere */
static struct chunk *
find_chunk_by_loc(struct disk *d, u_long offset, u_long size)
{
struct chunk *c1, *c2;
if (!d->chunks)
msgFatal("No chunk list for %s!", d->name);
for (c1 = d->chunks->part; c1; c1 = c1->next) {
if (c1->type == freebsd) {
if (c1->offset == offset && c1->size == size)
return c1;
for (c2 = c1->part; c2; c2 = c2->next) {
if (c2->type == part && c2->offset == offset &&
c2->size == size)
return c2;
}
}
}
return NULL;
}
static Boolean static Boolean
check_conflict(char *name) check_conflict(char *name)
{ {
@ -130,7 +152,7 @@ record_fbsd_chunks(struct disk **disks)
int i, j, p; int i, j, p;
struct chunk *c1, *c2; struct chunk *c1, *c2;
j = p = current_chunk = 0; j = p = 0;
for (i = 0; disks[i]; i++) { for (i = 0; disks[i]; i++) {
if (!disks[i]->chunks) if (!disks[i]->chunks)
msgFatal("No chunk list found for %s!", disks[i]->name); msgFatal("No chunk list found for %s!", disks[i]->name);
@ -141,7 +163,6 @@ record_fbsd_chunks(struct disk **disks)
fbsd_chunk_info[j].type = PART_SLICE; fbsd_chunk_info[j].type = PART_SLICE;
fbsd_chunk_info[j].d = disks[i]; fbsd_chunk_info[j].d = disks[i];
fbsd_chunk_info[j].c = c1; fbsd_chunk_info[j].c = c1;
fbsd_chunk_info[j].p = NULL;
++j; ++j;
} }
} }
@ -158,7 +179,6 @@ record_fbsd_chunks(struct disk **disks)
fbsd_chunk_info[j].type = PART_FILESYSTEM; fbsd_chunk_info[j].type = PART_FILESYSTEM;
fbsd_chunk_info[j].d = disks[i]; fbsd_chunk_info[j].d = disks[i];
fbsd_chunk_info[j].c = c2; fbsd_chunk_info[j].c = c2;
fbsd_chunk_info[j].p = c2->private;
++j; ++j;
} }
} }
@ -167,6 +187,8 @@ record_fbsd_chunks(struct disk **disks)
} }
fbsd_chunk_info[j].d = NULL; fbsd_chunk_info[j].d = NULL;
fbsd_chunk_info[j].c = NULL; fbsd_chunk_info[j].c = NULL;
if (current_chunk >= j)
current_chunk = j ? j - 1 : 0;
} }
static PartInfo * static PartInfo *
@ -180,33 +202,39 @@ new_part(char *mpoint, Boolean newfs)
return ret; return ret;
} }
int PartInfo *
get_mountpoint(int i) get_mountpoint(struct chunk *c)
{ {
char *val; char *val;
PartInfo *tmp;
val = msgGetInput(fbsd_chunk_info[i].p ? val = msgGetInput(c && c->private ?
fbsd_chunk_info[i].p->mountpoint : NULL, ((PartInfo *)c->private)->mountpoint : NULL,
"Please specify a mount point for the new partition"); "Please specify a mount point for the partition");
if (val) { if (val) {
if (!strcmp(val, "/")) {
if (fbsd_chunk_info[i].c->flags & CHUNK_PAST_1024) {
msgConfirm("This region cannot be used for your root partition as\nit is past the 1024'th cylinder mark and the system would not be\nable to boot from it. Please pick another location for your\nroot partition and try again!");
return 1;
}
fbsd_chunk_info[i].c->flags |= CHUNK_IS_ROOT;
}
if (check_conflict(val)) { if (check_conflict(val)) {
msgConfirm("You already have a mountpoint for %s assigned!", val); msgConfirm("You already have a mountpoint for %s assigned!", val);
return 1; return NULL;
} }
safe_free(fbsd_chunk_info[i].c->private); else if (!strcmp(val, "/")) {
fbsd_chunk_info[i].c->private = new_part(val, TRUE); if (c && c->flags & CHUNK_PAST_1024) {
fbsd_chunk_info[i].c->private_free = free; msgConfirm("This region cannot be used for your root partition as\nit is past the 1024'th cylinder mark and the system would not be\nable to boot from it. Please pick another location for your\nroot partition and try again!");
fbsd_chunk_info[i].p = fbsd_chunk_info[i].c->private; return NULL;
return 0; }
else if (c)
c->flags |= CHUNK_IS_ROOT;
}
else if (c)
c->flags &= ~CHUNK_IS_ROOT;
safe_free(c ? c->private : NULL);
tmp = new_part(val, TRUE);
if (c) {
c->private = tmp;
c->private_free = safe_free;
}
return tmp;
} }
return 1; return NULL;
} }
static PartType static PartType
@ -238,6 +266,9 @@ get_partition_type(void)
#define PART_NEWFS_COL (PART_SIZE_COL + 8) #define PART_NEWFS_COL (PART_SIZE_COL + 8)
#define PART_OFF 42 #define PART_OFF 42
/* How many mounted partitions to display in column before going to next */
#define CHUNK_COLUMN_MAX 6
static void static void
print_fbsd_chunks(void) print_fbsd_chunks(void)
{ {
@ -291,21 +322,20 @@ print_fbsd_chunks(void)
memset(onestr, ' ', PART_OFF - 1); memset(onestr, ' ', PART_OFF - 1);
onestr[PART_OFF - 1] = '\0'; onestr[PART_OFF - 1] = '\0';
/* Go for two columns */ /* Go for two columns */
if (prow == (CHUNK_PART_START_ROW + 8)) if (prow == (CHUNK_PART_START_ROW + CHUNK_COLUMN_MAX))
pcol = PART_OFF; pcol = PART_OFF;
else else
pcol = 0; pcol = 0;
memcpy(onestr + PART_PART_COL, fbsd_chunk_info[i].c->name, memcpy(onestr + PART_PART_COL, fbsd_chunk_info[i].c->name,
strlen(fbsd_chunk_info[i].c->name)); strlen(fbsd_chunk_info[i].c->name));
if (fbsd_chunk_info[i].type == PART_FILESYSTEM) { if (fbsd_chunk_info[i].type == PART_FILESYSTEM) {
if (fbsd_chunk_info[i].p) { if (fbsd_chunk_info[i].c->private) {
mountpoint = fbsd_chunk_info[i].p->mountpoint; mountpoint = ((PartInfo *)fbsd_chunk_info[i].c->private)->mountpoint;
newfs = fbsd_chunk_info[i].p->newfs ? "Y" : "N"; newfs = ((PartInfo *)fbsd_chunk_info[i].c->private)->newfs ? "Y" : "N";
} }
else { else {
fbsd_chunk_info[i].c->private = new_part("", FALSE); fbsd_chunk_info[i].c->private = new_part("", FALSE);
fbsd_chunk_info[i].c->private_free = free; fbsd_chunk_info[i].c->private_free = safe_free;
fbsd_chunk_info[i].p = fbsd_chunk_info[i].c->private;
mountpoint = " "; mountpoint = " ";
newfs = "N"; newfs = "N";
} }
@ -331,15 +361,16 @@ print_fbsd_chunks(void)
static void static void
print_command_summary() print_command_summary()
{ {
mvprintw(19, 0, mvprintw(17, 0,
"The following commands are valid here (upper or lower case):"); "The following commands are valid here (upper or lower case):");
mvprintw(20, 0, "C = Create FreeBSD Partition D = Delete Partition"); mvprintw(19, 0, "C = Create Partition D = Delete Partition M = Mount Partition");
mvprintw(21, 0, "M = Mount Partition (no newfs) ESC = Proceed to summary screen"); mvprintw(20, 0, "N = Newfs Options T = Toggle Newfs ESC = Finish Partitioning");
mvprintw(22, 0, "The default target will be displayed in "); mvprintw(21, 0, "The default target will be displayed in ");
attrset(A_REVERSE); attrset(A_REVERSE);
addstr("reverse video"); addstr("reverse video");
attrset(A_NORMAL); attrset(A_NORMAL);
mvprintw(22, 0, "Use F1 or ? to get more help");
move(0, 0); move(0, 0);
} }
@ -349,6 +380,8 @@ partition_disks(struct disk **disks)
int sz, key = 0; int sz, key = 0;
Boolean partitioning; Boolean partitioning;
char *msg = NULL; char *msg = NULL;
PartInfo *p;
PartType type;
dialog_clear(); dialog_clear();
partitioning = TRUE; partitioning = TRUE;
@ -405,27 +438,47 @@ partition_disks(struct disk **disks)
if (sz <= FS_MIN_SIZE) if (sz <= FS_MIN_SIZE)
msg = "Not enough space to create additional FreeBSD partition"; msg = "Not enough space to create additional FreeBSD partition";
else { else {
char *val, tmp[20]; char *val, *cp, tmp[20];
int size; int size;
snprintf(tmp, 20, "%d", sz); snprintf(tmp, 20, "%d", sz);
val = msgGetInput(tmp, "Please specify size for new FreeBSD partition"); val = msgGetInput(tmp, "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, 0, 0)) > 0) { if (val && (size = strtol(val, &cp, 0)) > 0) {
PartType type; struct chunk *tmp;
u_long flags = 0;
if (*cp && toupper(*cp) == 'M')
size *= 2048;
type = get_partition_type(); type = get_partition_type();
if (type == PART_NONE) if (type == PART_NONE)
break; break;
else 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;
Create_Chunk(fbsd_chunk_info[current_chunk].d, Create_Chunk(fbsd_chunk_info[current_chunk].d,
fbsd_chunk_info[current_chunk].c->offset + fbsd_chunk_info[current_chunk].c->offset +
sz - size, sz - size,
size, size,
part, part,
type == PART_SWAP ? FS_SWAP : freebsd, (type == PART_SWAP) ? FS_SWAP : freebsd,
fbsd_chunk_info[current_chunk].c->flags); flags);
if (get_mountpoint(current_chunk)) tmp = find_chunk_by_loc(fbsd_chunk_info[current_chunk].d,
break; fbsd_chunk_info[current_chunk].c->offset + sz - size, size);
record_fbsd_chunks(disks); if (!tmp)
msgConfirm("Unable to create the partition. Too big?");
else {
tmp->private = p;
tmp->private_free = safe_free;
record_fbsd_chunks(disks);
}
} }
} }
break; break;
@ -441,12 +494,27 @@ partition_disks(struct disk **disks)
break; break;
case 'M': /* mount */ case 'M': /* mount */
if (fbsd_chunk_info[current_chunk].type == PART_SLICE) { switch(fbsd_chunk_info[current_chunk].type) {
case PART_SLICE:
msg = "You can't mount one of these directly!"; msg = "You can't mount one of these directly!";
break; break;
case PART_SWAP:
msg = "You don't need to specify a mountpoint for a swap partition.";
break;
case PART_FILESYSTEM:
p = get_mountpoint(fbsd_chunk_info[current_chunk].c);
if (p) {
p->newfs = FALSE;
record_fbsd_chunks(disks);
}
break;
default:
msgFatal("Bogus partition under cursor???");
break;
} }
if (get_mountpoint(current_chunk))
record_fbsd_chunks(disks);
break; break;
case 27: /* ESC */ case 27: /* ESC */
@ -472,9 +540,7 @@ write_disks(struct disk **disks)
Set_Boot_Mgr(disks[i], bteasy17); Set_Boot_Mgr(disks[i], bteasy17);
else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?")) else if (i == 0 && !msgYesNo("Would you like to remove an existing boot manager?"))
Set_Boot_Mgr(disks[i], mbr); Set_Boot_Mgr(disks[i], mbr);
#if 0
Write_Disk(disks[i]); Write_Disk(disks[i]);
#endif
} }
return 0; return 0;
} }

View File

@ -7,8 +7,9 @@ main(int argc, char **argv)
char buf[4096]; char buf[4096];
int i; int i;
if (argc < 2)
return 1;
i = tgetent(buf, argv[1]); i = tgetent(buf, argv[1]);
printf("%s",buf); printf("%s",buf);
return 0; return 0;
} }