1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DLP_LINK_MANAGER_H 17 #define DLP_LINK_MANAGER_H 18 #include <unordered_map> 19 #include <string> 20 #include "dlp_file.h" 21 #include "dlp_link_file.h" 22 #include "rwlock.h" 23 24 namespace OHOS { 25 namespace Security { 26 namespace DlpPermission { 27 static const int FUSE_DEV_FD = 1000; 28 29 class DlpLinkManager final { 30 public: 31 static DlpLinkManager& GetInstance(); ~DlpLinkManager()32 ~DlpLinkManager() {}; 33 34 int32_t AddDlpLinkFile(std::shared_ptr<DlpFile>& filePtr, const std::string& dlpLinkName); 35 int32_t StopDlpLinkFile(std::shared_ptr<DlpFile>& filePtr); 36 int32_t RestartDlpLinkFile(std::shared_ptr<DlpFile>& filePtr); 37 int32_t ReplaceDlpLinkFile(std::shared_ptr<DlpFile>& filePtr, const std::string& dlpLinkName); 38 int32_t DeleteDlpLinkFile(std::shared_ptr<DlpFile>& filePtr); 39 DlpLinkFile* LookUpDlpLinkFile(const std::string& dlpLinkName); 40 void DumpDlpLinkFile(std::vector<DlpLinkFileInfo>& linkList); 41 42 private: 43 DlpLinkManager(); 44 DISALLOW_COPY_AND_MOVE(DlpLinkManager); 45 46 OHOS::Utils::RWLock g_DlpLinkMapLock_; 47 std::unordered_map<std::string, DlpLinkFile*> g_DlpLinkFileNameMap_; 48 }; 49 } // namespace DlpPermission 50 } // namespace Security 51 } // namespace OHOS 52 53 #endif 54