aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lawrence2015-11-05 15:38:40 -0600
committerPaul Lawrence2015-11-13 09:49:31 -0600
commitd0db337d727707977fa562bcc492b27270e67937 (patch)
treece8ca7e2cf3ae6ace1a36120ed25bc9f67672852 /recovery.cpp
parent8b5f9d74a045b60667acbd54988171b14d57212e (diff)
downloadplatform-bootable-recovery-d0db337d727707977fa562bcc492b27270e67937.tar.gz
platform-bootable-recovery-d0db337d727707977fa562bcc492b27270e67937.tar.xz
platform-bootable-recovery-d0db337d727707977fa562bcc492b27270e67937.zip
Create convert_fbe breadcrumb file to support conversion to FBE
Change-Id: I38b29e1e34ea793e4b87cd27a1d39fa905fddf7a
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 5f3bfca4..e348b84d 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -76,7 +76,10 @@ static const char *INTENT_FILE = "/cache/recovery/intent";
76static const char *LOG_FILE = "/cache/recovery/log"; 76static const char *LOG_FILE = "/cache/recovery/log";
77static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install"; 77static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install";
78static const char *LOCALE_FILE = "/cache/recovery/last_locale"; 78static const char *LOCALE_FILE = "/cache/recovery/last_locale";
79static const char *CONVERT_FBE_DIR = "/cache/recovery/convert_fbe";
80static const char *CONVERT_FBE_FILE = "/cache/recovery/convert_fbe/convert_fbe";
79static const char *CACHE_ROOT = "/cache"; 81static const char *CACHE_ROOT = "/cache";
82static const char *DATA_ROOT = "/data";
80static const char *SDCARD_ROOT = "/sdcard"; 83static const char *SDCARD_ROOT = "/sdcard";
81static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log"; 84static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
82static const char *TEMPORARY_INSTALL_FILE = "/tmp/last_install"; 85static const char *TEMPORARY_INSTALL_FILE = "/tmp/last_install";
@@ -503,6 +506,7 @@ typedef struct _saved_log_file {
503 506
504static bool erase_volume(const char* volume) { 507static bool erase_volume(const char* volume) {
505 bool is_cache = (strcmp(volume, CACHE_ROOT) == 0); 508 bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
509 bool is_data = (strcmp(volume, DATA_ROOT) == 0);
506 510
507 ui->SetBackground(RecoveryUI::ERASING); 511 ui->SetBackground(RecoveryUI::ERASING);
508 ui->SetProgressType(RecoveryUI::INDETERMINATE); 512 ui->SetProgressType(RecoveryUI::INDETERMINATE);
@@ -557,7 +561,25 @@ static bool erase_volume(const char* volume) {
557 ui->Print("Formatting %s...\n", volume); 561 ui->Print("Formatting %s...\n", volume);
558 562
559 ensure_path_unmounted(volume); 563 ensure_path_unmounted(volume);
560 int result = format_volume(volume); 564
565 int result;
566
567 if (is_data && reason && strcmp(reason, "convert_fbe") == 0) {
568 // Create convert_fbe breadcrumb file to signal to init
569 // to convert to file based encryption, not full disk encryption
570 mkdir(CONVERT_FBE_DIR, 0700);
571 FILE* f = fopen(CONVERT_FBE_FILE, "wb");
572 if (!f) {
573 ui->Print("Failed to convert to file encryption\n");
574 return true;
575 }
576 fclose(f);
577 result = format_volume(volume, CONVERT_FBE_DIR);
578 remove(CONVERT_FBE_FILE);
579 rmdir(CONVERT_FBE_DIR);
580 } else {
581 result = format_volume(volume);
582 }
561 583
562 if (is_cache) { 584 if (is_cache) {
563 while (head) { 585 while (head) {