diff options
author | Hridya Valsaraju <hridya@google.com> | 2018-09-05 16:57:24 -0700 |
---|---|---|
committer | Hridya Valsaraju <hridya@google.com> | 2018-09-07 12:22:00 -0700 |
commit | bf9f8d1a643b7586af009ec65b1358859e3aea64 (patch) | |
tree | 451481ca3b94e3a109cd557f0f391311982b54e9 /fastboot/device/variables.cpp | |
parent | 33dcdb808b7d60107d527c22815d586b51836836 (diff) |
Integrate with fastboot HAL to get partition type
Bug: 79480454
Bug: 78793464
Test: fastboot getvar partition-type:userdata
Change-Id: Ib096ee8061568b8503f3a3f2dbb7e19a932162c4
Diffstat (limited to 'fastboot/device/variables.cpp')
-rw-r--r-- | fastboot/device/variables.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 9f3fa7597..9ac2ddab6 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -31,6 +31,9 @@ using ::android::hardware::boot::V1_0::BoolResult; using ::android::hardware::boot::V1_0::Slot; +using ::android::hardware::fastboot::V1_0::FileSystemType; +using ::android::hardware::fastboot::V1_0::Result; +using ::android::hardware::fastboot::V1_0::Status; constexpr int kMaxDownloadSizeDefault = 0x20000000; constexpr char kFastbootProtocolVersion[] = "0.4"; @@ -195,6 +198,47 @@ bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& ar return true; } +bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args, + std::string* message) { + if (args.size() < 1) { + *message = "Missing argument"; + return false; + } + std::string partition_name = args[0]; + auto fastboot_hal = device->fastboot_hal(); + if (!fastboot_hal) { + *message = "Fastboot HAL not found"; + return false; + } + + FileSystemType type; + Result ret; + auto ret_val = + fastboot_hal->getPartitionType(args[0], [&](FileSystemType fs_type, Result result) { + type = fs_type; + ret = result; + }); + if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) { + *message = "Unable to retrieve partition type"; + } else { + switch (type) { + case FileSystemType::RAW: + *message = "raw"; + return true; + case FileSystemType::EXT4: + *message = "ext4"; + return true; + case FileSystemType::F2FS: + *message = "f2fs"; + return true; + default: + *message = "Unknown file system type"; + } + } + + return false; +} + bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args, std::string* message) { if (args.size() < 1) { |