I hope this gets my changes merged back into the current branch.
Removed a layer of menus. Auto select partition to install into -- first FreeBSD partition in MBR table. Abort if no FreeBSD partition. Added a F_BUTTON type. Fixed up label editor to show free space properly. Fixed a few bugs.
This commit is contained in:
parent
3fa6f2210c
commit
d35f2e963a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4665
@ -9,7 +9,7 @@ SRCS = bootarea.c editor.c exec.c dkcksum.c label.c main.c mbr.c \
|
||||
termcap.c utils.c makedevs.c ourcurses.c
|
||||
|
||||
CFLAGS += -Wall -g -static -I${.CURDIR}/../../sys/
|
||||
LDADD = -ldialog -lncurses -lmytinfo -lforms
|
||||
LDADD = -ldialog -lncurses -lmytinfo
|
||||
DPADD = ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO}
|
||||
|
||||
makedevs.c: dev2c.sh
|
||||
|
@ -10,17 +10,32 @@ disp_fields(WINDOW *window, struct field field[], int no_fields)
|
||||
int i, j;
|
||||
int len;
|
||||
|
||||
wattrset(window, dialog_attr);
|
||||
for (i=0; i < no_fields; i++) {
|
||||
len=strlen(field[i].field);
|
||||
wmove(window, field[i].y, field[i].x);
|
||||
for (j=0; j < field[i].width; j++)
|
||||
if (j < len)
|
||||
waddch(window, field[i].field[j]);
|
||||
else
|
||||
waddch(window, ' ');
|
||||
switch (field[i].type) {
|
||||
case F_TITLE:
|
||||
case F_EDIT:
|
||||
if (field[i].type == F_TITLE)
|
||||
wattrset(window, title_attr);
|
||||
else
|
||||
wattrset(window, dialog_attr);
|
||||
len=strlen(field[i].field);
|
||||
for (j=0; j < field[i].width; j++)
|
||||
if (j < len)
|
||||
waddch(window, field[i].field[j]);
|
||||
else
|
||||
waddch(window, ' ');
|
||||
break;
|
||||
case F_BUTTON:
|
||||
print_button(window, field[i].field,
|
||||
field[i].y,
|
||||
field[i].x,
|
||||
FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
wrefresh(window);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
@ -51,3 +66,151 @@ change_field(struct field field, int key)
|
||||
}
|
||||
return (next);
|
||||
}
|
||||
|
||||
int
|
||||
edit_line(WINDOW *window, int y, int x, char *field, int width, int maxlen)
|
||||
{
|
||||
int len;
|
||||
int key = 0;
|
||||
int fpos, dispos, curpos;
|
||||
int i;
|
||||
int done = 0;
|
||||
|
||||
len = strlen(field);
|
||||
if (len < width) {
|
||||
fpos = len;
|
||||
curpos = len;
|
||||
dispos = 0;
|
||||
} else {
|
||||
fpos = width;
|
||||
curpos = width;
|
||||
dispos = len - width;
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ struct field {
|
||||
int left;
|
||||
int right;
|
||||
char field[80];
|
||||
int type;
|
||||
};
|
||||
|
||||
#define F_EDIT 0
|
||||
#define F_TITLE 1
|
||||
#define F_BUTTON 2
|
||||
#define F_TOGGLE 3
|
||||
|
||||
int disp_fields(WINDOW *, struct field *, int);
|
||||
int change_field(struct field, int);
|
||||
int edit_line(WINDOW *, int, int, char *, int, int);
|
||||
|
@ -30,42 +30,42 @@ extern char boot2[];
|
||||
int
|
||||
disk_size(struct disklabel *lbl)
|
||||
{
|
||||
int size;
|
||||
|
||||
size = lbl->d_secsize * lbl->d_nsectors *
|
||||
int size;
|
||||
|
||||
size = lbl->d_secsize * lbl->d_nsectors *
|
||||
lbl->d_ntracks * lbl->d_ncylinders;
|
||||
return (size / 1024 / 1024);
|
||||
return (size / 1024 / 1024);
|
||||
}
|
||||
|
||||
int
|
||||
sectstoMb(int nsects, int secsize)
|
||||
{
|
||||
int size;
|
||||
|
||||
size = nsects * secsize;
|
||||
if (size)
|
||||
int size;
|
||||
|
||||
size = nsects * secsize;
|
||||
if (size)
|
||||
size /= 1024 * 1024;
|
||||
return (size);
|
||||
return (size);
|
||||
}
|
||||
|
||||
int
|
||||
Mbtosects(int Mb, int secsize)
|
||||
{
|
||||
int nsects;
|
||||
int nsects;
|
||||
|
||||
nsects = (Mb * 1024 * 1024) / secsize;
|
||||
return(nsects);
|
||||
nsects = (Mb * 1024 * 1024) / secsize;
|
||||
return(nsects);
|
||||
}
|
||||
|
||||
int
|
||||
rndtocylbdry(int size, int secpercyl)
|
||||
{
|
||||
int nocyls;
|
||||
|
||||
nocyls = size / secpercyl;
|
||||
if ((nocyls * secpercyl) < size)
|
||||
nocyls++;
|
||||
return (nocyls * secpercyl);
|
||||
int nocyls;
|
||||
|
||||
nocyls = size / secpercyl;
|
||||
if ((nocyls * secpercyl) < size)
|
||||
nocyls++;
|
||||
return (nocyls * secpercyl);
|
||||
}
|
||||
|
||||
char *
|
||||
@ -108,11 +108,12 @@ edit_disklabel(int disk)
|
||||
int key = 0;
|
||||
int next;
|
||||
int cur_field;
|
||||
int cur_part;
|
||||
int i;
|
||||
struct disklabel *lbl = &disk_list[disk].lbl;
|
||||
int offset;
|
||||
int nsects;
|
||||
int avail_sects;
|
||||
int offset, slop;
|
||||
int nsects, hog;
|
||||
int avail_sects, free;
|
||||
|
||||
lbl->d_magic = DISKMAGIC;
|
||||
bcopy("INSTALLATION", lbl->d_typename, strlen("INSTALLATION"));
|
||||
@ -126,7 +127,7 @@ edit_disklabel(int disk)
|
||||
lbl->d_sbsize = SBSIZE;
|
||||
lbl->d_npartitions = 8;
|
||||
|
||||
/* Inialise the fstab entries */
|
||||
/* Initialise the entries */
|
||||
for (i=0; i < MAXPARTITIONS; i++) {
|
||||
disk_list[disk].mounts[i].fs_spec =
|
||||
(char *)malloc(label_field[i*5].maxlen+1);
|
||||
@ -152,6 +153,9 @@ edit_disklabel(int disk)
|
||||
return (-1);
|
||||
}
|
||||
sprintf(disk_list[disk].mounts[i].fs_file, "%s", "Not Mounted");
|
||||
|
||||
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))) {
|
||||
@ -162,10 +166,39 @@ edit_disklabel(int disk)
|
||||
keypad(window, TRUE);
|
||||
|
||||
draw_box(window, 0, 0, 24, 79, dialog_attr, border_attr);
|
||||
|
||||
|
||||
cur_field = 1;
|
||||
while (key != ESC) {
|
||||
|
||||
/* Update disklabel */
|
||||
|
||||
avail_sects = lbl->d_partitions[OURPART].p_size;
|
||||
offset = lbl->d_partitions[OURPART].p_offset;
|
||||
slop = rndtocylbdry(offset, lbl->d_secpercyl) - offset;
|
||||
for (i=0; i < MAXPARTITIONS; i++) {
|
||||
if (i == OURPART)
|
||||
continue;
|
||||
if (i == RAWPART)
|
||||
continue;
|
||||
lbl->d_partitions[i].p_offset = offset;
|
||||
nsects = atoi(label_field[(i*5)+3].field);
|
||||
nsects = Mbtosects(nsects, lbl->d_secsize);
|
||||
nsects = rndtocylbdry(nsects, lbl->d_secpercyl);
|
||||
if (slop) {
|
||||
nsects += slop;
|
||||
slop = 0;
|
||||
}
|
||||
if (nsects > avail_sects)
|
||||
nsects = avail_sects;
|
||||
avail_sects -= nsects;
|
||||
offset += nsects;
|
||||
if (nsects == 0)
|
||||
lbl->d_partitions[i].p_offset = 0;
|
||||
lbl->d_partitions[i].p_size = nsects;
|
||||
lbl->d_partitions[i].p_fsize = DEFFSIZE;
|
||||
lbl->d_partitions[i].p_frag = DEFFRAG;
|
||||
}
|
||||
|
||||
for (i=0; i < MAXPARTITIONS; i++) {
|
||||
sprintf(label_field[(i*5)].field, "%s",
|
||||
disk_list[disk].mounts[i].fs_spec);
|
||||
@ -179,21 +212,47 @@ edit_disklabel(int disk)
|
||||
disk_list[disk].mounts[i].fs_file);
|
||||
}
|
||||
|
||||
disp_fields(window, label_field, sizeof(label_field)/sizeof(struct field));
|
||||
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);
|
||||
next = change_field(label_field[cur_field], key);
|
||||
if (next == -1)
|
||||
beep();
|
||||
else
|
||||
cur_field = next;
|
||||
sprintf(label_field[47].field, "%d",
|
||||
sectstoMb(avail_sects, lbl->d_secsize));
|
||||
|
||||
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,
|
||||
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 */
|
||||
|
||||
/* Update label */
|
||||
for (i=0; i<MAXPARTITIONS; i++) {
|
||||
sprintf(disk_list[disk].mounts[i].fs_spec, "%s",
|
||||
label_field[(i*5)].field);
|
||||
@ -202,27 +261,6 @@ edit_disklabel(int disk)
|
||||
sprintf(disk_list[disk].mounts[i].fs_file, "%s",
|
||||
label_field[(i*5)+4].field);
|
||||
}
|
||||
|
||||
avail_sects = lbl->d_partitions[OURPART].p_size;
|
||||
offset = lbl->d_partitions[OURPART].p_offset;
|
||||
for (i=0; i < MAXPARTITIONS; i++) {
|
||||
if (i == OURPART)
|
||||
continue;
|
||||
if (i == RAWPART)
|
||||
continue;
|
||||
lbl->d_partitions[i].p_offset = offset;
|
||||
nsects = atoi(label_field[(i*5)+3].field);
|
||||
nsects = Mbtosects(nsects, lbl->d_secsize);
|
||||
if (nsects > avail_sects)
|
||||
nsects = avail_sects;
|
||||
avail_sects -= nsects;
|
||||
offset += nsects;
|
||||
if (nsects == 0)
|
||||
lbl->d_partitions[i].p_offset = 0;
|
||||
lbl->d_partitions[i].p_size = nsects;
|
||||
lbl->d_partitions[i].p_fsize = DEFFSIZE;
|
||||
lbl->d_partitions[i].p_frag = DEFFRAG;
|
||||
}
|
||||
}
|
||||
|
||||
if (write_bootblocks(disk) == -1)
|
||||
|
@ -1,48 +1,52 @@
|
||||
struct field label_field[] = {
|
||||
{ 4, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{ 4, 16, 3, 3, 2, 36, 6, -1, 2, "YES"},
|
||||
{ 4, 27, 6, 30, 3, 37, 7, -1, 3, "MSDOS"},
|
||||
{ 4, 39, 5, 5, 4, 38, 8, -1, 4, "1000"},
|
||||
{ 4, 47, 30, 80, 6, 39, 9, -1, 1, "/an/example/mountpoint"},
|
||||
{ 6, 02, 4, 4, -1, -1, -1, -1, -1, "wd0b"},
|
||||
{ 6, 16, 3, 3, 7, 1, 11, -1, 7, "YES"},
|
||||
{ 6, 27, 6, 20, 8, 2, 12, -1, 8, "MSDOS"},
|
||||
{ 6, 39, 5, 5, 9, 3, 13, -1, 9, "1000"},
|
||||
{ 6, 47, 30, 80, 11, 4, 14, -1, 6, "/an/example/mountpoint"},
|
||||
{ 8, 02, 10, 10, -1, -1, -1, -1, -1, "wd0c"},
|
||||
{ 8, 16, 3, 3, 12, 6, 16, -1, 12, "YES"},
|
||||
{ 8, 27, 6, 20, 13, 7, 17, -1, 13, "MSDOS"},
|
||||
{ 8, 39, 5, 5, 14, 8, 18, -1, 14, "1000"},
|
||||
{ 8, 47, 30, 80, 16, 9, 19, -1, 11, "/an/example/mountpoint"},
|
||||
{10, 02, 10, 10, -1, -1, -1, -1, -1, "wd0d"},
|
||||
{10, 16, 3, 3, 17, 11, 21, -1, 17, "YES"},
|
||||
{10, 27, 6, 20, 18, 12, 22, -1, 18, "MSDOS"},
|
||||
{10, 39, 5, 5, 19, 13, 23, -1, 19, "1000"},
|
||||
{10, 47, 30, 80, 21, 14, 24, -1, 16, "/an/example/mountpoint"},
|
||||
{12, 02, 10, 10, -1, -1, -1, -1, -1, "wd0e"},
|
||||
{12, 16, 3, 3, 22, 16, 26, -1, 22, "YES"},
|
||||
{12, 27, 6, 20, 23, 17, 27, -1, 23, "MSDOS"},
|
||||
{12, 39, 5, 5, 24, 18, 28, -1, 24, "1000"},
|
||||
{12, 47, 30, 80, 26, 19, 29, -1, 21, "/an/example/mountpoint"},
|
||||
{14, 02, 10, 10, -1, -1, -1, -1, -1, "wd0f"},
|
||||
{14, 16, 3, 3, 27, 21, 31, -1, 27, "YES"},
|
||||
{14, 27, 6, 20, 28, 22, 32, -1, 28, "MSDOS"},
|
||||
{14, 39, 5, 5, 29, 23, 33, -1, 29, "1000"},
|
||||
{14, 47, 30, 80, 31, 24, 34, -1, 26, "/an/example/mountpoint"},
|
||||
{16, 02, 10, 10, -1, -1, -1, -1, -1, "wd0g"},
|
||||
{16, 16, 3, 3, 32, 26, 36, -1, 32, "YES"},
|
||||
{16, 27, 6, 20, 33, 27, 37, -1, 33, "MSDOS"},
|
||||
{16, 39, 5, 5, 34, 28, 38, -1, 34, "1000"},
|
||||
{16, 47, 30, 80, 36, 29, 39, -1, 31, "/an/example/mountpoint"},
|
||||
{18, 02, 10, 10, -1, -1, -1, -1, -1, "wd0h"},
|
||||
{18, 16, 3, 3, 37, 31, 1, -1, 37, "YES"},
|
||||
{18, 27, 6, 20, 38, 32, 2, -1, 38, "MSDOS"},
|
||||
{18, 39, 5, 5, 39, 33, 3, -1, 39, "1000"},
|
||||
{18, 47, 30, 80, 1, 34, 4, -1, 36, "/an/example/mountpoint"},
|
||||
{ 0, 18, 17, 17, -1, -1, -1, -1, -1, "Disk label editor"},
|
||||
{ 2, 2, 11, 11, -1, -1, -1, -1, -1, "Partition"},
|
||||
{ 2, 14, 8, 8, -1, -1, -1, -1, -1, "Preserve"},
|
||||
{ 2, 25, 10, 10, -1, -1, -1, -1, -1, "Filesystem"},
|
||||
{ 2, 39, 5, 5, -1, -1, -1, -1, -1, "Size"},
|
||||
{ 2, 47, 10, 10, -1, -1, -1, -1, -1, "Mountpoint"}
|
||||
{ 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},
|
||||
};
|
||||
|
@ -151,46 +151,46 @@ clear_mbr(struct mbr *mbr, char *bootcode)
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* If installing to the whole disk
|
||||
* then clobber any existing bootcode.
|
||||
* Must replace any old bootcode that was read
|
||||
* from disk with our bootblocks.
|
||||
*/
|
||||
|
||||
TellEm("Loading MBR code from %s", bootcode);
|
||||
fd = open(bootcode, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
sprintf(errmsg, "Couldn't open boot file %s\n", bootcode);
|
||||
return(-1);
|
||||
}
|
||||
TellEm("Loading MBR code from %s", bootcode);
|
||||
fd = open(bootcode, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
sprintf(errmsg, "Couldn't open boot file %s\n", bootcode);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (read(fd, mbr->bootcode, MBRSIZE) < 0) {
|
||||
sprintf(errmsg, "Couldn't read from boot file %s\n", bootcode);
|
||||
return(-1);
|
||||
}
|
||||
if (read(fd, mbr->bootcode, MBRSIZE) < 0) {
|
||||
sprintf(errmsg, "Couldn't read from boot file %s\n", bootcode);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (close(fd) == -1) {
|
||||
sprintf(errmsg, "Couldn't close boot file %s\n", bootcode);
|
||||
return(-1);
|
||||
}
|
||||
if (close(fd) == -1) {
|
||||
sprintf(errmsg, "Couldn't close boot file %s\n", bootcode);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Create an empty partition table */
|
||||
|
||||
for (i=0; i < NDOSPART; i++) {
|
||||
mbr->dospart[i].dp_flag = 0;
|
||||
mbr->dospart[i].dp_shd = 0;
|
||||
mbr->dospart[i].dp_ssect = 0;
|
||||
mbr->dospart[i].dp_scyl = 0;
|
||||
mbr->dospart[i].dp_typ = 0;
|
||||
mbr->dospart[i].dp_ehd = 0;
|
||||
mbr->dospart[i].dp_esect = 0;
|
||||
mbr->dospart[i].dp_ecyl = 0;
|
||||
mbr->dospart[i].dp_start = 0;
|
||||
mbr->dospart[i].dp_size = 0;
|
||||
}
|
||||
/* Create an empty partition table */
|
||||
|
||||
mbr->magic = MBR_MAGIC;
|
||||
|
||||
dialog_clear();
|
||||
return(0);
|
||||
for (i=0; i < NDOSPART; i++) {
|
||||
mbr->dospart[i].dp_flag = 0;
|
||||
mbr->dospart[i].dp_shd = 0;
|
||||
mbr->dospart[i].dp_ssect = 0;
|
||||
mbr->dospart[i].dp_scyl = 0;
|
||||
mbr->dospart[i].dp_typ = 0;
|
||||
mbr->dospart[i].dp_ehd = 0;
|
||||
mbr->dospart[i].dp_esect = 0;
|
||||
mbr->dospart[i].dp_ecyl = 0;
|
||||
mbr->dospart[i].dp_start = 0;
|
||||
mbr->dospart[i].dp_size = 0;
|
||||
}
|
||||
|
||||
mbr->magic = MBR_MAGIC;
|
||||
|
||||
dialog_clear();
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
@ -212,7 +212,7 @@ dedicated_mbr(struct mbr *mbr, char *bootcode, struct disklabel *lbl)
|
||||
dp->dp_size =
|
||||
(lbl->d_nsectors * lbl->d_ntracks * lbl->d_ncylinders) - dp->dp_start;
|
||||
|
||||
dp->dp_typ = DOSPTYP_386BSD;
|
||||
dp->dp_typ = MBR_PTYPE_FreeBSD;
|
||||
dp->dp_flag = ACTIVE;
|
||||
|
||||
return(0);
|
||||
@ -253,12 +253,9 @@ get_geom_values(int disk)
|
||||
sprintf(field[2].field, "%ld", lbl->d_nsectors);
|
||||
|
||||
disp_fields(window, field, sizeof(field)/sizeof(struct field));
|
||||
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);
|
||||
key = edit_line(window, field[cur_field].y, field[cur_field].x,
|
||||
field[cur_field].field, field[cur_field].width,
|
||||
field[cur_field].maxlen);
|
||||
next = change_field(field[cur_field], key);
|
||||
if (next == -1)
|
||||
beep();
|
||||
@ -288,7 +285,7 @@ edit_mbr(int disk)
|
||||
|
||||
/* Confirm disk parameters */
|
||||
#ifdef 0
|
||||
dialog_msgbox("BIOS disk geometry values", "In order to setup the boot area of the disk it is necessary to know the BIOS values for the disk geometry i.e. the number of cylinders, heads and sectors. These values may be different form the real geometry of the disk, depending on whether or not your system uses geometry translation. At this stage it is the entries from the BIOS that are needed. If you do not know these they can be found by rebooting the machine and entering th BIOS setup routine. See you BIOS manual for details", -1, -1, 1)
|
||||
dialog_msgbox("\nBIOS disk geometry values", "In order to setup the boot area of the disk it is necessary to know the BIOS values for the disk geometry i.e. the number of cylinders, heads and sectors. These values may be different form the real geometry of the disk, depending on whether or not your system uses geometry translation. At this stage it is the entries from the BIOS that are needed. If you do not know these they can be found by rebooting the machine and entering th BIOS setup routine. See you BIOS manual for details.\n", -1, -1, 1)
|
||||
#endif
|
||||
if (get_geom_values(disk) == -1)
|
||||
return(-1);
|
||||
@ -303,10 +300,11 @@ edit_mbr(int disk)
|
||||
while (!ok) {
|
||||
AskAbort(scratch);
|
||||
if (!dialog_yesno(TITLE,
|
||||
"Are you sure you wish to proceed ?",
|
||||
-1, -1)) {
|
||||
"\nAre you sure you wish to proceed ?\n",
|
||||
-1, -1)) {
|
||||
dialog_clear();
|
||||
if (dedicated_mbr(mbr, boot1, &disk_list[disk].lbl) == -1) {
|
||||
sprintf(scratch, "\n\nCouldn't create new master boot record.\n\n%s", errmsg);
|
||||
sprintf(scratch, "\nCouldn't create new master boot record.\n\n%s", errmsg);
|
||||
return(-1);
|
||||
}
|
||||
ok = 1;
|
||||
@ -314,17 +312,14 @@ edit_mbr(int disk)
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(scratch, "Do you wish to dedicate the whole disk to FreeBSD?\n\nDoing so will overwrite any existing data on the disk.");
|
||||
sprintf(scratch, "\nDo you wish to dedicate the whole disk to FreeBSD?\n\nDoing so will overwrite any existing data on the disk.\n");
|
||||
dialog_clear_norefresh();
|
||||
if (!dialog_yesno(TITLE, scratch, -1, -1))
|
||||
if (dedicated_mbr(mbr, boot1, &disk_list[disk].lbl) == -1) {
|
||||
sprintf(scratch, "\n\nCouldn't dedicate disk to FreeBSD.\n\n %s", errmsg);
|
||||
sprintf(scratch, "\nCouldn't dedicate disk to FreeBSD.\n\n %s", errmsg);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Fill in fields with mbr data */
|
||||
|
||||
|
||||
if (!(window = newwin(24, 79, 0, 0))) {
|
||||
sprintf(errmsg, "Failed to open window for MBR editor\n");
|
||||
return (-1);
|
||||
@ -353,43 +348,60 @@ edit_mbr(int disk)
|
||||
}
|
||||
|
||||
disp_fields(window, mbr_field, sizeof(mbr_field)/sizeof(struct field));
|
||||
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);
|
||||
mbr->dospart[i].dp_scyl = atoi(mbr_field[(i*12)+3].field);
|
||||
mbr->dospart[i].dp_shd = atoi(mbr_field[(i*12)+4].field);
|
||||
mbr->dospart[i].dp_ssect = atoi(mbr_field[(i*12)+5].field);
|
||||
mbr->dospart[i].dp_ecyl = atoi(mbr_field[(i*12)+7].field);
|
||||
mbr->dospart[i].dp_ehd = atoi(mbr_field[(i*12)+8].field);
|
||||
mbr->dospart[i].dp_esect = atoi(mbr_field[(i*12)+9].field);
|
||||
mbr->dospart[i].dp_size = atoi(mbr_field[(i*12)+10].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);
|
||||
/* Propagate changes to MBR */
|
||||
for (i=0; i < NDOSPART; i++) {
|
||||
mbr->dospart[i].dp_start = atoi(mbr_field[(i*12)+2].field);
|
||||
mbr->dospart[i].dp_scyl = atoi(mbr_field[(i*12)+3].field);
|
||||
mbr->dospart[i].dp_shd = atoi(mbr_field[(i*12)+4].field);
|
||||
mbr->dospart[i].dp_ssect = atoi(mbr_field[(i*12)+5].field);
|
||||
mbr->dospart[i].dp_ecyl = atoi(mbr_field[(i*12)+7].field);
|
||||
mbr->dospart[i].dp_ehd = atoi(mbr_field[(i*12)+8].field);
|
||||
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;
|
||||
case F_TITLE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
next = change_field(mbr_field[cur_field], key);
|
||||
if (next == -1)
|
||||
beep();
|
||||
else
|
||||
cur_field = next;
|
||||
}
|
||||
|
||||
sprintf(scratch, "Writing a new master boot record can erase the current disk contents.\n\n Are you sure you want to write the new MBR?");
|
||||
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");
|
||||
dialog_clear_norefresh();
|
||||
if (!dialog_yesno("Write new MBR?", scratch, -1, -1)) {
|
||||
sprintf(scratch, "/dev/r%s%dd", disk_list[disk].devconf->dc_name,
|
||||
disk_list[disk].devconf->dc_unit);
|
||||
if (write_mbr(scratch, mbr) == -1) {
|
||||
sprintf(scratch, "The following error occured while trying to write the new MBR\n\n%s", errmsg);
|
||||
sprintf(scratch, "\nThe following error occured while trying to write the new MBR.\n\n%s", errmsg);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Find first FreeBSD partition, as kernel would upon boot */
|
||||
disk_list[disk].inst_part = -1;
|
||||
for (i=0; i < NDOSPART; i++)
|
||||
if (mbr->dospart[i].dp_typ == MBR_PTYPE_FreeBSD) {
|
||||
disk_list[disk].inst_part = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (disk_list[disk].inst_part == -1) {
|
||||
sprintf(errmsg, "\nThere is no space allocated to FreeBSD on %s\n",
|
||||
diskname(disk));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
delwin(window);
|
||||
dialog_clear();
|
||||
return (0);
|
||||
|
@ -147,7 +147,7 @@ query_devices()
|
||||
}
|
||||
|
||||
int
|
||||
select_disk()
|
||||
configure_disks()
|
||||
{
|
||||
char *disk_names[] = {"wd", "sd", 0};
|
||||
char diskname[20];
|
||||
@ -203,115 +203,35 @@ select_disk()
|
||||
sprintf(options[(no_disks*2)+1], " Done");
|
||||
|
||||
dialog_clear_norefresh();
|
||||
if (dialog_menu("FreeBSD Installation", scratch, -1, -1, min(5,no_disks+1), no_disks+1,
|
||||
options, selection)) {
|
||||
sprintf(scratch,"You selected cancel.");
|
||||
if (dialog_menu("FreeBSD Installation", scratch, -1, -1,
|
||||
min(5, no_disks), no_disks, options, selection)) {
|
||||
dialog_clear_norefresh();
|
||||
sprintf(scratch,"\nYou selected cancel.\n");
|
||||
AskAbort(scratch);
|
||||
valid = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
choice = atoi(selection);
|
||||
if (choice == no_disks+1)
|
||||
valid = 1;
|
||||
else
|
||||
if (disk_list[choice-1].selected)
|
||||
disk_list[choice-1].selected = 0;
|
||||
else
|
||||
disk_list[choice-1].selected = 1;
|
||||
} while (!valid);
|
||||
dialog_clear();
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
configure_disks()
|
||||
{
|
||||
int i;
|
||||
int items;
|
||||
int choice;
|
||||
int valid=0;
|
||||
int disks[MAX_NO_DEVICES];
|
||||
|
||||
do {
|
||||
sprintf(scratch, "Select disk to configure");
|
||||
|
||||
items = 0;
|
||||
for (i = 0; i < no_disks; i++) {
|
||||
if (disk_list[i].selected) {
|
||||
sprintf(options[(items*2)], "%d",items+1);
|
||||
sprintf(options[(items*2)+1], "%s%d",
|
||||
disk_list[i].devconf->dc_name,
|
||||
disk_list[i].devconf->dc_unit);
|
||||
disks[items] = i;
|
||||
items++;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(options[items*2], "%d", items+1);
|
||||
sprintf(options[(items*2)+1], "Done");
|
||||
items++;
|
||||
|
||||
dialog_clear_norefresh();
|
||||
if (dialog_menu("FreeBSD Installation", scratch, -1, -1, min(5,items), items,
|
||||
options, selection)) {
|
||||
sprintf(scratch,"You selected cancel.");
|
||||
AskAbort(scratch);
|
||||
valid = 0;
|
||||
continue;
|
||||
}
|
||||
choice = atoi(selection);
|
||||
if (choice == items)
|
||||
if (choice == no_disks)
|
||||
valid = 1;
|
||||
else {
|
||||
if (edit_mbr(disks[choice-1]) == -1) {
|
||||
sprintf(scratch, "The following error occured while\nediting the master boot record.\n%s", errmsg);
|
||||
if (edit_mbr(choice-1) == -1) {
|
||||
sprintf(scratch, "\nThe following error occured while\nediting the master boot record.\n%s", errmsg);
|
||||
AskAbort(scratch);
|
||||
valid = 0;
|
||||
continue;
|
||||
};
|
||||
disk_list[disks[choice-1]].inst_part = select_partition(disks[choice-1]);
|
||||
if (edit_disklabel(disks[choice-1]) == -1) {
|
||||
sprintf(scratch, "The following error occured while\nediting the disklabel.\n%s", errmsg);
|
||||
if (edit_disklabel(choice-1) == -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;
|
||||
}
|
||||
} while (!valid);
|
||||
dialog_clear();
|
||||
}
|
||||
|
||||
int
|
||||
select_partition(int disk)
|
||||
{
|
||||
int valid;
|
||||
int i;
|
||||
int choice;
|
||||
|
||||
do {
|
||||
valid = 1;
|
||||
|
||||
sprintf(scratch,"Select one of the following areas to install to:");
|
||||
for (i=0; i < NDOSPART; i++) {
|
||||
sprintf(options[(i*2)], "%d",i+1);
|
||||
sprintf(options[(i*2)+1], "%s, (%ldMb)",
|
||||
part_type(disk_list[disk].mbr.dospart[i].dp_typ),
|
||||
disk_list[disk].mbr.dospart[i].dp_size * 512 / (1024 * 1024));
|
||||
}
|
||||
dialog_clear_norefresh();
|
||||
if (dialog_menu(TITLE,
|
||||
scratch, -1, -1, 4, 4, options, selection)) {
|
||||
sprintf(scratch,"You did not select a valid partition");
|
||||
AskAbort(scratch);
|
||||
valid = 0;
|
||||
}
|
||||
dialog_clear();
|
||||
choice = atoi(selection) - 1;
|
||||
} while (!valid);
|
||||
return(choice);
|
||||
}
|
||||
|
||||
int
|
||||
stage1()
|
||||
{
|
||||
@ -319,18 +239,6 @@ stage1()
|
||||
int ok = 0;
|
||||
|
||||
query_devices();
|
||||
|
||||
while (!ok) {
|
||||
select_disk();
|
||||
for (i=0; i < no_disks; i++)
|
||||
if (disk_list[i].selected)
|
||||
ok = 1;
|
||||
if (!ok) {
|
||||
sprintf(scratch, "You did not select any disks to install to.");
|
||||
AskAbort(scratch);
|
||||
}
|
||||
}
|
||||
|
||||
configure_disks();
|
||||
exit(1);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: utils.c,v 1.30 1994/11/17 23:36:49 ache Exp $
|
||||
* $Id: utils.c,v 1.31 1994/11/19 00:09:00 ache Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -99,10 +99,11 @@ AskAbort(char *fmt, ...)
|
||||
va_start(ap,fmt);
|
||||
vsnprintf(p, 2048, fmt, ap);
|
||||
va_end(ap);
|
||||
strcat(p, "\nDo you wish to abort the installation?");
|
||||
if (!dialog_yesno("Abort", p, -1, -1))
|
||||
strcat(p, "\nDo you wish to abort the installation?\n");
|
||||
if (!dialog_yesno("Abort", p, -1, -1)) {
|
||||
dialog_clear_norefresh();
|
||||
Abort();
|
||||
else
|
||||
} else
|
||||
dialog_clear();
|
||||
free(p);
|
||||
}
|
||||
@ -110,7 +111,7 @@ AskAbort(char *fmt, ...)
|
||||
void
|
||||
Abort()
|
||||
{
|
||||
if (dialog_yesno("Exit sysinstall","Are you sure you want to quit?",
|
||||
if (dialog_yesno("Exit sysinstall","\nAre you sure you want to quit?\n",
|
||||
-1, -1)) {
|
||||
dialog_clear();
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user