Merge "Traverse /etc/init in a well-defined order"

This commit is contained in:
Glenn Kasten 2016-10-09 17:11:03 +00:00 committed by Gerrit Code Review
commit db7715c7dd

View file

@ -122,14 +122,20 @@ bool Parser::ParseConfigDir(const std::string& path) {
return false; return false;
} }
dirent* current_file; dirent* current_file;
std::vector<std::string> files;
while ((current_file = readdir(config_dir.get()))) { while ((current_file = readdir(config_dir.get()))) {
std::string current_path =
android::base::StringPrintf("%s/%s", path.c_str(), current_file->d_name);
// Ignore directories and only process regular files. // Ignore directories and only process regular files.
if (current_file->d_type == DT_REG) { if (current_file->d_type == DT_REG) {
if (!ParseConfigFile(current_path)) { std::string current_path =
LOG(ERROR) << "could not import file '" << current_path << "'"; android::base::StringPrintf("%s/%s", path.c_str(), current_file->d_name);
} files.emplace_back(current_path);
}
}
// Sort first so we load files in a consistent order (bug 31996208)
std::sort(files.begin(), files.end());
for (const auto& file : files) {
if (!ParseConfigFile(file)) {
LOG(ERROR) << "could not import file '" << file << "'";
} }
} }
return true; return true;