• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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_STORAGE_DAEMON_VOLUME_MANAGER_H
17 #define OHOS_STORAGE_DAEMON_VOLUME_MANAGER_H
18 
19 #include "storage_rl_map.h"
20 #include "volume/volume_info.h"
21 
22 namespace OHOS {
23 namespace StorageDaemon {
24 class VolumeManager final {
25 public:
26     virtual ~VolumeManager() = default;
27     static VolumeManager &Instance();
28 
29     std::string CreateVolume(const std::string diskId, dev_t device, bool isUserdata);
30     int32_t DestroyVolume(const std::string volId);
31 
32     int32_t Check(const std::string volId);
33     int32_t Mount(const std::string volId, uint32_t flags);
34     int32_t UMount(const std::string volId);
35     int32_t MountUsbFuse(std::string volumeId, std::string &fsUuid, int &fuseFd);
36     int32_t TryToFix(const std::string volId, uint32_t flags);
37     int32_t Format(const std::string volId, const std::string fsType);
38     int32_t SetVolumeDescription(const std::string volId, const std::string description);
39     int32_t QueryUsbIsInUse(const std::string &diskPath, bool &isInUse);
40 
41 private:
42     VolumeManager() = default;
43     DISALLOW_COPY_AND_MOVE(VolumeManager);
44 
45     bool IsMtpDeviceInUse(const std::string &diskPath);
46     StorageService::StorageRlMap<std::string, std::shared_ptr<VolumeInfo>> volumes_;
47 
48     std::shared_ptr<VolumeInfo> GetVolume(const std::string volId);
49     int32_t CreateMountUsbFusePath(std::string fsUuid);
50     int32_t ReadVolumeUuid(std::string volumeId, std::string &fsUuid);
51     std::string mountUsbFusePath_;
52 };
53 } // STORAGE_DAEMON
54 } // OHOS
55 
56 #endif // OHOS_STORAGE_DAEMON_VOLUME_MANAGER_H