diff options
author | HashBang <hashbang173@gmail.com> | 2016-01-30 20:20:09 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2016-02-03 23:05:56 +0100 |
commit | ed974bb87ab099e5168768b3381dcdf80d83f3c8 (patch) | |
tree | d258894dae7a12c3570f1cc346026e7582321e35 /partition.cpp | |
parent | sort languages by display value (diff) | |
download | android_bootable_recovery-ed974bb87ab099e5168768b3381dcdf80d83f3c8.tar android_bootable_recovery-ed974bb87ab099e5168768b3381dcdf80d83f3c8.tar.gz android_bootable_recovery-ed974bb87ab099e5168768b3381dcdf80d83f3c8.tar.bz2 android_bootable_recovery-ed974bb87ab099e5168768b3381dcdf80d83f3c8.tar.lz android_bootable_recovery-ed974bb87ab099e5168768b3381dcdf80d83f3c8.tar.xz android_bootable_recovery-ed974bb87ab099e5168768b3381dcdf80d83f3c8.tar.zst android_bootable_recovery-ed974bb87ab099e5168768b3381dcdf80d83f3c8.zip |
Diffstat (limited to 'partition.cpp')
-rw-r--r-- | partition.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/partition.cpp b/partition.cpp index d038c38f1..c511298ec 100644 --- a/partition.cpp +++ b/partition.cpp @@ -68,6 +68,7 @@ extern "C" { #include <sys/xattr.h> #include <linux/xattr.h> #endif +#include <sparse_format.h> using namespace std; @@ -407,12 +408,12 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) { } else if (Mount_Point == "/system_image") { Display_Name = "System Image"; Backup_Display_Name = Display_Name; - Can_Flash_Img = false; + Can_Flash_Img = true; Can_Be_Backed_Up = true; } else if (Mount_Point == "/vendor_image") { Display_Name = "Vendor Image"; Backup_Display_Name = Display_Name; - Can_Flash_Img = false; + Can_Flash_Img = true; Can_Be_Backed_Up = true; } } @@ -2375,7 +2376,24 @@ bool TWPartition::Flash_Image_DD(string Filename) { string Command; gui_msg(Msg("flashing=Flashing {1}...")(Display_Name)); - Command = "dd bs=8388608 if='" + Filename + "' of=" + Actual_Block_Device; + + uint32_t magic = 0; + int fd = open(Filename.c_str(), O_RDONLY); + if (fd < 0) { + gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Filename)(strerror(errno))); + return false; + } + if (read(fd, &magic, sizeof(magic)) != sizeof(magic)) { + gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Filename)(strerror(errno))); + close(fd); + return false; + } + close(fd); + if (magic == SPARSE_HEADER_MAGIC) { + Command = "simg2img '" + Filename + "' " + Actual_Block_Device; + } else { + Command = "dd bs=8388608 if='" + Filename + "' of=" + Actual_Block_Device; + } LOGINFO("Flash command: '%s'\n", Command.c_str()); TWFunc::Exec_Cmd(Command); return true; |