Skip to content

Commit

Permalink
Issue #1302: Add SMART support for QNAP TR-004 (non-RAID mode).
Browse files Browse the repository at this point in the history
Fixes: #1302

Signed-off-by: Volker Theile <votdev@gmx.de>
  • Loading branch information
votdev committed May 8, 2022
1 parent b486a87 commit 778ceb1
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
6 changes: 6 additions & 0 deletions deb/openmediavault/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
openmediavault (6.0.27-1) stable; urgency=low

* Issue #1302: Add SMART support for QNAP TR-004 (non-RAID mode).

-- Volker Theile <volker.theile@openmediavault.org> Sun, 08 May 2022 08:57:06 +0200

openmediavault (6.0.26-1) stable; urgency=low

* Update locale files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ def description(self):

@property
def smart_device_type(self):
return 'sat' if self.is_usb else ''
if self.is_usb:
model_map = {
'TR-004 DISK00': 'jmb39x-q,0',
'TR-004 DISK01': 'jmb39x-q,1',
'TR-004 DISK02': 'jmb39x-q,2',
'TR-004 DISK03': 'jmb39x-q,3'
}
return model_map.get(self.model.strip(), 'sat')
return ''

@cached_property
def hctl(self) -> HCTL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ require_once("openmediavault/functions.inc");
class StorageDevice extends \OMV\System\BlockDevice
implements StorageDeviceInterface {
/**
* Get the device model.
* Get the device model (via udev or sysfs).
* @return string The device model, otherwise an empty string.
* Note, underscores are replaced by blanks when the value is
* retrieved via udev.
*/
public function getModel() {
if (FALSE === $this->hasUdevProperty("ID_MODEL")) {
Expand All @@ -45,8 +47,10 @@ class StorageDevice extends \OMV\System\BlockDevice
}

/**
* Get the device vendor.
* Get the device vendor (via udev or sysfs).
* @return string The device vendor, otherwise an empty string.
* Note, underscores are replaced by blanks when the value is
* retrieved via udev.
*/
public function getVendor() {
if (FALSE === $this->hasUdevProperty("ID_VENDOR")) {
Expand All @@ -63,6 +67,7 @@ class StorageDevice extends \OMV\System\BlockDevice
/**
* Get the device serial number.
* @return string The device serial number, otherwise an empty string.
* Note, underscores are replaced by blanks.
*/
public function getSerialNumber() {
if (FALSE === $this->hasUdevProperty("ID_SERIAL_SHORT"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,25 @@ interface StorageDeviceInterface {
public function getSectorSize();

/**
* Get the device model.
* @return The device model, otherwise an empty string.
* Get the device model (via udev or sysfs).
* @return string The device model, otherwise an empty string.
* Note, underscores are replaced by blanks when the value is
* retrieved via udev.
*/
public function getModel();

/**
* Get the device vendor.
* @return The device vendor, otherwise an empty string.
* Get the device vendor (via udev or sysfs).
* @return string The device vendor, otherwise an empty string.
* Note, underscores are replaced by blanks when the value is
* retrieved via udev.
*/
public function getVendor();

/**
* Get the device serial number.
* @return The device serial number, otherwise an empty string.
* @return string The device serial number, otherwise an empty string.
* Note, underscores are replaced by blanks.
*/
public function getSerialNumber();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ class StorageDeviceSD extends StorageDevice implements SmartInterface {
* See \OMV\System\Storage\SmartInterface interface definition.
*/
public function getSmartDeviceType() {
return (TRUE === $this->isUsb()) ? "sat" : "";
if (TRUE === $this->isUsb()) {
$modelMap = [
"TR-004 DISK00" => "jmb39x-q,0",
"TR-004 DISK01" => "jmb39x-q,1",
"TR-004 DISK02" => "jmb39x-q,2",
"TR-004 DISK03" => "jmb39x-q,3"
];
return array_value($modelMap, $this->getModel(), "sat");
}
return "";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface UdevInterface {
/**
* Queries the udev database for device information stored in the
* udev database.
* Note, blanks are automatically trimmed.
* @param boolean force Force the collection of the information,
* although the information is already cached. Defaults to FALSE.
* @result void
Expand Down

0 comments on commit 778ceb1

Please sign in to comment.