summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbigbiff bigbiff <bigbiff@teamw.in>2019-03-23 23:33:17 +0100
committerDees Troy <dees_troy@teamw.in>2019-04-03 02:08:39 +0200
commite4bdb15a5f6b0894b46fd34ad7b1a3093d6a102c (patch)
tree2ea6d8f25a05aeadcc39eccf6c028c992fd7f8e0
parentMerge "ADB Backup: Ignore creating backup folder for phones not decrypted. This allows you to continue without error. Also we should not set restore path for images in adb backup. Change-Id: Ia75a70377b8e1364fefc82ad41ccf74fa3b7a3c3" into android-9.0 (diff)
downloadandroid_bootable_recovery-e4bdb15a5f6b0894b46fd34ad7b1a3093d6a102c.tar
android_bootable_recovery-e4bdb15a5f6b0894b46fd34ad7b1a3093d6a102c.tar.gz
android_bootable_recovery-e4bdb15a5f6b0894b46fd34ad7b1a3093d6a102c.tar.bz2
android_bootable_recovery-e4bdb15a5f6b0894b46fd34ad7b1a3093d6a102c.tar.lz
android_bootable_recovery-e4bdb15a5f6b0894b46fd34ad7b1a3093d6a102c.tar.xz
android_bootable_recovery-e4bdb15a5f6b0894b46fd34ad7b1a3093d6a102c.tar.zst
android_bootable_recovery-e4bdb15a5f6b0894b46fd34ad7b1a3093d6a102c.zip
-rwxr-xr-xdata.cpp7
-rwxr-xr-xpartitionmanager.cpp8
-rwxr-xr-xtwrp-functions.cpp12
-rwxr-xr-xtwrp-functions.hpp1
4 files changed, 24 insertions, 4 deletions
diff --git a/data.cpp b/data.cpp
index cf9dd2476..92255357c 100755
--- a/data.cpp
+++ b/data.cpp
@@ -1043,6 +1043,11 @@ void DataManager::Output_Version(void)
char version[255];
std::string cacheDir = TWFunc::get_cache_dir();
+ if (cacheDir.empty()) {
+ LOGINFO("Unable to find cache directory\n");
+ return;
+ }
+
std::string recoveryCacheDir = cacheDir + "recovery/";
if (cacheDir == NON_AB_CACHE_DIR) {
@@ -1053,7 +1058,7 @@ void DataManager::Output_Version(void)
}
if (!TWFunc::Path_Exists(recoveryCacheDir)) {
LOGINFO("Recreating %s folder.\n", recoveryCacheDir.c_str());
- if (mkdir(recoveryCacheDir.c_str(), S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0) {
+ if (!TWFunc::Create_Dir_Recursive(recoveryCacheDir.c_str(), S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP, 0, 0)) {
LOGERR("DataManager::Output_Version -- Unable to make %s: %s\n", recoveryCacheDir.c_str(), strerror(errno));
return;
}
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 26a48e5dc..34ba6aea6 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -2222,7 +2222,13 @@ int TWPartitionManager::Fstab_Processed(void) {
void TWPartitionManager::Output_Storage_Fstab(void) {
std::vector<TWPartition*>::iterator iter;
char storage_partition[255];
- string Temp;
+ std::string Temp;
+ std::string cacheDir = TWFunc::get_cache_dir();
+
+ if (cacheDir.empty()) {
+ LOGINFO("Unable to find cache directory\n");
+ return;
+ }
std::string storageFstab = TWFunc::get_cache_dir() + "recovery/storage.fstab";
FILE *fp = fopen(storageFstab.c_str(), "w");
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 0730ca849..28a0f0cc7 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -535,7 +535,7 @@ void TWFunc::Update_Log_File(void) {
if (!TWFunc::Path_Exists(recoveryDir)) {
LOGINFO("Recreating %s folder.\n", recoveryDir.c_str());
- if (mkdir(recoveryDir.c_str(), S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0) {
+ if (!Create_Dir_Recursive(recoveryDir, S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP, 0, 0)) {
LOGINFO("Unable to create %s folder.\n", recoveryDir.c_str());
}
}
@@ -1171,7 +1171,15 @@ int TWFunc::stream_adb_backup(string &Restore_Name) {
std::string TWFunc::get_cache_dir() {
if (PartitionManager.Find_Partition_By_Path(NON_AB_CACHE_DIR) == NULL) {
- return AB_CACHE_DIR;
+ if (PartitionManager.Find_Partition_By_Path(NON_AB_CACHE_DIR) == NULL) {
+ if (PartitionManager.Find_Partition_By_Path(PERSIST_CACHE_DIR) == NULL) {
+ LOGINFO("Unable to find a directory to store TWRP logs.");
+ return "";
+ }
+ return PERSIST_CACHE_DIR;
+ } else {
+ return AB_CACHE_DIR;
+ }
}
else {
return NON_AB_CACHE_DIR;
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 669a9e970..a892e7574 100755
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -28,6 +28,7 @@ using namespace std;
#define NON_AB_CACHE_DIR "/cache/"
#define AB_CACHE_DIR "/data/cache/"
+#define PERSIST_CACHE_DIR "/persist/cache/"
typedef enum
{