From 6dd3a38fffc80f3e87914b6180ccb22d2d47f8d1 Mon Sep 17 00:00:00 2001 From: Paul Richards Date: Sat, 19 Nov 1994 17:29:19 +0000 Subject: [PATCH] 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. --- sbin/sysinstall/bootarea.c | 16 +-- sbin/sysinstall/editor.c | 190 ++++++++----------------------- sbin/sysinstall/editor.h | 2 + sbin/sysinstall/label.c | 169 +++++++++++++++++++--------- sbin/sysinstall/label.h | 100 ++++++++--------- sbin/sysinstall/mbr.c | 90 ++++++++++----- sbin/sysinstall/mbr.h | 212 ++++++++++++++++++----------------- sbin/sysinstall/stage1.c | 42 ++++--- sbin/sysinstall/sysinstall.h | 2 + sbin/sysinstall/utils.c | 56 --------- 10 files changed, 418 insertions(+), 461 deletions(-) diff --git a/sbin/sysinstall/bootarea.c b/sbin/sysinstall/bootarea.c index 00d22e20149f..44aca12fb360 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 c1cd6905c448..cdf70eec6a6a 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); - - 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); - - 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); + switch (key) { + case '\n': + case '\r': + return (0); + case KEY_UP: + case KEY_DOWN: + case KEY_BTAB: + case '\t': + default: + return (key); + } +} + +int +toggle_press(WINDOW *window, struct field field) +{ + int 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 79dd6a62e907..2783cc811a39 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 9dc8c3883d33..eb68434c8b43 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) { @@ -76,6 +78,18 @@ diskname(int disk) return (scratch); } +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) { @@ -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(); + 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].width, + label_field[cur_field].maxlen, + item_selected_attr, 1, + label_field[cur_field].field); + + /* Update mount info */ + + for (i=0; id_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 134f8324e127..8ae238021191 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 554061af6c1c..e268d5a5bfcb 100644 --- a/sbin/sysinstall/stage1.c +++ b/sbin/sysinstall/stage1.c @@ -12,6 +12,7 @@ * its use. */ +#define DKTYPENAMES #include #include #include @@ -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 0222bcf319b5..370cc020d85c 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 #include #include diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c index 1a062ed67f72..1e87031714b6 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; -}