Enforce that internal storage is prepared first
Before doing anything else in fscrypt_prepare_user_storage(), error out
if adoptable storage is being prepared before internal storage. Without
this explicit check, making this mistake results in a sequence of weird
errors that is hard to trace back to the actual problem.
Bug: 231387956
Change-Id: Ib26cc1bd46ffa2578f6f0156dfacc5496dae3178
(cherry picked from commit c66c2e306d
)
Merged-In: Ib26cc1bd46ffa2578f6f0156dfacc5496dae3178
This commit is contained in:
parent
e07afb81e2
commit
c193c3fbb8
1 changed files with 17 additions and 0 deletions
17
FsCrypt.cpp
17
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);
|
||||
|
|
Loading…
Reference in a new issue