summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Peck <gary@realify.com>2012-11-22 06:07:58 +0100
committerDees_Troy <dees_troy@teamw.in>2012-12-18 22:39:06 +0100
commit15e623db7ac3127aa440ed133a310e6e640f665b (patch)
treecf78207060894c668d2ef55b73f3c1ea84d22ad5
parentFix keyboard layout on 800x1280 layout (diff)
downloadandroid_bootable_recovery-15e623db7ac3127aa440ed133a310e6e640f665b.tar
android_bootable_recovery-15e623db7ac3127aa440ed133a310e6e640f665b.tar.gz
android_bootable_recovery-15e623db7ac3127aa440ed133a310e6e640f665b.tar.bz2
android_bootable_recovery-15e623db7ac3127aa440ed133a310e6e640f665b.tar.lz
android_bootable_recovery-15e623db7ac3127aa440ed133a310e6e640f665b.tar.xz
android_bootable_recovery-15e623db7ac3127aa440ed133a310e6e640f665b.tar.zst
android_bootable_recovery-15e623db7ac3127aa440ed133a310e6e640f665b.zip
-rw-r--r--partition.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/partition.cpp b/partition.cpp
index 0590d981c..d391f9881 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -1300,8 +1300,21 @@ bool TWPartition::Restore_DD(string restore_folder) {
string Full_FileName, Command;
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, "Restoring");
- ui_print("Restoring %s...\n", Display_Name.c_str());
Full_FileName = restore_folder + "/" + Backup_FileName;
+
+ if (!Find_Partition_Size()) {
+ LOGE("Unable to find partition size for '%s'\n", Mount_Point.c_str());
+ return false;
+ }
+ unsigned long long backup_size = TWFunc::Get_File_Size(Full_FileName);
+ if (backup_size > Size) {
+ LOGE("Size (%iMB) of backup '%s' is larger than target device '%s' (%iMB)\n",
+ (int)(backup_size / 1048576LLU), Full_FileName.c_str(),
+ Actual_Block_Device.c_str(), (int)(Size / 1048576LLU));
+ return false;
+ }
+
+ ui_print("Restoring %s...\n", Display_Name.c_str());
Command = "dd bs=4096 if='" + Full_FileName + "' of=" + Actual_Block_Device;
LOGI("Restore command: '%s'\n", Command.c_str());
system(Command.c_str());