From 52a98cbd51343f20d5a7c8ddc46e5355b8cd9e4a Mon Sep 17 00:00:00 2001 From: LoveSy Date: Mon, 10 Apr 2023 18:55:30 +0800 Subject: [PATCH] Temp workaround for module file context --- native/src/core/module.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/native/src/core/module.cpp b/native/src/core/module.cpp index 493f306bb..612abbbe6 100644 --- a/native/src/core/module.cpp +++ b/native/src/core/module.cpp @@ -146,17 +146,19 @@ void mirror_node::mount() { } void module_node::mount() { - string src = module_mnt + module + parent()->root()->prefix + node_path(); - if (node_path() == "/system/etc/hosts") { + std::string path = module + (parent()->root()->prefix + node_path()); + string mnt_src = module_mnt + path; + { + string src = MODULEROOT "/" + path; + if (exist()) clone_attr(mirror_path().data(), src.data()); // special case for /system/etc/hosts to ensure it is writable - src = std::string(MODULEROOT "/") + module + parent()->root()->prefix + "/system/etc/hosts"; + if (node_path() == "/system/etc/hosts") mnt_src = std::move(src); + } + if (isa(parent())) { + create_and_mount("module", mnt_src); + } else { + bind_mount("module", mnt_src.data(), node_path().data()); } - if (exist()) - clone_attr(mirror_path().data(), src.data()); - if (isa(parent())) - create_and_mount("module", src); - else - bind_mount("module", src.data(), node_path().data()); } void tmpfs_node::mount() {