summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2012-09-26 18:00:39 +0200
committerDees_Troy <dees_troy@teamw.in>2012-09-26 18:01:13 +0200
commit094207a4d71efaec4d10ea96e9b60da0c59f3920 (patch)
treee5100447ede760751acec56274ae1eac78a855ad
parentUpdate version and readme (diff)
downloadandroid_bootable_recovery-094207a4d71efaec4d10ea96e9b60da0c59f3920.tar
android_bootable_recovery-094207a4d71efaec4d10ea96e9b60da0c59f3920.tar.gz
android_bootable_recovery-094207a4d71efaec4d10ea96e9b60da0c59f3920.tar.bz2
android_bootable_recovery-094207a4d71efaec4d10ea96e9b60da0c59f3920.tar.lz
android_bootable_recovery-094207a4d71efaec4d10ea96e9b60da0c59f3920.tar.xz
android_bootable_recovery-094207a4d71efaec4d10ea96e9b60da0c59f3920.tar.zst
android_bootable_recovery-094207a4d71efaec4d10ea96e9b60da0c59f3920.zip
-rw-r--r--partition.cpp9
-rw-r--r--partitionmanager.cpp7
-rw-r--r--partitions.hpp2
-rw-r--r--twbootloader.cpp22
4 files changed, 19 insertions, 21 deletions
diff --git a/partition.cpp b/partition.cpp
index 6f2130911..56c69b386 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -119,8 +119,8 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
} else if (item_index == 1) {
// Primary Block Device
if (Fstab_File_System == "mtd" || Fstab_File_System == "yaffs2") {
- Primary_Block_Device = ptr;
- Find_MTD_Block_Device(Primary_Block_Device);
+ MTD_Name = ptr;
+ Find_MTD_Block_Device(MTD_Name);
} else if (*ptr != '/') {
if (Display_Error)
LOGE("Invalid block device on '%s', '%s', %i\n", Line.c_str(), ptr, index);
@@ -168,12 +168,10 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
if (Mount_Point == "/system") {
Display_Name = "System";
Wipe_Available_in_GUI = true;
- MTD_Name = "system";
} else if (Mount_Point == "/data") {
Display_Name = "Data";
Wipe_Available_in_GUI = true;
Wipe_During_Factory_Reset = true;
- MTD_Name = "userdata";
#ifdef RECOVERY_SDCARD_ON_DATA
Has_Data_Media = true;
Is_Storage = true;
@@ -212,7 +210,6 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Display_Name = "Cache";
Wipe_Available_in_GUI = true;
Wipe_During_Factory_Reset = true;
- MTD_Name = "cache";
if (!TWFunc::Path_Exists("/cache/recovery")) {
LOGI("Recreating /cache/recovery folder.\n");
TWFunc::Recursive_Mkdir("/cache/recovery");
@@ -266,7 +263,6 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Find_Actual_Block_Device();
Setup_Image(Display_Error);
if (Mount_Point == "/boot") {
- MTD_Name = "boot";
int backup_display_size = (int)(Backup_Size / 1048576LLU);
DataManager::SetValue(TW_BACKUP_BOOT_SIZE, backup_display_size);
if (Backup_Size == 0) {
@@ -275,7 +271,6 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
} else
DataManager::SetValue(TW_HAS_BOOT_PARTITION, 1);
} else if (Mount_Point == "/recovery") {
- MTD_Name = "recovery";
int backup_display_size = (int)(Backup_Size / 1048576LLU);
DataManager::SetValue(TW_BACKUP_RECOVERY_SIZE, backup_display_size);
if (Backup_Size == 0) {
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index df67bb52c..034b5cdf7 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -178,8 +178,6 @@ void TWPartitionManager::Output_Partition(TWPartition* Part) {
printf(" Backup_Name: %s\n", Part->Backup_Name.c_str());
if (!Part->Backup_FileName.empty())
printf(" Backup_FileName: %s\n", Part->Backup_FileName.c_str());
- if (!Part->MTD_Name.empty())
- printf(" MTD_Name: %s\n", Part->MTD_Name.c_str());
if (!Part->Storage_Path.empty())
printf(" Storage_Path: %s\n", Part->Storage_Path.c_str());
if (!Part->Current_File_System.empty())
@@ -191,6 +189,8 @@ void TWPartitionManager::Output_Partition(TWPartition* Part) {
} else {
printf("%s | %s | Size: %iMB\n", Part->Mount_Point.c_str(), Part->Actual_Block_Device.c_str(), (int)(Part->Size / mb));
}
+ if (!Part->MTD_Name.empty())
+ printf(" MTD_Name: %s\n", Part->MTD_Name.c_str());
string back_meth = Part->Backup_Method_By_Name();
printf(" Backup_Method: %s\n\n", back_meth.c_str());
}
@@ -1219,6 +1219,9 @@ int TWPartitionManager::Factory_Reset(void) {
if ((*iter)->Wipe_During_Factory_Reset && (*iter)->Is_Present) {
if (!(*iter)->Wipe())
ret = false;
+ } else if ((*iter)->Has_Android_Secure) {
+ if (!(*iter)->Wipe_AndSec())
+ ret = false;
}
}
return ret;
diff --git a/partitions.hpp b/partitions.hpp
index 5bd1197cc..5a919ae82 100644
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -64,6 +64,7 @@ public:
public:
string Current_File_System; // Current file system
string Actual_Block_Device; // Actual block device (one of primary, alternate, or decrypted)
+ string MTD_Name; // Name of the partition for MTD devices
protected:
bool Process_Fstab_Line(string Line, bool Display_Error); // Processes a fstab line
@@ -97,7 +98,6 @@ protected:
string Display_Name; // Display name for the GUI
string Backup_Name; // Backup name -- used for backup filenames
string Backup_FileName; // Actual backup filename
- string MTD_Name; // Name of the partition for MTD devices
Backup_Method_enum Backup_Method; // Method used for backup
bool Has_Data_Media; // Indicates presence of /data/media, may affect wiping and backup methods
bool Has_Android_Secure; // Indicates the presence of .android_secure on this partition
diff --git a/twbootloader.cpp b/twbootloader.cpp
index 905c78ed0..826ceca09 100644
--- a/twbootloader.cpp
+++ b/twbootloader.cpp
@@ -73,22 +73,22 @@ static int get_bootloader_message_mtd(struct bootloader_message *out,
const TWPartition* Partition) {
size_t write_size;
mtd_scan_partitions();
- const MtdPartition *part = mtd_find_partition_by_name(Partition->Actual_Block_Device.c_str());
+ const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
- LOGE("Can't find %s\n", Partition->Actual_Block_Device.c_str());
+ LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
return -1;
}
MtdReadContext *read = mtd_read_partition(part);
if (read == NULL) {
- LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+ LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
return -1;
}
const ssize_t size = write_size * MISC_PAGES;
char data[size];
ssize_t r = mtd_read_data(read, data, size);
- if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+ if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
mtd_read_close(read);
if (r != size) return -1;
@@ -99,22 +99,22 @@ static int set_bootloader_message_mtd(const struct bootloader_message *in,
const TWPartition* Partition) {
size_t write_size;
mtd_scan_partitions();
- const MtdPartition *part = mtd_find_partition_by_name(Partition->Actual_Block_Device.c_str());
+ const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
- LOGE("Can't find %s\n", Partition->Actual_Block_Device.c_str());
+ LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
return -1;
}
MtdReadContext *read = mtd_read_partition(part);
if (read == NULL) {
- LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+ LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
return -1;
}
ssize_t size = write_size * MISC_PAGES;
char data[size];
ssize_t r = mtd_read_data(read, data, size);
- if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+ if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
mtd_read_close(read);
if (r != size) return -1;
@@ -122,16 +122,16 @@ static int set_bootloader_message_mtd(const struct bootloader_message *in,
MtdWriteContext *write = mtd_write_partition(part);
if (write == NULL) {
- LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+ LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
return -1;
}
if (mtd_write_data(write, data, size) != size) {
- LOGE("Can't write %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+ LOGE("Can't write %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
mtd_write_close(write);
return -1;
}
if (mtd_write_close(write)) {
- LOGE("Can't finish %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+ LOGE("Can't finish %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
return -1;
}