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_DISK_INFO_H 17 #define OHOS_STORAGE_DAEMON_DISK_INFO_H 18 19 #include <list> 20 #include <string> 21 22 #include <sys/types.h> 23 24 namespace OHOS { 25 namespace StorageDaemon { 26 const int sInital = 0; 27 const int sCreate = 1; 28 const int sScan = 2; 29 const int sDestroy = 4; 30 31 class DiskInfo { 32 public: 33 enum DeviceFlag { 34 SD_FLAG = 1, 35 USB_FLAG = 2, 36 }; 37 38 DiskInfo(std::string sysPath_, std::string devPath_, dev_t device, int flag); 39 virtual ~DiskInfo(); 40 int Create(); 41 int Destroy(); 42 void ReadMetadata(); 43 int ReadPartition(); 44 int CreateVolume(dev_t dev); 45 int Partition(); 46 dev_t GetDevice() const; 47 std::string GetId() const; 48 std::string GetDevPath() const; 49 uint64_t GetDevDSize() const; 50 std::string GetSysPath() const; 51 std::string GetDevVendor() const; 52 int GetDevFlag() const; 53 54 private: 55 std::string id_; 56 uint64_t size_ {}; 57 /* device vendor infomation */ 58 std::string vendor_; 59 std::string sysPath_; 60 int status { sInital }; 61 std::string eventPath_; 62 std::string devPath_; 63 dev_t device_ {}; 64 unsigned int flags_ {}; 65 std::list<std::string> volumeId_; 66 }; 67 } // STORAGE_DAEMON 68 } // OHOS 69 70 #endif // OHOS_STORAGE_DAEMON_DISK_INFO_H 71