summaryrefslogtreecommitdiffstats
path: root/twrp-functions.cpp
diff options
context:
space:
mode:
authorDees Troy <dees_troy@teamw.in>2013-10-01 17:34:15 +0200
committerGerrit Code Review <gerrit@198.50.184.117>2013-10-01 17:34:15 +0200
commit0221bd9c4d05cd19d03aae69b2e65dbba1cad982 (patch)
treea13ae2ef4b5f3257c46d305476e328b57eeb4218 /twrp-functions.cpp
parentMerge "Fix checking for file_contexts in updater" into twrp2.7 (diff)
parentImprovements to Update_Log_File (diff)
downloadandroid_bootable_recovery-0221bd9c4d05cd19d03aae69b2e65dbba1cad982.tar
android_bootable_recovery-0221bd9c4d05cd19d03aae69b2e65dbba1cad982.tar.gz
android_bootable_recovery-0221bd9c4d05cd19d03aae69b2e65dbba1cad982.tar.bz2
android_bootable_recovery-0221bd9c4d05cd19d03aae69b2e65dbba1cad982.tar.lz
android_bootable_recovery-0221bd9c4d05cd19d03aae69b2e65dbba1cad982.tar.xz
android_bootable_recovery-0221bd9c4d05cd19d03aae69b2e65dbba1cad982.tar.zst
android_bootable_recovery-0221bd9c4d05cd19d03aae69b2e65dbba1cad982.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();
}