aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu2017-07-19 18:06:50 -0500
committerandroid-build-merger2017-07-19 18:06:50 -0500
commit6d8827e0d3e1563d6d7e7d47f955c0118059134c (patch)
treeb8f24a1af336f7fd0236e5ccf861ac2b15c383ed /recovery.cpp
parentc61bbe158e3ea795a99b9005f5ebfdebad723fc7 (diff)
parent94a8ea1797cf807458f94953fe721985bf1261f0 (diff)
downloadplatform-bootable-recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.tar.gz
platform-bootable-recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.tar.xz
platform-bootable-recovery-6d8827e0d3e1563d6d7e7d47f955c0118059134c.zip
Merge "Fix the android-cloexec-* warnings in bootable/recovery"
am: 94a8ea1797 Change-Id: I57ae57bab58f603540654bb24df9facca9a7d625
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 852f1e86..50115885 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -250,7 +250,7 @@ static void redirect_stdio(const char* filename) {
250 auto start = std::chrono::steady_clock::now(); 250 auto start = std::chrono::steady_clock::now();
251 251
252 // Child logger to actually write to the log file. 252 // Child logger to actually write to the log file.
253 FILE* log_fp = fopen(filename, "a"); 253 FILE* log_fp = fopen(filename, "ae");
254 if (log_fp == nullptr) { 254 if (log_fp == nullptr) {
255 PLOG(ERROR) << "fopen \"" << filename << "\" failed"; 255 PLOG(ERROR) << "fopen \"" << filename << "\" failed";
256 close(pipefd[0]); 256 close(pipefd[0]);
@@ -419,27 +419,27 @@ static void copy_log_file_to_pmsg(const char* source, const char* destination) {
419static off_t tmplog_offset = 0; 419static off_t tmplog_offset = 0;
420 420
421static void copy_log_file(const char* source, const char* destination, bool append) { 421static void copy_log_file(const char* source, const char* destination, bool append) {
422 FILE* dest_fp = fopen_path(destination, append ? "a" : "w"); 422 FILE* dest_fp = fopen_path(destination, append ? "ae" : "we");
423 if (dest_fp == nullptr) { 423 if (dest_fp == nullptr) {
424 PLOG(ERROR) << "Can't open " << destination; 424 PLOG(ERROR) << "Can't open " << destination;
425 } else { 425 } else {
426 FILE* source_fp = fopen(source, "r"); 426 FILE* source_fp = fopen(source, "re");
427 if (source_fp != nullptr) { 427 if (source_fp != nullptr) {
428 if (append) { 428 if (append) {
429 fseeko(source_fp, tmplog_offset, SEEK_SET); // Since last write 429 fseeko(source_fp, tmplog_offset, SEEK_SET); // Since last write
430 } 430 }
431 char buf[4096]; 431 char buf[4096];
432 size_t bytes; 432 size_t bytes;
433 while ((bytes = fread(buf, 1, sizeof(buf), source_fp)) != 0) { 433 while ((bytes = fread(buf, 1, sizeof(buf), source_fp)) != 0) {
434 fwrite(buf, 1, bytes, dest_fp); 434 fwrite(buf, 1, bytes, dest_fp);
435 } 435 }
436 if (append) { 436 if (append) {
437 tmplog_offset = ftello(source_fp); 437 tmplog_offset = ftello(source_fp);
438 } 438 }
439 check_and_fclose(source_fp, source); 439 check_and_fclose(source_fp, source);
440 }
441 check_and_fclose(dest_fp, destination);
442 } 440 }
441 check_and_fclose(dest_fp, destination);
442 }
443} 443}
444 444
445static void copy_logs() { 445static void copy_logs() {
@@ -488,7 +488,7 @@ static void finish_recovery() {
488 if (!locale.empty() && has_cache) { 488 if (!locale.empty() && has_cache) {
489 LOG(INFO) << "Saving locale \"" << locale << "\""; 489 LOG(INFO) << "Saving locale \"" << locale << "\"";
490 490
491 FILE* fp = fopen_path(LOCALE_FILE, "w"); 491 FILE* fp = fopen_path(LOCALE_FILE, "we");
492 if (!android::base::WriteStringToFd(locale, fileno(fp))) { 492 if (!android::base::WriteStringToFd(locale, fileno(fp))) {
493 PLOG(ERROR) << "Failed to save locale to " << LOCALE_FILE; 493 PLOG(ERROR) << "Failed to save locale to " << LOCALE_FILE;
494 } 494 }
@@ -552,7 +552,7 @@ static bool erase_volume(const char* volume) {
552 } 552 }
553 553
554 std::string data(sb.st_size, '\0'); 554 std::string data(sb.st_size, '\0');
555 FILE* f = fopen(path.c_str(), "rb"); 555 FILE* f = fopen(path.c_str(), "rbe");
556 fread(&data[0], 1, data.size(), f); 556 fread(&data[0], 1, data.size(), f);
557 fclose(f); 557 fclose(f);
558 558
@@ -580,7 +580,7 @@ static bool erase_volume(const char* volume) {
580 ui->Print("Failed to make convert_fbe dir %s\n", strerror(errno)); 580 ui->Print("Failed to make convert_fbe dir %s\n", strerror(errno));
581 return true; 581 return true;
582 } 582 }
583 FILE* f = fopen(CONVERT_FBE_FILE, "wb"); 583 FILE* f = fopen(CONVERT_FBE_FILE, "wbe");
584 if (!f) { 584 if (!f) {
585 ui->Print("Failed to convert to file encryption %s\n", strerror(errno)); 585 ui->Print("Failed to convert to file encryption %s\n", strerror(errno));
586 return true; 586 return true;