From 0d87851037b97b130eff193374b5ca1893278ece Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Sat, 9 Apr 2011 01:41:45 -0400 Subject: [PATCH] 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 --- extendedcommands.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/extendedcommands.c b/extendedcommands.c index 717d8d2..3ee1cce 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -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];