Cope with Open_Disk() failure much more gracefully.

This commit is contained in:
Jordan K. Hubbard 1997-01-16 14:42:21 +00:00
parent f7b630a403
commit 2974f2c077
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=21772
3 changed files with 30 additions and 24 deletions

View File

@ -189,7 +189,8 @@ diskPartition(Device *dev, Disk *d)
char *val, geometry[80]; char *val, geometry[80];
/* Now print our overall state */ /* Now print our overall state */
print_chunks(d); if (d)
print_chunks(d);
print_command_summary(); print_command_summary();
if (msg) { if (msg) {
attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL); attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
@ -357,17 +358,18 @@ diskPartition(Device *dev, Disk *d)
"can't undo it."); "can't undo it.");
} }
else if (!msgYesNo("Are you SURE you want to Undo everything?")) { else if (!msgYesNo("Are you SURE you want to Undo everything?")) {
d = Open_Disk(d->name); char cp[BUFSIZ];
if (!d) {
msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", d->name); sstrncpy(cp, d->name, sizeof cp);
clear();
break;
}
Free_Disk(dev->private); Free_Disk(dev->private);
d = Open_Disk(cp);
if (!d)
msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp);
dev->private = d; dev->private = d;
variable_unset(DISK_PARTITIONED); variable_unset(DISK_PARTITIONED);
variable_unset(DISK_LABELLED); variable_unset(DISK_LABELLED);
record_chunks(d); if (d)
record_chunks(d);
} }
clear(); clear();
break; break;

View File

@ -189,7 +189,8 @@ diskPartition(Device *dev, Disk *d)
char *val, geometry[80]; char *val, geometry[80];
/* Now print our overall state */ /* Now print our overall state */
print_chunks(d); if (d)
print_chunks(d);
print_command_summary(); print_command_summary();
if (msg) { if (msg) {
attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL); attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
@ -357,17 +358,18 @@ diskPartition(Device *dev, Disk *d)
"can't undo it."); "can't undo it.");
} }
else if (!msgYesNo("Are you SURE you want to Undo everything?")) { else if (!msgYesNo("Are you SURE you want to Undo everything?")) {
d = Open_Disk(d->name); char cp[BUFSIZ];
if (!d) {
msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", d->name); sstrncpy(cp, d->name, sizeof cp);
clear();
break;
}
Free_Disk(dev->private); Free_Disk(dev->private);
d = Open_Disk(cp);
if (!d)
msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp);
dev->private = d; dev->private = d;
variable_unset(DISK_PARTITIONED); variable_unset(DISK_PARTITIONED);
variable_unset(DISK_LABELLED); variable_unset(DISK_LABELLED);
record_chunks(d); if (d)
record_chunks(d);
} }
clear(); clear();
break; break;

View File

@ -189,7 +189,8 @@ diskPartition(Device *dev, Disk *d)
char *val, geometry[80]; char *val, geometry[80];
/* Now print our overall state */ /* Now print our overall state */
print_chunks(d); if (d)
print_chunks(d);
print_command_summary(); print_command_summary();
if (msg) { if (msg) {
attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL); attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
@ -357,17 +358,18 @@ diskPartition(Device *dev, Disk *d)
"can't undo it."); "can't undo it.");
} }
else if (!msgYesNo("Are you SURE you want to Undo everything?")) { else if (!msgYesNo("Are you SURE you want to Undo everything?")) {
d = Open_Disk(d->name); char cp[BUFSIZ];
if (!d) {
msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", d->name); sstrncpy(cp, d->name, sizeof cp);
clear();
break;
}
Free_Disk(dev->private); Free_Disk(dev->private);
d = Open_Disk(cp);
if (!d)
msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp);
dev->private = d; dev->private = d;
variable_unset(DISK_PARTITIONED); variable_unset(DISK_PARTITIONED);
variable_unset(DISK_LABELLED); variable_unset(DISK_LABELLED);
record_chunks(d); if (d)
record_chunks(d);
} }
clear(); clear();
break; break;