recovery: Prevent the users from doing stupid things.

Don't allow formatting of special partitions like radio, bootloader,
or misc. No sense in formatting recovery from recovery either dawg.

Change-Id: I0f935aad103574b17be237993730afaeae623871
This commit is contained in:
Steve Kondik 2011-04-09 01:41:45 -04:00
parent 814a934c8f
commit 0d87851037

View File

@ -487,6 +487,12 @@ typedef struct {
Volume* v;
} FormatMenuEntry;
int is_safe_to_format(char* name)
{
return !(strcmp(name, "/misc") == 0 || strcmp(name, "/radio") == 0
|| strcmp(name, "/bootloader") == 0 || strcmp(name, "/recovery") == 0);
}
void show_partition_menu()
{
static char* headers[] = { "Mounts and Storage Menu",
@ -525,11 +531,13 @@ void show_partition_menu()
sprintf(&mount_menue[mountable_volumes].unmount, "unmount %s", v->mount_point);
mount_menue[mountable_volumes].v = &device_volumes[i];
++mountable_volumes;
sprintf(&format_menue[formatable_volumes].txt, "format %s", v->mount_point);
format_menue[formatable_volumes].v = &device_volumes[i];
++formatable_volumes;
if (is_safe_to_format(v->mount_point)) {
sprintf(&format_menue[formatable_volumes].txt, "format %s", v->mount_point);
format_menue[formatable_volumes].v = &device_volumes[i];
++formatable_volumes;
}
}
else if (strcmp("ramdisk", v->fs_type) != 0 && strcmp("misc", v->mount_point) != 0 && strcmp("mtd", v->fs_type) == 0)
else if (strcmp("ramdisk", v->fs_type) != 0 && strcmp("mtd", v->fs_type) == 0 && is_safe_to_format(v->mount_point))
{
sprintf(&format_menue[formatable_volumes].txt, "format %s", v->mount_point);
format_menue[formatable_volumes].v = &device_volumes[i];