From 41a569fc2dda73489da49581a4d1243cc7bccbdb Mon Sep 17 00:00:00 2001 From: Kyle Schwarz Date: Mon, 19 Dec 2022 01:09:01 -0500 Subject: [PATCH] Device: Consider VSA when calculating logical disk size When the underlying disk driver has VSA access the total size must be calculated with respect to the VSA offset. --- device/device.cpp | 7 ++++++- include/icsneo/disk/diskdriver.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/device/device.cpp b/device/device.cpp index 771b062..1e30dec 100644 --- a/device/device.cpp +++ b/device/device.cpp @@ -642,7 +642,12 @@ std::optional Device::getLogicalDiskSize() { return std::nullopt; } - return info->getReportedSize(); + const auto reportedSize = info->getReportedSize(); + + if (diskReadDriver->getAccess() == Disk::Access::VSA) + return reportedSize - diskReadDriver->getVSAOffset(); + + return reportedSize; } std::optional Device::getVSAOffsetInLogicalDisk() { diff --git a/include/icsneo/disk/diskdriver.h b/include/icsneo/disk/diskdriver.h index 4fdf45b..daa76ac 100644 --- a/include/icsneo/disk/diskdriver.h +++ b/include/icsneo/disk/diskdriver.h @@ -33,6 +33,7 @@ public: virtual std::pair getBlockSizeBounds() const = 0; void setVSAOffset(uint64_t offset) { vsaOffset = offset; } + uint64_t getVSAOffset() const { return vsaOffset; } protected: uint64_t vsaOffset = 0;