Export the part number and serial number
This commit exposes the eMMC's part name and serial number over the
appropriate D-Bus interface, so that it can be exposed over Redfish in
bmcweb.
Tested:
$ busctl introspect xyz.openbmc_project.eStoraged \
/xyz/openbmc_project/inventory/storage/mmcblk0
...
xyz.openbmc_project.Inventory.Decorator.Asset interface - - -
.PartNumber property s "ABCDEF" emits-change
.SerialNumber property s "123456abcd" emits-change
...
$ wget -qO- http://localhost:80/redfish/v1/Chassis/DC_SCM/Drives/mmcblk0
{
"@odata.id": "/redfish/v1/Chassis/DC_SCM/Drives/mmcblk0",
"@odata.type": "#Drive.v1_7_0.Drive",
"CapacityBytes": 15634268160,
"Id": "mmcblk0",
"Links": {
"Chassis": {
"@odata.id": "/redfish/v1/Chassis/DC_SCM"
}
},
"Name": "Name",
"PartNumber": "ABCDEF",
"PhysicalLocation": {
"PartLocation": {
"LocationType": "Embedded"
}
},
"SerialNumber": "123456abcd",
"Status": {
"State": "Enabled"
}
}
Signed-off-by: John Wedig <johnwedig@google.com>
Change-Id: I1d17f08b99907620b5f2c73fdaeacc84950ce64e
diff --git a/include/util.hpp b/include/util.hpp
index 2834950..a6af6ed 100644
--- a/include/util.hpp
+++ b/include/util.hpp
@@ -21,6 +21,18 @@
*/
uint8_t findPredictedMediaLifeLeftPercent(const std::string& sysfsPath);
+/** @brief Get the part number (aka part name) for the storage device
+ * @param[in] sysfsPath - The path to the linux sysfs interface.
+ * @return part name as a string (or "unknown" if it couldn't be retrieved)
+ */
+std::string getPartNumber(const std::filesystem::path& sysfsPath);
+
+/** @brief Get the serial number for the storage device
+ * @param[in] sysfsPath - The path to the linux sysfs interface.
+ * @return serial name as a string (or "unknown" if it couldn't be retrieved)
+ */
+std::string getSerialNumber(const std::filesystem::path& sysfsPath);
+
/** @brief Look for the device described by the provided StorageData.
* @details Currently, this function assumes that there's only one eMMC.
* When we need to support multiple eMMCs, we will put more information in