• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 OHOS_MEDIA_FUSE_MANAGER_H
17 #define OHOS_MEDIA_FUSE_MANAGER_H
18 
19 #include <string>
20 #include <sys/stat.h>
21 
22 namespace OHOS {
23 namespace Media {
24 class MediaFuseDaemon;
25 
26 class MediaFuseManager {
27 public:
28     static MediaFuseManager &GetInstance();
29     void Start();
30     void Stop();
31     int32_t DoGetAttr(const char *path, struct stat *stbuf);
32     int32_t DoOpen(const char *path, int flags, int &fd);
33     int32_t DoRelease(const char *path, const int &fd);
34 private:
35     MediaFuseManager() = default;
36     ~MediaFuseManager() = default;
37 
38     int32_t MountFuse(std::string &mountpoint);
39     int32_t UMountFuse();
40     bool CheckDeviceInLinux();
41 
42 private:
43     std::shared_ptr<MediaFuseDaemon> fuseDaemon_;
44     bool isInLinux_;
45 };
46 
47 class MediafusePermCheckInfo {
48 public:
49     MediafusePermCheckInfo(const std::string &filePath, const std::string &mode, const std::string &fileId,
50         const std::string &appId, const int32_t &uid);
51     ~MediafusePermCheckInfo() = default;
52     int32_t CheckPermission(uint32_t &tokenCaller);
53 private:
54     std::string filePath_;
55     std::string mode_;
56     std::string fileId_;
57     std::string appId_;
58     int32_t uid_;
59 };
60 } // namespace Media
61 } // namespace OHOS
62 #endif // OHOS_MEDIA_FUSE_MANAGER_H
63 
64