libpldmresponder: FRU: construct PDRs

Construct FRU record set and entity association PDRs for the FRUs for
which the BMC collects VPD (FRU information off of an EEPROM).

These PDRs are structured as per PLDM spec DSP0248 v1.2.0.

Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: I2c72d74dad449561b26c74482e00d1606546c5a2
diff --git a/utils.hpp b/utils.hpp
index bfbfb5d..6e128be 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -5,6 +5,7 @@
 #include <unistd.h>
 
 #include <exception>
+#include <filesystem>
 #include <iostream>
 #include <sdbusplus/server.hpp>
 #include <string>
@@ -21,6 +22,8 @@
 namespace utils
 {
 
+namespace fs = std::filesystem;
+
 /** @struct CustomFD
  *
  *  RAII wrapper for file descriptor.
@@ -203,5 +206,17 @@
                          const PropertyValue& value) const override;
 };
 
+/** @brief Fetch parent D-Bus object based on pathname
+ *
+ *  @param[in] dbusObj - child D-Bus object
+ *
+ *  @return std::string - the parent D-Bus object path
+ */
+inline std::string findParent(const std::string& dbusObj)
+{
+    fs::path p(dbusObj);
+    return p.parent_path().string();
+}
+
 } // namespace utils
 } // namespace pldm