summaryrefslogtreecommitdiffstats
path: root/src/hardware
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2013-12-10 19:23:37 +0100
committerPeter Schiffer <pschiffe@redhat.com>2013-12-10 19:23:37 +0100
commite99df5fdba9bb16dfec1e1a80f001fe97622e71b (patch)
tree2482189e6d504ee20fb6e957aa3303164ee5aa91 /src/hardware
parent4d3e9d9f3bda71faf6b46286e1ad78fb0e3696cf (diff)
downloadopenlmi-providers-e99df5fdba9bb16dfec1e1a80f001fe97622e71b.tar.gz
openlmi-providers-e99df5fdba9bb16dfec1e1a80f001fe97622e71b.tar.xz
openlmi-providers-e99df5fdba9bb16dfec1e1a80f001fe97622e71b.zip
Hardware: use lsblk as primary source for disks
This patch makes lsblk primary source for information about disks instead of smartctl. This change was needed because in virtual environment some disks might be recognized by smartctl while others not, and in this case, some disks would be missing in LMI classes. With lsblk, all disks are always listed. Smartctl is used as source of additional information if avaiable.
Diffstat (limited to 'src/hardware')
-rw-r--r--src/hardware/LMI_DiskDriveProvider.c101
-rw-r--r--src/hardware/LMI_DiskDriveRealizesProvider.c40
-rw-r--r--src/hardware/LMI_DiskDriveSystemDeviceProvider.c38
-rw-r--r--src/hardware/LMI_DiskPhysicalPackageContainerProvider.c38
-rw-r--r--src/hardware/LMI_DiskPhysicalPackageProvider.c63
-rw-r--r--src/hardware/lsblk.c6
-rw-r--r--src/hardware/smartctl.c12
7 files changed, 122 insertions, 176 deletions
diff --git a/src/hardware/LMI_DiskDriveProvider.c b/src/hardware/LMI_DiskDriveProvider.c
index 9bfe8df..31e4a48 100644
--- a/src/hardware/LMI_DiskDriveProvider.c
+++ b/src/hardware/LMI_DiskDriveProvider.c
@@ -64,44 +64,28 @@ static CMPIStatus LMI_DiskDriveEnumInstances(
{
LMI_DiskDrive lmi_hdd;
const char *ns = KNameSpace(cop);
- unsigned i, hdds_nb = 0, rotational = 0;
- char instance_id[INSTANCE_ID_LEN], *id, *name, path[PATH_MAX], *basename;
+ unsigned i, j, rotational = 0;
+ char instance_id[INSTANCE_ID_LEN], path[PATH_MAX], *name;
CMPIUint16 operational_status;
SmartctlHdd *smtcl_hdds = NULL;
unsigned smtcl_hdds_nb = 0;
LsblkHdd *lsblk_hdds = NULL;
unsigned lsblk_hdds_nb = 0;
+ if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
+ goto done;
+ }
if (smartctl_get_hdds(&smtcl_hdds, &smtcl_hdds_nb) != 0 || smtcl_hdds_nb < 1) {
smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb);
- if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
- goto done;
- }
- }
-
- if (smtcl_hdds_nb > 0) {
- hdds_nb = smtcl_hdds_nb;
- } else {
- hdds_nb = lsblk_hdds_nb;
}
- for (i = 0; i < hdds_nb; i++) {
- /* in fallback mode, use only disk devices from lsblk */
- if (smtcl_hdds_nb < 1) {
- if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
- continue;
- }
+ for (i = 0; i < lsblk_hdds_nb; i++) {
+ /* use only disk devices from lsblk */
+ if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
+ continue;
}
- if (smtcl_hdds_nb > 0) {
- id = smtcl_hdds[i].serial_number;
- name = smtcl_hdds[i].name;
- basename = smtcl_hdds[i].dev_basename;
- } else {
- id = lsblk_hdds[i].name;
- name = lsblk_hdds[i].name;
- basename = lsblk_hdds[i].basename;
- }
+ name = lsblk_hdds[i].name;
LMI_DiskDrive_Init(&lmi_hdd, _cb, ns);
@@ -115,37 +99,50 @@ static CMPIStatus LMI_DiskDriveEnumInstances(
"This object represents one physical disk drive in system.");
snprintf(instance_id, INSTANCE_ID_LEN,
- ORGID ":" ORGID "_" DISK_DRIVE_CLASS_NAME ":%s", id);
+ ORGID ":" ORGID "_" DISK_DRIVE_CLASS_NAME ":%s",
+ lsblk_hdds[i].name);
- LMI_DiskDrive_Set_DeviceID(&lmi_hdd, id);
- LMI_DiskDrive_Set_Name(&lmi_hdd, name);
- LMI_DiskDrive_Set_ElementName(&lmi_hdd, name);
+ LMI_DiskDrive_Set_DeviceID(&lmi_hdd, lsblk_hdds[i].name);
LMI_DiskDrive_Set_InstanceID(&lmi_hdd, instance_id);
- /* if we have smartctl output */
- if (smtcl_hdds_nb > 0) {
- operational_status = get_operational_status(
- smtcl_hdds[i].smart_status);
-
- LMI_DiskDrive_Init_OperationalStatus(&lmi_hdd, 1);
- LMI_DiskDrive_Set_OperationalStatus(&lmi_hdd, 0, operational_status);
- if (operational_status == LMI_DiskDrive_OperationalStatus_OK) {
- LMI_DiskDrive_Set_EnabledState(&lmi_hdd,
- LMI_DiskDrive_EnabledState_Enabled);
- } else {
- LMI_DiskDrive_Set_EnabledState(&lmi_hdd,
- LMI_DiskDrive_EnabledState_Unknown);
+ /* check for smartctl output */
+ for (j = 0; j < smtcl_hdds_nb; j++) {
+ if (strcmp(smtcl_hdds[j].dev_path, lsblk_hdds[i].name) == 0) {
+ operational_status = get_operational_status(
+ smtcl_hdds[j].smart_status);
+ if (strlen(smtcl_hdds[j].name)) {
+ name = smtcl_hdds[j].name;
+ } else if (strlen(smtcl_hdds[j].model)) {
+ name = smtcl_hdds[j].model;
+ }
+
+ LMI_DiskDrive_Init_OperationalStatus(&lmi_hdd, 1);
+ LMI_DiskDrive_Set_OperationalStatus(&lmi_hdd, 0, operational_status);
+ if (operational_status == LMI_DiskDrive_OperationalStatus_OK) {
+ LMI_DiskDrive_Set_EnabledState(&lmi_hdd,
+ LMI_DiskDrive_EnabledState_Enabled);
+ } else {
+ LMI_DiskDrive_Set_EnabledState(&lmi_hdd,
+ LMI_DiskDrive_EnabledState_Unknown);
+ }
+
+ LMI_DiskDrive_Set_FormFactor(&lmi_hdd,
+ get_hdd_form_factor(smtcl_hdds[j].form_factor));
+ LMI_DiskDrive_Set_RPM(&lmi_hdd, smtcl_hdds[j].rpm);
+ if (smtcl_hdds[j].port_speed) {
+ LMI_DiskDrive_Set_InterconnectSpeed(&lmi_hdd,
+ smtcl_hdds[j].port_speed);
+ }
+
+ break;
}
-
- LMI_DiskDrive_Set_FormFactor(&lmi_hdd,
- get_hdd_form_factor(smtcl_hdds[i].form_factor));
- LMI_DiskDrive_Set_InterconnectSpeed(&lmi_hdd,
- smtcl_hdds[i].port_speed);
- LMI_DiskDrive_Set_RPM(&lmi_hdd, smtcl_hdds[i].rpm);
}
+ LMI_DiskDrive_Set_Name(&lmi_hdd, name);
+ LMI_DiskDrive_Set_ElementName(&lmi_hdd, name);
+
snprintf(path, PATH_MAX, SYSFS_BLOCK_PATH "/%s/queue/rotational",
- basename);
+ lsblk_hdds[i].basename);
if (path_get_unsigned(path, &rotational) == 0) {
if (rotational == 1) {
LMI_DiskDrive_Set_DiskType(&lmi_hdd,
@@ -163,10 +160,10 @@ static CMPIStatus LMI_DiskDriveEnumInstances(
LMI_DiskDrive_DiskType_Unknown);
}
- if (basename[0] == 'h') {
+ if (lsblk_hdds[i].basename[0] == 'h') {
LMI_DiskDrive_Set_InterconnectType(&lmi_hdd,
LMI_DiskDrive_InterconnectType_ATA);
- } else if (basename[0] == 's') {
+ } else if (lsblk_hdds[i].basename[0] == 's') {
/* TODO: What about SAS? */
LMI_DiskDrive_Set_InterconnectType(&lmi_hdd,
LMI_DiskDrive_InterconnectType_SATA);
diff --git a/src/hardware/LMI_DiskDriveRealizesProvider.c b/src/hardware/LMI_DiskDriveRealizesProvider.c
index c33691d..ac32810 100644
--- a/src/hardware/LMI_DiskDriveRealizesProvider.c
+++ b/src/hardware/LMI_DiskDriveRealizesProvider.c
@@ -22,7 +22,6 @@
#include "LMI_DiskDriveRealizes.h"
#include "LMI_Hardware.h"
#include "globals.h"
-#include "smartctl.h"
#include "lsblk.h"
static const CMPIBroker* _cb;
@@ -61,38 +60,18 @@ static CMPIStatus LMI_DiskDriveRealizesEnumInstances(
LMI_DiskPhysicalPackageRef lmi_hdd_phys;
LMI_DiskDriveRef lmi_hdd;
const char *ns = KNameSpace(cop);
- unsigned i, hdds_nb = 0;
- char *id;
- SmartctlHdd *smtcl_hdds = NULL;
- unsigned smtcl_hdds_nb = 0;
+ unsigned i;
LsblkHdd *lsblk_hdds = NULL;
unsigned lsblk_hdds_nb = 0;
- if (smartctl_get_hdds(&smtcl_hdds, &smtcl_hdds_nb) != 0 || smtcl_hdds_nb < 1) {
- smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb);
- if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
- goto done;
- }
- }
-
- if (smtcl_hdds_nb > 0) {
- hdds_nb = smtcl_hdds_nb;
- } else {
- hdds_nb = lsblk_hdds_nb;
+ if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
+ goto done;
}
- for (i = 0; i < hdds_nb; i++) {
- /* in fallback mode, use only disk devices from lsblk */
- if (smtcl_hdds_nb < 1) {
- if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
- continue;
- }
- }
-
- if (smtcl_hdds_nb > 0) {
- id = smtcl_hdds[i].serial_number;
- } else {
- id = lsblk_hdds[i].name;
+ for (i = 0; i < lsblk_hdds_nb; i++) {
+ /* use only disk devices from lsblk */
+ if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
+ continue;
}
LMI_DiskDriveRealizes_Init(&lmi_hdd_realizes, _cb, ns);
@@ -103,12 +82,12 @@ static CMPIStatus LMI_DiskDriveRealizesEnumInstances(
LMI_DiskDriveRef_Set_SystemName(&lmi_hdd, get_system_name());
LMI_DiskDriveRef_Set_CreationClassName(&lmi_hdd,
ORGID "_" DISK_DRIVE_CLASS_NAME);
- LMI_DiskDriveRef_Set_DeviceID(&lmi_hdd, id);
+ LMI_DiskDriveRef_Set_DeviceID(&lmi_hdd, lsblk_hdds[i].name);
LMI_DiskPhysicalPackageRef_Init(&lmi_hdd_phys, _cb, ns);
LMI_DiskPhysicalPackageRef_Set_CreationClassName(&lmi_hdd_phys,
ORGID "_" DISK_PHYS_PKG_CLASS_NAME);
- LMI_DiskPhysicalPackageRef_Set_Tag(&lmi_hdd_phys, id);
+ LMI_DiskPhysicalPackageRef_Set_Tag(&lmi_hdd_phys, lsblk_hdds[i].name);
LMI_DiskDriveRealizes_Set_Dependent(&lmi_hdd_realizes, &lmi_hdd);
LMI_DiskDriveRealizes_Set_Antecedent(&lmi_hdd_realizes, &lmi_hdd_phys);
@@ -117,7 +96,6 @@ static CMPIStatus LMI_DiskDriveRealizesEnumInstances(
}
done:
- smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb);
lsblk_free_hdds(&lsblk_hdds, &lsblk_hdds_nb);
CMReturn(CMPI_RC_OK);
diff --git a/src/hardware/LMI_DiskDriveSystemDeviceProvider.c b/src/hardware/LMI_DiskDriveSystemDeviceProvider.c
index 981de58..00ab2fa 100644
--- a/src/hardware/LMI_DiskDriveSystemDeviceProvider.c
+++ b/src/hardware/LMI_DiskDriveSystemDeviceProvider.c
@@ -22,7 +22,6 @@
#include "LMI_DiskDriveSystemDevice.h"
#include "LMI_Hardware.h"
#include "globals.h"
-#include "smartctl.h"
#include "lsblk.h"
static const CMPIBroker* _cb;
@@ -60,38 +59,18 @@ static CMPIStatus LMI_DiskDriveSystemDeviceEnumInstances(
LMI_DiskDriveSystemDevice lmi_hdd_sys;
LMI_DiskDriveRef lmi_hdd;
const char *ns = KNameSpace(cop);
- unsigned i, hdds_nb = 0;
- char *id;
- SmartctlHdd *smtcl_hdds = NULL;
- unsigned smtcl_hdds_nb = 0;
+ unsigned i;
LsblkHdd *lsblk_hdds = NULL;
unsigned lsblk_hdds_nb = 0;
- if (smartctl_get_hdds(&smtcl_hdds, &smtcl_hdds_nb) != 0 || smtcl_hdds_nb < 1) {
- smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb);
- if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
- goto done;
- }
- }
-
- if (smtcl_hdds_nb > 0) {
- hdds_nb = smtcl_hdds_nb;
- } else {
- hdds_nb = lsblk_hdds_nb;
+ if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
+ goto done;
}
- for (i = 0; i < hdds_nb; i++) {
- /* in fallback mode, use only disk devices from lsblk */
- if (smtcl_hdds_nb < 1) {
- if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
- continue;
- }
- }
-
- if (smtcl_hdds_nb > 0) {
- id = smtcl_hdds[i].serial_number;
- } else {
- id = lsblk_hdds[i].name;
+ for (i = 0; i < lsblk_hdds_nb; i++) {
+ /* use only disk devices from lsblk */
+ if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
+ continue;
}
LMI_DiskDriveSystemDevice_Init(&lmi_hdd_sys, _cb, ns);
@@ -102,7 +81,7 @@ static CMPIStatus LMI_DiskDriveSystemDeviceEnumInstances(
LMI_DiskDriveRef_Set_SystemName(&lmi_hdd, get_system_name());
LMI_DiskDriveRef_Set_CreationClassName(&lmi_hdd,
ORGID "_" DISK_DRIVE_CLASS_NAME);
- LMI_DiskDriveRef_Set_DeviceID(&lmi_hdd, id);
+ LMI_DiskDriveRef_Set_DeviceID(&lmi_hdd, lsblk_hdds[i].name);
LMI_DiskDriveSystemDevice_SetObjectPath_GroupComponent(
&lmi_hdd_sys, lmi_get_computer_system());
@@ -113,7 +92,6 @@ static CMPIStatus LMI_DiskDriveSystemDeviceEnumInstances(
}
done:
- smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb);
lsblk_free_hdds(&lsblk_hdds, &lsblk_hdds_nb);
CMReturn(CMPI_RC_OK);
diff --git a/src/hardware/LMI_DiskPhysicalPackageContainerProvider.c b/src/hardware/LMI_DiskPhysicalPackageContainerProvider.c
index 4518b4e..d55aaaf 100644
--- a/src/hardware/LMI_DiskPhysicalPackageContainerProvider.c
+++ b/src/hardware/LMI_DiskPhysicalPackageContainerProvider.c
@@ -23,7 +23,6 @@
#include "LMI_Hardware.h"
#include "globals.h"
#include "dmidecode.h"
-#include "smartctl.h"
#include "lsblk.h"
static const CMPIBroker* _cb;
@@ -62,28 +61,16 @@ static CMPIStatus LMI_DiskPhysicalPackageContainerEnumInstances(
LMI_DiskPhysicalPackageRef lmi_hdd;
LMI_ChassisRef lmi_chassis;
const char *ns = KNameSpace(cop);
- unsigned i, hdds_nb = 0;
- char *tag;
+ unsigned i;
DmiChassis dmi_chassis;
- SmartctlHdd *smtcl_hdds = NULL;
- unsigned smtcl_hdds_nb = 0;
LsblkHdd *lsblk_hdds = NULL;
unsigned lsblk_hdds_nb = 0;
if (dmi_get_chassis(&dmi_chassis) != 0) {
goto done;
}
- if (smartctl_get_hdds(&smtcl_hdds, &smtcl_hdds_nb) != 0 || smtcl_hdds_nb < 1) {
- smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb);
- if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
- goto done;
- }
- }
-
- if (smtcl_hdds_nb > 0) {
- hdds_nb = smtcl_hdds_nb;
- } else {
- hdds_nb = lsblk_hdds_nb;
+ if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
+ goto done;
}
LMI_ChassisRef_Init(&lmi_chassis, _cb, ns);
@@ -91,18 +78,10 @@ static CMPIStatus LMI_DiskPhysicalPackageContainerEnumInstances(
ORGID "_" CHASSIS_CLASS_NAME);
LMI_ChassisRef_Set_Tag(&lmi_chassis, dmi_get_chassis_tag(&dmi_chassis));
- for (i = 0; i < hdds_nb; i++) {
- /* in fallback mode, use only disk devices from lsblk */
- if (smtcl_hdds_nb < 1) {
- if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
- continue;
- }
- }
-
- if (smtcl_hdds_nb > 0) {
- tag = smtcl_hdds[i].serial_number;
- } else {
- tag = lsblk_hdds[i].name;
+ for (i = 0; i < lsblk_hdds_nb; i++) {
+ /* use only disk devices from lsblk */
+ if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
+ continue;
}
LMI_DiskPhysicalPackageContainer_Init(&lmi_hdd_container, _cb, ns);
@@ -110,7 +89,7 @@ static CMPIStatus LMI_DiskPhysicalPackageContainerEnumInstances(
LMI_DiskPhysicalPackageRef_Init(&lmi_hdd, _cb, ns);
LMI_DiskPhysicalPackageRef_Set_CreationClassName(&lmi_hdd,
ORGID "_" DISK_PHYS_PKG_CLASS_NAME);
- LMI_DiskPhysicalPackageRef_Set_Tag(&lmi_hdd, tag);
+ LMI_DiskPhysicalPackageRef_Set_Tag(&lmi_hdd, lsblk_hdds[i].name);
LMI_DiskPhysicalPackageContainer_Set_GroupComponent(&lmi_hdd_container,
&lmi_chassis);
@@ -122,7 +101,6 @@ static CMPIStatus LMI_DiskPhysicalPackageContainerEnumInstances(
done:
dmi_free_chassis(&dmi_chassis);
- smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb);
lsblk_free_hdds(&lsblk_hdds, &lsblk_hdds_nb);
CMReturn(CMPI_RC_OK);
diff --git a/src/hardware/LMI_DiskPhysicalPackageProvider.c b/src/hardware/LMI_DiskPhysicalPackageProvider.c
index 3daac03..48f09df 100644
--- a/src/hardware/LMI_DiskPhysicalPackageProvider.c
+++ b/src/hardware/LMI_DiskPhysicalPackageProvider.c
@@ -59,47 +59,43 @@ static CMPIStatus LMI_DiskPhysicalPackageEnumInstances(
{
LMI_DiskPhysicalPackage lmi_hdd;
const char *ns = KNameSpace(cop);
- unsigned i, hdds_nb = 0;
- char instance_id[INSTANCE_ID_LEN], *id, *manufacturer, *serial_nb,
- *name, *model;
+ unsigned i, j;
+ char instance_id[INSTANCE_ID_LEN], *serial_nb, *name, *model;
SmartctlHdd *smtcl_hdds = NULL;
unsigned smtcl_hdds_nb = 0;
LsblkHdd *lsblk_hdds = NULL;
unsigned lsblk_hdds_nb = 0;
+ if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
+ goto done;
+ }
if (smartctl_get_hdds(&smtcl_hdds, &smtcl_hdds_nb) != 0 || smtcl_hdds_nb < 1) {
smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb);
- if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) {
- goto done;
- }
- }
-
- if (smtcl_hdds_nb > 0) {
- hdds_nb = smtcl_hdds_nb;
- } else {
- hdds_nb = lsblk_hdds_nb;
}
- for (i = 0; i < hdds_nb; i++) {
- /* in fallback mode, use only disk devices from lsblk */
- if (smtcl_hdds_nb < 1) {
- if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
- continue;
- }
+ for (i = 0; i < lsblk_hdds_nb; i++) {
+ /* use only disk devices from lsblk */
+ if (strcmp(lsblk_hdds[i].type, "disk") != 0) {
+ continue;
}
- if (smtcl_hdds_nb > 0) {
- id = smtcl_hdds[i].serial_number;
- manufacturer = smtcl_hdds[i].manufacturer;
- model = smtcl_hdds[i].model;
- serial_nb = smtcl_hdds[i].serial_number;
- name = smtcl_hdds[i].name;
- } else {
- id = lsblk_hdds[i].name;
- manufacturer = lsblk_hdds[i].vendor;
- model = lsblk_hdds[i].model;
- serial_nb = lsblk_hdds[i].serial;
- name = lsblk_hdds[i].name;
+ model = lsblk_hdds[i].model;
+ serial_nb = lsblk_hdds[i].serial;
+ name = lsblk_hdds[i].name;
+
+ /* check for smartctl output */
+ for (j = 0; j < smtcl_hdds_nb; j++) {
+ if (strcmp(smtcl_hdds[j].dev_path, lsblk_hdds[i].name) == 0) {
+ model = smtcl_hdds[i].model;
+ serial_nb = smtcl_hdds[i].serial_number;
+ if (strlen(smtcl_hdds[j].name)) {
+ name = smtcl_hdds[j].name;
+ } else if (strlen(smtcl_hdds[j].model)) {
+ name = smtcl_hdds[j].model;
+ }
+
+ break;
+ }
}
LMI_DiskPhysicalPackage_Init(&lmi_hdd, _cb, ns);
@@ -113,10 +109,11 @@ static CMPIStatus LMI_DiskPhysicalPackageEnumInstances(
"This object represents one physical disk package in system.");
snprintf(instance_id, INSTANCE_ID_LEN,
- ORGID ":" ORGID "_" DISK_PHYS_PKG_CLASS_NAME ":%s", id);
+ ORGID ":" ORGID "_" DISK_PHYS_PKG_CLASS_NAME ":%s",
+ lsblk_hdds[i].name);
- LMI_DiskPhysicalPackage_Set_Tag(&lmi_hdd, id);
- LMI_DiskPhysicalPackage_Set_Manufacturer(&lmi_hdd, manufacturer);
+ LMI_DiskPhysicalPackage_Set_Tag(&lmi_hdd, lsblk_hdds[i].name);
+ LMI_DiskPhysicalPackage_Set_Manufacturer(&lmi_hdd, lsblk_hdds[i].vendor);
LMI_DiskPhysicalPackage_Set_Model(&lmi_hdd, model);
LMI_DiskPhysicalPackage_Set_SerialNumber(&lmi_hdd, serial_nb);
LMI_DiskPhysicalPackage_Set_Name(&lmi_hdd, name);
diff --git a/src/hardware/lsblk.c b/src/hardware/lsblk.c
index d8fc078..611ab5c 100644
--- a/src/hardware/lsblk.c
+++ b/src/hardware/lsblk.c
@@ -155,6 +155,12 @@ short lsblk_get_hdds(LsblkHdd **hdds, unsigned *hdds_nb)
(*hdds)[curr_hdd].revision = get_part_of_string_between(buffer[i], "REV=\"", "\"");
(*hdds)[curr_hdd].vendor = get_part_of_string_between(buffer[i], "VENDOR=\"", "\"");
+ (*hdds)[curr_hdd].basename = strdup(basename(path));
+ if (!(*hdds)[curr_hdd].basename) {
+ warn("Failed to allocate memory.");
+ goto done;
+ }
+
curr_hdd++;
}
diff --git a/src/hardware/smartctl.c b/src/hardware/smartctl.c
index afa690f..4e7c04c 100644
--- a/src/hardware/smartctl.c
+++ b/src/hardware/smartctl.c
@@ -215,10 +215,22 @@ short smartctl_get_hdds(SmartctlHdd **hdds, unsigned *hdds_nb)
/* Model */
buf = copy_string_part_after_delim(buffer[i], "Device Model:");
if (buf) {
+ free((*hdds)[curr_hdd].model);
(*hdds)[curr_hdd].model = buf;
buf = NULL;
continue;
}
+ /* Model, second version */
+ buf = copy_string_part_after_delim(buffer[i], "Product:");
+ if (buf) {
+ if (!(*hdds)[curr_hdd].model) {
+ (*hdds)[curr_hdd].model = buf;
+ } else {
+ free(buf);
+ }
+ buf = NULL;
+ continue;
+ }
/* Serial Number */
buf = copy_string_part_after_delim(buffer[i], "Serial Number:");
if (buf) {