summaryrefslogtreecommitdiffstats
path: root/twrp-functions.cpp
diff options
context:
space:
mode:
authorDees Troy <dees_troy@teamw.in>2013-09-19 22:49:25 +0200
committerDees Troy <dees_troy@teamw.in>2013-09-19 22:52:45 +0200
commit9d7fdf5274b9d472780996d798d67515155f34b0 (patch)
tree578afc13eec2149f32d2d878a9038d91d6781443 /twrp-functions.cpp
parentMerge "Remove unneeded images" into twrp2.7 (diff)
downloadandroid_bootable_recovery-9d7fdf5274b9d472780996d798d67515155f34b0.tar
android_bootable_recovery-9d7fdf5274b9d472780996d798d67515155f34b0.tar.gz
android_bootable_recovery-9d7fdf5274b9d472780996d798d67515155f34b0.tar.bz2
android_bootable_recovery-9d7fdf5274b9d472780996d798d67515155f34b0.tar.lz
android_bootable_recovery-9d7fdf5274b9d472780996d798d67515155f34b0.tar.xz
android_bootable_recovery-9d7fdf5274b9d472780996d798d67515155f34b0.tar.zst
android_bootable_recovery-9d7fdf5274b9d472780996d798d67515155f34b0.zip
Diffstat (limited to 'twrp-functions.cpp')
-rw-r--r--twrp-functions.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 50df2ed9b..c39a6b242 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -261,6 +261,7 @@ unsigned long TWFunc::Get_File_Size(string Path) {
}
void TWFunc::Copy_Log(string Source, string Destination) {
+ PartitionManager.Mount_By_Path(Destination, false);
FILE *destination_log = fopen(Destination.c_str(), "a");
if (destination_log == NULL) {
LOGERR("TWFunc::Copy_Log -- Can't open destination log file: '%s'\n", Destination.c_str());
@@ -282,11 +283,20 @@ void TWFunc::Copy_Log(string Source, string Destination) {
void TWFunc::Update_Log_File(void) {
// Copy logs to cache so the system can find out what happened.
- Copy_Log(TMP_LOG_FILE, "/cache/recovery/log");
- copy_file("/cache/recovery/log", "/cache/recovery/last_log", 600);
- chown("/cache/recovery/log", 1000, 1000);
- chmod("/cache/recovery/log", 0600);
- chmod("/cache/recovery/last_log", 0640);
+ if (PartitionManager.Mount_By_Path("/cache", false)) {
+ if (!TWFunc::Path_Exists("/cache/recovery/.")) {
+ LOGINFO("Recreating /cache/recovery folder.\n");
+ if (mkdir("/cache/recovery", S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0)
+ LOGINFO("Unable to create /cache/recovery folder.\n");
+ }
+ Copy_Log(TMP_LOG_FILE, "/cache/recovery/log");
+ copy_file("/cache/recovery/log", "/cache/recovery/last_log", 600);
+ chown("/cache/recovery/log", 1000, 1000);
+ chmod("/cache/recovery/log", 0600);
+ chmod("/cache/recovery/last_log", 0640);
+ } else {
+ LOGINFO("Failed to mount /cache for TWFunc::Update_Log_File\n");
+ }
// Reset bootloader message
TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
@@ -304,11 +314,12 @@ void TWFunc::Update_Log_File(void) {
}
}
- if (!PartitionManager.Mount_By_Path("/cache", true) || (unlink("/cache/recovery/command") && errno != ENOENT)) {
- LOGINFO("Can't unlink %s\n", "/cache/recovery/command");
+ if (PartitionManager.Mount_By_Path("/cache", true)) {
+ if (unlink("/cache/recovery/command") && errno != ENOENT) {
+ LOGINFO("Can't unlink %s\n", "/cache/recovery/command");
+ }
}
- PartitionManager.UnMount_By_Path("/cache", true);
sync();
}