the beginnings of adding a format option,

This commit is contained in:
Koushik K. Dutta 2010-03-19 13:34:36 -07:00
parent d3243fe047
commit 5899ac9ca0
5 changed files with 72 additions and 38 deletions

View File

@ -27,9 +27,9 @@ char* MENU_ITEMS[] = { "reboot system now",
"wipe data/factory reset",
"wipe cache partition",
"install zip from sdcard",
"backup",
"restore",
"mount partitions",
"nandroid",
"partitions menu",
"advanced",
NULL };
int device_toggle_display(volatile char* key_pressed, int key_code) {

View File

@ -373,8 +373,10 @@ void show_mount_usb_storage_menu()
__system("echo 0 > /sys/devices/platform/usb_mass_storage/lun0/enable");
}
#define MOUNTABLE_COUNT 4
#define MTD_COUNT 3
void show_mount_menu()
void show_partition_menu()
{
static char* headers[] = { "Mount and unmount partitions",
"",
@ -382,47 +384,56 @@ void show_mount_menu()
};
typedef char* string;
string mounts[4][3] = {
{ "mount /system", "unmount /system", "SYSTEM:" },
{ "mount /data", "unmount /data", "DATA:" },
{ "mount /cache", "unmount /cache", "CACHE:" },
{ "mount /sdcard", "unmount /sdcard", "SDCARD:" }
string mounts[MOUNTABLE_COUNT][4] = {
{ "mount /system", "unmount /system", "format SYSTEM:", "SYSTEM:" },
{ "mount /data", "unmount /data", "format DATA:", "DATA:" },
{ "mount /cache", "unmount /cache", "format CACHE:", "CACHE:" },
{ "mount /sdcard", "unmount /sdcard", NULL, "SDCARD:" }
};
for (;;)
{
int ismounted[4];
int ismounted[MOUNTABLE_COUNT];
int i;
static string options[6];
for (i = 0; i < 4; i++)
static string options[MOUNTABLE_COUNT + MTD_COUNT + 1 + 1]; // mountables, format mtds, usb storage, null
for (i = 0; i < MOUNTABLE_COUNT; i++)
{
ismounted[i] = is_root_path_mounted(mounts[i][2]);
ismounted[i] = is_root_path_mounted(mounts[i][3]);
options[i] = ismounted[i] ? mounts[i][1] : mounts[i][0];
}
for (i = 0; i < MTD_COUNT; i++)
{
options[MOUNTABLE_COUNT + i] = mounts[i][2];
}
options[4] = "mount USB storage";
options[5] = NULL;
options[MOUNTABLE_COUNT + MTD_COUNT] = "mount USB storage";
options[MOUNTABLE_COUNT + MTD_COUNT + 1] = NULL;
int chosen_item = get_menu_selection(headers, options, 0);
if (chosen_item == GO_BACK)
break;
if (chosen_item == 4)
if (chosen_item == MOUNTABLE_COUNT + MTD_COUNT)
{
show_mount_usb_storage_menu();
}
else if (chosen_item < 4)
else if (chosen_item < MOUNTABLE_COUNT)
{
if (ismounted[chosen_item])
{
if (0 != ensure_root_path_unmounted(mounts[chosen_item][2]))
ui_print("Error unmounting %s!\n", mounts[chosen_item][2]);
if (0 != ensure_root_path_unmounted(mounts[chosen_item][3]))
ui_print("Error unmounting %s!\n", mounts[chosen_item][3]);
}
else
{
if (0 != ensure_root_path_mounted(mounts[chosen_item][2]))
ui_print("Error mounting %s!\n", mounts[chosen_item][2]);
if (0 != ensure_root_path_mounted(mounts[chosen_item][3]))
ui_print("Error mounting %s!\n", mounts[chosen_item][3]);
}
}
else if (chosen_item < MOUNTABLE_COUNT + MTD_COUNT)
{
chosen_item = chosen_item - MOUNTABLE_COUNT;
}
}
}
@ -515,3 +526,33 @@ int amend_main(int argc, char** argv)
}
return run_script(argv[1], 0);
}
void show_nandroid_menu()
{
static char* headers[] = { "Nandroid",
"",
NULL
};
static char* list[] = { "Backup",
"Restore",
NULL
};
int chosen_item = get_menu_selection(headers, list, 0);
switch (chosen_item)
{
case 0:
{
struct timeval tp;
gettimeofday(&tp, NULL);
char backup_path[PATH_MAX];
sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec);
nandroid_backup(backup_path);
}
break;
case 1:
show_nandroid_restore_menu();
break;
}
}

View File

@ -20,7 +20,10 @@ void
show_nandroid_restore_menu();
void
show_mount_menu();
show_nandroid_menu();
void
show_partition_menu();
void
show_choose_zip_menu();

View File

@ -445,20 +445,11 @@ prompt_and_wait()
case ITEM_INSTALL_ZIP:
show_install_update_menu();
break;
case ITEM_BACKUP:
{
struct timeval tp;
gettimeofday(&tp, NULL);
char backup_path[PATH_MAX];
sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec);
nandroid_backup(backup_path);
}
case ITEM_NANDROID:
show_nandroid_menu();
break;
case ITEM_RESTORE:
show_nandroid_restore_menu();
break;
case ITEM_MOUNT:
show_mount_menu();
case ITEM_PARTITION:
show_partition_menu();
break;
/*
case ITEM_MOUNT_SDCARD:

View File

@ -68,9 +68,8 @@ int device_wipe_data();
#define ITEM_WIPE_DATA 2
#define ITEM_WIPE_CACHE 3
#define ITEM_INSTALL_ZIP 4
#define ITEM_BACKUP 5
#define ITEM_RESTORE 6
#define ITEM_MOUNT 7
#define ITEM_NANDROID 5
#define ITEM_PARTITION 6
// Header text to display above the main menu.
extern char* MENU_HEADERS[];