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_EXTERNAL_VOLUME_INFO_H 17 #define OHOS_STORAGE_DAEMON_EXTERNAL_VOLUME_INFO_H 18 19 #include <vector> 20 #include <sys/types.h> 21 #include <map> 22 #include "volume/volume_info.h" 23 24 namespace OHOS { 25 namespace StorageDaemon { 26 class ExternalVolumeInfo : public VolumeInfo { 27 public: 28 ExternalVolumeInfo() = default; 29 virtual ~ExternalVolumeInfo() = default; 30 31 int32_t GetFsType(); 32 std::string GetFsUuid(); 33 std::string GetFsLabel(); 34 35 protected: 36 virtual int32_t DoCreate(dev_t dev) override; 37 virtual int32_t DoDestroy() override; 38 virtual int32_t DoMount(const std::string mountPath, uint32_t mountFlags) override; 39 virtual int32_t DoUMount(const std::string mountPath, bool force) override; 40 virtual int32_t DoCheck() override; 41 virtual int32_t DoFormat(std::string type) override; 42 43 private: 44 std::string devPath_; 45 std::string fsLabel_; 46 std::string fsUuid_; 47 std::string fsType_; 48 dev_t device_; 49 50 const std::string devPathDir_ = "/dev/block/%s"; 51 std::vector<std::string> supportMountType_ = { "ext2", "ext3", "ext4", "ntfs", "exfat", "vfat" }; 52 std::map<std::string, std::string> supportFormatType_ = { 53 {"ext2", "mke2fs"}, {"ext3", "mke2fs"}, {"ext4", "mke2fs"}, {"ntfs", "mkfs.ntfs"}, {"exfat", "mkfs.exfat"} 54 }; 55 56 int32_t ReadMetadata(); 57 std::string GetBlkidData(const std::string type); 58 }; 59 } // STORAGE_DAEMON 60 } // OHOS 61 62 #endif // OHOS_STORAGE_DAEMON_EXTERNAL_VOLUME_INFO_H 63