From 4d17006b57331e10ffd861b68e2c92909db15276 Mon Sep 17 00:00:00 2001 From: Paul Crowley Date: Tue, 24 Apr 2018 17:06:30 -0700 Subject: [PATCH] Wipe metadata when we wipe userdata and cache. Bug: 78469699 Test: Run "fastboot -w" and see that metadata is wiped Change-Id: I2d795281c48b59c87d4f8f010037d95186f55684 --- fastboot/fastboot.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 51b3f0c06..9463cc917 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -1644,20 +1644,20 @@ int FastBoot::Main(int argc, char* argv[]) { } if (wants_wipe) { - fb_queue_erase("userdata"); - if (set_fbe_marker) { - fprintf(stderr, "setting FBE marker on initial userdata...\n"); - std::string initial_userdata_dir = create_fbemarker_tmpdir(); - fb_perform_format(transport, "userdata", 1, "", "", initial_userdata_dir); - delete_fbemarker_tmpdir(initial_userdata_dir); - } else { - fb_perform_format(transport, "userdata", 1, "", "", ""); - } - - std::string cache_type; - if (fb_getvar(transport, "partition-type:cache", &cache_type) && !cache_type.empty()) { - fb_queue_erase("cache"); - fb_perform_format(transport, "cache", 1, "", "", ""); + std::vector partitions = { "userdata", "cache", "metadata" }; + for (const auto& partition : partitions) { + std::string partition_type; + if (!fb_getvar(transport, std::string{"partition-type:"} + partition, &partition_type)) continue; + if (partition_type.empty()) continue; + fb_queue_erase(partition); + if (partition == "userdata" && set_fbe_marker) { + fprintf(stderr, "setting FBE marker on initial userdata...\n"); + std::string initial_userdata_dir = create_fbemarker_tmpdir(); + fb_perform_format(transport, partition, 1, "", "", initial_userdata_dir); + delete_fbemarker_tmpdir(initial_userdata_dir); + } else { + fb_perform_format(transport, partition, 1, "", "", ""); + } } } if (wants_set_active) {