file_io_type_lid.hpp: Support patch path

Add the ability to patch lid files by having pldm check first if the
lid file exists in the patch directory.

Tested: Verified the expected lid path by printing it out:
- Without lid patches:
Dec 12 18:16:50 witherspoon-128-YL30UF74T00E-YL30UF74T00E-YL30UF74T00E pldmd[363]: LidHandler: lidPath=/usr/share/host-fw/81e002ff.lid
- With lid patches:
Dec 12 18:21:04 witherspoon-128-YL30UF74T00E-YL30UF74T00E-YL30UF74T00E pldmd[363]: LidHandler: lidPath=/usr/local/share/host-fw/81e002ff.lid

Change-Id: I5c70ef69d7be02d090a4516f27c11132e3fff29f
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/meson.build b/meson.build
index 797d8f4..87905a2 100644
--- a/meson.build
+++ b/meson.build
@@ -24,6 +24,7 @@
   conf_data.set_quoted('FILE_TABLE_JSON', '/usr/share/pldm/fileTable.json')
   conf_data.set_quoted('LID_PERM_DIR', '/usr/share/host-fw')
   conf_data.set_quoted('LID_TEMP_DIR', '/usr/share/host-fw')
+  conf_data.set_quoted('LID_PATCH_DIR', '/usr/local/share/host-fw')
   conf_data.set('DMA_MAXSIZE', get_option('oem-ibm-dma-maxsize'))
   add_global_arguments('-DOEM_IBM', language : 'c')
   add_global_arguments('-DOEM_IBM', language : 'cpp')
diff --git a/oem/ibm/libpldmresponder/file_io_type_lid.hpp b/oem/ibm/libpldmresponder/file_io_type_lid.hpp
index 0f640f0..ef9c221 100644
--- a/oem/ibm/libpldmresponder/file_io_type_lid.hpp
+++ b/oem/ibm/libpldmresponder/file_io_type_lid.hpp
@@ -4,6 +4,7 @@
 
 #include "file_io_by_type.hpp"
 
+#include <filesystem>
 #include <sstream>
 #include <string>
 
@@ -13,6 +14,7 @@
 {
 
 using namespace pldm::responder::dma;
+namespace fs = std::filesystem;
 
 /** @class LidHandler
  *
@@ -29,7 +31,16 @@
         std::string dir = permSide ? LID_PERM_DIR : LID_TEMP_DIR;
         std::stringstream stream;
         stream << std::hex << fileHandle;
-        lidPath = std::move(dir) + '/' + stream.str() + ".lid";
+        auto lidName = stream.str() + ".lid";
+        auto patch = fs::path(LID_PATCH_DIR) / lidName;
+        if (fs::is_regular_file(patch))
+        {
+            lidPath = patch;
+        }
+        else
+        {
+            lidPath = std::move(dir) + '/' + lidName;
+        }
     }
 
     virtual int writeFromMemory(uint32_t /*offset*/, uint32_t /*length*/,