Merge branch 'gingerbread' of git://github.com/CyanogenMod/android_bootable_recovery into gingerbread

This commit is contained in:
root 2011-05-26 22:19:42 +01:00
commit 0bf1c6e598
11 changed files with 67 additions and 46 deletions

View File

@ -26,7 +26,7 @@ LOCAL_MODULE := recovery
LOCAL_FORCE_STATIC_EXECUTABLE := true
RECOVERY_VERSION := ClockworkMod Recovery v3.1.0.2
RECOVERY_VERSION := ClockworkMod Recovery v3.2.0.0
LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
RECOVERY_API_VERSION := 2
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)

View File

@ -38,6 +38,8 @@
#include "mounts.h"
#include "flashutils/flashutils.h"
#include "edify/expr.h"
#include <libgen.h>
int signature_check_enabled = 1;
int script_assert_enabled = 1;
@ -413,7 +415,7 @@ int format_unknown_device(const char *device, const char* path, const char *fs_t
// device may simply be a name, like "system"
if (device[0] != '/')
return erase_raw_partition(device);
return erase_raw_partition(fs_type, device);
// if this is SDEXT:, don't worry about it if it does not exist.
if (0 == strcmp(path, "/sd-ext"))
@ -630,6 +632,8 @@ int extendedcommand_file_exists()
return 0 == stat(EXTENDEDCOMMAND_SCRIPT, &file_info);
}
void process_volumes();
int edify_main(int argc, char** argv) {
load_volume_table();
process_volumes();

View File

@ -44,4 +44,6 @@ wipe_battery_stats();
void create_fstab();
int has_datadata();
int has_datadata();
void handle_failure(int ret);

View File

@ -146,5 +146,5 @@ int main(int argc, char **argv)
return 2;
}
return backup_raw_partition(argv[1], argv[2]);
return backup_raw_partition(NULL, argv[1], argv[2]);
}

View File

@ -99,5 +99,5 @@ int main(int argc, char **argv)
return 2;
}
return erase_raw_partition(argv[1]);
return erase_raw_partition(NULL, argv[1]);
}

View File

@ -22,6 +22,7 @@
#include <unistd.h>
#include "cutils/log.h"
#include "flashutils.h"
#if 0
#define LOG_TAG "flash_image"
@ -147,7 +148,7 @@ int main(int argc, char **argv)
return 2;
}
int ret = restore_raw_partition(argv[1], argv[2]);
int ret = restore_raw_partition(NULL, argv[1], argv[2]);
if (ret != 0)
fprintf(stderr, "failed with error: %d\n", ret);
return ret;

View File

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdio.h>
#include "flashutils/flashutils.h"
@ -69,7 +70,7 @@ __system(const char *command)
return (pid == -1 ? -1 : pstat);
}
static int detect_partition(const char *partition)
static int detect_partition(const char *partitionType, const char *partition)
{
int type = device_flash_type();
if (strstr(partition, "/dev/block/mtd") != NULL)
@ -78,12 +79,24 @@ static int detect_partition(const char *partition)
type = MMC;
else if (strstr(partition, "/dev/block/bml") != NULL)
type = BML;
if (partitionType != NULL) {
if (strstr(partitionType, "mtd") != NULL)
type = MTD;
else if (strstr(partitionType, "emmc") != NULL)
type = MMC;
else if (strstr(partitionType, "bml") != NULL)
type = BML;
}
printf("partitionType: %s\n", partitionType);
printf("partition: %s\n", partition);
printf("detected type: %d\n", type);
return type;
}
int restore_raw_partition(const char *partition, const char *filename)
int restore_raw_partition(const char* partitionType, const char *partition, const char *filename)
{
int type = detect_partition(partition);
int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_restore_raw_partition(partition, filename);
@ -96,9 +109,9 @@ int restore_raw_partition(const char *partition, const char *filename)
}
}
int backup_raw_partition(const char *partition, const char *filename)
int backup_raw_partition(const char* partitionType, const char *partition, const char *filename)
{
int type = detect_partition(partition);
int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_backup_raw_partition(partition, filename);
@ -112,9 +125,9 @@ int backup_raw_partition(const char *partition, const char *filename)
}
}
int erase_raw_partition(const char *partition)
int erase_raw_partition(const char* partitionType, const char *partition)
{
int type = detect_partition(partition);
int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_erase_raw_partition(partition);
@ -129,7 +142,7 @@ int erase_raw_partition(const char *partition)
int erase_partition(const char *partition, const char *filesystem)
{
int type = detect_partition(partition);
int type = detect_partition(NULL, partition);
switch (type) {
case MTD:
return cmd_mtd_erase_partition(partition, filesystem);
@ -144,7 +157,7 @@ int erase_partition(const char *partition, const char *filesystem)
int mount_partition(const char *partition, const char *mount_point, const char *filesystem, int read_only)
{
int type = detect_partition(partition);
int type = detect_partition(NULL, partition);
switch (type) {
case MTD:
return cmd_mtd_mount_partition(partition, mount_point, filesystem, read_only);

View File

@ -1,9 +1,9 @@
#ifndef FLASHUTILS_H
#define FLASHUTILS_H
int restore_raw_partition(const char *partition, const char *filename);
int backup_raw_partition(const char *partition, const char *filename);
int erase_raw_partition(const char *partition);
int restore_raw_partition(const char* partitionType, const char *partition, const char *filename);
int backup_raw_partition(const char* partitionType, const char *partition, const char *filename);
int erase_raw_partition(const char* partitionType, const char *partition);
int erase_partition(const char *partition, const char *filesystem);
int mount_partition(const char *partition, const char *mount_point, const char *filesystem, int read_only);
int get_partition_device(const char *partition, char *device);

View File

@ -37,6 +37,25 @@
#include "extendedcommands.h"
#include "nandroid.h"
#include "flashutils/flashutils.h"
#include <libgen.h>
void nandroid_generate_timestamp_path(const char* backup_path)
{
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, PATH_MAX, "/sdcard/clockworkmod/backup/%F.%H.%M.%S", tmp);
}
}
int print_and_error(const char* message) {
ui_print("%s", message);
@ -45,7 +64,7 @@ int print_and_error(const char* message) {
int yaffs_files_total = 0;
int yaffs_files_count = 0;
void yaffs_callback(char* filename)
void yaffs_callback(const char* filename)
{
char* justfile = basename(filename);
if (strlen(justfile) < 30)
@ -56,7 +75,7 @@ void yaffs_callback(char* filename)
ui_reset_text_col();
}
void compute_directory_stats(char* directory)
void compute_directory_stats(const char* directory)
{
char tmp[PATH_MAX];
sprintf(tmp, "find %s | wc -l > /tmp/dircount", directory);
@ -115,7 +134,7 @@ int nandroid_backup_partition(const char* backup_path, const char* root) {
const char* name = basename(root);
sprintf(tmp, "%s/%s.img", backup_path, name);
ui_print("Backing up %s image...\n", name);
if (0 != (ret = backup_raw_partition(vol->device, tmp))) {
if (0 != (ret = backup_raw_partition(vol->fs_type, vol->device, tmp))) {
ui_print("Error while backing up %s image!", name);
return ret;
}
@ -162,7 +181,7 @@ int nandroid_backup(const char* backup_path)
serialno[0] = 0;
property_get("ro.serialno", serialno, "");
sprintf(tmp, "%s/wimax.%s.img", backup_path, serialno);
ret = backup_raw_partition(vol->device, tmp);
ret = backup_raw_partition(vol->fs_type, vol->device, tmp);
if (0 != ret)
return print_and_error("Error while dumping WiMAX image!\n");
}
@ -294,7 +313,7 @@ int nandroid_restore_partition(const char* backup_path, const char* root) {
}
sprintf(tmp, "%s%s.img", backup_path, root);
ui_print("Restoring %s image...\n", name);
if (0 != (ret = restore_raw_partition(vol->device, tmp))) {
if (0 != (ret = restore_raw_partition(vol->fs_type, vol->device, tmp))) {
ui_print("Error while flashing %s image!", name);
return ret;
}
@ -348,7 +367,7 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
if (0 != (ret = format_volume("/wimax")))
return print_and_error("Error while formatting wimax!\n");
ui_print("Restoring WiMAX image...\n");
if (0 != (ret = restore_raw_partition(vol->device, tmp)))
if (0 != (ret = restore_raw_partition(vol->fs_type, vol->device, tmp)))
return ret;
}
}
@ -380,22 +399,6 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
return 0;
}
void nandroid_generate_timestamp_path(char* backup_path)
{
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, PATH_MAX, "/sdcard/clockworkmod/backup/%F.%H.%M.%S", tmp);
}
}
int nandroid_usage()
{
printf("Usage: nandroid backup\n");

View File

@ -4,6 +4,5 @@
int nandroid_main(int argc, char** argv);
int nandroid_backup(const char* backup_path);
int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext, int restore_wimax);
void nandroid_generate_timestamp_path(char* backup_path);
#endif

View File

@ -28,6 +28,9 @@
#include "common.h"
#include "make_ext4fs.h"
#include "flashutils/flashutils.h"
#include "extendedcommands.h"
int num_volumes;
Volume* device_volumes;
@ -301,10 +304,6 @@ int format_volume(const char* volume) {
return 0;
}
if (strcmp(v->fs_type, "emmc") == 0) {
return erase_raw_partition(v->device);
}
if (strcmp(v->fs_type, "ext4") == 0) {
reset_ext4fs_info();
int result = make_ext4fs(v->device, NULL, NULL, 0, 0, 0);