summaryrefslogtreecommitdiffstats
path: root/partition.cpp
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2012-09-26 15:49:14 +0200
committerDees_Troy <dees_troy@teamw.in>2012-09-26 15:50:10 +0200
commit7c2dec8020f592fac48fea370e06f6bfd00e2798 (patch)
treeccbc8bcb44eaf4c8847d4bfcbca344609261f19b /partition.cpp
parentConvert makelist to C++ (diff)
downloadandroid_bootable_recovery-7c2dec8020f592fac48fea370e06f6bfd00e2798.tar
android_bootable_recovery-7c2dec8020f592fac48fea370e06f6bfd00e2798.tar.gz
android_bootable_recovery-7c2dec8020f592fac48fea370e06f6bfd00e2798.tar.bz2
android_bootable_recovery-7c2dec8020f592fac48fea370e06f6bfd00e2798.tar.lz
android_bootable_recovery-7c2dec8020f592fac48fea370e06f6bfd00e2798.tar.xz
android_bootable_recovery-7c2dec8020f592fac48fea370e06f6bfd00e2798.tar.zst
android_bootable_recovery-7c2dec8020f592fac48fea370e06f6bfd00e2798.zip
Diffstat (limited to '')
-rw-r--r--partition.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/partition.cpp b/partition.cpp
index a9d50917f..6f2130911 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -101,9 +101,8 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
if (full_line[index] <= 32)
full_line[index] = '\0';
}
- string mount_pt(full_line);
- Mount_Point = mount_pt;
- LOGI("Processing '%s'\n", mount_pt);
+ Mount_Point = full_line;
+ LOGI("Processing '%s'\n", Mount_Point.c_str());
Backup_Path = Mount_Point;
index = Mount_Point.size();
while (index < line_len) {
@@ -1076,7 +1075,7 @@ bool TWPartition::Backup_Tar(string backup_folder) {
string Full_FileName, Split_FileName, Tar_Args, Command;
int use_compression, index, backup_count;
struct stat st;
- unsigned long long total_bsize = 0;
+ unsigned long long total_bsize = 0, file_size;
if (!Mount(true))
return false;
@@ -1110,11 +1109,12 @@ bool TWPartition::Backup_Tar(string backup_folder) {
ui_print("Backup archive %i of %i...\n", (index + 1), backup_count);
system(Command.c_str()); // sending backup command formed earlier above
- if (stat(Full_FileName.c_str(), &st) != 0 || st.st_size == 0) {
- LOGE("File size is zero bytes. Aborting...\n\n"); // oh noes! file size is 0, abort! abort!
+ file_size = TWFunc::Get_File_Size(Full_FileName);
+ if (file_size == 0) {
+ LOGE("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str()); // oh noes! file size is 0, abort! abort!
return false;
}
- total_bsize += st.st_size;
+ total_bsize += file_size;
}
ui_print(" * Total size: %llu bytes.\n", total_bsize);
system("cd /tmp && rm -rf list");
@@ -1126,6 +1126,10 @@ bool TWPartition::Backup_Tar(string backup_folder) {
Command = "cd " + Backup_Path + " && tar " + Tar_Args + " -f '" + Full_FileName + "' ./*";
LOGI("Backup command: '%s'\n", Command.c_str());
system(Command.c_str());
+ if (TWFunc::Get_File_Size(Full_FileName) == 0) {
+ LOGE("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
+ return false;
+ }
}
return true;
}
@@ -1146,6 +1150,10 @@ bool TWPartition::Backup_DD(string backup_folder) {
Command = "dd if=" + Actual_Block_Device + " of='" + Full_FileName + "'";
LOGI("Backup command: '%s'\n", Command.c_str());
system(Command.c_str());
+ if (TWFunc::Get_File_Size(Full_FileName) != Backup_Size) {
+ LOGE("Backup file size %lu for '%s' is does not match backup size %llu.\n", TWFunc::Get_File_Size(Full_FileName), Full_FileName.c_str(), Backup_Size);
+ return false;
+ }
return true;
}
@@ -1165,6 +1173,11 @@ bool TWPartition::Backup_Dump_Image(string backup_folder) {
Command = "dump_image " + MTD_Name + " '" + Full_FileName + "'";
LOGI("Backup command: '%s'\n", Command.c_str());
system(Command.c_str());
+ if (TWFunc::Get_File_Size(Full_FileName) == 0) {
+ // Actual size may not match backup size due to bad blocks on MTD devices so just check for 0 bytes
+ LOGE("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
+ return false;
+ }
return true;
}