From d2217b51679ac96c5f05e3c91b4b3fe840cf274f Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 7 Jun 2019 19:18:46 +0900 Subject: [PATCH] Read *.rc files from flattened APEX This change fixes a bug that *.rc files in APEXes are not read when the APEXes are flattened. This was because init used "/apex/*@*/etc/*.rc" glob pattern to find the files, which gives 0 result with flattened APEXes; with flattend APEXes /system/apex is just bind-mounted to /apex, and therefore, the name@version directories don't exist. Fixing the issue by globing /apex/*/etc/*.rc and filter-out the paths with @ to avoid double parsing the *.rc files in case of non-flattend APEXes. Bug: 134067086 Test: revert I75ec6b69cca1cef071b50fac9a4cf8b8ceddb142 build sdk_gphone_x86_64 and record a video in the camera app. The recording works. `ps -A | grep media.swcodec` shows media.swcodec process. `atest CtsStatsdHostTestCases:android.cts.statsd.atom.UidAtomTests#testAudioState` passes Test: build sdk_phone_x86_64 and do the same. Change-Id: I00af1910a8e8a330addc4c6903e5f3695aeb6865 --- init/builtins.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/init/builtins.cpp b/init/builtins.cpp index e9d58c605..d93fd6d54 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -1076,10 +1076,7 @@ static Result do_mark_post_data(const BuiltinArguments& args) { static Result do_parse_apex_configs(const BuiltinArguments& args) { glob_t glob_result; - // @ is added to filter out the later paths, which are bind mounts of the places - // where the APEXes are really mounted at. Otherwise, we will parse the - // same file twice. - static constexpr char glob_pattern[] = "/apex/*@*/etc/*.rc"; + static constexpr char glob_pattern[] = "/apex/*/etc/*.rc"; const int ret = glob(glob_pattern, GLOB_MARK, nullptr, &glob_result); if (ret != 0 && ret != GLOB_NOMATCH) { globfree(&glob_result); @@ -1088,7 +1085,15 @@ static Result do_parse_apex_configs(const BuiltinArguments& args) { std::vector configs; Parser parser = CreateServiceOnlyParser(ServiceList::GetInstance()); for (size_t i = 0; i < glob_result.gl_pathc; i++) { - configs.emplace_back(glob_result.gl_pathv[i]); + std::string path = glob_result.gl_pathv[i]; + // Filter-out /apex/@ paths. The paths are bind-mounted to + // /apex/ paths, so unless we filter them out, we will parse the + // same file twice. + std::vector paths = android::base::Split(path, "/"); + if (paths.size() >= 2 && paths[1].find('@') != std::string::npos) { + continue; + } + configs.push_back(path); } globfree(&glob_result);