Update the in-core disklabel when we change the on-disk version.
Fix up the editor links for the disklabel editor. Correct the display of fields when they're longer than the viewable length.
This commit is contained in:
parent
26b39132e4
commit
48dd1a4713
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4651
@ -146,5 +146,18 @@ 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));
|
||||
return (-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
@ -8,13 +8,16 @@ int
|
||||
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++) {
|
||||
mvwprintw(window, field[i].y, field[i].x, "%s", field[i].field);
|
||||
j=strlen(field[i].field);
|
||||
if (j < field[i].width)
|
||||
for (; j < field[i].width; j++)
|
||||
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, ' ');
|
||||
}
|
||||
wrefresh(window);
|
||||
|
@ -105,7 +105,7 @@ int
|
||||
edit_disklabel(int disk)
|
||||
{
|
||||
WINDOW *window;
|
||||
int key;
|
||||
int key = 0;
|
||||
int next;
|
||||
int cur_field;
|
||||
int i;
|
||||
@ -114,19 +114,45 @@ edit_disklabel(int disk)
|
||||
int nsects;
|
||||
int avail_sects;
|
||||
|
||||
lbl->d_magic = DISKMAGIC;
|
||||
bcopy("INSTALLATION", lbl->d_typename, strlen("INSTALLATION"));
|
||||
lbl->d_rpm = 3600;
|
||||
lbl->d_interleave = 1;
|
||||
lbl->d_trackskew = 0;
|
||||
lbl->d_cylskew = 0;
|
||||
lbl->d_magic2 = DISKMAGIC;
|
||||
lbl->d_checksum = 0;
|
||||
lbl->d_bbsize = BBSIZE;
|
||||
lbl->d_sbsize = SBSIZE;
|
||||
lbl->d_npartitions = 8;
|
||||
lbl->d_boot0 = boot1;
|
||||
lbl->d_boot1 = boot2;
|
||||
lbl->d_magic = DISKMAGIC;
|
||||
bcopy("INSTALLATION", lbl->d_typename, strlen("INSTALLATION"));
|
||||
lbl->d_rpm = 3600;
|
||||
lbl->d_interleave = 1;
|
||||
lbl->d_trackskew = 0;
|
||||
lbl->d_cylskew = 0;
|
||||
lbl->d_magic2 = DISKMAGIC;
|
||||
lbl->d_checksum = 0;
|
||||
lbl->d_bbsize = BBSIZE;
|
||||
lbl->d_sbsize = SBSIZE;
|
||||
lbl->d_npartitions = 8;
|
||||
|
||||
/* Inialise the fstab entries */
|
||||
for (i=0; i < MAXPARTITIONS; i++) {
|
||||
disk_list[disk].mounts[i].fs_spec =
|
||||
(char *)malloc(label_field[i*5].maxlen+1);
|
||||
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,
|
||||
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);
|
||||
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");
|
||||
}
|
||||
|
||||
if (!(window = newwin(24, 79, 0, 0))) {
|
||||
sprintf(errmsg, "Failed to open window for disklabel editor\n");
|
||||
@ -137,12 +163,12 @@ edit_disklabel(int disk)
|
||||
|
||||
draw_box(window, 0, 0, 24, 79, dialog_attr, border_attr);
|
||||
|
||||
|
||||
cur_field = 1;
|
||||
while (key != ESC) {
|
||||
for (i=0; i < MAXPARTITIONS; i++) {
|
||||
sprintf(label_field[(i*5)].field, "%s%d%s", disk_list[disk].devconf->dc_name,
|
||||
disk_list[disk].devconf->dc_unit,
|
||||
partname[i]);
|
||||
sprintf(label_field[(i*5)].field, "%s",
|
||||
disk_list[disk].mounts[i].fs_spec);
|
||||
sprintf(label_field[(i*5)+1].field, "%s",
|
||||
disk_list[disk].mounts[i].fs_mntops);
|
||||
sprintf(label_field[(i*5)+2].field, "%s",
|
||||
@ -200,6 +226,7 @@ edit_disklabel(int disk)
|
||||
if (write_bootblocks(disk) == -1)
|
||||
return(-1);
|
||||
|
||||
delwin(window);
|
||||
dialog_clear();
|
||||
return(0);
|
||||
}
|
||||
|
@ -1,44 +1,44 @@
|
||||
struct field label_field[] = {
|
||||
{ 4, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{ 4, 16, 3, 3, 2, -1, -1, -1, -1, "YES"},
|
||||
{ 4, 27, 20, 20, 3, -1, -1, -1, -1, "MSDOS"},
|
||||
{ 4, 39, 5, 5, 4, -1, -1, -1, -1, "1000"},
|
||||
{ 4, 47, 20, 30, 6, -1, -1, -1, -1, "/an/example/mountpoint"},
|
||||
{ 6, 02, 4, 4, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{ 6, 16, 3, 3, 7, -1, -1, -1, -1, "YES"},
|
||||
{ 6, 27, 20, 20, 8, -1, -1, -1, -1, "MSDOS"},
|
||||
{ 6, 39, 5, 5, 9, -1, -1, -1, -1, "1000"},
|
||||
{ 6, 47, 20, 30, 11, -1, -1, -1, -1, "/an/example/mountpoint"},
|
||||
{ 8, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{ 8, 16, 3, 3, 12, -1, -1, -1, -1, "YES"},
|
||||
{ 8, 27, 20, 20, 13, -1, -1, -1, -1, "MSDOS"},
|
||||
{ 8, 39, 5, 5, 14, -1, -1, -1, -1, "1000"},
|
||||
{ 8, 47, 20, 30, 16, -1, -1, -1, -1, "/an/example/mountpoint"},
|
||||
{10, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{10, 16, 3, 3, 17, -1, -1, -1, -1, "YES"},
|
||||
{10, 27, 20, 20, 18, -1, -1, -1, -1, "MSDOS"},
|
||||
{10, 39, 5, 5, 19, -1, -1, -1, -1, "1000"},
|
||||
{10, 47, 20, 30, 21, -1, -1, -1, -1, "/an/example/mountpoint"},
|
||||
{12, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{12, 16, 3, 3, 22, -1, -1, -1, -1, "YES"},
|
||||
{12, 27, 20, 20, 23, -1, -1, -1, -1, "MSDOS"},
|
||||
{12, 39, 5, 5, 24, -1, -1, -1, -1, "1000"},
|
||||
{12, 47, 20, 30, 26, -1, -1, -1, -1, "/an/example/mountpoint"},
|
||||
{14, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{14, 16, 3, 3, 27, -1, -1, -1, -1, "YES"},
|
||||
{14, 27, 20, 20, 28, -1, -1, -1, -1, "MSDOS"},
|
||||
{14, 39, 5, 5, 29, -1, -1, -1, -1, "1000"},
|
||||
{14, 47, 20, 30, 31, -1, -1, -1, -1, "/an/example/mountpoint"},
|
||||
{16, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{16, 16, 3, 3, 32, -1, -1, -1, -1, "YES"},
|
||||
{16, 27, 20, 20, 33, -1, -1, -1, -1, "MSDOS"},
|
||||
{16, 39, 5, 5, 34, -1, -1, -1, -1, "1000"},
|
||||
{16, 47, 20, 30, 36, -1, -1, -1, -1, "/an/example/mountpoint"},
|
||||
{18, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
|
||||
{18, 16, 3, 3, 37, -1, -1, -1, -1, "YES"},
|
||||
{18, 27, 20, 20, 38, -1, -1, -1, -1, "MSDOS"},
|
||||
{18, 39, 5, 5, 39, -1, -1, -1, -1, "1000"},
|
||||
{18, 47, 20, 30, 1, -1, -1, -1, -1, "/an/example/mountpoint"},
|
||||
{ 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"},
|
||||
|
@ -229,13 +229,13 @@ get_geom_values(int disk)
|
||||
int next = 0;
|
||||
|
||||
struct field field[] = {
|
||||
{2, 27, 06, 10, 01, 02, 01, -1, -1, "000000"},
|
||||
{4, 27, 06, 10, 02, 00, 02, -1, -1, "000000"},
|
||||
{6, 27, 06, 10, 00, 01, 00, -1, -1, "000000"},
|
||||
{0, 07, 06, 10, -1, -1, -1, -1, -1, "Disk geomtetry parameters"},
|
||||
{2, 02, 06, 10, -1, -1, -1, -1, -1, "Number of cylinders:"},
|
||||
{4, 02, 06, 10, -1, -1, -1, -1, -1, "Number of tracks (heads):"},
|
||||
{6, 02, 06, 10, -1, -1, -1, -1, -1, "Number of sectors:"}
|
||||
{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:"}
|
||||
};
|
||||
|
||||
if (!(window = newwin(10, 40, 5, 20))) {
|
||||
@ -285,7 +285,9 @@ edit_mbr(int disk)
|
||||
struct mbr *mbr = &disk_list[disk].mbr;
|
||||
|
||||
/* 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)
|
||||
#endif
|
||||
if (get_geom_values(disk) == -1)
|
||||
return(-1);
|
||||
|
||||
@ -384,6 +386,8 @@ edit_mbr(int disk)
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
delwin(window);
|
||||
dialog_clear();
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user