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 <map> 23 #include <memory> 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 41 private: 42 VolumeManager() = default; 43 DISALLOW_COPY_AND_MOVE(VolumeManager); 44 45 static VolumeManager* instance_; 46 std::map<std::string, std::shared_ptr<VolumeInfo>> volumes_; 47 48 std::shared_ptr<VolumeInfo> GetVolume(const std::string volId); 49 }; 50 } // STORAGE_DAEMON 51 } // OHOS 52 53 #endif // OHOS_STORAGE_DAEMON_VOLUME_MANAGER_H