From fee4031d0fd9d6c6e2ee72aa547423149974e825 Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Sat, 8 Aug 2020 00:37:39 +0800 Subject: [PATCH] Keep disable file when module update --- native/jni/core/module.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/native/jni/core/module.cpp b/native/jni/core/module.cpp index feef65930..b6636cdbf 100644 --- a/native/jni/core/module.cpp +++ b/native/jni/core/module.cpp @@ -618,7 +618,12 @@ static void prepare_modules() { if (entry->d_type == DT_DIR) { // Cleanup old module if exists if (faccessat(mfd, entry->d_name, F_OK, 0) == 0) { - frm_rf(xopenat(mfd, entry->d_name, O_RDONLY | O_CLOEXEC)); + int modfd = xopenat(mfd, entry->d_name, O_RDONLY | O_CLOEXEC); + if (faccessat(modfd, "disable", F_OK, 0) == 0) { + auto disable = entry->d_name + "/disable"s; + close(xopenat(ufd, disable.data(), O_RDONLY | O_CREAT | O_CLOEXEC, 0)); + } + frm_rf(modfd); unlinkat(mfd, entry->d_name, AT_REMOVEDIR); } LOGI("Upgrade / New module: %s\n", entry->d_name);