Use relative path to append path
The path append behavior changed between std::experimental and
std::filesystem, appending an absolute path (path with a leading slash)
replaces the path instead of appending to it, therefore need to use the
relative path (path without the leading slash) when appending.
The issue was that directories were attempted to be created on "/xyz/.."
instead of "SETTINGS_PERSIST_PATH/xyz/..", causing the settings manager
to fail with:
what(): filesystem error: cannot create directories: Read-only file
system [/xyz/openbmc_project/control/host0]
Tested: Verified this error is not seeing when making redfish calls.
Also verified the generated build/settings_manager.hpp file uses either
the relative path or the xyz path doesn't have the leading slash:
p /= path.relative_path();
path = fs::path(SETTINGS_PERSIST_PATH) / "xyz/openbmc_project/control/host0/TPMEnable";
Change-Id: Idd456baff5f39dc4464745daef9cb884481dca45
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/settings_manager.mako.hpp b/settings_manager.mako.hpp
index a1ee9ce..186a6c2 100644
--- a/settings_manager.mako.hpp
+++ b/settings_manager.mako.hpp
@@ -140,7 +140,7 @@
}
% endif
fs::path p(SETTINGS_PERSIST_PATH);
- p /= path;
+ p /= path.relative_path();
p += persistent::fileSuffix;
fs::create_directories(p.parent_path());
std::ofstream os(p.c_str(), std::ios::binary);
@@ -291,7 +291,8 @@
fs::path path{};
% for index, path in enumerate(objects):
- path = fs::path(SETTINGS_PERSIST_PATH) / "${path}";
+<% relativePath = path[1:] %>\
+ path = fs::path(SETTINGS_PERSIST_PATH) / "${relativePath}";
path += persistent::fileSuffix;
auto initSetting${index} = [&]()
{