summaryrefslogtreecommitdiffstats
path: root/sbin/sysinstall
diff options
context:
space:
mode:
authorpaul <paul@FreeBSD.org>1994-11-19 17:29:19 +0000
committerpaul <paul@FreeBSD.org>1994-11-19 17:29:19 +0000
commit10b6f8dcf3759d972f34253008107434b7ca4438 (patch)
tree222cebf0094dd1fac1e665b2df782ca0e756c472 /sbin/sysinstall
parent535da6b2598fb690f00854fa64895ce1ceb7e6ba (diff)
downloadFreeBSD-src-10b6f8dcf3759d972f34253008107434b7ca4438.zip
FreeBSD-src-10b6f8dcf3759d972f34253008107434b7ca4438.tar.gz
Implemented buttons for all the screens.
Could do with some cosmetic tuning regarding placement and things. Fixed some dialog code (from Andrew). Pass mountpoints onto stage2 in a struct fstab *mounts[] Fix all the field connections to conform to the new L&F document.
Diffstat (limited to 'sbin/sysinstall')
-rw-r--r--sbin/sysinstall/bootarea.c16
-rw-r--r--sbin/sysinstall/editor.c186
-rw-r--r--sbin/sysinstall/editor.h2
-rw-r--r--sbin/sysinstall/label.c167
-rw-r--r--sbin/sysinstall/label.h100
-rw-r--r--sbin/sysinstall/mbr.c90
-rw-r--r--sbin/sysinstall/mbr.h212
-rw-r--r--sbin/sysinstall/stage1.c42
-rw-r--r--sbin/sysinstall/sysinstall.h2
-rw-r--r--sbin/sysinstall/utils.c56
10 files changed, 415 insertions, 458 deletions
diff --git a/sbin/sysinstall/bootarea.c b/sbin/sysinstall/bootarea.c
index 00d22e2..44aca12 100644
--- a/sbin/sysinstall/bootarea.c
+++ b/sbin/sysinstall/bootarea.c
@@ -134,6 +134,14 @@ write_bootblocks(int disk)
return (-1);
}
+ /* Update the in-core label too if possible */
+
+ if (ioctl(fd, DIOCSDINFO, lbl) < 0) {
+ sprintf(errmsg, "Couldn't change in-core disklabel for %s\n\n%s",
+ scratch, strerror(errno));
+ return (-1);
+ }
+
if (enable_label(fd) == -1)
return (-1);
@@ -146,14 +154,6 @@ write_bootblocks(int disk)
if (disable_label(fd) == -1)
return (-1);
- /* Update the in-core label too if possible */
-
- if (ioctl(fd, DIOCSDINFO, lbl) < 0) {
- sprintf(errmsg, "Couldn't change in-core disklabel for %s\n\n%s",
- scratch, strerror(errno));
- return (-1);
- }
-
if (close(fd) == -1) {
sprintf(errmsg, "Couldn't close device %s\n\n%s",
scratch, strerror(errno));
diff --git a/sbin/sysinstall/editor.c b/sbin/sysinstall/editor.c
index c1cd690..cdf70ee 100644
--- a/sbin/sysinstall/editor.c
+++ b/sbin/sysinstall/editor.c
@@ -58,7 +58,7 @@ change_field(struct field field, int key)
break;
case '\n':
case '\r':
- next = field.next;
+ next = field.right;
break;
default:
next = -1;
@@ -66,151 +66,53 @@ change_field(struct field field, int key)
}
return (next);
}
-
+
int
-edit_line(WINDOW *window, int y, int x, char *field, int width, int maxlen)
+button_press(WINDOW *window, struct field field)
{
- int len;
- int key = 0;
- int fpos, dispos, curpos;
- int i;
- int done = 0;
+ int key;
- len = strlen(field);
- if (len < width) {
- fpos = len;
- curpos = len;
- dispos = 0;
- } else {
- fpos = width;
- curpos = width;
- dispos = len - width;
- };
+ print_button(window, field.field,
+ field.y,
+ field.x,
+ TRUE);
+ key = wgetch(window);
+ switch (key) {
+ case '\n':
+ case '\r':
+ return (0);
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_BTAB:
+ case '\t':
+ default:
+ return (key);
+ }
+}
- do {
- wattrset(window, item_selected_attr);
- wmove(window, y, x);
- for (i=0; i < width; i++)
- if (i < (len - dispos))
- waddch(window, field[dispos+i]);
- else
- waddch(window, ' ');
- wmove(window, y, x + curpos);
- wrefresh(window);
+int
+toggle_press(WINDOW *window, struct field field)
+{
+ int key;
- key = wgetch(window);
- switch (key) {
- case TAB:
- case KEY_BTAB:
- case KEY_UP:
- case KEY_DOWN:
- case ESC:
- case '\n':
- case '\r':
- case ' ':
- done = 1;
- break;
- case KEY_HOME:
- if (len < width) {
- fpos = len;
- curpos = len;
- dispos = 0;
- } else {
- fpos = width;
- curpos = width;
- dispos = len - width;
- };
- break;
- case KEY_END:
- if (len < width) {
- dispos = 0;
- curpos = len - 1;
- } else {
- dispos = len - width - 1;
- curpos = width - 1;
- }
- fpos = len - 1;
- break;
- case KEY_LEFT:
- if ((!curpos) && (!dispos)) {
- beep();
- break;
- }
- if (--curpos < 0) {
- curpos = 0;
- if (--dispos < 0)
- dispos = 0;
- }
- if (--fpos < 0)
- fpos = 0;
- break;
- case KEY_RIGHT:
- if ((curpos + dispos) == len) {
- beep();
- break;
- }
- if ((curpos == (width-1)) && (dispos == (maxlen - width -1))) {
- beep();
- break;
- }
- if (++curpos >= width) {
- curpos = width - 1;
- dispos++;
- }
- if (dispos >= len)
- dispos = len - 1;
- if (++fpos >= len) {
- fpos = len;
- }
- break;
- case KEY_BACKSPACE:
- case KEY_DC:
- if ((!curpos) && (!dispos)) {
- beep();
- break;
- }
- if (fpos > 0) {
- memmove(field+fpos-1, field+fpos, len - fpos);
- len--;
- fpos--;
- if (curpos > 0)
- --curpos;
- if (!curpos)
- --dispos;
- if (dispos < 0)
- dispos = 0;
- } else
- beep();
- break;
- default:
- if (len < maxlen - 1) {
- memmove(field+fpos+1, field+fpos, len - fpos);
- field[fpos] = key;
- len++;
- fpos++;
- if (++curpos == width) {
- --curpos;
- dispos++;
- }
- if (len == (maxlen - 1)) {
- dispos = (maxlen - width - 1);
- }
- } else
- beep();
- break;
- }
- } while (!done);
- wattrset(window, dialog_attr);
- wmove(window, y, x);
- for (i=0; i < width; i++)
- if (i < (len - dispos))
- waddch(window, field[dispos+i]);
- else
- waddch(window, ' ');
- wmove(window, y, x + curpos);
- wstandend(window);
- field[len] = 0;
- wrefresh(window);
- return (key);
+ key = wgetch(window);
+
+ switch (key) {
+ case ' ':
+ field.spare++;
+ if (!field.misc[field.spare])
+ field.spare = 0;
+ sprintf(field.field, "%", field.misc[field.spare]);
+ return (key);
+ break;
+ case '\n':
+ case '\r':
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_BTAB:
+ case '\t':
+ default:
+ return (key);
+ }
}
diff --git a/sbin/sysinstall/editor.h b/sbin/sysinstall/editor.h
index 79dd6a6..2783cc8 100644
--- a/sbin/sysinstall/editor.h
+++ b/sbin/sysinstall/editor.h
@@ -13,6 +13,8 @@ struct field {
int right;
char field[80];
int type;
+ int spare;
+ char *misc;
};
#define F_EDIT 0
diff --git a/sbin/sysinstall/label.c b/sbin/sysinstall/label.c
index 9dc8c38..eb68434 100644
--- a/sbin/sysinstall/label.c
+++ b/sbin/sysinstall/label.c
@@ -27,6 +27,8 @@ char *partname[MAXPARTITIONS] = {"a", "b", "c", "d", "e", "f", "g", "h"};
extern char boot1[];
extern char boot2[];
+char *yesno[] = {"yes", "no", 0};
+
int
disk_size(struct disklabel *lbl)
{
@@ -77,6 +79,18 @@ diskname(int disk)
}
int
+get_fs_type(char *fstype)
+{
+ int i;
+
+ for (i=0; fstypenames[i]; i++)
+ if (strcmp(fstype, fstypenames[i]))
+ return (i);
+
+ return (FS_OTHER);
+}
+
+int
read_disklabel(int disk)
{
int fd;
@@ -106,6 +120,7 @@ edit_disklabel(int disk)
{
WINDOW *window;
int key = 0;
+ int done;
int next;
int cur_field;
int cur_part;
@@ -128,37 +143,74 @@ edit_disklabel(int disk)
lbl->d_npartitions = 8;
/* Initialise the entries */
+
for (i=0; i < MAXPARTITIONS; i++) {
+
disk_list[disk].mounts[i].fs_spec =
- (char *)malloc(label_field[i*5].maxlen+1);
+ (char *)malloc(80);
if (!disk_list[disk].mounts[i].fs_spec) {
sprintf(errmsg, "Couldn't allocate memory for device mounts\n");
return (-1);
}
sprintf(disk_list[disk].mounts[i].fs_spec,
- "%s%d%s", disk_list[disk].devconf->dc_name,
+ "/dev/%s%d%s", disk_list[disk].devconf->dc_name,
disk_list[disk].devconf->dc_unit,
partname[i]);
- disk_list[disk].mounts[i].fs_mntops =
- (char *)malloc(label_field[(i*5)+1].maxlen+1);
- if (!disk_list[disk].mounts[i].fs_mntops) {
- sprintf(errmsg, "Couldn't allocate memory for mount options\n");
- return (-1);
- }
- sprintf(disk_list[disk].mounts[i].fs_mntops, "%s", "YES");
+
disk_list[disk].mounts[i].fs_file =
- (char *)malloc(label_field[(i*5)+4].maxlen+1);
+ (char *)malloc(80);
if (!disk_list[disk].mounts[i].fs_file) {
sprintf(errmsg, "Couldn't allocate memory for mount points\n");
return (-1);
}
sprintf(disk_list[disk].mounts[i].fs_file, "%s", "Not Mounted");
+ disk_list[disk].mounts[i].fs_vfstype =
+ (char *)malloc(80);
+ if (!disk_list[disk].mounts[i].fs_vfstype) {
+ sprintf(errmsg, "Couldn't allocate memory for filesystem type\n");
+ return (-1);
+ }
+ switch (lbl->d_partitions[i].p_fstype) {
+ case FS_BSDFFS:
+ sprintf(disk_list[disk].mounts[i].fs_vfstype, "%s", "ufs");
+ break;
+ case FS_MSDOS:
+ sprintf(disk_list[disk].mounts[i].fs_vfstype, "%s", "msdos");
+ break;
+ case FS_SWAP:
+ sprintf(disk_list[disk].mounts[i].fs_vfstype, "%s", "swap");
+ break;
+ default:
+ sprintf(disk_list[disk].mounts[i].fs_vfstype, "%s", "unused");
+ }
+
+ disk_list[disk].mounts[i].fs_mntops =
+ (char *)malloc(80);
+ if (!disk_list[disk].mounts[i].fs_mntops) {
+ sprintf(errmsg, "Couldn't allocate memory for mount options\n");
+ return (-1);
+ }
+ sprintf(disk_list[disk].mounts[i].fs_mntops, "%s", "YES");
+
sprintf(label_field[(i*5)+3].field, "%d",
sectstoMb(lbl->d_partitions[i].p_size, lbl->d_secsize));
}
- if (!(window = newwin(24, 79, 0, 0))) {
+ /*
+ * Setup the RAWPART and OURPART partition ourselves from the MBR
+ * in case either one doesn't exist or the new MBR invalidates them.
+ */
+
+ cur_part = disk_list[disk].inst_part;
+ lbl->d_partitions[OURPART].p_size =
+ disk_list[disk].mbr.dospart[cur_part].dp_size;
+ lbl->d_partitions[OURPART].p_offset =
+ disk_list[disk].mbr.dospart[cur_part].dp_start;
+ lbl->d_partitions[RAWPART].p_size = lbl->d_secperunit;
+ lbl->d_partitions[RAWPART].p_offset = 0;
+
+ if (!(window = newwin(LINES, COLS, 0, 0))) {
sprintf(errmsg, "Failed to open window for disklabel editor\n");
return (-1);
}
@@ -167,8 +219,13 @@ edit_disklabel(int disk)
draw_box(window, 0, 0, 24, 79, dialog_attr, border_attr);
+ /* Only one toggle to set up */
+ for (i=0; i < MAXPARTITIONS; i++)
+ label_field[(i*5)+1].misc = yesno;
+
cur_field = 1;
- while (key != ESC) {
+ done = 0;
+ while (!done && (key != ESC)) {
/* Update disklabel */
@@ -205,7 +262,7 @@ edit_disklabel(int disk)
sprintf(label_field[(i*5)+1].field, "%s",
disk_list[disk].mounts[i].fs_mntops);
sprintf(label_field[(i*5)+2].field, "%s",
- fstypenames[lbl->d_partitions[i].p_fstype]);
+ disk_list[disk].mounts[i].fs_vfstype);
sprintf(label_field[(i*5)+3].field, "%d",
sectstoMb(lbl->d_partitions[i].p_size,lbl->d_secsize));
sprintf(label_field[(i*5)+4].field, "%s",
@@ -218,49 +275,52 @@ edit_disklabel(int disk)
disp_fields(window, label_field,
sizeof(label_field)/sizeof(struct field));
- do {
- next = change_field(label_field[cur_field], key);
- if (next == -1) {
- beep();
- break;
- } else
- cur_field = next;
- cur_part = cur_field/5;
- } while ((cur_part == OURPART) || (cur_part == RAWPART));
-
- if (label_field[cur_field].type == F_EDIT)
- key = edit_line(window, label_field[cur_field].y,
+ switch (label_field[cur_field].type) {
+ case F_EDIT:
+ key = line_edit(window, label_field[cur_field].y,
label_field[cur_field].x,
- label_field[cur_field].field,
label_field[cur_field].width,
- label_field[cur_field].maxlen);
- if (label_field[cur_field].type == F_TOGGLE) {
- /* There's ony one fortunately */
- key = edit_line(window, label_field[cur_field].y,
- label_field[cur_field].x,
- label_field[cur_field].field,
- label_field[cur_field].width,
- label_field[cur_field].maxlen);
- if (key == ' ') {
- if (strcmp(label_field[cur_field].field, "YES"))
- strcpy(label_field[cur_field].field, "NO");
- } else
- strcpy(label_field[cur_field].field, "YES");
- }
- /*
- * Skip certain partitions.
- * XXX - This isn't very elegant.
- */
- /* Update mount info */
-
- for (i=0; i<MAXPARTITIONS; i++) {
- sprintf(disk_list[disk].mounts[i].fs_spec, "%s",
- label_field[(i*5)].field);
- sprintf(disk_list[disk].mounts[i].fs_mntops, "%s",
- label_field[(i*5)+1].field);
- sprintf(disk_list[disk].mounts[i].fs_file, "%s",
- label_field[(i*5)+4].field);
+ label_field[cur_field].maxlen,
+ item_selected_attr, 1,
+ label_field[cur_field].field);
+
+ /* Update mount info */
+
+ for (i=0; i<MAXPARTITIONS; i++) {
+ sprintf(disk_list[disk].mounts[i].fs_spec, "%s",
+ label_field[(i*5)].field);
+ sprintf(disk_list[disk].mounts[i].fs_file, "%s",
+ label_field[(i*5)+4].field);
+ sprintf(disk_list[disk].mounts[i].fs_vfstype, "%s",
+ label_field[(i*5)+2].field);
+ sprintf(disk_list[disk].mounts[i].fs_mntops, "%s",
+ label_field[(i*5)+1].field);
+ }
+ break;
+ case F_BUTTON:
+ key = button_press(window, label_field[cur_field]);
+ if (!key && !strcmp(label_field[cur_field].field, "OK")) {
+ done = 1;
+ continue;
+ }
+ if (!key && !strcmp(label_field[cur_field].field, "Cancel")) {
+ sprintf(errmsg, "\nUser aborted.\n");
+ dialog_clear_norefresh();
+ return (-1);
+ }
+ break;
+ case F_TOGGLE:
+ key = toggle_press(window, label_field[cur_field]);
+ break;
+ case F_TITLE:
+ default:
+ break;
}
+ next = change_field(label_field[cur_field], key);
+ if (next == -1) {
+ beep();
+ } else
+ cur_field = next;
}
if (write_bootblocks(disk) == -1)
@@ -271,7 +331,6 @@ edit_disklabel(int disk)
return(0);
}
-
void
display_disklabel(int disk)
{
diff --git a/sbin/sysinstall/label.h b/sbin/sysinstall/label.h
index f95d0c9..7af153e 100644
--- a/sbin/sysinstall/label.h
+++ b/sbin/sysinstall/label.h
@@ -1,52 +1,52 @@
struct field label_field[] = {
- { 6, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a", F_EDIT},
- { 6, 16, 3, 3, 2, 1, 6, -1, 2, "YES", F_TOGGLE},
- { 6, 27, 6, 30, 3, 1, 7, -1, 3, "MSDOS", F_EDIT},
- { 6, 39, 5, 5, 4, 1, 8, -1, 4, "1000", F_EDIT},
- { 6, 47, 30, 80, 6, 1, 9, -1, 1, "/an/example/mountpoint", F_EDIT},
- { 8, 02, 4, 4, -1, -1, -1, -1, -1, "wd0b", F_EDIT},
- { 8, 16, 3, 3, 7, 1, 11, -1, 7, "YES", F_TOGGLE},
- { 8, 27, 6, 20, 8, 2, 12, -1, 8, "MSDOS", F_EDIT},
- { 8, 39, 5, 5, 9, 3, 13, -1, 9, "1000", F_EDIT},
- { 8, 47, 30, 80, 11, 4, 14, -1, 6, "/an/example/mountpoint", F_EDIT},
- {10, 02, 10, 10, -1, -1, -1, -1, -1, "wd0c", F_EDIT},
- {10, 16, 3, 3, 12, 6, 16, -1, 12, "YES", F_TOGGLE},
- {10, 27, 6, 20, 13, 7, 17, -1, 13, "MSDOS", F_EDIT},
- {10, 39, 5, 5, 14, 8, 18, -1, 14, "1000", F_EDIT},
- {10, 47, 30, 80, 16, 9, 19, -1, 11, "/an/example/mountpoint", F_EDIT},
- {12, 02, 10, 10, -1, -1, -1, -1, -1, "wd0d", F_EDIT},
- {12, 16, 3, 3, 17, 11, 21, -1, 17, "YES", F_TOGGLE},
- {12, 27, 6, 20, 18, 12, 22, -1, 18, "MSDOS", F_EDIT},
- {12, 39, 5, 5, 19, 13, 23, -1, 19, "1000", F_EDIT},
- {12, 47, 30, 80, 21, 14, 24, -1, 16, "/an/example/mountpoint", F_EDIT},
- {14, 02, 10, 10, -1, -1, -1, -1, -1, "wd0e", F_EDIT},
- {14, 16, 3, 3, 22, 16, 26, -1, 22, "YES", F_TOGGLE},
- {14, 27, 6, 20, 23, 17, 27, -1, 23, "MSDOS", F_EDIT},
- {14, 39, 5, 5, 24, 18, 28, -1, 24, "1000", F_EDIT},
- {14, 47, 30, 80, 26, 19, 29, -1, 21, "/an/example/mountpoint", F_EDIT},
- {16, 02, 10, 10, -1, -1, -1, -1, -1, "wd0f", F_EDIT},
- {16, 16, 3, 3, 27, 21, 31, -1, 27, "YES", F_TOGGLE},
- {16, 27, 6, 20, 28, 22, 32, -1, 28, "MSDOS", F_EDIT},
- {16, 39, 5, 5, 29, 23, 33, -1, 29, "1000", F_EDIT},
- {16, 47, 30, 80, 31, 24, 34, -1, 26, "/an/example/mountpoint", F_EDIT},
- {18, 02, 10, 10, -1, -1, -1, -1, -1, "wd0g", F_EDIT},
- {18, 16, 3, 3, 32, 26, 36, -1, 32, "YES", F_TOGGLE},
- {18, 27, 6, 20, 33, 27, 37, -1, 33, "MSDOS", F_EDIT},
- {18, 39, 5, 5, 34, 28, 38, -1, 34, "1000", F_EDIT},
- {18, 47, 30, 80, 36, 29, 39, -1, 31, "/an/example/mountpoint", F_EDIT},
- {20, 02, 10, 10, -1, -1, -1, -1, -1, "wd0h", F_EDIT},
- {20, 16, 3, 3, 37, 31, 1, -1, 37, "YES", F_TOGGLE},
- {20, 27, 6, 20, 38, 32, 1, -1, 38, "MSDOS", F_EDIT},
- {20, 39, 5, 5, 39, 33, 1, -1, 39, "1000", F_EDIT},
- {20, 47, 30, 80, 1, 34, 1, -1, 1, "/an/example/mountpoint", F_EDIT},
- { 0, 27, 17, 17, -1, -1, -1, -1, -1, "Disk label editor", F_TITLE},
- { 4, 2, 11, 11, -1, -1, -1, -1, -1, "Partition", F_TITLE},
- { 4, 14, 8, 8, -1, -1, -1, -1, -1, "Preserve", F_TITLE},
- { 4, 25, 10, 10, -1, -1, -1, -1, -1, "Filesystem", F_TITLE},
- { 4, 39, 5, 5, -1, -1, -1, -1, -1, "Size", F_TITLE},
- { 4, 47, 10, 10, -1, -1, -1, -1, -1, "Mountpoint", F_TITLE},
- { 2, 34, 11, 11, -1, -1, -1, -1, -1, "Free space:", F_EDIT},
- { 2, 47, 6, 6, -1, -1, -1, -1, -1, "000000", F_EDIT},
- {22, 30, 2, 2, -1, -1, -1, -1, -1, "OK", F_BUTTON},
- {22, 50, 2, 2, -1, -1, -1, -1, -1, "Cancel", F_BUTTON},
+ { 6, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a", F_TITLE, 0, 0},
+ { 6, 16, 4, 4, -1, 48, 6, 49, 2, "YES", F_EDIT, 0, 0},
+ { 6, 27, 7, 7, -1, 48, 7, 1, 3, "MSDOS", F_EDIT, 0, 0},
+ { 6, 39, 5, 5, -1, 49, 8, 2, 4, "1000", F_EDIT, 0, 0},
+ { 6, 47, 30, 79, -1, 49, 9, 3, 6, "/an/example/mountpoint", F_EDIT, 0, 0},
+ { 8, 02, 4, 4, -1, -1, -1, -1, -1, "wd0b", F_TITLE, 0, 0},
+ { 8, 16, 4, 4, -1, 1, 11, 4, 7, "YES", F_EDIT, 0, 0},
+ { 8, 27, 7, 7, -1, 2, 12, 6, 8, "MSDOS", F_EDIT, 0, 0},
+ { 8, 39, 5, 5, -1, 3, 13, 7, 9, "1000", F_EDIT, 0, 0},
+ { 8, 47, 30, 79, -1, 4, 14, 8, 11, "/an/example/mountpoint", F_EDIT, 0, 0},
+ {10, 02, 10, 10, -1, -1, -1, -1, -1, "wd0c", F_TITLE, 0, 0},
+ {10, 16, 4, 4, -1, 6, 16, 9, 12, "YES", F_EDIT, 0, 0},
+ {10, 27, 7, 7, -1, 7, 17, 11, 13, "MSDOS", F_EDIT, 0, 0},
+ {10, 39, 5, 5, -1, 8, 18, 12, 14, "1000", F_EDIT, 0, 0},
+ {10, 47, 30, 79, -1, 9, 19, 13, 16, "/an/example/mountpoint", F_EDIT, 0, 0},
+ {12, 02, 10, 10, -1, -1, -1, -1, -1, "wd0d", F_TITLE, 0, 0},
+ {12, 16, 4, 4, -1, 11, 21, 14, 17, "YES", F_EDIT, 0, 0},
+ {12, 27, 7, 7, -1, 12, 22, 16, 18, "MSDOS", F_EDIT, 0, 0},
+ {12, 39, 5, 5, -1, 13, 23, 17, 19, "1000", F_EDIT, 0, 0},
+ {12, 47, 30, 79, -1, 14, 24, 18, 21, "/an/example/mountpoint", F_EDIT, 0, 0},
+ {14, 02, 10, 10, -1, -1, -1, -1, -1, "wd0e", F_TITLE, 0, 0},
+ {14, 16, 4, 4, -1, 16, 26, 19, 22, "YES", F_EDIT, 0, 0},
+ {14, 27, 7, 7, -1, 17, 27, 21, 23, "MSDOS", F_EDIT, 0, 0},
+ {14, 39, 5, 5, -1, 18, 28, 22, 24, "1000", F_EDIT, 0, 0},
+ {14, 47, 30, 79, -1, 19, 29, 23, 26, "/an/example/mountpoint", F_EDIT, 0, 0},
+ {16, 02, 10, 10, -1, -1, -1, -1, -1, "wd0f", F_TITLE, 0, 0},
+ {16, 16, 4, 4, -1, 21, 31, 24, 27, "YES", F_EDIT, 0, 0},
+ {16, 27, 7, 7, -1, 22, 32, 26, 28, "MSDOS", F_EDIT, 0, 0},
+ {16, 39, 5, 5, -1, 23, 33, 27, 29, "1000", F_EDIT, 0, 0},
+ {16, 47, 30, 79, -1, 24, 34, 28, 31, "/an/example/mountpoint", F_EDIT, 0, 0},
+ {18, 02, 10, 10, -1, -1, -1, -1, -1, "wd0g", F_TITLE, 0, 0},
+ {18, 16, 4, 4, -1, 26, 36, 29, 32, "YES", F_EDIT, 0, 0},
+ {18, 27, 7, 7, -1, 27, 37, 31, 33, "MSDOS", F_EDIT, 0, 0},
+ {18, 39, 5, 5, -1, 28, 38, 32, 34, "1000", F_EDIT, 0, 0},
+ {18, 47, 30, 79, -1, 29, 39, 33, 36, "/an/example/mountpoint", F_EDIT, 0, 0},
+ {20, 02, 10, 10, -1, -1, -1, -1, -1, "wd0h", F_TITLE, 0, 0},
+ {20, 16, 4, 4, -1, 31, 48, 34, 37, "YES", F_EDIT, 0, 0},
+ {20, 27, 7, 7, -1, 32, 48, 36, 38, "MSDOS", F_EDIT, 0, 0},
+ {20, 39, 5, 5, -1, 33, 49, 37, 39, "1000", F_EDIT, 0, 0},
+ {20, 47, 30, 79, 1, 34, 49, 38, 48, "/an/example/mountpoint", F_EDIT, 0, 0},
+ { 0, 27, 17, 17, -1, -1, -1, -1, -1, "Disk label editor", F_TITLE, 0, 0},
+ { 4, 2, 11, 11, -1, -1, -1, -1, -1, "Partition", F_TITLE, 0, 0},
+ { 4, 14, 8, 8, -1, -1, -1, -1, -1, "Preserve", F_TITLE, 0, 0},
+ { 4, 25, 10, 10, -1, -1, -1, -1, -1, "Filesystem", F_TITLE, 0, 0},
+ { 4, 39, 5, 5, -1, -1, -1, -1, -1, "Size", F_TITLE, 0, 0},
+ { 4, 47, 10, 10, -1, -1, -1, -1, -1, "Mountpoint", F_TITLE, 0, 0},
+ { 2, 02, 11, 11, -1, -1, -1, -1, -1, "Free space:", F_EDIT, 0, 0},
+ { 2, 15, 6, 6, -1, -1, -1, -1, -1, "000000", F_TITLE, 0, 0},
+ {22, 20, 2, 2, -1, 36, 1, 39, 49, "OK", F_BUTTON, 0, 0},
+ {22, 45, 2, 2, -1, 38, 3, 48, 1, "Cancel", F_BUTTON, 0, 0}
};
diff --git a/sbin/sysinstall/mbr.c b/sbin/sysinstall/mbr.c
index f6644dd..e7189b7 100644
--- a/sbin/sysinstall/mbr.c
+++ b/sbin/sysinstall/mbr.c
@@ -226,18 +226,21 @@ get_geom_values(int disk)
int key = 0;
int cur_field = 0;
int next = 0;
+ int done=0;
struct field field[] = {
- {2, 28, 06, 10, 01, 02, 01, -1, 01, "Unset"},
- {4, 28, 06, 10, 02, 00, 02, -1, 02, "Unset"},
- {6, 28, 06, 10, 00, 01, 00, -1, 00, "Unset"},
- {0, 07, 24, 24, -1, -1, -1, -1, -1, "BIOS geometry parameters"},
- {2, 02, 20, 20, -1, -1, -1, -1, -1, "Number of cylinders:"},
- {4, 02, 25, 25, -1, -1, -1, -1, -1, "Number of tracks (heads):"},
- {6, 02, 18, 18, -1, -1, -1, -1, -1, "Number of sectors:"}
+{2, 28, 06, 10, 01, 04, 01, 4, 01, "Unset", F_EDIT, 0, 0},
+{4, 28, 06, 10, 02, 00, 02, 0, 02, "Unset", F_EDIT, 0, 0},
+{6, 28, 06, 10, 03, 01, 03, 1, 03, "Unset", F_EDIT, 0, 0},
+{10, 7, 2, 2, 4, 2, 4, 2, 4, "OK", F_BUTTON, 0, 0},
+{10, 20, 6, 6, 0, 3, 0, 3, 0, "Cancel", F_BUTTON, 0, 0},
+{0, 07, 24, 24, -1, -1, -1, -1, -1, "BIOS geometry parameters", F_TITLE, 0, 0},
+{2, 02, 20, 20, -1, -1, -1, -1, -1, "Number of cylinders:", F_TITLE, 0, 0},
+{4, 02, 25, 25, -1, -1, -1, -1, -1, "Number of tracks (heads):", F_TITLE, 0, 0},
+{6, 02, 18, 18, -1, -1, -1, -1, -1, "Number of sectors:", F_TITLE, 0, 0}
};
- if (!(window = newwin(10, 40, 5, 20))) {
+ if (!(window = newwin(14, 40, 5, 20))) {
sprintf(errmsg, "Failed to open window for geometry editor");
return (-1);
};
@@ -245,17 +248,38 @@ get_geom_values(int disk)
keypad(window, TRUE);
dialog_clear_norefresh();
- draw_box(window, 0, 0, 9, 40, dialog_attr, border_attr);
+ draw_box(window, 0, 0, 14, 40, dialog_attr, border_attr);
- while (key != ESC) {
+ done = 0;
+ while (!done && (key != ESC)) {
sprintf(field[0].field, "%ld", lbl->d_ncylinders);
sprintf(field[1].field, "%ld", lbl->d_ntracks);
sprintf(field[2].field, "%ld", lbl->d_nsectors);
disp_fields(window, field, sizeof(field)/sizeof(struct field));
- key = edit_line(window, field[cur_field].y, field[cur_field].x,
- field[cur_field].field, field[cur_field].width,
- field[cur_field].maxlen);
+ switch (field[cur_field].type) {
+ case F_EDIT:
+ key = line_edit(window, field[cur_field].y, field[cur_field].x,
+ field[cur_field].width, field[cur_field].maxlen,
+ item_selected_attr, 1, field[cur_field].field);
+ break;
+ case F_BUTTON:
+ key = button_press(window, field[cur_field]);
+ if (!key && !strcmp(field[cur_field].field, "OK")) {
+ done = 1;
+ continue;
+ }
+ if (!key && !strcmp(field[cur_field].field, "Cancel")) {
+ sprintf(errmsg, "\nUser aborted.\n");
+ dialog_clear_norefresh();
+ return (-1);
+ }
+ case F_TOGGLE:
+ case F_TITLE:
+ default:
+ break;
+ }
+
next = change_field(field[cur_field], key);
if (next == -1)
beep();
@@ -320,7 +344,7 @@ edit_mbr(int disk)
return(-1);
}
- if (!(window = newwin(24, 79, 0, 0))) {
+ if (!(window = newwin(LINES, COLS, 0, 0))) {
sprintf(errmsg, "Failed to open window for MBR editor\n");
return (-1);
};
@@ -331,7 +355,8 @@ edit_mbr(int disk)
draw_box(window, 0, 0, 24, 79, dialog_attr, border_attr);
cur_field = 1;
- while (key != ESC) {
+ ok = 0;
+ while (!ok && (key != ESC)) {
for (i=0; i < NDOSPART; i++) {
sprintf(mbr_field[(i*12)+1].field, "%s", part_type(mbr->dospart[i].dp_typ));
sprintf(mbr_field[(i*12)+2].field, "%ld", mbr->dospart[i].dp_start);
@@ -350,10 +375,12 @@ edit_mbr(int disk)
disp_fields(window, mbr_field, sizeof(mbr_field)/sizeof(struct field));
switch (mbr_field[cur_field].type) {
case F_EDIT:
- key = edit_line(window, mbr_field[cur_field].y,
- mbr_field[cur_field].x,
- mbr_field[cur_field].field, mbr_field[cur_field].width,
- mbr_field[cur_field].maxlen);
+ key = line_edit(window, mbr_field[cur_field].y,
+ mbr_field[cur_field].x,
+ mbr_field[cur_field].width,
+ mbr_field[cur_field].maxlen,
+ item_selected_attr, 1,
+ mbr_field[cur_field].field);
/* Propagate changes to MBR */
for (i=0; i < NDOSPART; i++) {
mbr->dospart[i].dp_start = atoi(mbr_field[(i*12)+2].field);
@@ -365,16 +392,29 @@ edit_mbr(int disk)
mbr->dospart[i].dp_esect = atoi(mbr_field[(i*12)+9].field);
mbr->dospart[i].dp_size = atoi(mbr_field[(i*12)+10].field);
}
- next = change_field(mbr_field[cur_field], key);
- if (next == -1)
- beep();
- else
- cur_field = next;
- break;
+ break;
+ case F_BUTTON:
+ key = button_press(window, mbr_field[cur_field]);
+ if (!key && !strcmp(mbr_field[cur_field].field, "OK")) {
+ ok = 1;
+ continue;
+ }
+ if (!key && !strcmp(mbr_field[cur_field].field, "Cancel")) {
+ sprintf(errmsg, "\nUser aborted.\n");
+ dialog_clear_norefresh();
+ return (-1);
+ }
+ break;
+ case F_TOGGLE:
case F_TITLE:
default:
break;
}
+ next = change_field(mbr_field[cur_field], key);
+ if (next == -1)
+ beep();
+ else
+ cur_field = next;
}
sprintf(scratch, "\nWriting a new master boot record can erase the current disk contents.\n\n Are you sure you want to write the new MBR?\n");
diff --git a/sbin/sysinstall/mbr.h b/sbin/sysinstall/mbr.h
index 134f832..8ae2380 100644
--- a/sbin/sysinstall/mbr.h
+++ b/sbin/sysinstall/mbr.h
@@ -1,107 +1,109 @@
struct field mbr_field[] = {
- { 0, 25, 31, -1, -1, -1, -1, -1, -1, "Master Boot Record (MBR) editor"},
- { 4, 8, 30, 30, 2, 36, 2, 13, 13, "Uknown"},
- { 5, 31, 7, 10, 3, 1, 3, 14, 14, "0"},
- { 6, 5, 5, 10, 4, 2, 6, 17, 17, "0"},
- { 6, 14, 5, 10, 5, 2, 6, 17, 15, "0"},
- { 6, 24, 5, 10, 6, 2, 6, 17, 15, "0"},
- { 7, 31, 7, 10, 7, 3, 7, 18, 18, "0"},
- { 8, 5, 5, 10, 8, 6, 10, 22, 8, "0"},
- { 8, 14, 5, 10, 9, 6, 10, 22, 9, "0"},
- { 8, 24, 5, 10, 10, 6, 10, 22, 19, "0"},
- { 9, 9, 6, 10, 11, 7, 12, 24, 11, "0"},
- { 9, 27, 5, 10, 12, 7, 12, 24, 22, "0"},
- {10, 10, 10, 10, 13, 10, 25, 24, 24, "Not Active"},
- { 4, 47, 30, 30, 14, 2, 2, 2, 1, "Uknown"},
- { 5, 70, 7, 10, 15, 3, 3, 3, 2, "0"},
- { 6, 44, 5, 10, 16, 1, 5, 1, 16, "0"},
- { 6, 54, 5, 10, 17, 1, 6, 2, 17, "0"},
- { 6, 64, 5, 10, 18, 1, 7, 3, 3, "0"},
- { 7, 70, 7, 10, 19, 6, 6, 6, 6, "0"},
- { 8, 44, 5, 10, 20, 2, 2, 2, 20, "0"},
- { 8, 54, 5, 10, 21, 3, 2, 2, 21, "0"},
- { 8, 64, 5, 10, 22, 4, 2, 2, 7, "0"},
- { 9, 48, 6, 10, 23, 2, 2, 2, 23, "0"},
- { 9, 66, 5, 10, 24, 2, 2, 2, 10, "0"},
- {10, 49, 10, 10, 25, 2, 2, 2, 12, "Not Active"},
- {14, 8, 30, 30, 26, 12, 26, 2, 14, "Uknown"},
- {15, 31, 7, 10, 27, 25, 27, 3, 15, "0"},
- {16, 5, 5, 10, 28, 26, 30, 1, 16, "0"},
- {16, 14, 5, 10, 29, 26, 30, 2, 16, "0"},
- {16, 24, 5, 10, 30, 26, 30, 3, 16, "0"},
- {17, 31, 7, 10, 31, 27, 31, 6, 17, "0"},
- {18, 5, 5, 10, 32, 30, 34, 2, 2, "0"},
- {18, 14, 5, 10, 33, 30, 34, 2, 2, "0"},
- {18, 24, 5, 10, 34, 30, 34, 2, 3, "0"},
- {19, 9, 6, 10, 35, 31, 36, 2, 2, "0"},
- {19, 27, 5, 10, 36, 31, 36, 2, 2, "0"},
- {20, 10, 10, 10, 37, 34, 01, 2, 2, "Not Active"},
- {14, 47, 30, 30, 38, 2, 2, 2, 4, "Uknown"},
- {15, 70, 7, 10, 39, 3, 3, 3, 4, "0"},
- {16, 44, 5, 10, 40, 1, 5, 1, 4, "0"},
- {16, 54, 5, 10, 41, 1, 6, 2, 5, "0"},
- {16, 64, 5, 10, 42, 1, 7, 3, 6, "0"},
- {17, 70, 7, 10, 43, 6, 6, 6, 7, "0"},
- {18, 44, 5, 10, 44, 2, 2, 2, 2, "0"},
- {18, 54, 5, 10, 45, 3, 2, 2, 2, "0"},
- {18, 64, 5, 10, 46, 4, 2, 2, 3, "0"},
- {19, 48, 6, 10, 47, 2, 2, 2, 2, "0"},
- {19, 66, 5, 10, 48, 2, 2, 2, 2, "0"},
- {20, 49, 10, 10, 01, 2, 2, 2, 2, "Not Active"},
- {2, 15, 11, -1, -1, -1, -1, -1, -1, "Partition 1"},
- {2, 55, 11, -1, -1, -1, -1, -1, -1, "Partition 2"},
- {12, 15, 11, -1, -1, -1, -1, -1, -1, "Partition 3"},
- {12, 55, 11, -1, -1, -1, -1, -1, -1, "Partition 4"},
- { 4, 2, 5, -1, -1, -1, -1, -1, -1, "Type:"},
- { 5, 2, 28, -1, -1, -1, -1, -1, -1, "Starting at absolute sector:"},
- { 6, 2, 2, -1, -1, -1, -1, -1, -1, "C:"},
- { 6, 11, 2, -1, -1, -1, -1, -1, -1, "H:"},
- { 6, 21, 2, -1, -1, -1, -1, -1, -1, "S:"},
- { 7, 2, 26, -1, -1, -1, -1, -1, -1, "Ending at absolute sector:"},
- { 8, 2, 2, -1, -1, -1, -1, -1, -1, "C:"},
- { 8, 11, 2, -1, -1, -1, -1, -1, -1, "H:"},
- { 8, 21, 2, -1, -1, -1, -1, -1, -1, "S:"},
- { 9, 02, 7, -1, -1, -1, -1, -1, -1, "Size: ("},
- { 9, 18, 8, -1, -1, -1, -1, -1, -1, "sectors)"},
- { 9, 33, 2, -1, -1, -1, -1, -1, -1, "Mb"},
- {10, 2, 7, -1, -1, -1, -1, -1, -1, "Status:"},
- { 4, 41, 5, -1, -1, -1, -1, -1, -1, "Type:"},
- { 5, 41, 28, -1, -1, -1, -1, -1, -1, "Starting at absolute sector:"},
- { 6, 41, 2, -1, -1, -1, -1, -1, -1, "C:"},
- { 6, 51, 2, -1, -1, -1, -1, -1, -1, "H:"},
- { 6, 61, 2, -1, -1, -1, -1, -1, -1, "S:"},
- { 7, 41, 26, -1, -1, -1, -1, -1, -1, "Ending at absolute sector:"},
- { 8, 41, 2, -1, -1, -1, -1, -1, -1, "C:"},
- { 8, 51, 2, -1, -1, -1, -1, -1, -1, "H:"},
- { 8, 61, 2, -1, -1, -1, -1, -1, -1, "S:"},
- { 9, 41, 7, -1, -1, -1, -1, -1, -1, "Size: ("},
- { 9, 57, 8, -1, -1, -1, -1, -1, -1, "sectors)"},
- { 9, 72, 2, -1, -1, -1, -1, -1, -1, "Mb"},
- {10, 41, 7, -1, -1, -1, -1, -1, -1, "Status:"},
- {14, 02, 5, -1, -1, -1, -1, -1, -1, "Type:"},
- {15, 02, 28, -1, -1, -1, -1, -1, -1, "Starting at absolute sector:"},
- {16, 2, 2, -1, -1, -1, -1, -1, -1, "C:"},
- {16, 11, 2, -1, -1, -1, -1, -1, -1, "H:"},
- {16, 21, 2, -1, -1, -1, -1, -1, -1, "S:"},
- {17, 02, 26, -1, -1, -1, -1, -1, -1, "Ending at absolute sector:"},
- {18, 02, 2, -1, -1, -1, -1, -1, -1, "C:"},
- {18, 11, 2, -1, -1, -1, -1, -1, -1, "H:"},
- {18, 21, 2, -1, -1, -1, -1, -1, -1, "S:"},
- {19, 02, 7, -1, -1, -1, -1, -1, -1, "Size: ("},
- {19, 18, 8, -1, -1, -1, -1, -1, -1, "sectors)"},
- {19, 33, 2, -1, -1, -1, -1, -1, -1, "Mb"},
- {20, 02, 7, -1, -1, -1, -1, -1, -1, "Status:"},
- {14, 41, 5, -1, -1, -1, -1, -1, -1, "Type:"},
- {15, 41, 28, -1, -1, -1, -1, -1, -1, "Starting at absolute sector:"},
- {16, 41, 2, -1, -1, -1, -1, -1, -1, "C:"},
- {16, 51, 2, -1, -1, -1, -1, -1, -1, "H:"},
- {16, 61, 2, -1, -1, -1, -1, -1, -1, "S:"},
- {17, 41, 26, -1, -1, -1, -1, -1, -1, "Ending at absolute sector:"},
- {18, 41, 2, -1, -1, -1, -1, -1, -1, "C:"},
- {18, 51, 2, -1, -1, -1, -1, -1, -1, "H:"},
- {18, 61, 2, -1, -1, -1, -1, -1, -1, "S:"},
- {19, 41, 7, -1, -1, -1, -1, -1, -1, "Size: ("},
- {19, 57, 8, -1, -1, -1, -1, -1, -1, "sectors)"},
- {19, 72, 2, -1, -1, -1, -1, -1, -1, "Mb"},
- {20, 41, 7, -1, -1, -1, -1, -1, -1, "Status:"}
+ { 0, 25, 31, -1, -1, -1, -1, -1, -1, "Master Boot Record (MBR) editor", F_TITLE, 0, 0},
+ { 4, 8, 30, 30, 2, 49, 2, 50, 2, "Uknown", F_EDIT, 0, 0},
+ { 5, 31, 7, 10, 3, 1, 3, 1, 3, "0", F_EDIT, 0, 0},
+ { 6, 5, 5, 10, 4, 2, 6, 2, 4, "0", F_EDIT, 0, 0},
+ { 6, 14, 5, 10, 5, 2, 6, 3, 5, "0", F_EDIT, 0, 0},
+ { 6, 24, 5, 10, 6, 2, 6, 4, 6, "0", F_EDIT, 0, 0},
+ { 7, 31, 7, 10, 7, 3, 7, 5, 7, "0", F_EDIT, 0, 0},
+ { 8, 5, 5, 10, 8, 6, 10, 6, 8, "0", F_EDIT, 0, 0},
+ { 8, 14, 5, 10, 9, 6, 10, 7, 9, "0", F_EDIT, 0, 0},
+ { 8, 24, 5, 10, 10, 6, 10, 8, 10, "0", F_EDIT, 0, 0},
+ { 9, 9, 6, 10, 11, 7, 12, 9, 11, "0", F_EDIT, 0, 0},
+ { 9, 27, 5, 10, 12, 7, 12, 10, 12, "0", F_EDIT, 0, 0},
+ {10, 10, 10, 10, 13, 10, 25, 11, 13, "Not Active", F_EDIT, 0, 0},
+ { 4, 47, 30, 30, 14, 50, 14, 12, 14, "Uknown", F_EDIT, 0, 0},
+ { 5, 70, 7, 10, 15, 13, 15, 13, 15, "0", F_EDIT, 0, 0},
+ { 6, 44, 5, 10, 16, 14, 18, 14, 16, "0", F_EDIT, 0, 0},
+ { 6, 54, 5, 10, 17, 14, 18, 15, 17, "0", F_EDIT, 0, 0},
+ { 6, 64, 5, 10, 18, 14, 18, 16, 18, "0", F_EDIT, 0, 0},
+ { 7, 70, 7, 10, 19, 15, 19, 17, 19, "0", F_EDIT, 0, 0},
+ { 8, 44, 5, 10, 20, 18, 22, 18, 20, "0", F_EDIT, 0, 0},
+ { 8, 54, 5, 10, 21, 18, 22, 19, 21, "0", F_EDIT, 0, 0},
+ { 8, 64, 5, 10, 22, 18, 22, 20, 22, "0", F_EDIT, 0, 0},
+ { 9, 48, 6, 10, 23, 19, 24, 21, 23, "0", F_EDIT, 0, 0},
+ { 9, 66, 5, 10, 24, 20, 24, 22, 24, "0", F_EDIT, 0, 0},
+ {10, 49, 10, 10, 25, 22, 37, 23, 25, "Not Active", F_EDIT, 0, 0},
+ {14, 8, 30, 30, 26, 12, 26, 24, 26, "Uknown", F_EDIT, 0, 0},
+ {15, 31, 7, 10, 27, 25, 27, 25, 27, "0", F_EDIT, 0, 0},
+ {16, 5, 5, 10, 28, 26, 30, 26, 28, "0", F_EDIT, 0, 0},
+ {16, 14, 5, 10, 29, 26, 30, 27, 29, "0", F_EDIT, 0, 0},
+ {16, 24, 5, 10, 30, 26, 30, 28, 30, "0", F_EDIT, 0, 0},
+ {17, 31, 7, 10, 31, 27, 31, 29, 31, "0", F_EDIT, 0, 0},
+ {18, 5, 5, 10, 32, 30, 34, 30, 32, "0", F_EDIT, 0, 0},
+ {18, 14, 5, 10, 33, 30, 34, 31, 33, "0", F_EDIT, 0, 0},
+ {18, 24, 5, 10, 34, 30, 34, 32, 34, "0", F_EDIT, 0, 0},
+ {19, 9, 6, 10, 35, 31, 36, 33, 35, "0", F_EDIT, 0, 0},
+ {19, 27, 5, 10, 36, 31, 36, 34, 36, "0", F_EDIT, 0, 0},
+ {20, 10, 10, 10, 37, 34, 49, 35, 37, "Not Active", F_EDIT, 0, 0},
+ {14, 47, 30, 30, 38, 24, 38, 36, 38, "Uknown", F_EDIT, 0, 0},
+ {15, 70, 7, 10, 39, 37, 39, 37, 39, "0", F_EDIT, 0, 0},
+ {16, 44, 5, 10, 40, 38, 42, 38, 40, "0", F_EDIT, 0, 0},
+ {16, 54, 5, 10, 41, 38, 42, 39, 41, "0", F_EDIT, 0, 0},
+ {16, 64, 5, 10, 42, 38, 42, 40, 42, "0", F_EDIT, 0, 0},
+ {17, 70, 7, 10, 43, 39, 43, 41, 43, "0", F_EDIT, 0, 0},
+ {18, 44, 5, 10, 44, 42, 46, 42, 44, "0", F_EDIT, 0, 0},
+ {18, 54, 5, 10, 45, 43, 46, 43, 45, "0", F_EDIT, 0, 0},
+ {18, 64, 5, 10, 46, 43, 46, 44, 46, "0", F_EDIT, 0, 0},
+ {19, 48, 6, 10, 47, 43, 48, 45, 47, "0", F_EDIT, 0, 0},
+ {19, 66, 5, 10, 48, 44, 48, 46, 48, "0", F_EDIT, 0, 0},
+ {20, 49, 10, 10, 49, 46, 50, 47, 49, "Not Active", F_EDIT, 0, 0},
+ {22, 15, 2, 2, 50, 36, 1, 48, 50, "OK", F_BUTTON, 0, 0},
+ {22, 50, 6, 6, 1, 48, 13, 49, 1, "Cancel", F_BUTTON, 0, 0},
+ {2, 15, 11, -1, -1, -1, -1, -1, -1, "Partition 1", F_TITLE, 0, 0},
+ {2, 55, 11, -1, -1, -1, -1, -1, -1, "Partition 2", F_TITLE, 0, 0},
+ {12, 15, 11, -1, -1, -1, -1, -1, -1, "Partition 3", F_TITLE, 0, 0},
+ {12, 55, 11, -1, -1, -1, -1, -1, -1, "Partition 4", F_TITLE, 0, 0},
+ { 4, 2, 5, -1, -1, -1, -1, -1, -1, "Type:", F_TITLE, 0, 0},
+ { 5, 2, 28, -1, -1, -1, -1, -1, -1, "Starting at absolute sector:", F_TITLE, 0, 0},
+ { 6, 2, 2, -1, -1, -1, -1, -1, -1, "C:", F_TITLE, 0, 0},
+ { 6, 11, 2, -1, -1, -1, -1, -1, -1, "H:", F_TITLE, 0, 0},
+ { 6, 21, 2, -1, -1, -1, -1, -1, -1, "S:", F_TITLE, 0, 0},
+ { 7, 2, 26, -1, -1, -1, -1, -1, -1, "Ending at absolute sector:", F_TITLE, 0, 0},
+ { 8, 2, 2, -1, -1, -1, -1, -1, -1, "C:", F_TITLE, 0, 0},
+ { 8, 11, 2, -1, -1, -1, -1, -1, -1, "H:", F_TITLE, 0, 0},
+ { 8, 21, 2, -1, -1, -1, -1, -1, -1, "S:", F_TITLE, 0, 0},
+ { 9, 02, 7, -1, -1, -1, -1, -1, -1, "Size: (", F_TITLE, 0, 0},
+ { 9, 18, 8, -1, -1, -1, -1, -1, -1, "sectors)", F_TITLE, 0, 0},
+ { 9, 33, 2, -1, -1, -1, -1, -1, -1, "Mb", F_TITLE, 0, 0},
+ {10, 2, 7, -1, -1, -1, -1, -1, -1, "Status:", F_TITLE, 0, 0},
+ { 4, 41, 5, -1, -1, -1, -1, -1, -1, "Type:", F_TITLE, 0, 0},
+ { 5, 41, 28, -1, -1, -1, -1, -1, -1, "Starting at absolute sector:", F_TITLE, 0, 0},
+ { 6, 41, 2, -1, -1, -1, -1, -1, -1, "C:", F_TITLE, 0, 0},
+ { 6, 51, 2, -1, -1, -1, -1, -1, -1, "H:", F_TITLE, 0, 0},
+ { 6, 61, 2, -1, -1, -1, -1, -1, -1, "S:", F_TITLE, 0, 0},
+ { 7, 41, 26, -1, -1, -1, -1, -1, -1, "Ending at absolute sector:", F_TITLE, 0, 0},
+ { 8, 41, 2, -1, -1, -1, -1, -1, -1, "C:", F_TITLE, 0, 0},
+ { 8, 51, 2, -1, -1, -1, -1, -1, -1, "H:", F_TITLE, 0, 0},
+ { 8, 61, 2, -1, -1, -1, -1, -1, -1, "S:", F_TITLE, 0, 0},
+ { 9, 41, 7, -1, -1, -1, -1, -1, -1, "Size: (", F_TITLE, 0, 0},
+ { 9, 57, 8, -1, -1, -1, -1, -1, -1, "sectors)", F_TITLE, 0, 0},
+ { 9, 72, 2, -1, -1, -1, -1, -1, -1, "Mb", F_TITLE, 0, 0},
+ {10, 41, 7, -1, -1, -1, -1, -1, -1, "Status:", F_TITLE, 0, 0},
+ {14, 02, 5, -1, -1, -1, -1, -1, -1, "Type:", F_TITLE, 0, 0},
+ {15, 02, 28, -1, -1, -1, -1, -1, -1, "Starting at absolute sector:", F_TITLE, 0, 0},
+ {16, 2, 2, -1, -1, -1, -1, -1, -1, "C:", F_TITLE, 0, 0},
+ {16, 11, 2, -1, -1, -1, -1, -1, -1, "H:", F_TITLE, 0, 0},
+ {16, 21, 2, -1, -1, -1, -1, -1, -1, "S:", F_TITLE, 0, 0},
+ {17, 02, 26, -1, -1, -1, -1, -1, -1, "Ending at absolute sector:", F_TITLE, 0, 0},
+ {18, 02, 2, -1, -1, -1, -1, -1, -1, "C:", F_TITLE, 0, 0},
+ {18, 11, 2, -1, -1, -1, -1, -1, -1, "H:", F_TITLE, 0, 0},
+ {18, 21, 2, -1, -1, -1, -1, -1, -1, "S:", F_TITLE, 0, 0},
+ {19, 02, 7, -1, -1, -1, -1, -1, -1, "Size: (", F_TITLE, 0, 0},
+ {19, 18, 8, -1, -1, -1, -1, -1, -1, "sectors)", F_TITLE, 0, 0},
+ {19, 33, 2, -1, -1, -1, -1, -1, -1, "Mb", F_TITLE, 0, 0},
+ {20, 02, 7, -1, -1, -1, -1, -1, -1, "Status:", F_TITLE, 0, 0},
+ {14, 41, 5, -1, -1, -1, -1, -1, -1, "Type:", F_TITLE, 0, 0},
+ {15, 41, 28, -1, -1, -1, -1, -1, -1, "Starting at absolute sector:", F_TITLE, 0, 0},
+ {16, 41, 2, -1, -1, -1, -1, -1, -1, "C:", F_TITLE, 0, 0},
+ {16, 51, 2, -1, -1, -1, -1, -1, -1, "H:", F_TITLE, 0, 0},
+ {16, 61, 2, -1, -1, -1, -1, -1, -1, "S:", F_TITLE, 0, 0},
+ {17, 41, 26, -1, -1, -1, -1, -1, -1, "Ending at absolute sector:", F_TITLE, 0, 0},
+ {18, 41, 2, -1, -1, -1, -1, -1, -1, "C:", F_TITLE, 0, 0},
+ {18, 51, 2, -1, -1, -1, -1, -1, -1, "H:", F_TITLE, 0, 0},
+ {18, 61, 2, -1, -1, -1, -1, -1, -1, "S:", F_TITLE, 0, 0},
+ {19, 41, 7, -1, -1, -1, -1, -1, -1, "Size: (", F_TITLE, 0, 0},
+ {19, 57, 8, -1, -1, -1, -1, -1, -1, "sectors)", F_TITLE, 0, 0},
+ {19, 72, 2, -1, -1, -1, -1, -1, -1, "Mb", F_TITLE, 0, 0},
+ {20, 41, 7, -1, -1, -1, -1, -1, -1, "Status:", F_TITLE, 0, 0}
};
diff --git a/sbin/sysinstall/stage1.c b/sbin/sysinstall/stage1.c
index 554061a..e268d5a 100644
--- a/sbin/sysinstall/stage1.c
+++ b/sbin/sysinstall/stage1.c
@@ -12,6 +12,7 @@
* its use.
*/
+#define DKTYPENAMES
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -53,9 +54,11 @@ char selection[30];
char *device_names[] = {"wd", "sd", "cd", "mcd", 0};
struct devconf *device_list[MAX_NO_DEVICES];
struct disk disk_list[MAX_NO_DEVICES];
+struct fstab *mounts[MAX_NO_MOUNTS];
int no_devices;
int no_disks;
+int no_mounts;
int
alloc_memory()
@@ -185,18 +188,11 @@ configure_disks()
for (i = 0; i < no_disks; i++) {
sprintf(options[(i*2)], "%d",i+1);
- if (disk_list[i].selected)
- sprintf(options[(i*2)+1], " ** %s, (%dMb) -> %s%d",
- disk_list[i].lbl.d_typename,
- disk_size(&disk_list[i].lbl),
+ sprintf(options[(i*2)+1], "%s%d: %s (%dMb)",
disk_list[i].devconf->dc_name,
- disk_list[i].devconf->dc_unit);
- else
- sprintf(options[(i*2)+1], " %s, (%dMb) -> %s%d",
+ disk_list[i].devconf->dc_unit,
disk_list[i].lbl.d_typename,
- disk_size(&disk_list[i].lbl),
- disk_list[i].devconf->dc_name,
- disk_list[i].devconf->dc_unit);
+ disk_size(&disk_list[i].lbl));
}
sprintf(options[no_disks*2], "%d", no_disks+1);
@@ -204,30 +200,30 @@ configure_disks()
dialog_clear_norefresh();
if (dialog_menu("FreeBSD Installation", scratch, -1, -1,
- min(5, no_disks), no_disks, options, selection)) {
+ min(5, no_disks+1), no_disks+1, options, selection)) {
dialog_clear_norefresh();
sprintf(scratch,"\nYou selected cancel.\n");
AskAbort(scratch);
valid = 0;
continue;
}
- choice = atoi(selection);
+ choice = atoi(selection) - 1;
if (choice == no_disks)
valid = 1;
else {
- if (edit_mbr(choice-1) == -1) {
+ if (edit_mbr(choice) == -1) {
sprintf(scratch, "\nThe following error occured while\nediting the master boot record.\n%s", errmsg);
AskAbort(scratch);
valid = 0;
continue;
};
- if (edit_disklabel(choice-1) == -1) {
+ if (edit_disklabel(choice) == -1) {
sprintf(scratch, "\nThe following error occured while\nediting the disklabel.\n%s", errmsg);
AskAbort(scratch);
valid = 0;
continue;
}
- disk_list[choice-1].selected = 1;
+ disk_list[choice].selected = 1;
}
} while (!valid);
}
@@ -235,10 +231,20 @@ configure_disks()
int
stage1()
{
- int i;
- int ok = 0;
+ int i, j;
query_devices();
configure_disks();
- exit(1);
+ /* List filesystems */
+ for (i=0; i < MAX_NO_DEVICES; i++) {
+ if (!disk_list[i].selected)
+ continue;
+ for (j=0; j < MAXPARTITIONS; j++) {
+ if ((j == OURPART) || (j == RAWPART))
+ continue;
+ if (!disk_list[i].lbl.d_partitions[j].p_size)
+ continue;
+ mounts[no_mounts++] = &disk_list[i].mounts[j];
+ }
+ }
}
diff --git a/sbin/sysinstall/sysinstall.h b/sbin/sysinstall/sysinstall.h
index 0222bcf..370cc02 100644
--- a/sbin/sysinstall/sysinstall.h
+++ b/sbin/sysinstall/sysinstall.h
@@ -19,9 +19,11 @@
#define MAX_NO_DEVICES 10
#define MAX_NO_DISKS 10
+#define MAX_NO_MOUNTS 30
#define MAX_NO_FS 30
#define MAXFS MAX_NO_FS
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c
index 1a062ed..1e87031 100644
--- a/sbin/sysinstall/utils.c
+++ b/sbin/sysinstall/utils.c
@@ -264,59 +264,3 @@ PartMb(struct disklabel *lbl,int part)
l = 1024*1024/lbl->d_secsize;
return (lbl->d_partitions[part].p_size + l/2)/l;
}
-
-void
-CleanMount(int disk, int part)
-{
- int i = MP[disk][part];
- if (Fmount[i]) {
- free(Fmount[i]);
- Fmount[i] = 0;
- }
- if (Fname[i]) {
- free(Fname[i]);
- Fname[i] = 0;
- }
- if (Ftype[i]) {
- free(Ftype[i]);
- Ftype[i] = 0;
- }
- MP[disk][part] = 0;
-}
-
-char *
-SetMount(int disk, int part, char *path)
-{
- int k;
- char buf[80];
-
- CleanMount(disk,part);
- for (k = 1; k < MAX_NO_FS; k++)
- if (!Fmount[k])
- break;
-
- if (k >= MAX_NO_FS)
- return "Maximum number of filesystems exceeded";
-
- Fmount[k] = StrAlloc(path);
- sprintf(buf, "%s%c", Dname[disk], part + 'a');
- Fname[k] = StrAlloc(buf);
- switch (Dlbl[disk]->d_partitions[part].p_fstype) {
- case FS_BSDFFS:
- Ftype[k] = StrAlloc("ufs");
- break;
- case FS_MSDOS:
- Ftype[k] = StrAlloc("msdos");
- break;
- case FS_SWAP:
- Ftype[k] = StrAlloc("swap");
- break;
- default:
- CleanMount(disk,part);
- return "Unknown filesystem-type";
- }
- Fsize[k] = (Dlbl[disk]->d_partitions[part].p_size+1024)/2048;
-
- MP[disk][part] = k;
- return NULL;
-}
OpenPOWER on IntegriCloud