From a762e14f0312f8c97fb401ad94a2cde92404506a Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 8 Nov 2021 16:45:49 -0800 Subject: recovery_utils: remove FDE support Support for FDE is being removed from Android, having been replaced by FBE. This CL removes the FDE-specific code from recovery_utils: - Remove the code that wiped FstabEntry::key_loc if it is a block device, since key_loc was only used by FDE. - Remove support for reserving a crypto footer when formatting volumes, since crypto footers were only used by FDE. Bug: 191796797 Change-Id: I90b1e4cacd2f3e5cce77a82a0af744fcc7da9400 --- recovery_utils/roots.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/recovery_utils/roots.cpp b/recovery_utils/roots.cpp index 19484478c..0b82c1ccd 100644 --- a/recovery_utils/roots.cpp +++ b/recovery_utils/roots.cpp @@ -33,8 +33,7 @@ #include #include #include -#include -#include +#include #include #include @@ -161,29 +160,16 @@ int format_volume(const std::string& volume, const std::string& directory) { needs_projid = android::base::GetBoolProperty("external_storage.projid.enabled", false); } - // If there's a key_loc that looks like a path, it should be a block device for storing encryption - // metadata. Wipe it too. - if (!v->key_loc.empty() && v->key_loc[0] == '/') { - LOG(INFO) << "Wiping " << v->key_loc; - int fd = open(v->key_loc.c_str(), O_WRONLY | O_CREAT, 0644); - if (fd == -1) { - PLOG(ERROR) << "format_volume: Failed to open " << v->key_loc; - return -1; - } - wipe_block_device(fd, get_file_size(fd)); - close(fd); - } - int64_t length = 0; if (v->length > 0) { length = v->length; - } else if (v->length < 0 || v->key_loc == "footer") { + } else if (v->length < 0) { android::base::unique_fd fd(open(v->blk_device.c_str(), O_RDONLY)); if (fd == -1) { PLOG(ERROR) << "format_volume: failed to open " << v->blk_device; return -1; } - length = get_file_size(fd.get(), v->length ? -v->length : CRYPT_FOOTER_OFFSET); + length = get_file_size(fd.get(), -v->length); if (length <= 0) { LOG(ERROR) << "get_file_size: invalid size " << length << " for " << v->blk_device; return -1; -- cgit v1.2.3