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