Merge "init: Sort the list of flattened APEX folders to avoid variations" am: 0f2c5417c3 am: 570fe2083c

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1538222

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I90ee4644f921d6bde03dbaef3f3e86fc080affaa
This commit is contained in:
Jiyong Park 2020-12-31 04:34:56 +00:00 committed by Automerger Merge Worker
commit 8b40485f58

View file

@ -115,22 +115,29 @@ static Result<void> ActivateFlattenedApexesFrom(const std::string& from_dir,
return {};
}
dirent* entry;
std::vector<std::string> entries;
while ((entry = readdir(dir.get())) != nullptr) {
if (entry->d_name[0] == '.') continue;
if (entry->d_type == DT_DIR) {
const std::string apex_path = from_dir + "/" + entry->d_name;
const auto apex_manifest = GetApexManifest(apex_path);
if (!apex_manifest.ok()) {
LOG(ERROR) << apex_path << " is not an APEX directory: " << apex_manifest.error();
continue;
}
const std::string mount_path = to_dir + "/" + apex_manifest->name();
if (auto result = MountDir(apex_path, mount_path); !result.ok()) {
return result;
}
on_activate(apex_path, *apex_manifest);
entries.push_back(entry->d_name);
}
}
std::sort(entries.begin(), entries.end());
for (const auto& name : entries) {
const std::string apex_path = from_dir + "/" + name;
const auto apex_manifest = GetApexManifest(apex_path);
if (!apex_manifest.ok()) {
LOG(ERROR) << apex_path << " is not an APEX directory: " << apex_manifest.error();
continue;
}
const std::string mount_path = to_dir + "/" + apex_manifest->name();
if (auto result = MountDir(apex_path, mount_path); !result.ok()) {
return result;
}
on_activate(apex_path, *apex_manifest);
}
return {};
}