diff --git a/src/core/smartattributeparseddata.cpp b/src/core/smartattributeparseddata.cpp index b310a7b..8e16899 100644 --- a/src/core/smartattributeparseddata.cpp +++ b/src/core/smartattributeparseddata.cpp @@ -260,7 +260,7 @@ void SmartAttributeParsedData::verifySectors() if (prettyUnit() != SmartAttributeUnit::Sectors) return; - quint64 maxSectors = disk()->size() / 512ULL; + quint64 maxSectors = disk()->sectors(); if (prettyValue() == 0xFFFFFFFFULL || prettyValue() == 0xFFFFFFFFFFFFULL || (maxSectors > 0 && prettyValue() > maxSectors)) diff --git a/src/core/smartdiskinformation.cpp b/src/core/smartdiskinformation.cpp index 85a5dbb..30e1a6c 100644 --- a/src/core/smartdiskinformation.cpp +++ b/src/core/smartdiskinformation.cpp @@ -27,7 +27,7 @@ SmartDiskInformation::SmartDiskInformation() : m_ModelName(QString()), m_FirmwareVersion(QString()), m_SerialNumber(QString()), - m_Size(0), + m_Sectors(0), m_Temperature(0), m_BadSectors(0), m_PoweredOn(0), @@ -64,7 +64,7 @@ void SmartDiskInformation::updateOverall() return; } - quint64 sector_threshold = u64log2(size() / 512) * 1024; + quint64 sector_threshold = u64log2(sectors()) * 1024; if (badSectors() >= sector_threshold) { m_Overall = SmartStatus::Overall::BadSectorsMany; diff --git a/src/core/smartdiskinformation.h b/src/core/smartdiskinformation.h index dbf3d38..8b9c957 100644 --- a/src/core/smartdiskinformation.h +++ b/src/core/smartdiskinformation.h @@ -66,9 +66,9 @@ public: return m_SerialNumber; /**< @return the disk serial number */ } - quint64 size() const + quint64 sectors() const { - return m_Size; /**< @return disk size */ + return m_Sectors; /**< @return disk size */ } bool smartStatus() const @@ -127,9 +127,9 @@ public: m_SerialNumber = serial; } - void setSize(quint64 size) + void setSectors(quint64 numSectors) { - m_Size = size; + m_Sectors = numSectors; } void setPowerCycles(quint64 powerCycleCt) @@ -159,7 +159,7 @@ private: QString m_ModelName; QString m_FirmwareVersion; QString m_SerialNumber; - quint64 m_Size; + quint64 m_Sectors; quint64 m_Temperature; quint64 m_BadSectors; quint64 m_PoweredOn; diff --git a/src/core/smartparser.cpp b/src/core/smartparser.cpp index 294691e..f7a7377 100644 --- a/src/core/smartparser.cpp +++ b/src/core/smartparser.cpp @@ -64,6 +64,7 @@ bool SmartParser::init() QString status = QStringLiteral("status"); QString value = QStringLiteral("value"); QString user_capacity = QStringLiteral("user_capacity"); + QString blocks = QStringLiteral("blocks"); if (!smartJson.contains(device)) { qDebug() << "smart disk open failed for " << devicePath() << ": " << strerror(errno); @@ -91,7 +92,10 @@ bool SmartParser::init() m_DiskInformation->setModel(smartJson[model_name].toString()); m_DiskInformation->setFirmware(smartJson[firmware].toString()); m_DiskInformation->setSerial(smartJson[serial_number].toString()); - m_DiskInformation->setSize(smartJson[user_capacity].toVariant().toULongLong()); + + const auto user_capacity_object = smartJson[user_capacity].toObject(); + QString user_capacity_blocks = QStringLiteral("bytes"); + m_DiskInformation->setSectors(user_capacity_object[user_capacity_blocks].toVariant().toULongLong()); QJsonObject selfTest = smartJson[self_test].toObject(); QJsonObject selfTestStatus = selfTest[status].toObject(); diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index a2e7d6c..5ec790d 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -80,6 +80,7 @@ ActionReply ExternalCommandHelper::init(const QVariantMap& args) return reply; } + /** Reads the given number of bytes from the sourceDevice into the given buffer. @param sourceDevice device or file to read from @param buffer buffer to store the bytes read in