AB/Non AB Devices: updates for moving cache
This patchset updates all the places we touch cache on AB devices
and non AB devices so that we can write to the appropriate
location. AB devices removed the cache partition and moved it to
/data/cache.
Change-Id: I485ec205a604f1f07ceb7700ae9c4e720fd55c3e
diff --git a/data.cpp b/data.cpp
index cf8349b..0ece4e7 100755
--- a/data.cpp
+++ b/data.cpp
@@ -1038,33 +1038,38 @@
string Path;
char version[255];
- if (!PartitionManager.Mount_By_Path("/cache", false)) {
- LOGINFO("Unable to mount '%s' to write version number.\n", Path.c_str());
- return;
- }
- 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) {
- LOGERR("DataManager::Output_Version -- Unable to make /cache/recovery\n");
+ std::string cacheDir = TWFunc::get_cache_dir();
+ std::string recoveryCacheDir = cacheDir + "recovery/";
+
+ if (cacheDir == NON_AB_CACHE_DIR) {
+ if (!PartitionManager.Mount_By_Path(NON_AB_CACHE_DIR, false)) {
+ LOGINFO("Unable to mount '%s' to write version number.\n", Path.c_str());
return;
}
}
- Path = "/cache/recovery/.version";
- if (TWFunc::Path_Exists(Path)) {
- unlink(Path.c_str());
+ 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) {
+ LOGERR("DataManager::Output_Version -- Unable to make %s: %s\n", recoveryCacheDir.c_str(), strerror(errno));
+ return;
+ }
}
- FILE *fp = fopen(Path.c_str(), "w");
+ std::string verPath = recoveryCacheDir + ".version";
+ if (TWFunc::Path_Exists(verPath)) {
+ unlink(verPath.c_str());
+ }
+ FILE *fp = fopen(verPath.c_str(), "w");
if (fp == NULL) {
- gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Path)(strerror(errno)));
+ gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(verPath)(strerror(errno)));
return;
}
strcpy(version, TW_VERSION_STR);
fwrite(version, sizeof(version[0]), strlen(version) / sizeof(version[0]), fp);
fclose(fp);
- TWFunc::copy_file("/etc/recovery.fstab", "/cache/recovery/recovery.fstab", 0644);
+ TWFunc::copy_file("/etc/recovery.fstab", recoveryCacheDir + "recovery.fstab", 0644);
PartitionManager.Output_Storage_Fstab();
sync();
- LOGINFO("Version number saved to '%s'\n", Path.c_str());
+ LOGINFO("Version number saved to '%s'\n", verPath.c_str());
#endif
}
@@ -1077,10 +1082,6 @@
GetValue(TW_IS_ENCRYPTED, is_enc);
GetValue(TW_HAS_DATA_MEDIA, has_data_media);
- if (is_enc == 1 && has_data_media == 1) {
- LOGINFO("Cannot load settings -- encrypted.\n");
- return;
- }
memset(mkdir_path, 0, sizeof(mkdir_path));
memset(settings_file, 0, sizeof(settings_file));