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 FUSE_DAEMON_H 17 #define FUSE_DAEMON_H 18 19 #include <condition_variable> 20 #include <fuse_i.h> 21 #include <fuse_lowlevel.h> 22 #include <mutex> 23 #include <string> 24 #include "dlp_link_file.h" 25 #include "rwlock.h" 26 27 namespace OHOS { 28 namespace Security { 29 namespace DlpPermission { 30 typedef struct DirAddParams { 31 fuse_req_t req; 32 char *directBuf; 33 size_t bufLen; 34 std::string entryName; 35 struct stat* entryStat; 36 off_t nextOff; 37 off_t curOff; 38 } DirAddParams; 39 40 enum DaemonStatus { 41 DAEMON_UNDEF, 42 DAEMON_ENABLE, 43 DAEMON_DISABLE, 44 }; 45 46 class FuseDaemon { 47 public: 48 static int InitFuseFs(); 49 static struct stat* GetRootFileStat(); 50 static int WaitDaemonEnable(void); 51 static void NotifyDaemonEnable(void); 52 static void NotifyDaemonDisable(void); 53 static void InitRootFileStat(void); 54 static void FuseFsDaemonThread(int fuseFd); 55 56 static std::condition_variable daemonEnableCv_; 57 static enum DaemonStatus daemonStatus_; 58 static std::mutex daemonEnableMtx_; 59 static struct stat rootFileStat_; 60 static bool init_; 61 static std::mutex initMutex_; 62 static struct fuse_lowlevel_ops fuseDaemonOper_; 63 }; 64 } // namespace DlpPermission 65 } // namespace Security 66 } // namespace OHOS 67 68 #endif 69