vold: fsync both file and directory after write keys
Use vold version of writeStringToFile which fsync files, and
manually fsync directories after initialize global DE
(cherry picked from commit a98464f688
)
Bug: 71810347
Test: Build pass and reboot stress test.
Original boot failure symptom is NOT reproducible.
Change-Id: I1ca8f8cf0ccfd01075a9c33f79042e58d99aea26
Merged-In: I1ca8f8cf0ccfd01075a9c33f79042e58d99aea26
This commit is contained in:
parent
97466cb145
commit
11621353f2
1 changed files with 6 additions and 10 deletions
16
FsCrypt.cpp
16
FsCrypt.cpp
|
@ -60,10 +60,10 @@
|
|||
#include <android-base/unique_fd.h>
|
||||
|
||||
using android::base::StringPrintf;
|
||||
using android::base::WriteStringToFile;
|
||||
using android::fs_mgr::GetEntryForMountPoint;
|
||||
using android::vold::kEmptyAuthentication;
|
||||
using android::vold::KeyBuffer;
|
||||
using android::vold::writeStringToFile;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -351,18 +351,14 @@ bool fscrypt_initialize_global_de() {
|
|||
|
||||
std::string modestring = device_ref.contents_mode + ":" + device_ref.filenames_mode;
|
||||
std::string mode_filename = std::string("/data") + fscrypt_key_mode;
|
||||
if (!android::base::WriteStringToFile(modestring, mode_filename)) {
|
||||
PLOG(ERROR) << "Cannot save type";
|
||||
return false;
|
||||
}
|
||||
if (!android::vold::writeStringToFile(modestring, mode_filename)) return false;
|
||||
|
||||
std::string ref_filename = std::string("/data") + fscrypt_key_ref;
|
||||
if (!android::base::WriteStringToFile(device_ref.key_raw_ref, ref_filename)) {
|
||||
PLOG(ERROR) << "Cannot save key reference to:" << ref_filename;
|
||||
return false;
|
||||
}
|
||||
if (!android::vold::writeStringToFile(device_ref.key_raw_ref, ref_filename)) return false;
|
||||
|
||||
LOG(INFO) << "Wrote system DE key reference to:" << ref_filename;
|
||||
|
||||
if (!android::vold::FsyncDirectory(device_key_dir)) return false;
|
||||
s_global_de_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -419,7 +415,7 @@ static void drop_caches() {
|
|||
// Clean any dirty pages (otherwise they won't be dropped).
|
||||
sync();
|
||||
// Drop inode and page caches.
|
||||
if (!WriteStringToFile("3", "/proc/sys/vm/drop_caches")) {
|
||||
if (!writeStringToFile("3", "/proc/sys/vm/drop_caches")) {
|
||||
PLOG(ERROR) << "Failed to drop caches during key eviction";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue