2010-02-12 06:27:06 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2010-02-12 08:43:24 +00:00
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/limits.h>
|
|
|
|
#include <dirent.h>
|
2010-02-25 22:51:05 +00:00
|
|
|
#include <sys/stat.h>
|
2010-02-12 08:43:24 +00:00
|
|
|
|
2010-02-25 19:39:07 +00:00
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
2010-02-12 06:27:06 +00:00
|
|
|
#include "bootloader.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "cutils/properties.h"
|
|
|
|
#include "firmware.h"
|
|
|
|
#include "install.h"
|
|
|
|
#include "minui/minui.h"
|
|
|
|
#include "minzip/DirUtil.h"
|
|
|
|
#include "roots.h"
|
|
|
|
#include "recovery_ui.h"
|
|
|
|
|
2010-03-13 01:00:58 +00:00
|
|
|
#include "../../external/yaffs2/yaffs2/utils/mkyaffs2image.h"
|
2010-03-13 01:43:26 +00:00
|
|
|
#include "../../external/yaffs2/yaffs2/utils/unyaffs.h"
|
2010-03-13 01:00:58 +00:00
|
|
|
|
2010-03-13 07:21:12 +00:00
|
|
|
#include "extendedcommands.h"
|
|
|
|
#include "nandroid.h"
|
2010-12-19 01:42:31 +00:00
|
|
|
#include "mounts.h"
|
2010-12-19 05:31:02 +00:00
|
|
|
#include "flashutils/flashutils.h"
|
2010-12-20 04:37:57 +00:00
|
|
|
#include "edify/expr.h"
|
2011-05-26 18:47:56 +00:00
|
|
|
#include <libgen.h>
|
2011-09-06 04:14:06 +00:00
|
|
|
#include "mtdutils/mtdutils.h"
|
2011-11-10 18:55:22 +00:00
|
|
|
#include "bmlutils/bmlutils.h"
|
2011-11-17 00:00:35 +00:00
|
|
|
#include "cutils/android_reboot.h"
|
2011-05-26 18:47:56 +00:00
|
|
|
|
2010-03-13 07:21:12 +00:00
|
|
|
|
2010-02-12 06:27:06 +00:00
|
|
|
int signature_check_enabled = 1;
|
|
|
|
int script_assert_enabled = 1;
|
2010-12-19 01:42:31 +00:00
|
|
|
static const char *SDCARD_UPDATE_FILE = "/sdcard/update.zip";
|
2010-02-12 06:27:06 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
toggle_signature_check()
|
|
|
|
{
|
|
|
|
signature_check_enabled = !signature_check_enabled;
|
|
|
|
ui_print("Signature Check: %s\n", signature_check_enabled ? "Enabled" : "Disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
void toggle_script_asserts()
|
|
|
|
{
|
|
|
|
script_assert_enabled = !script_assert_enabled;
|
2010-02-12 08:43:24 +00:00
|
|
|
ui_print("Script Asserts: %s\n", script_assert_enabled ? "Enabled" : "Disabled");
|
|
|
|
}
|
|
|
|
|
2010-03-08 10:58:04 +00:00
|
|
|
int install_zip(const char* packagefilepath)
|
2010-02-22 05:10:25 +00:00
|
|
|
{
|
|
|
|
ui_print("\n-- Installing: %s\n", packagefilepath);
|
2010-12-19 05:31:02 +00:00
|
|
|
if (device_flash_type() == MTD) {
|
|
|
|
set_sdcard_update_bootloader_message();
|
|
|
|
}
|
2010-02-22 05:10:25 +00:00
|
|
|
int status = install_package(packagefilepath);
|
2010-04-19 01:06:24 +00:00
|
|
|
ui_reset_progress();
|
2010-02-22 05:10:25 +00:00
|
|
|
if (status != INSTALL_SUCCESS) {
|
|
|
|
ui_set_background(BACKGROUND_ICON_ERROR);
|
|
|
|
ui_print("Installation aborted.\n");
|
2010-03-08 10:58:04 +00:00
|
|
|
return 1;
|
2010-11-14 08:18:40 +00:00
|
|
|
}
|
2010-02-25 22:53:57 +00:00
|
|
|
ui_set_background(BACKGROUND_ICON_NONE);
|
2010-03-03 08:42:58 +00:00
|
|
|
ui_print("\nInstall from sdcard complete.\n");
|
2010-03-08 10:58:04 +00:00
|
|
|
return 0;
|
2010-02-22 05:10:25 +00:00
|
|
|
}
|
|
|
|
|
2011-06-18 08:26:32 +00:00
|
|
|
char* INSTALL_MENU_ITEMS[] = { "choose zip from sdcard",
|
|
|
|
"apply /sdcard/update.zip",
|
2010-02-22 05:10:25 +00:00
|
|
|
"toggle signature verification",
|
|
|
|
"toggle script asserts",
|
2011-09-06 04:14:06 +00:00
|
|
|
"choose zip from internal sdcard",
|
2010-02-22 05:10:25 +00:00
|
|
|
NULL };
|
2011-06-18 08:26:32 +00:00
|
|
|
#define ITEM_CHOOSE_ZIP 0
|
|
|
|
#define ITEM_APPLY_SDCARD 1
|
2010-02-22 05:10:25 +00:00
|
|
|
#define ITEM_SIG_CHECK 2
|
|
|
|
#define ITEM_ASSERTS 3
|
2011-09-06 04:14:06 +00:00
|
|
|
#define ITEM_CHOOSE_ZIP_INT 4
|
2010-02-22 05:10:25 +00:00
|
|
|
|
|
|
|
void show_install_update_menu()
|
|
|
|
{
|
|
|
|
static char* headers[] = { "Apply update from .zip file on SD card",
|
|
|
|
"",
|
2010-11-14 08:18:40 +00:00
|
|
|
NULL
|
2010-02-22 05:10:25 +00:00
|
|
|
};
|
2011-09-06 04:14:06 +00:00
|
|
|
|
|
|
|
if (volume_for_path("/emmc") == NULL)
|
|
|
|
INSTALL_MENU_ITEMS[ITEM_CHOOSE_ZIP_INT] = NULL;
|
|
|
|
|
2010-02-22 05:10:25 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
2010-12-19 01:42:31 +00:00
|
|
|
int chosen_item = get_menu_selection(headers, INSTALL_MENU_ITEMS, 0, 0);
|
2010-02-22 05:10:25 +00:00
|
|
|
switch (chosen_item)
|
|
|
|
{
|
|
|
|
case ITEM_ASSERTS:
|
|
|
|
toggle_script_asserts();
|
|
|
|
break;
|
|
|
|
case ITEM_SIG_CHECK:
|
|
|
|
toggle_signature_check();
|
|
|
|
break;
|
|
|
|
case ITEM_APPLY_SDCARD:
|
2010-07-15 04:01:21 +00:00
|
|
|
{
|
|
|
|
if (confirm_selection("Confirm install?", "Yes - Install /sdcard/update.zip"))
|
2010-12-19 01:42:31 +00:00
|
|
|
install_zip(SDCARD_UPDATE_FILE);
|
2010-02-22 05:10:25 +00:00
|
|
|
break;
|
2010-07-15 04:01:21 +00:00
|
|
|
}
|
2010-02-22 05:10:25 +00:00
|
|
|
case ITEM_CHOOSE_ZIP:
|
2011-09-06 04:14:06 +00:00
|
|
|
show_choose_zip_menu("/sdcard/");
|
|
|
|
break;
|
|
|
|
case ITEM_CHOOSE_ZIP_INT:
|
|
|
|
show_choose_zip_menu("/emmc/");
|
2010-02-22 05:10:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-02-22 05:10:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-02 23:46:21 +00:00
|
|
|
void free_string_array(char** array)
|
|
|
|
{
|
|
|
|
if (array == NULL)
|
|
|
|
return;
|
|
|
|
char* cursor = array[0];
|
|
|
|
int i = 0;
|
|
|
|
while (cursor != NULL)
|
|
|
|
{
|
|
|
|
free(cursor);
|
|
|
|
cursor = array[++i];
|
|
|
|
}
|
|
|
|
free(array);
|
|
|
|
}
|
|
|
|
|
2010-02-25 22:51:05 +00:00
|
|
|
char** gather_files(const char* directory, const char* fileExtensionOrDirectory, int* numFiles)
|
2010-02-12 08:43:24 +00:00
|
|
|
{
|
|
|
|
char path[PATH_MAX] = "";
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *de;
|
|
|
|
int total = 0;
|
|
|
|
int i;
|
2010-03-13 07:21:12 +00:00
|
|
|
char** files = NULL;
|
2010-02-25 22:53:57 +00:00
|
|
|
int pass;
|
|
|
|
*numFiles = 0;
|
|
|
|
int dirLen = strlen(directory);
|
2010-02-12 08:43:24 +00:00
|
|
|
|
2010-02-22 05:10:25 +00:00
|
|
|
dir = opendir(directory);
|
2010-02-12 08:43:24 +00:00
|
|
|
if (dir == NULL) {
|
2010-02-22 05:10:25 +00:00
|
|
|
ui_print("Couldn't open directory.\n");
|
|
|
|
return NULL;
|
2010-02-12 08:43:24 +00:00
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-03-13 07:21:12 +00:00
|
|
|
int extension_length = 0;
|
2010-02-25 22:53:57 +00:00
|
|
|
if (fileExtensionOrDirectory != NULL)
|
|
|
|
extension_length = strlen(fileExtensionOrDirectory);
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-02-25 22:53:57 +00:00
|
|
|
int isCounting = 1;
|
|
|
|
i = 0;
|
|
|
|
for (pass = 0; pass < 2; pass++) {
|
|
|
|
while ((de=readdir(dir)) != NULL) {
|
|
|
|
// skip hidden files
|
|
|
|
if (de->d_name[0] == '.')
|
|
|
|
continue;
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-02-25 22:53:57 +00:00
|
|
|
// NULL means that we are gathering directories, so skip this
|
|
|
|
if (fileExtensionOrDirectory != NULL)
|
|
|
|
{
|
|
|
|
// make sure that we can have the desired extension (prevent seg fault)
|
|
|
|
if (strlen(de->d_name) < extension_length)
|
|
|
|
continue;
|
|
|
|
// compare the extension
|
|
|
|
if (strcmp(de->d_name + strlen(de->d_name) - extension_length, fileExtensionOrDirectory) != 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct stat info;
|
2010-04-02 23:46:21 +00:00
|
|
|
char fullFileName[PATH_MAX];
|
2010-02-25 22:53:57 +00:00
|
|
|
strcpy(fullFileName, directory);
|
|
|
|
strcat(fullFileName, de->d_name);
|
|
|
|
stat(fullFileName, &info);
|
|
|
|
// make sure it is a directory
|
|
|
|
if (!(S_ISDIR(info.st_mode)))
|
|
|
|
continue;
|
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-02-25 22:53:57 +00:00
|
|
|
if (pass == 0)
|
|
|
|
{
|
|
|
|
total++;
|
|
|
|
continue;
|
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-02-25 22:51:05 +00:00
|
|
|
files[i] = (char*) malloc(dirLen + strlen(de->d_name) + 2);
|
|
|
|
strcpy(files[i], directory);
|
|
|
|
strcat(files[i], de->d_name);
|
2010-02-25 22:53:57 +00:00
|
|
|
if (fileExtensionOrDirectory == NULL)
|
|
|
|
strcat(files[i], "/");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (pass == 1)
|
|
|
|
break;
|
|
|
|
if (total == 0)
|
|
|
|
break;
|
|
|
|
rewinddir(dir);
|
|
|
|
*numFiles = total;
|
|
|
|
files = (char**) malloc((total+1)*sizeof(char*));
|
|
|
|
files[total]=NULL;
|
|
|
|
}
|
2010-02-25 22:51:05 +00:00
|
|
|
|
|
|
|
if(closedir(dir) < 0) {
|
|
|
|
LOGE("Failed to close directory.");
|
2010-02-12 08:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (total==0) {
|
2010-02-22 05:10:25 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-02-12 08:43:24 +00:00
|
|
|
|
2010-12-29 18:15:18 +00:00
|
|
|
// sort the result
|
|
|
|
if (files != NULL) {
|
|
|
|
for (i = 0; i < total; i++) {
|
|
|
|
int curMax = -1;
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < total - i; j++) {
|
|
|
|
if (curMax == -1 || strcmp(files[curMax], files[j]) < 0)
|
|
|
|
curMax = j;
|
|
|
|
}
|
|
|
|
char* temp = files[curMax];
|
|
|
|
files[curMax] = files[total - i - 1];
|
|
|
|
files[total - i - 1] = temp;
|
|
|
|
}
|
|
|
|
}
|
2010-07-01 07:23:25 +00:00
|
|
|
|
2010-02-25 22:53:57 +00:00
|
|
|
return files;
|
2010-02-25 22:51:05 +00:00
|
|
|
}
|
2010-02-12 08:43:24 +00:00
|
|
|
|
2010-02-25 22:51:05 +00:00
|
|
|
// pass in NULL for fileExtensionOrDirectory and you will get a directory chooser
|
|
|
|
char* choose_file_menu(const char* directory, const char* fileExtensionOrDirectory, const char* headers[])
|
|
|
|
{
|
|
|
|
char path[PATH_MAX] = "";
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *de;
|
|
|
|
int numFiles = 0;
|
2010-02-25 22:53:57 +00:00
|
|
|
int numDirs = 0;
|
2010-02-25 22:51:05 +00:00
|
|
|
int i;
|
2010-04-02 23:46:21 +00:00
|
|
|
char* return_value = NULL;
|
2010-02-25 22:53:57 +00:00
|
|
|
int dir_len = strlen(directory);
|
|
|
|
|
|
|
|
char** files = gather_files(directory, fileExtensionOrDirectory, &numFiles);
|
2010-03-13 07:21:12 +00:00
|
|
|
char** dirs = NULL;
|
2010-02-25 22:53:57 +00:00
|
|
|
if (fileExtensionOrDirectory != NULL)
|
|
|
|
dirs = gather_files(directory, NULL, &numDirs);
|
|
|
|
int total = numDirs + numFiles;
|
|
|
|
if (total == 0)
|
|
|
|
{
|
|
|
|
ui_print("No files found.\n");
|
|
|
|
}
|
2010-04-02 23:46:21 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char** list = (char**) malloc((total + 1) * sizeof(char*));
|
|
|
|
list[total] = NULL;
|
2010-02-25 22:53:57 +00:00
|
|
|
|
|
|
|
|
2010-04-02 23:46:21 +00:00
|
|
|
for (i = 0 ; i < numDirs; i++)
|
|
|
|
{
|
|
|
|
list[i] = strdup(dirs[i] + dir_len);
|
|
|
|
}
|
2010-02-22 05:10:25 +00:00
|
|
|
|
2010-04-02 23:46:21 +00:00
|
|
|
for (i = 0 ; i < numFiles; i++)
|
|
|
|
{
|
|
|
|
list[numDirs + i] = strdup(files[i] + dir_len);
|
|
|
|
}
|
2010-02-22 05:10:25 +00:00
|
|
|
|
2010-04-02 23:46:21 +00:00
|
|
|
for (;;)
|
2010-02-25 22:53:57 +00:00
|
|
|
{
|
2010-12-19 01:42:31 +00:00
|
|
|
int chosen_item = get_menu_selection(headers, list, 0, 0);
|
2010-04-02 23:46:21 +00:00
|
|
|
if (chosen_item == GO_BACK)
|
|
|
|
break;
|
|
|
|
static char ret[PATH_MAX];
|
|
|
|
if (chosen_item < numDirs)
|
|
|
|
{
|
|
|
|
char* subret = choose_file_menu(dirs[chosen_item], fileExtensionOrDirectory, headers);
|
|
|
|
if (subret != NULL)
|
|
|
|
{
|
|
|
|
strcpy(ret, subret);
|
|
|
|
return_value = ret;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
2010-11-14 08:18:40 +00:00
|
|
|
}
|
2010-04-02 23:46:21 +00:00
|
|
|
strcpy(ret, files[chosen_item - numDirs]);
|
|
|
|
return_value = ret;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
free_string_array(list);
|
2010-02-22 16:53:34 +00:00
|
|
|
}
|
2010-04-02 23:46:21 +00:00
|
|
|
|
|
|
|
free_string_array(files);
|
|
|
|
free_string_array(dirs);
|
|
|
|
return return_value;
|
2010-02-22 05:10:25 +00:00
|
|
|
}
|
|
|
|
|
2011-09-06 04:14:06 +00:00
|
|
|
void show_choose_zip_menu(const char *mount_point)
|
2010-02-22 05:10:25 +00:00
|
|
|
{
|
2011-09-06 04:14:06 +00:00
|
|
|
if (ensure_path_mounted(mount_point) != 0) {
|
|
|
|
LOGE ("Can't mount %s\n", mount_point);
|
2010-02-22 05:10:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char* headers[] = { "Choose a zip to apply",
|
|
|
|
"",
|
2010-11-14 08:18:40 +00:00
|
|
|
NULL
|
2010-02-22 05:10:25 +00:00
|
|
|
};
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2011-09-06 04:14:06 +00:00
|
|
|
char* file = choose_file_menu(mount_point, ".zip", headers);
|
2010-02-22 05:10:25 +00:00
|
|
|
if (file == NULL)
|
|
|
|
return;
|
2010-07-15 04:01:21 +00:00
|
|
|
static char* confirm_install = "Confirm install?";
|
|
|
|
static char confirm[PATH_MAX];
|
|
|
|
sprintf(confirm, "Yes - Install %s", basename(file));
|
|
|
|
if (confirm_selection(confirm_install, confirm))
|
2010-12-19 01:42:31 +00:00
|
|
|
install_zip(file);
|
2010-02-22 05:10:25 +00:00
|
|
|
}
|
|
|
|
|
2011-10-27 04:25:34 +00:00
|
|
|
void show_nandroid_restore_menu(const char* path)
|
2010-02-22 05:10:25 +00:00
|
|
|
{
|
2011-10-27 04:25:34 +00:00
|
|
|
if (ensure_path_mounted(path) != 0) {
|
|
|
|
LOGE("Can't mount %s\n", path);
|
2010-03-13 07:21:12 +00:00
|
|
|
return;
|
2010-03-13 01:43:26 +00:00
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-02-22 05:10:25 +00:00
|
|
|
static char* headers[] = { "Choose an image to restore",
|
|
|
|
"",
|
2010-11-14 08:18:40 +00:00
|
|
|
NULL
|
2010-02-22 05:10:25 +00:00
|
|
|
};
|
|
|
|
|
2011-10-27 04:25:34 +00:00
|
|
|
char tmp[PATH_MAX];
|
|
|
|
sprintf(tmp, "%s/clockworkmod/backup/", path);
|
|
|
|
char* file = choose_file_menu(tmp, NULL, headers);
|
2010-02-22 05:10:25 +00:00
|
|
|
if (file == NULL)
|
|
|
|
return;
|
2010-07-15 04:01:21 +00:00
|
|
|
|
|
|
|
if (confirm_selection("Confirm restore?", "Yes - Restore"))
|
2010-12-30 07:36:03 +00:00
|
|
|
nandroid_restore(file, 1, 1, 1, 1, 1, 0);
|
2010-02-26 22:14:23 +00:00
|
|
|
}
|
|
|
|
|
2011-02-28 00:54:09 +00:00
|
|
|
#ifndef BOARD_UMS_LUNFILE
|
|
|
|
#define BOARD_UMS_LUNFILE "/sys/devices/platform/usb_mass_storage/lun0/file"
|
|
|
|
#endif
|
|
|
|
|
2010-03-15 05:42:30 +00:00
|
|
|
void show_mount_usb_storage_menu()
|
2010-02-26 22:14:23 +00:00
|
|
|
{
|
2011-01-02 04:03:30 +00:00
|
|
|
int fd;
|
2010-12-19 01:42:31 +00:00
|
|
|
Volume *vol = volume_for_path("/sdcard");
|
2011-02-28 00:54:09 +00:00
|
|
|
if ((fd = open(BOARD_UMS_LUNFILE, O_WRONLY)) < 0) {
|
2011-01-02 04:03:30 +00:00
|
|
|
LOGE("Unable to open ums lunfile (%s)", strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-04-26 16:15:22 +00:00
|
|
|
if ((write(fd, vol->device, strlen(vol->device)) < 0) &&
|
|
|
|
(!vol->device2 || (write(fd, vol->device, strlen(vol->device2)) < 0))) {
|
2011-01-02 04:03:30 +00:00
|
|
|
LOGE("Unable to write to ums lunfile (%s)", strerror(errno));
|
|
|
|
close(fd);
|
|
|
|
return -1;
|
|
|
|
}
|
2010-02-26 22:14:23 +00:00
|
|
|
static char* headers[] = { "USB Mass Storage device",
|
|
|
|
"Leaving this menu unmount",
|
|
|
|
"your SD card from your PC.",
|
|
|
|
"",
|
2010-11-14 08:18:40 +00:00
|
|
|
NULL
|
2010-02-26 22:14:23 +00:00
|
|
|
};
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-02-26 22:14:23 +00:00
|
|
|
static char* list[] = { "Unmount", NULL };
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-02-26 22:14:23 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
2010-12-19 01:42:31 +00:00
|
|
|
int chosen_item = get_menu_selection(headers, list, 0, 0);
|
2010-02-26 22:14:23 +00:00
|
|
|
if (chosen_item == GO_BACK || chosen_item == 0)
|
|
|
|
break;
|
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2011-02-28 00:54:09 +00:00
|
|
|
if ((fd = open(BOARD_UMS_LUNFILE, O_WRONLY)) < 0) {
|
2011-01-02 04:03:30 +00:00
|
|
|
LOGE("Unable to open ums lunfile (%s)", strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char ch = 0;
|
|
|
|
if (write(fd, &ch, 1) < 0) {
|
|
|
|
LOGE("Unable to write to ums lunfile (%s)", strerror(errno));
|
|
|
|
close(fd);
|
|
|
|
return -1;
|
|
|
|
}
|
2010-02-27 01:44:33 +00:00
|
|
|
}
|
2010-03-07 21:39:21 +00:00
|
|
|
|
2010-07-15 04:01:21 +00:00
|
|
|
int confirm_selection(const char* title, const char* confirm)
|
2010-03-19 21:37:11 +00:00
|
|
|
{
|
2010-08-23 23:13:14 +00:00
|
|
|
struct stat info;
|
|
|
|
if (0 == stat("/sdcard/clockworkmod/.no_confirm", &info))
|
|
|
|
return 1;
|
|
|
|
|
2010-07-15 04:01:21 +00:00
|
|
|
char* confirm_headers[] = { title, " THIS CAN NOT BE UNDONE.", "", NULL };
|
|
|
|
char* items[] = { "No",
|
|
|
|
"No",
|
|
|
|
"No",
|
|
|
|
"No",
|
|
|
|
"No",
|
|
|
|
"No",
|
|
|
|
"No",
|
2010-07-15 01:38:02 +00:00
|
|
|
confirm, //" Yes -- wipe partition", // [7
|
2010-07-15 04:01:21 +00:00
|
|
|
"No",
|
|
|
|
"No",
|
|
|
|
"No",
|
2010-03-19 21:37:11 +00:00
|
|
|
NULL };
|
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
int chosen_item = get_menu_selection(confirm_headers, items, 0, 0);
|
2010-03-19 21:37:11 +00:00
|
|
|
return chosen_item == 7;
|
|
|
|
}
|
|
|
|
|
2011-01-02 01:55:22 +00:00
|
|
|
#define MKE2FS_BIN "/sbin/mke2fs"
|
|
|
|
#define TUNE2FS_BIN "/sbin/tune2fs"
|
|
|
|
#define E2FSCK_BIN "/sbin/e2fsck"
|
|
|
|
|
2011-09-06 04:14:06 +00:00
|
|
|
int format_device(const char *device, const char *path, const char *fs_type) {
|
|
|
|
Volume* v = volume_for_path(path);
|
|
|
|
if (v == NULL) {
|
|
|
|
// no /sdcard? let's assume /data/media
|
|
|
|
if (strstr(path, "/sdcard") == path && is_data_media()) {
|
|
|
|
return format_unknown_device(NULL, path, NULL);
|
|
|
|
}
|
|
|
|
// silent failure for sd-ext
|
|
|
|
if (strcmp(path, "/sd-ext") == 0)
|
|
|
|
return -1;
|
|
|
|
LOGE("unknown volume \"%s\"\n", path);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (strcmp(fs_type, "ramdisk") == 0) {
|
|
|
|
// you can't format the ramdisk.
|
|
|
|
LOGE("can't format_volume \"%s\"", path);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-11-10 18:55:22 +00:00
|
|
|
if (strcmp(fs_type, "rfs") == 0) {
|
|
|
|
if (ensure_path_unmounted(path) != 0) {
|
|
|
|
LOGE("format_volume failed to unmount \"%s\"\n", v->mount_point);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (0 != format_rfs_device(device, path)) {
|
|
|
|
LOGE("format_volume: format_rfs_device failed on %s\n", device);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-06 04:14:06 +00:00
|
|
|
if (strcmp(v->mount_point, path) != 0) {
|
|
|
|
return format_unknown_device(v->device, path, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ensure_path_unmounted(path) != 0) {
|
|
|
|
LOGE("format_volume failed to unmount \"%s\"\n", v->mount_point);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(fs_type, "yaffs2") == 0 || strcmp(fs_type, "mtd") == 0) {
|
|
|
|
mtd_scan_partitions();
|
|
|
|
const MtdPartition* partition = mtd_find_partition_by_name(device);
|
|
|
|
if (partition == NULL) {
|
|
|
|
LOGE("format_volume: no MTD partition \"%s\"\n", device);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
MtdWriteContext *write = mtd_write_partition(partition);
|
|
|
|
if (write == NULL) {
|
|
|
|
LOGW("format_volume: can't open MTD \"%s\"\n", device);
|
|
|
|
return -1;
|
|
|
|
} else if (mtd_erase_blocks(write, -1) == (off_t) -1) {
|
|
|
|
LOGW("format_volume: can't erase MTD \"%s\"\n", device);
|
|
|
|
mtd_write_close(write);
|
|
|
|
return -1;
|
|
|
|
} else if (mtd_write_close(write)) {
|
|
|
|
LOGW("format_volume: can't close MTD \"%s\"\n",device);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(fs_type, "ext4") == 0) {
|
|
|
|
reset_ext4fs_info();
|
|
|
|
int result = make_ext4fs(device, NULL, NULL, 0, 0, 0);
|
|
|
|
if (result != 0) {
|
|
|
|
LOGE("format_volume: make_extf4fs failed on %s\n", device);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return format_unknown_device(device, path, fs_type);
|
|
|
|
}
|
|
|
|
|
2011-01-02 01:55:22 +00:00
|
|
|
int format_unknown_device(const char *device, const char* path, const char *fs_type)
|
2010-03-31 06:29:43 +00:00
|
|
|
{
|
2011-01-02 02:06:17 +00:00
|
|
|
LOGI("Formatting unknown device.\n");
|
2011-01-02 02:00:27 +00:00
|
|
|
|
2011-06-16 21:13:02 +00:00
|
|
|
if (fs_type != NULL && get_flash_type(fs_type) != UNSUPPORTED)
|
2011-05-26 18:14:15 +00:00
|
|
|
return erase_raw_partition(fs_type, device);
|
2011-01-02 01:55:22 +00:00
|
|
|
|
2011-01-02 22:11:24 +00:00
|
|
|
// if this is SDEXT:, don't worry about it if it does not exist.
|
2010-12-19 01:42:31 +00:00
|
|
|
if (0 == strcmp(path, "/sd-ext"))
|
2010-04-19 01:06:24 +00:00
|
|
|
{
|
|
|
|
struct stat st;
|
2010-12-19 01:42:31 +00:00
|
|
|
Volume *vol = volume_for_path("/sd-ext");
|
|
|
|
if (vol == NULL || 0 != stat(vol->device, &st))
|
2010-04-19 01:06:24 +00:00
|
|
|
{
|
|
|
|
ui_print("No app2sd partition found. Skipping format of /sd-ext.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2010-04-18 23:00:21 +00:00
|
|
|
|
2011-01-02 22:11:24 +00:00
|
|
|
if (NULL != fs_type) {
|
|
|
|
if (strcmp("ext3", fs_type) == 0) {
|
|
|
|
LOGI("Formatting ext3 device.\n");
|
|
|
|
if (0 != ensure_path_unmounted(path)) {
|
|
|
|
LOGE("Error while unmounting %s.\n", path);
|
|
|
|
return -12;
|
|
|
|
}
|
|
|
|
return format_ext3_device(device);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp("ext2", fs_type) == 0) {
|
|
|
|
LOGI("Formatting ext2 device.\n");
|
|
|
|
if (0 != ensure_path_unmounted(path)) {
|
|
|
|
LOGE("Error while unmounting %s.\n", path);
|
|
|
|
return -12;
|
|
|
|
}
|
|
|
|
return format_ext2_device(device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
if (0 != ensure_path_mounted(path))
|
2010-03-31 06:29:43 +00:00
|
|
|
{
|
|
|
|
ui_print("Error mounting %s!\n", path);
|
2010-06-23 07:02:14 +00:00
|
|
|
ui_print("Skipping format...\n");
|
|
|
|
return 0;
|
2010-03-31 06:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char tmp[PATH_MAX];
|
2011-06-09 02:03:27 +00:00
|
|
|
if (strcmp(path, "/data") == 0) {
|
|
|
|
sprintf(tmp, "cd /data ; for f in $(ls -a | grep -v ^media$); do rm -rf $f; done");
|
|
|
|
__system(tmp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(tmp, "rm -rf %s/*", path);
|
|
|
|
__system(tmp);
|
|
|
|
sprintf(tmp, "rm -rf %s/.*", path);
|
|
|
|
__system(tmp);
|
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
ensure_path_unmounted(path);
|
2010-03-31 06:29:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
//#define MOUNTABLE_COUNT 5
|
|
|
|
//#define DEVICE_COUNT 4
|
|
|
|
//#define MMC_COUNT 2
|
2010-03-15 05:42:30 +00:00
|
|
|
|
2011-02-13 19:59:30 +00:00
|
|
|
typedef struct {
|
|
|
|
char mount[255];
|
|
|
|
char unmount[255];
|
|
|
|
Volume* v;
|
|
|
|
} MountMenuEntry;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char txt[255];
|
|
|
|
Volume* v;
|
|
|
|
} FormatMenuEntry;
|
|
|
|
|
2011-04-09 05:41:45 +00:00
|
|
|
int is_safe_to_format(char* name)
|
|
|
|
{
|
2011-05-08 05:42:58 +00:00
|
|
|
char str[255];
|
|
|
|
char* partition;
|
2011-06-09 22:37:28 +00:00
|
|
|
property_get("ro.cwm.forbid_format", str, "/misc,/radio,/bootloader,/recovery,/efs");
|
2011-05-08 05:42:58 +00:00
|
|
|
|
|
|
|
partition = strtok(str, ", ");
|
|
|
|
while (partition != NULL) {
|
|
|
|
if (strcmp(name, partition) == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
partition = strtok(NULL, ", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2011-04-09 05:41:45 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 20:34:36 +00:00
|
|
|
void show_partition_menu()
|
2010-03-15 05:42:30 +00:00
|
|
|
{
|
2010-08-23 23:13:14 +00:00
|
|
|
static char* headers[] = { "Mounts and Storage Menu",
|
2010-03-15 05:42:30 +00:00
|
|
|
"",
|
2010-11-14 08:18:40 +00:00
|
|
|
NULL
|
2010-03-15 05:42:30 +00:00
|
|
|
};
|
|
|
|
|
2011-02-13 19:59:30 +00:00
|
|
|
static MountMenuEntry* mount_menue = NULL;
|
|
|
|
static FormatMenuEntry* format_menue = NULL;
|
|
|
|
|
2010-03-15 05:42:30 +00:00
|
|
|
typedef char* string;
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2011-02-13 19:59:30 +00:00
|
|
|
int i, mountable_volumes, formatable_volumes;
|
|
|
|
int num_volumes;
|
|
|
|
Volume* device_volumes;
|
|
|
|
|
|
|
|
num_volumes = get_num_volumes();
|
|
|
|
device_volumes = get_device_volumes();
|
|
|
|
|
|
|
|
string options[255];
|
|
|
|
|
|
|
|
if(!device_volumes)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mountable_volumes = 0;
|
|
|
|
formatable_volumes = 0;
|
|
|
|
|
|
|
|
mount_menue = malloc(num_volumes * sizeof(MountMenuEntry));
|
|
|
|
format_menue = malloc(num_volumes * sizeof(FormatMenuEntry));
|
|
|
|
|
|
|
|
for (i = 0; i < num_volumes; ++i) {
|
|
|
|
Volume* v = &device_volumes[i];
|
2011-03-17 18:37:21 +00:00
|
|
|
if(strcmp("ramdisk", v->fs_type) != 0 && strcmp("mtd", v->fs_type) != 0 && strcmp("emmc", v->fs_type) != 0 && strcmp("bml", v->fs_type) != 0)
|
2011-02-13 19:59:30 +00:00
|
|
|
{
|
|
|
|
sprintf(&mount_menue[mountable_volumes].mount, "mount %s", v->mount_point);
|
|
|
|
sprintf(&mount_menue[mountable_volumes].unmount, "unmount %s", v->mount_point);
|
|
|
|
mount_menue[mountable_volumes].v = &device_volumes[i];
|
|
|
|
++mountable_volumes;
|
2011-04-09 05:41:45 +00:00
|
|
|
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;
|
|
|
|
}
|
2011-02-13 19:59:30 +00:00
|
|
|
}
|
2011-04-09 05:41:45 +00:00
|
|
|
else if (strcmp("ramdisk", v->fs_type) != 0 && strcmp("mtd", v->fs_type) == 0 && is_safe_to_format(v->mount_point))
|
2011-02-13 19:59:30 +00:00
|
|
|
{
|
|
|
|
sprintf(&format_menue[formatable_volumes].txt, "format %s", v->mount_point);
|
|
|
|
format_menue[formatable_volumes].v = &device_volumes[i];
|
|
|
|
++formatable_volumes;
|
|
|
|
}
|
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
|
2010-07-15 04:01:21 +00:00
|
|
|
static char* confirm_format = "Confirm format?";
|
2010-07-15 01:38:02 +00:00
|
|
|
static char* confirm = "Yes - Format";
|
2011-05-01 01:04:04 +00:00
|
|
|
char confirm_string[255];
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-03-15 05:42:30 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2011-02-13 19:59:30 +00:00
|
|
|
for (i = 0; i < mountable_volumes; i++)
|
|
|
|
{
|
|
|
|
MountMenuEntry* e = &mount_menue[i];
|
|
|
|
Volume* v = e->v;
|
|
|
|
if(is_path_mounted(v->mount_point))
|
|
|
|
options[i] = e->unmount;
|
|
|
|
else
|
|
|
|
options[i] = e->mount;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < formatable_volumes; i++)
|
|
|
|
{
|
|
|
|
FormatMenuEntry* e = &format_menue[i];
|
|
|
|
|
|
|
|
options[mountable_volumes+i] = e->txt;
|
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2011-02-13 19:59:30 +00:00
|
|
|
options[mountable_volumes+formatable_volumes] = "mount USB storage";
|
|
|
|
options[mountable_volumes+formatable_volumes + 1] = NULL;
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2011-02-13 19:59:30 +00:00
|
|
|
int chosen_item = get_menu_selection(headers, &options, 0, 0);
|
2010-03-15 05:42:30 +00:00
|
|
|
if (chosen_item == GO_BACK)
|
|
|
|
break;
|
2011-02-13 19:59:30 +00:00
|
|
|
if (chosen_item == (mountable_volumes+formatable_volumes))
|
2010-03-15 05:42:30 +00:00
|
|
|
{
|
|
|
|
show_mount_usb_storage_menu();
|
|
|
|
}
|
2011-02-13 19:59:30 +00:00
|
|
|
else if (chosen_item < mountable_volumes)
|
2010-03-15 05:42:30 +00:00
|
|
|
{
|
2011-02-13 19:59:30 +00:00
|
|
|
MountMenuEntry* e = &mount_menue[chosen_item];
|
|
|
|
Volume* v = e->v;
|
|
|
|
|
|
|
|
if (is_path_mounted(v->mount_point))
|
2010-03-15 05:42:30 +00:00
|
|
|
{
|
2011-02-13 19:59:30 +00:00
|
|
|
if (0 != ensure_path_unmounted(v->mount_point))
|
|
|
|
ui_print("Error unmounting %s!\n", v->mount_point);
|
2010-03-15 05:42:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-13 19:59:30 +00:00
|
|
|
if (0 != ensure_path_mounted(v->mount_point))
|
|
|
|
ui_print("Error mounting %s!\n", v->mount_point);
|
2010-03-15 05:42:30 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-13 19:59:30 +00:00
|
|
|
else if (chosen_item < (mountable_volumes + formatable_volumes))
|
2010-03-19 20:34:36 +00:00
|
|
|
{
|
2011-02-13 19:59:30 +00:00
|
|
|
chosen_item = chosen_item - mountable_volumes;
|
|
|
|
FormatMenuEntry* e = &format_menue[chosen_item];
|
|
|
|
Volume* v = e->v;
|
|
|
|
|
2011-05-01 01:04:04 +00:00
|
|
|
sprintf(confirm_string, "%s - %s", v->mount_point, confirm_format);
|
|
|
|
|
|
|
|
if (!confirm_selection(confirm_string, confirm))
|
2010-03-19 21:37:11 +00:00
|
|
|
continue;
|
2011-02-13 19:59:30 +00:00
|
|
|
ui_print("Formatting %s...\n", v->mount_point);
|
|
|
|
if (0 != format_volume(v->mount_point))
|
|
|
|
ui_print("Error formatting %s!\n", v->mount_point);
|
2010-03-31 06:29:43 +00:00
|
|
|
else
|
|
|
|
ui_print("Done.\n");
|
2010-03-19 20:34:36 +00:00
|
|
|
}
|
2010-03-15 05:42:30 +00:00
|
|
|
}
|
2011-02-13 19:59:30 +00:00
|
|
|
|
|
|
|
free(mount_menue);
|
|
|
|
free(format_menue);
|
|
|
|
|
2010-03-15 05:42:30 +00:00
|
|
|
}
|
|
|
|
|
2011-10-27 04:25:34 +00:00
|
|
|
void show_nandroid_advanced_restore_menu(const char* path)
|
2010-03-26 01:19:23 +00:00
|
|
|
{
|
2011-10-30 01:48:18 +00:00
|
|
|
if (ensure_path_mounted(path) != 0) {
|
|
|
|
LOGE ("Can't mount sdcard\n");
|
2010-03-26 01:19:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char* advancedheaders[] = { "Choose an image to restore",
|
|
|
|
"",
|
|
|
|
"Choose an image to restore",
|
|
|
|
"first. The next menu will",
|
|
|
|
"you more options.",
|
|
|
|
"",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2011-10-30 01:48:18 +00:00
|
|
|
char tmp[PATH_MAX];
|
2011-11-11 08:26:32 +00:00
|
|
|
sprintf(tmp, "%s/clockworkmod/backup/", path);
|
2011-10-30 01:48:18 +00:00
|
|
|
char* file = choose_file_menu(tmp, NULL, advancedheaders);
|
2010-03-26 01:19:23 +00:00
|
|
|
if (file == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
static char* headers[] = { "Nandroid Advanced Restore",
|
|
|
|
"",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static char* list[] = { "Restore boot",
|
|
|
|
"Restore system",
|
|
|
|
"Restore data",
|
|
|
|
"Restore cache",
|
2010-04-01 19:20:39 +00:00
|
|
|
"Restore sd-ext",
|
2010-12-29 18:15:18 +00:00
|
|
|
"Restore wimax",
|
2010-03-26 01:19:23 +00:00
|
|
|
NULL
|
|
|
|
};
|
2010-12-30 07:36:03 +00:00
|
|
|
|
|
|
|
if (0 != get_partition_device("wimax", tmp)) {
|
|
|
|
// disable wimax restore option
|
|
|
|
list[5] = NULL;
|
|
|
|
}
|
2010-07-15 04:01:21 +00:00
|
|
|
|
|
|
|
static char* confirm_restore = "Confirm restore?";
|
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
int chosen_item = get_menu_selection(headers, list, 0, 0);
|
2010-03-26 01:19:23 +00:00
|
|
|
switch (chosen_item)
|
|
|
|
{
|
|
|
|
case 0:
|
2010-07-15 04:01:21 +00:00
|
|
|
if (confirm_selection(confirm_restore, "Yes - Restore boot"))
|
2010-12-29 18:15:18 +00:00
|
|
|
nandroid_restore(file, 1, 0, 0, 0, 0, 0);
|
2010-03-26 01:19:23 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2010-07-15 04:01:21 +00:00
|
|
|
if (confirm_selection(confirm_restore, "Yes - Restore system"))
|
2010-12-29 18:15:18 +00:00
|
|
|
nandroid_restore(file, 0, 1, 0, 0, 0, 0);
|
2010-03-26 01:19:23 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2010-07-15 04:01:21 +00:00
|
|
|
if (confirm_selection(confirm_restore, "Yes - Restore data"))
|
2010-12-29 18:15:18 +00:00
|
|
|
nandroid_restore(file, 0, 0, 1, 0, 0, 0);
|
2010-03-26 01:19:23 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2010-07-15 04:01:21 +00:00
|
|
|
if (confirm_selection(confirm_restore, "Yes - Restore cache"))
|
2010-12-29 18:15:18 +00:00
|
|
|
nandroid_restore(file, 0, 0, 0, 1, 0, 0);
|
2010-03-26 01:19:23 +00:00
|
|
|
break;
|
2010-04-18 23:00:21 +00:00
|
|
|
case 4:
|
2010-07-15 04:01:21 +00:00
|
|
|
if (confirm_selection(confirm_restore, "Yes - Restore sd-ext"))
|
2010-12-29 18:15:18 +00:00
|
|
|
nandroid_restore(file, 0, 0, 0, 0, 1, 0);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (confirm_selection(confirm_restore, "Yes - Restore wimax"))
|
|
|
|
nandroid_restore(file, 0, 0, 0, 0, 0, 1);
|
2010-04-18 23:00:21 +00:00
|
|
|
break;
|
2010-03-26 01:19:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-19 20:34:36 +00:00
|
|
|
void show_nandroid_menu()
|
|
|
|
{
|
|
|
|
static char* headers[] = { "Nandroid",
|
|
|
|
"",
|
2010-11-14 08:18:40 +00:00
|
|
|
NULL
|
2010-03-19 20:34:36 +00:00
|
|
|
};
|
|
|
|
|
2011-10-27 04:25:34 +00:00
|
|
|
static char* list[] = { "backup",
|
|
|
|
"restore",
|
|
|
|
"advanced restore",
|
|
|
|
"backup to internal sdcard",
|
|
|
|
"restore from internal sdcard",
|
|
|
|
"advanced restore from internal sdcard",
|
2010-03-19 20:34:36 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2011-10-27 04:25:34 +00:00
|
|
|
if (volume_for_path("/emmc") == NULL)
|
2011-10-28 18:47:02 +00:00
|
|
|
list[3] = NULL;
|
2011-10-27 04:25:34 +00:00
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
int chosen_item = get_menu_selection(headers, list, 0, 0);
|
2010-03-19 20:34:36 +00:00
|
|
|
switch (chosen_item)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
char backup_path[PATH_MAX];
|
2010-03-27 22:26:11 +00:00
|
|
|
time_t t = time(NULL);
|
|
|
|
struct tm *tmp = localtime(&t);
|
|
|
|
if (tmp == NULL)
|
|
|
|
{
|
|
|
|
struct timeval tp;
|
|
|
|
gettimeofday(&tp, NULL);
|
|
|
|
sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strftime(backup_path, sizeof(backup_path), "/sdcard/clockworkmod/backup/%F.%H.%M.%S", tmp);
|
|
|
|
}
|
2010-03-19 20:34:36 +00:00
|
|
|
nandroid_backup(backup_path);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2011-10-27 04:25:34 +00:00
|
|
|
show_nandroid_restore_menu("/sdcard");
|
2010-03-19 20:34:36 +00:00
|
|
|
break;
|
2010-03-26 01:19:23 +00:00
|
|
|
case 2:
|
2011-10-27 04:25:34 +00:00
|
|
|
show_nandroid_advanced_restore_menu("/sdcard");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
char backup_path[PATH_MAX];
|
|
|
|
time_t t = time(NULL);
|
|
|
|
struct tm *tmp = localtime(&t);
|
|
|
|
if (tmp == NULL)
|
|
|
|
{
|
|
|
|
struct timeval tp;
|
|
|
|
gettimeofday(&tp, NULL);
|
|
|
|
sprintf(backup_path, "/emmc/clockworkmod/backup/%d", tp.tv_sec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strftime(backup_path, sizeof(backup_path), "/emmc/clockworkmod/backup/%F.%H.%M.%S", tmp);
|
|
|
|
}
|
|
|
|
nandroid_backup(backup_path);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
show_nandroid_restore_menu("/emmc");
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
show_nandroid_advanced_restore_menu("/emmc");
|
2010-03-26 01:19:23 +00:00
|
|
|
break;
|
2010-03-19 20:34:36 +00:00
|
|
|
}
|
2010-03-19 21:51:45 +00:00
|
|
|
}
|
|
|
|
|
2010-05-01 19:46:55 +00:00
|
|
|
void wipe_battery_stats()
|
|
|
|
{
|
2010-12-19 01:42:31 +00:00
|
|
|
ensure_path_mounted("/data");
|
2010-05-01 19:46:55 +00:00
|
|
|
remove("/data/system/batterystats.bin");
|
2010-12-19 01:42:31 +00:00
|
|
|
ensure_path_unmounted("/data");
|
2011-07-11 02:48:39 +00:00
|
|
|
ui_print("Battery Stats wiped.\n");
|
2010-05-01 19:46:55 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:51:45 +00:00
|
|
|
void show_advanced_menu()
|
|
|
|
{
|
|
|
|
static char* headers[] = { "Advanced and Debugging Menu",
|
|
|
|
"",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2010-04-07 06:04:52 +00:00
|
|
|
static char* list[] = { "Reboot Recovery",
|
2010-06-21 20:45:51 +00:00
|
|
|
"Wipe Dalvik Cache",
|
2010-05-01 19:46:55 +00:00
|
|
|
"Wipe Battery Stats",
|
2010-06-20 16:42:47 +00:00
|
|
|
"Report Error",
|
2010-04-07 06:04:52 +00:00
|
|
|
"Key Test",
|
2011-06-10 18:26:44 +00:00
|
|
|
"Show log",
|
2010-08-29 19:35:10 +00:00
|
|
|
#ifndef BOARD_HAS_SMALL_RECOVERY
|
2010-08-23 23:13:14 +00:00
|
|
|
"Partition SD Card",
|
|
|
|
"Fix Permissions",
|
2010-12-12 03:52:06 +00:00
|
|
|
#ifdef BOARD_HAS_SDCARD_INTERNAL
|
|
|
|
"Partition Internal SD Card",
|
|
|
|
#endif
|
2010-08-29 19:35:10 +00:00
|
|
|
#endif
|
2010-03-19 21:51:45 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2010-12-19 01:42:31 +00:00
|
|
|
int chosen_item = get_menu_selection(headers, list, 0, 0);
|
2010-03-19 21:51:45 +00:00
|
|
|
if (chosen_item == GO_BACK)
|
|
|
|
break;
|
|
|
|
switch (chosen_item)
|
|
|
|
{
|
|
|
|
case 0:
|
2011-06-10 18:26:44 +00:00
|
|
|
{
|
2011-11-17 00:00:35 +00:00
|
|
|
android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
|
2010-04-07 06:04:52 +00:00
|
|
|
break;
|
2011-06-10 18:26:44 +00:00
|
|
|
}
|
2010-04-07 06:04:52 +00:00
|
|
|
case 1:
|
2010-07-15 04:01:21 +00:00
|
|
|
{
|
2010-12-19 01:42:31 +00:00
|
|
|
if (0 != ensure_path_mounted("/data"))
|
2010-06-21 20:45:51 +00:00
|
|
|
break;
|
2010-12-19 01:42:31 +00:00
|
|
|
ensure_path_mounted("/sd-ext");
|
|
|
|
ensure_path_mounted("/cache");
|
2010-08-07 19:17:13 +00:00
|
|
|
if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) {
|
2010-07-15 04:01:21 +00:00
|
|
|
__system("rm -r /data/dalvik-cache");
|
2010-08-07 19:17:13 +00:00
|
|
|
__system("rm -r /cache/dalvik-cache");
|
|
|
|
__system("rm -r /sd-ext/dalvik-cache");
|
2011-09-06 04:14:06 +00:00
|
|
|
ui_print("Dalvik Cache wiped.\n");
|
2010-08-07 19:17:13 +00:00
|
|
|
}
|
2010-12-19 01:42:31 +00:00
|
|
|
ensure_path_unmounted("/data");
|
2010-05-01 19:46:55 +00:00
|
|
|
break;
|
2010-07-15 04:01:21 +00:00
|
|
|
}
|
2010-05-01 19:46:55 +00:00
|
|
|
case 2:
|
2010-07-15 04:01:21 +00:00
|
|
|
{
|
|
|
|
if (confirm_selection( "Confirm wipe?", "Yes - Wipe Battery Stats"))
|
|
|
|
wipe_battery_stats();
|
2010-06-20 16:42:47 +00:00
|
|
|
break;
|
2010-07-15 04:01:21 +00:00
|
|
|
}
|
2010-06-20 16:42:47 +00:00
|
|
|
case 3:
|
2010-06-21 20:45:51 +00:00
|
|
|
handle_failure(1);
|
|
|
|
break;
|
|
|
|
case 4:
|
2010-03-19 21:51:45 +00:00
|
|
|
{
|
|
|
|
ui_print("Outputting key codes.\n");
|
|
|
|
ui_print("Go back to end debugging.\n");
|
|
|
|
int key;
|
|
|
|
int action;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
key = ui_wait_key();
|
|
|
|
action = device_handle_key(key, 1);
|
|
|
|
ui_print("Key: %d\n", key);
|
|
|
|
}
|
|
|
|
while (action != GO_BACK);
|
2010-08-23 23:15:33 +00:00
|
|
|
break;
|
2010-03-19 21:51:45 +00:00
|
|
|
}
|
2010-08-17 23:55:38 +00:00
|
|
|
case 5:
|
2011-06-10 18:26:44 +00:00
|
|
|
{
|
|
|
|
ui_printlogtail(12);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 6:
|
2010-08-17 23:55:38 +00:00
|
|
|
{
|
2010-08-23 23:13:14 +00:00
|
|
|
static char* ext_sizes[] = { "128M",
|
|
|
|
"256M",
|
|
|
|
"512M",
|
|
|
|
"1024M",
|
2010-11-14 22:31:17 +00:00
|
|
|
"2048M",
|
|
|
|
"4096M",
|
2010-08-23 23:13:14 +00:00
|
|
|
NULL };
|
|
|
|
|
|
|
|
static char* swap_sizes[] = { "0M",
|
|
|
|
"32M",
|
|
|
|
"64M",
|
|
|
|
"128M",
|
|
|
|
"256M",
|
|
|
|
NULL };
|
|
|
|
|
|
|
|
static char* ext_headers[] = { "Ext Size", "", NULL };
|
|
|
|
static char* swap_headers[] = { "Swap Size", "", NULL };
|
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
int ext_size = get_menu_selection(ext_headers, ext_sizes, 0, 0);
|
2010-08-23 23:13:14 +00:00
|
|
|
if (ext_size == GO_BACK)
|
|
|
|
continue;
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
int swap_size = get_menu_selection(swap_headers, swap_sizes, 0, 0);
|
2010-08-23 23:13:14 +00:00
|
|
|
if (swap_size == GO_BACK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
char sddevice[256];
|
2010-12-19 01:42:31 +00:00
|
|
|
Volume *vol = volume_for_path("/sdcard");
|
|
|
|
strcpy(sddevice, vol->device);
|
2010-08-23 23:13:14 +00:00
|
|
|
// we only want the mmcblk, not the partition
|
|
|
|
sddevice[strlen("/dev/block/mmcblkX")] = NULL;
|
|
|
|
char cmd[PATH_MAX];
|
|
|
|
setenv("SDPATH", sddevice, 1);
|
|
|
|
sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]);
|
|
|
|
ui_print("Partitioning SD Card... please wait...\n");
|
|
|
|
if (0 == __system(cmd))
|
|
|
|
ui_print("Done!\n");
|
|
|
|
else
|
|
|
|
ui_print("An error occured while partitioning your SD Card. Please see /tmp/recovery.log for more details.\n");
|
2010-08-23 23:15:33 +00:00
|
|
|
break;
|
2010-08-17 23:55:38 +00:00
|
|
|
}
|
2011-06-10 18:26:44 +00:00
|
|
|
case 7:
|
2010-08-18 05:21:53 +00:00
|
|
|
{
|
2010-12-19 01:42:31 +00:00
|
|
|
ensure_path_mounted("/system");
|
|
|
|
ensure_path_mounted("/data");
|
2010-08-23 23:13:14 +00:00
|
|
|
ui_print("Fixing permissions...\n");
|
|
|
|
__system("fix_permissions");
|
|
|
|
ui_print("Done!\n");
|
2010-08-23 23:15:33 +00:00
|
|
|
break;
|
2010-08-18 05:21:53 +00:00
|
|
|
}
|
2011-06-10 18:26:44 +00:00
|
|
|
case 8:
|
2010-12-12 03:52:06 +00:00
|
|
|
{
|
|
|
|
static char* ext_sizes[] = { "128M",
|
|
|
|
"256M",
|
|
|
|
"512M",
|
|
|
|
"1024M",
|
|
|
|
"2048M",
|
|
|
|
"4096M",
|
|
|
|
NULL };
|
|
|
|
|
|
|
|
static char* swap_sizes[] = { "0M",
|
|
|
|
"32M",
|
|
|
|
"64M",
|
|
|
|
"128M",
|
|
|
|
"256M",
|
|
|
|
NULL };
|
|
|
|
|
|
|
|
static char* ext_headers[] = { "Data Size", "", NULL };
|
|
|
|
static char* swap_headers[] = { "Swap Size", "", NULL };
|
|
|
|
|
2010-12-19 01:42:31 +00:00
|
|
|
int ext_size = get_menu_selection(ext_headers, ext_sizes, 0, 0);
|
2010-12-12 03:52:06 +00:00
|
|
|
if (ext_size == GO_BACK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int swap_size = 0;
|
|
|
|
if (swap_size == GO_BACK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
char sddevice[256];
|
2010-12-19 01:42:31 +00:00
|
|
|
Volume *vol = volume_for_path("/emmc");
|
|
|
|
strcpy(sddevice, vol->device);
|
2010-12-12 03:52:06 +00:00
|
|
|
// we only want the mmcblk, not the partition
|
|
|
|
sddevice[strlen("/dev/block/mmcblkX")] = NULL;
|
|
|
|
char cmd[PATH_MAX];
|
|
|
|
setenv("SDPATH", sddevice, 1);
|
|
|
|
sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]);
|
|
|
|
ui_print("Partitioning Internal SD Card... please wait...\n");
|
|
|
|
if (0 == __system(cmd))
|
|
|
|
ui_print("Done!\n");
|
|
|
|
else
|
|
|
|
ui_print("An error occured while partitioning your Internal SD Card. Please see /tmp/recovery.log for more details.\n");
|
|
|
|
break;
|
|
|
|
}
|
2010-03-19 21:51:45 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-14 22:02:48 +00:00
|
|
|
}
|
|
|
|
|
2010-12-19 02:39:39 +00:00
|
|
|
void write_fstab_root(char *path, FILE *file)
|
2010-06-14 22:02:48 +00:00
|
|
|
{
|
2010-12-19 02:39:39 +00:00
|
|
|
Volume *vol = volume_for_path(path);
|
|
|
|
if (vol == NULL) {
|
2010-12-19 05:31:02 +00:00
|
|
|
LOGW("Unable to get recovery.fstab info for %s during fstab generation!\n", path);
|
2010-06-20 16:42:47 +00:00
|
|
|
return;
|
2010-06-20 20:16:06 +00:00
|
|
|
}
|
2010-11-14 08:18:40 +00:00
|
|
|
|
2010-12-20 16:49:20 +00:00
|
|
|
char device[200];
|
|
|
|
if (vol->device[0] != '/')
|
|
|
|
get_partition_device(vol->device, device);
|
|
|
|
else
|
|
|
|
strcpy(device, vol->device);
|
|
|
|
|
|
|
|
fprintf(file, "%s ", device);
|
2010-12-19 02:39:39 +00:00
|
|
|
fprintf(file, "%s ", path);
|
2011-02-28 01:28:30 +00:00
|
|
|
// special case rfs cause auto will mount it as vfat on samsung.
|
|
|
|
fprintf(file, "%s rw\n", vol->fs_type2 != NULL && strcmp(vol->fs_type, "rfs") != 0 ? "auto" : vol->fs_type);
|
2010-06-14 22:02:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void create_fstab()
|
|
|
|
{
|
2010-12-19 02:39:39 +00:00
|
|
|
struct stat info;
|
2010-06-23 07:02:14 +00:00
|
|
|
__system("touch /etc/mtab");
|
2010-06-14 22:02:48 +00:00
|
|
|
FILE *file = fopen("/etc/fstab", "w");
|
2010-06-20 20:16:06 +00:00
|
|
|
if (file == NULL) {
|
2010-12-19 02:39:39 +00:00
|
|
|
LOGW("Unable to create /etc/fstab!\n");
|
2010-06-20 16:42:47 +00:00
|
|
|
return;
|
2010-06-20 20:16:06 +00:00
|
|
|
}
|
2011-01-28 20:39:10 +00:00
|
|
|
Volume *vol = volume_for_path("/boot");
|
2011-02-12 18:21:11 +00:00
|
|
|
if (NULL != vol && strcmp(vol->fs_type, "mtd") != 0 && strcmp(vol->fs_type, "emmc") != 0 && strcmp(vol->fs_type, "bml") != 0)
|
2011-01-28 20:39:10 +00:00
|
|
|
write_fstab_root("/boot", file);
|
2010-12-19 02:39:39 +00:00
|
|
|
write_fstab_root("/cache", file);
|
|
|
|
write_fstab_root("/data", file);
|
2011-10-27 04:25:34 +00:00
|
|
|
write_fstab_root("/datadata", file);
|
|
|
|
write_fstab_root("/emmc", file);
|
2010-12-19 02:39:39 +00:00
|
|
|
write_fstab_root("/system", file);
|
|
|
|
write_fstab_root("/sdcard", file);
|
|
|
|
write_fstab_root("/sd-ext", file);
|
2010-06-14 22:02:48 +00:00
|
|
|
fclose(file);
|
2010-12-19 05:31:02 +00:00
|
|
|
LOGI("Completed outputting fstab.\n");
|
2010-06-20 16:42:47 +00:00
|
|
|
}
|
|
|
|
|
2010-12-19 11:38:29 +00:00
|
|
|
int bml_check_volume(const char *path) {
|
|
|
|
ui_print("Checking %s...\n", path);
|
|
|
|
ensure_path_unmounted(path);
|
|
|
|
if (0 == ensure_path_mounted(path)) {
|
|
|
|
ensure_path_unmounted(path);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Volume *vol = volume_for_path(path);
|
|
|
|
if (vol == NULL) {
|
|
|
|
LOGE("Unable process volume! Skipping...\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-20 04:37:57 +00:00
|
|
|
ui_print("%s may be rfs. Checking...\n", path);
|
2010-12-19 11:38:29 +00:00
|
|
|
char tmp[PATH_MAX];
|
|
|
|
sprintf(tmp, "mount -t rfs %s %s", vol->device, path);
|
|
|
|
int ret = __system(tmp);
|
|
|
|
printf("%d\n", ret);
|
|
|
|
return ret == 0 ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void process_volumes() {
|
|
|
|
create_fstab();
|
2011-06-10 16:45:52 +00:00
|
|
|
|
|
|
|
if (is_data_media()) {
|
|
|
|
setup_data_media();
|
2011-06-10 16:17:30 +00:00
|
|
|
}
|
|
|
|
|
2011-02-27 22:00:19 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// dead code.
|
2010-12-19 11:38:29 +00:00
|
|
|
if (device_flash_type() != BML)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ui_print("Checking for ext4 partitions...\n");
|
|
|
|
int ret = 0;
|
|
|
|
ret = bml_check_volume("/system");
|
|
|
|
ret |= bml_check_volume("/data");
|
|
|
|
if (has_datadata())
|
|
|
|
ret |= bml_check_volume("/datadata");
|
|
|
|
ret |= bml_check_volume("/cache");
|
|
|
|
|
|
|
|
if (ret == 0) {
|
|
|
|
ui_print("Done!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-21 08:58:43 +00:00
|
|
|
char backup_path[PATH_MAX];
|
|
|
|
time_t t = time(NULL);
|
|
|
|
char backup_name[PATH_MAX];
|
|
|
|
struct timeval tp;
|
|
|
|
gettimeofday(&tp, NULL);
|
|
|
|
sprintf(backup_name, "before-ext4-convert-%d", tp.tv_sec);
|
|
|
|
sprintf(backup_path, "/sdcard/clockworkmod/backup/%s", backup_name);
|
|
|
|
|
2010-12-19 11:38:29 +00:00
|
|
|
ui_set_show_text(1);
|
|
|
|
ui_print("Filesystems need to be converted to ext4.\n");
|
|
|
|
ui_print("A backup and restore will now take place.\n");
|
2010-12-20 04:37:57 +00:00
|
|
|
ui_print("If anything goes wrong, your backup will be\n");
|
2010-12-21 08:58:43 +00:00
|
|
|
ui_print("named %s. Try restoring it\n", backup_name);
|
2010-12-20 04:37:57 +00:00
|
|
|
ui_print("in case of error.\n");
|
2010-12-19 11:38:29 +00:00
|
|
|
|
2010-12-21 08:58:43 +00:00
|
|
|
nandroid_backup(backup_path);
|
2010-12-30 07:36:03 +00:00
|
|
|
nandroid_restore(backup_path, 1, 1, 1, 1, 1, 0);
|
2010-12-19 11:38:29 +00:00
|
|
|
ui_set_show_text(0);
|
|
|
|
}
|
|
|
|
|
2010-06-20 16:42:47 +00:00
|
|
|
void handle_failure(int ret)
|
|
|
|
{
|
|
|
|
if (ret == 0)
|
|
|
|
return;
|
2010-12-19 01:42:31 +00:00
|
|
|
if (0 != ensure_path_mounted("/sdcard"))
|
2010-06-20 16:42:47 +00:00
|
|
|
return;
|
2010-06-20 20:16:06 +00:00
|
|
|
mkdir("/sdcard/clockworkmod", S_IRWXU);
|
|
|
|
__system("cp /tmp/recovery.log /sdcard/clockworkmod/recovery.log");
|
2010-08-18 05:21:53 +00:00
|
|
|
ui_print("/tmp/recovery.log was copied to /sdcard/clockworkmod/recovery.log. Please open ROM Manager to report the issue.\n");
|
2010-11-14 08:18:40 +00:00
|
|
|
}
|
2010-12-19 01:42:31 +00:00
|
|
|
|
|
|
|
int is_path_mounted(const char* path) {
|
|
|
|
Volume* v = volume_for_path(path);
|
|
|
|
if (v == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (strcmp(v->fs_type, "ramdisk") == 0) {
|
|
|
|
// the ramdisk is always mounted.
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int result;
|
|
|
|
result = scan_mounted_volumes();
|
|
|
|
if (result < 0) {
|
|
|
|
LOGE("failed to scan mounted volumes\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const MountedVolume* mv =
|
|
|
|
find_mounted_volume_by_mount_point(v->mount_point);
|
|
|
|
if (mv) {
|
|
|
|
// volume is already mounted
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2010-12-19 06:37:49 +00:00
|
|
|
|
|
|
|
int has_datadata() {
|
|
|
|
Volume *vol = volume_for_path("/datadata");
|
|
|
|
return vol != NULL;
|
2011-01-04 18:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int volume_main(int argc, char **argv) {
|
|
|
|
load_volume_table();
|
|
|
|
return 0;
|
|
|
|
}
|