1 /*
2  * Copyright (c) 2021 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 <nocopyable.h>
20 #include <sys/types.h>
21 #include <string>
22 #include <memory>
23 #include "storage_rl_map.h"
24 #include "volume/volume_info.h"
25 
26 namespace OHOS {
27 namespace StorageDaemon {
28 class VolumeManager final {
29 public:
30     virtual ~VolumeManager() = default;
31     static VolumeManager* Instance();
32 
33     std::string CreateVolume(const std::string diskId, dev_t device);
34     int32_t DestroyVolume(const std::string volId);
35 
36     int32_t Check(const std::string volId);
37     int32_t Mount(const std::string volId, uint32_t flags);
38     int32_t UMount(const std::string volId);
39     int32_t Format(const std::string volId, const std::string fsType);
40     int32_t SetVolumeDescription(const std::string volId, const std::string description);
41 
42 private:
43     VolumeManager() = default;
44     DISALLOW_COPY_AND_MOVE(VolumeManager);
45 
46     static VolumeManager* instance_;
47     StorageService::StorageRlMap<std::string, std::shared_ptr<VolumeInfo>> volumes_;
48 
49     std::shared_ptr<VolumeInfo> GetVolume(const std::string volId);
50 };
51 } // STORAGE_DAEMON
52 } // OHOS
53 
54 #endif // OHOS_STORAGE_DAEMON_VOLUME_MANAGER_H