From a23bfbc509ac7b4d30fa99340c96049c99f334b2 Mon Sep 17 00:00:00 2001 From: dengjun Date: Wed, 15 Nov 2023 17:11:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dengjun --- .vscode/settings.json | 6 ++++++ bundle.json | 3 ++- interfaces/kits/js/BUILD.gn | 2 ++ .../js/src/mod_fileio/properties/filefmn.para | 14 +++++++++++++ .../js/src/mod_fileio/properties/open.cpp | 20 +++++++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json create mode 100644 interfaces/kits/js/src/mod_fileio/properties/filefmn.para diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..a4a1573f8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "__config": "cpp", + "__nullptr": "cpp" + } +} \ No newline at end of file diff --git a/bundle.json b/bundle.json index dbf370104..4b7315b04 100644 --- a/bundle.json +++ b/bundle.json @@ -37,7 +37,8 @@ "napi", "samgr", "app_file_service", - "build_framework" + "build_framework", + "init" ], "third_party": [ "bounds_checking_function", diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index dabc9346d..61de8e5bd 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -98,6 +98,7 @@ ohos_shared_library("fileio") { external_deps = [ "hilog:libhilog", "napi:ace_napi", + "init:libbegetutil", ] defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] } @@ -155,6 +156,7 @@ ohos_shared_library("fs") { external_deps = [ "hilog:libhilog", "napi:ace_napi", + "init:libbegetutil", ] if (!use_mingw_win && !use_mac) { diff --git a/interfaces/kits/js/src/mod_fileio/properties/filefmn.para b/interfaces/kits/js/src/mod_fileio/properties/filefmn.para new file mode 100644 index 000000000..a8f0e4c92 --- /dev/null +++ b/interfaces/kits/js/src/mod_fileio/properties/filefmn.para @@ -0,0 +1,14 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +const.filemanager.full_mout.enable=false \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fileio/properties/open.cpp b/interfaces/kits/js/src/mod_fileio/properties/open.cpp index 25d731c04..a2950b597 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/open.cpp @@ -19,6 +19,7 @@ #include #include #include "remote_uri.h" +#include "parameter.h" #include "../../common/napi/n_async/n_async_work_callback.h" #include "../../common/napi/n_async/n_async_work_promise.h" @@ -30,6 +31,22 @@ namespace DistributedFS { namespace ModuleFileIO { using namespace std; +const char* g_filemanagerFullMoutEnableParameter = "const.filemanager.full_mout.enable"; +const int32_t FULL_MOUT_ENABLE_SIZE = 6; + +namespace { + bool CheckFilemanagerFullMoutEnable() + { + char value[FULL_MOUT_ENABLE_SIZE] = "false"; + int retSysParam = GetParameter(g_filemanagerFullMoutEnableParameter, "false", value, FULL_MOUT_ENABLE_SIZE); + if (retSysParam > 0 && !std::strcmp(value, "true")) { + return true; + } + return false; + } +} + + napi_value Open::Sync(napi_env env, napi_callback_info info) { NFuncArg funcArg(env, info); @@ -92,6 +109,9 @@ napi_value Open::Sync(napi_env env, napi_callback_info info) static UniError DoOpenExec(const std::string& path, const unsigned int flags, const int32_t mode, shared_ptr arg) { + if (!CheckFilemanagerFullMoutEnable()) { + return UniError(errno); + } int fd = -1; if (!ModuleRemoteUri::RemoteUri::IsRemoteUri(path, fd, flags)) { fd = open(path.c_str(), flags, mode); -- Gitee