diff options
author | Paul Crowley <paulcrowley@google.com> | 2018-04-24 17:06:30 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2018-04-25 21:55:25 +0000 |
commit | d8525007e1885e17804cc8de082e46b531b3901c (patch) | |
tree | bd532b6b057bc70f3437cd34750cb2d4dd3d8799 | |
parent | 398b551d51ef8bda9836c3c629aa2dbe9c30c39d (diff) | |
download | core-d8525007e1885e17804cc8de082e46b531b3901c.tar.gz core-d8525007e1885e17804cc8de082e46b531b3901c.tar.bz2 core-d8525007e1885e17804cc8de082e46b531b3901c.zip |
Wipe metadata when we wipe userdata and cache.
Bug: 78469699
Test: Run "fastboot -w" and see that metadata is wiped
Merged-In: I2d795281c48b59c87d4f8f010037d95186f55684
Change-Id: I2d795281c48b59c87d4f8f010037d95186f55684
-rw-r--r-- | fastboot/fastboot.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 5017ebda0..e89586f15 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -1856,25 +1856,20 @@ int main(int argc, char **argv) } if (wants_wipe) { - fprintf(stderr, "wiping userdata...\n"); - fb_queue_erase("userdata"); - if (set_fbe_marker) { - fprintf(stderr, "setting FBE marker...\n"); - std::string initial_userdata_dir = create_fbemarker_tmpdir(); - if (initial_userdata_dir.empty()) { - return 1; + std::vector<std::string> 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, "", "", ""); } - 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()) { - fprintf(stderr, "wiping cache...\n"); - fb_queue_erase("cache"); - fb_perform_format(transport, "cache", 1, "", "", ""); } } if (wants_set_active) { |