summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2017-07-20 01:06:50 +0200
committerandroid-build-merger <android-build-merger@google.com>2017-07-20 01:06:50 +0200
commit6d8827e0d3e1563d6d7e7d47f955c0118059134c (patch)
treeb8f24a1af336f7fd0236e5ccf861ac2b15c383ed /recovery.cpp
parentMerge "Fix the missing char when showing recovery logs." (diff)
parentMerge "Fix the android-cloexec-* warnings in bootable/recovery" (diff)
downloadandroid_bootable_recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.tar
android_bootable_recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.tar.gz
android_bootable_recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.tar.bz2
android_bootable_recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.tar.lz
android_bootable_recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.tar.xz
android_bootable_recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.tar.zst
android_bootable_recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.zip
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 852f1e862..50115885f 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -250,7 +250,7 @@ static void redirect_stdio(const char* filename) {
auto start = std::chrono::steady_clock::now();
// Child logger to actually write to the log file.
- FILE* log_fp = fopen(filename, "a");
+ FILE* log_fp = fopen(filename, "ae");
if (log_fp == nullptr) {
PLOG(ERROR) << "fopen \"" << filename << "\" failed";
close(pipefd[0]);
@@ -419,27 +419,27 @@ static void copy_log_file_to_pmsg(const char* source, const char* destination) {
static off_t tmplog_offset = 0;
static void copy_log_file(const char* source, const char* destination, bool append) {
- FILE* dest_fp = fopen_path(destination, append ? "a" : "w");
- if (dest_fp == nullptr) {
- PLOG(ERROR) << "Can't open " << destination;
- } else {
- FILE* source_fp = fopen(source, "r");
- if (source_fp != nullptr) {
- if (append) {
- fseeko(source_fp, tmplog_offset, SEEK_SET); // Since last write
- }
- char buf[4096];
- size_t bytes;
- while ((bytes = fread(buf, 1, sizeof(buf), source_fp)) != 0) {
- fwrite(buf, 1, bytes, dest_fp);
- }
- if (append) {
- tmplog_offset = ftello(source_fp);
- }
- check_and_fclose(source_fp, source);
- }
- check_and_fclose(dest_fp, destination);
+ FILE* dest_fp = fopen_path(destination, append ? "ae" : "we");
+ if (dest_fp == nullptr) {
+ PLOG(ERROR) << "Can't open " << destination;
+ } else {
+ FILE* source_fp = fopen(source, "re");
+ if (source_fp != nullptr) {
+ if (append) {
+ fseeko(source_fp, tmplog_offset, SEEK_SET); // Since last write
+ }
+ char buf[4096];
+ size_t bytes;
+ while ((bytes = fread(buf, 1, sizeof(buf), source_fp)) != 0) {
+ fwrite(buf, 1, bytes, dest_fp);
+ }
+ if (append) {
+ tmplog_offset = ftello(source_fp);
+ }
+ check_and_fclose(source_fp, source);
}
+ check_and_fclose(dest_fp, destination);
+ }
}
static void copy_logs() {
@@ -488,7 +488,7 @@ static void finish_recovery() {
if (!locale.empty() && has_cache) {
LOG(INFO) << "Saving locale \"" << locale << "\"";
- FILE* fp = fopen_path(LOCALE_FILE, "w");
+ FILE* fp = fopen_path(LOCALE_FILE, "we");
if (!android::base::WriteStringToFd(locale, fileno(fp))) {
PLOG(ERROR) << "Failed to save locale to " << LOCALE_FILE;
}
@@ -552,7 +552,7 @@ static bool erase_volume(const char* volume) {
}
std::string data(sb.st_size, '\0');
- FILE* f = fopen(path.c_str(), "rb");
+ FILE* f = fopen(path.c_str(), "rbe");
fread(&data[0], 1, data.size(), f);
fclose(f);
@@ -580,7 +580,7 @@ static bool erase_volume(const char* volume) {
ui->Print("Failed to make convert_fbe dir %s\n", strerror(errno));
return true;
}
- FILE* f = fopen(CONVERT_FBE_FILE, "wb");
+ FILE* f = fopen(CONVERT_FBE_FILE, "wbe");
if (!f) {
ui->Print("Failed to convert to file encryption %s\n", strerror(errno));
return true;