diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..a4a1573f89eefb1daba0cd3d37d80899bb16314a --- /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 dbf37010436d05a9fb0fa3a8048b1a292aa0d541..4b7315b04617880cf3bc8eaf1b782f8d8c21ff6a 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 dabc9346d47f96e6f53246b5f35ed5fda3e68379..61de8e5bd888a9ecb83eb115bd87e501b4209caf 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 0000000000000000000000000000000000000000..a8f0e4c928bad608175e6cde86739ab0b915cb94 --- /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 25d731c04dccfad36a6cef7a797534a9342caf34..a2950b597b6f54d3abd7001ae352ad240eff0e41 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);