summaryrefslogtreecommitdiffstats
path: root/updater
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2018-03-01 19:52:54 +0100
committerandroid-build-merger <android-build-merger@google.com>2018-03-01 19:52:54 +0100
commit6c87845cfbb776969829b31acc26d770b1acf2be (patch)
tree4331b14fca44fbeb53d49614804c11569763d59b /updater
parentMerge "Fix the behavior of undefined commands in BlockImageVerify" am: ac4818d6af (diff)
parentMerge "Add a singleton CacheLocation to replace the hard coded locations" (diff)
downloadandroid_bootable_recovery-6c87845cfbb776969829b31acc26d770b1acf2be.tar
android_bootable_recovery-6c87845cfbb776969829b31acc26d770b1acf2be.tar.gz
android_bootable_recovery-6c87845cfbb776969829b31acc26d770b1acf2be.tar.bz2
android_bootable_recovery-6c87845cfbb776969829b31acc26d770b1acf2be.tar.lz
android_bootable_recovery-6c87845cfbb776969829b31acc26d770b1acf2be.tar.xz
android_bootable_recovery-6c87845cfbb776969829b31acc26d770b1acf2be.tar.zst
android_bootable_recovery-6c87845cfbb776969829b31acc26d770b1acf2be.zip
Diffstat (limited to 'updater')
-rw-r--r--updater/blockimg.cpp9
-rw-r--r--updater/include/updater/blockimg.h1
-rw-r--r--updater/updater.cpp5
3 files changed, 10 insertions, 5 deletions
diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp
index 4f085b204..e93196b27 100644
--- a/updater/blockimg.cpp
+++ b/updater/blockimg.cpp
@@ -53,6 +53,7 @@
#include "edify/expr.h"
#include "otafault/ota_io.h"
+#include "otautil/cache_location.h"
#include "otautil/error_code.h"
#include "otautil/print_sha1.h"
#include "otautil/rangeset.h"
@@ -65,17 +66,15 @@
#define DEBUG_ERASE 0
static constexpr size_t BLOCKSIZE = 4096;
-static constexpr const char* STASH_DIRECTORY_BASE = "/cache/recovery";
static constexpr mode_t STASH_DIRECTORY_MODE = 0700;
static constexpr mode_t STASH_FILE_MODE = 0600;
-std::string last_command_file = "/cache/recovery/last_command";
-
static CauseCode failure_type = kNoCause;
static bool is_retry = false;
static std::unordered_map<std::string, RangeSet> stash_map;
static void DeleteLastCommandFile() {
+ std::string last_command_file = CacheLocation::location().last_command_file();
if (unlink(last_command_file.c_str()) == -1 && errno != ENOENT) {
PLOG(ERROR) << "Failed to unlink: " << last_command_file;
}
@@ -84,6 +83,7 @@ static void DeleteLastCommandFile() {
// Parse the last command index of the last update and save the result to |last_command_index|.
// Return true if we successfully read the index.
static bool ParseLastCommandFile(int* last_command_index) {
+ std::string last_command_file = CacheLocation::location().last_command_file();
android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(last_command_file.c_str(), O_RDONLY)));
if (fd == -1) {
if (errno != ENOENT) {
@@ -119,6 +119,7 @@ static bool ParseLastCommandFile(int* last_command_index) {
// Update the last command index in the last_command_file if the current command writes to the
// stash either explicitly or implicitly.
static bool UpdateLastCommandIndex(int command_index, const std::string& command_string) {
+ std::string last_command_file = CacheLocation::location().last_command_file();
std::string last_command_tmp = last_command_file + ".tmp";
std::string content = std::to_string(command_index) + "\n" + command_string;
android::base::unique_fd wfd(
@@ -676,7 +677,7 @@ static std::string GetStashFileName(const std::string& base, const std::string&
return "";
}
- std::string fn(STASH_DIRECTORY_BASE);
+ std::string fn(CacheLocation::location().stash_directory_base());
fn += "/" + base + "/" + id + postfix;
return fn;
diff --git a/updater/include/updater/blockimg.h b/updater/include/updater/blockimg.h
index 2cc68ce9d..71733b303 100644
--- a/updater/include/updater/blockimg.h
+++ b/updater/include/updater/blockimg.h
@@ -19,7 +19,6 @@
#include <string>
-extern std::string last_command_file;
void RegisterBlockImageFunctions();
#endif
diff --git a/updater/updater.cpp b/updater/updater.cpp
index f55a0d3bd..f063e5fa1 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -34,6 +34,7 @@
#include "otafault/config.h"
#include "otautil/DirUtil.h"
#include "otautil/SysUtil.h"
+#include "otautil/cache_location.h"
#include "otautil/error_code.h"
#include "updater/blockimg.h"
#include "updater/install.h"
@@ -168,6 +169,10 @@ int main(int argc, char** argv) {
}
ota_io_init(za, state.is_retry);
+ // Initialize the cache_temp_source, last_command_file and stash_directory_base to their default
+ // locations.
+ CacheLocation::location().ResetLocations();
+
std::string result;
bool status = Evaluate(&state, root, &result);