summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-12 17:45:19 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-12 17:45:19 +0000
commit3844fbde4dc2611d7b5d0e9fc790ffb3f4b640d3 (patch)
tree00b3cd36e156830cf8a23333a4982641aff7eaff
parent05b887e79709007a928f78827321d9c8fcd58b18 (diff)
parentc193c3fbb827e3aa53b65e5e3dbd96fc11b75701 (diff)
downloadvold-3844fbde4dc2611d7b5d0e9fc790ffb3f4b640d3.tar.gz
Snap for 8580258 from c193c3fbb827e3aa53b65e5e3dbd96fc11b75701 to tm-frc-adbd-release
Change-Id: I836da424e43c361978a5f50336db23c367a274a8
-rw-r--r--FsCrypt.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/FsCrypt.cpp b/FsCrypt.cpp
index 42df78b1..6c081778 100644
--- a/FsCrypt.cpp
+++ b/FsCrypt.cpp
@@ -812,6 +812,23 @@ bool fscrypt_prepare_user_storage(const std::string& volume_uuid, userid_t user_
LOG(DEBUG) << "fscrypt_prepare_user_storage for volume " << escape_empty(volume_uuid)
<< ", user " << user_id << ", serial " << serial << ", flags " << flags;
+ // Internal storage must be prepared before adoptable storage, since the
+ // user's volume keys are stored in their internal storage.
+ if (!volume_uuid.empty()) {
+ if ((flags & android::os::IVold::STORAGE_FLAG_DE) &&
+ !android::vold::pathExists(android::vold::BuildDataMiscDePath("", user_id))) {
+ LOG(ERROR) << "Cannot prepare DE storage for user " << user_id << " on volume "
+ << volume_uuid << " before internal storage";
+ return false;
+ }
+ if ((flags & android::os::IVold::STORAGE_FLAG_CE) &&
+ !android::vold::pathExists(android::vold::BuildDataMiscCePath("", user_id))) {
+ LOG(ERROR) << "Cannot prepare CE storage for user " << user_id << " on volume "
+ << volume_uuid << " before internal storage";
+ return false;
+ }
+ }
+
if (flags & android::os::IVold::STORAGE_FLAG_DE) {
// DE_sys key
auto system_legacy_path = android::vold::BuildDataSystemLegacyPath(user_id);