Final autopart fixes.

This commit is contained in:
Jorrit Herder 2005-08-12 15:13:55 +00:00
parent 695bcec49e
commit 55f90307d2

View File

@ -2291,22 +2291,24 @@ printregions(region_t *theregions, int indent, int p_nr_partitions, int p_free_r
return; return;
} }
#define IS_YES 3
#define IS_NO 4
#define IS_OTHER 5
int int
is_sure(int flags, char *fmt, ...) is_sure(char *fmt, ...)
{ {
char yesno[10]; char yesno[10];
va_list ap; va_list ap;
va_start (ap, fmt); va_start (ap, fmt);
vprintf(fmt, ap); vprintf(fmt, ap);
va_end(ap); va_end(ap);
if(flags & SURE_SERIOUS) printf(" Please enter 'yes' or 'no': "); printf(" Please enter 'yes' or 'no': ");
else {
printf(" (y/n) [y] ");
}
fflush(stdout); fflush(stdout);
if(!fgets(yesno, sizeof(yesno)-1, stdin)) exit(1); if(!fgets(yesno, sizeof(yesno)-1, stdin)) exit(1);
if(!(flags & SURE_SERIOUS)) return (tolower(yesno[0]) != 'n');
return !strncmp(yesno, "yes", 3); if (strcmp(yesno, "yes\n") == 0) return(IS_YES);
if (strcmp(yesno, "no\n") == 0) return(IS_NO);
return IS_OTHER;
} }
void warn(char *message) void warn(char *message)
@ -2317,6 +2319,7 @@ void warn(char *message)
int int
may_kill_region(void) may_kill_region(void)
{ {
int confirmation;
char line[100]; char line[100];
int r, i; int r, i;
@ -2344,15 +2347,18 @@ may_kill_region(void)
i = regions[r].tableno; i = regions[r].tableno;
if(is_sure(0, "\nAre you sure you want to delete this region,\n" printf("\nPlease confirm that you want to delete region %d, loosing all data it", r);
"losing all data it contains? You have selected a region used\n" printf("\ncontains. You're disk is not actually updated right away, but still.");
"by %s (%s).\n\n" printf("\n\n");
"I won't actually update your disk right away, but still. Sure?",
typ2txt(table[i].sysind), prettysizeprint(table[i].size / 2))) { do {
confirmation = is_sure("Are you sure you want to continue?");
if (confirmation == IS_NO) return 0;
} while (confirmation != IS_YES);
table[i].sysind = NO_PART; table[i].sysind = NO_PART;
dirty = 1; dirty = 1;
regionize(); regionize();
}
/* User may go again. */ /* User may go again. */
return 0; return 0;
@ -2563,6 +2569,7 @@ scribble_region(region_t *reg, struct part_entry **pe)
int int
do_autopart(int resultfd) do_autopart(int resultfd)
{ {
int confirmation;
region_t *r; region_t *r;
struct part_entry *pe; struct part_entry *pe;
char sure[50]; char sure[50];
@ -2615,8 +2622,10 @@ do_autopart(int resultfd)
printf("into region %d of disk %d (%sp%d). Please confirm that you want\n", region, disk, devices[disk].dev->name, region); printf("into region %d of disk %d (%sp%d). Please confirm that you want\n", region, disk, devices[disk].dev->name, region);
printf("to use this selection to install MINIX 3.\n\n"); printf("to use this selection to install MINIX 3.\n\n");
if(!is_sure(SURE_SERIOUS, "Are you sure you want to continue?")) do {
return 1; confirmation = is_sure("Are you sure you want to continue?");
if (confirmation == IS_NO) return 1;
} while (confirmation != IS_YES);
/* Retrieve partition number in sorted order that we /* Retrieve partition number in sorted order that we
* have scribbled in. * have scribbled in.