Check the data directory before mount tmpfs

As it's possible that dir is not created when mount tmpfs on external
private mount, add a busy waiting check in zygote to ensure data
directory is created before we do our work.

Bug:189406326
Change-Id: I5e5beca36383027580eeb9ead77f59ce4b3ee4e5
This commit is contained in:
Zaijian Lin
2021-07-19 13:59:13 +08:00
parent f637a0d63d
commit ed36545f40

View File

@@ -201,6 +201,8 @@ static constexpr unsigned int STORAGE_DIR_CHECK_MAX_INTERVAL_US = 1000;
*/
static constexpr int STORAGE_DIR_CHECK_TIMEOUT_US = 1000 * 1000 * 60 * 5;
static void WaitUntilDirReady(const std::string& target, fail_fn_t fail_fn);
/**
* A helper class containing accounting information for USAPs.
*/
@@ -1248,7 +1250,11 @@ static void isolateAppData(JNIEnv* env, const std::vector<std::string>& merged_d
auto volPath = StringPrintf("%s/%s", externalPrivateMountPath, ent->d_name);
auto cePath = StringPrintf("%s/user", volPath.c_str());
auto dePath = StringPrintf("%s/user_de", volPath.c_str());
// Wait until dir user is created.
WaitUntilDirReady(cePath.c_str(), fail_fn);
MountAppDataTmpFs(cePath.c_str(), fail_fn);
// Wait until dir user_de is created.
WaitUntilDirReady(dePath.c_str(), fail_fn);
MountAppDataTmpFs(dePath.c_str(), fail_fn);
}
closedir(dir);