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_INFO_H 17 #define OHOS_STORAGE_DAEMON_VOLUME_INFO_H 18 19 #include <string> 20 #include <sys/types.h> 21 22 namespace OHOS { 23 namespace StorageDaemon { 24 enum VolumeState { 25 UNMOUNTED, 26 CHECKING, 27 MOUNTED, 28 EJECTING, 29 REMOVED, 30 BADREMOVABLE, 31 }; 32 33 enum VolumeType { 34 EXTERNAL, 35 }; 36 37 class VolumeInfo { 38 public: 39 VolumeInfo() = default; 40 virtual ~VolumeInfo() = default; 41 42 int32_t Create(const std::string volId, const std::string diskId, dev_t device); 43 int32_t Destroy(); 44 int32_t Mount(uint32_t flags); 45 int32_t UMount(bool force = false); 46 int32_t Check(); 47 int32_t Format(const std::string type); 48 int32_t SetVolumeDescription(const std::string description); 49 50 std::string GetVolumeId(); 51 int32_t GetVolumeType(); 52 std::string GetDiskId(); 53 int32_t GetState(); 54 55 protected: 56 virtual int32_t DoCreate(dev_t dev) = 0; 57 virtual int32_t DoDestroy() = 0; 58 virtual int32_t DoMount(uint32_t mountFlags) = 0; 59 virtual int32_t DoUMount(bool force) = 0; 60 virtual int32_t DoCheck() = 0; 61 virtual int32_t DoFormat(std::string type) = 0; 62 virtual int32_t DoSetVolDesc(std::string description) = 0; 63 64 private: 65 std::string id_; 66 std::string diskId_; 67 VolumeType type_; 68 VolumeState mountState_; 69 uint32_t mountFlags_; 70 int32_t userIdOwner_; 71 }; 72 } // STORAGE_DAEMON 73 } // OHOS 74 75 #endif // OHOS_STORAGE_DAEMON_VOLUME_INFO_H