diff options
author | Eddie James <eajames@us.ibm.com> | 2019-03-19 20:58:53 +0000 |
---|---|---|
committer | Eddie James <eajames@linux.ibm.com> | 2019-04-09 10:51:20 -0500 |
commit | 774f9af9a2d861f49c878d9eeca9830bef44127b (patch) | |
tree | 6b77eb6565e1f937403dda58296aa0d1493bbdf8 /occ_device.cpp | |
parent | 577a935e0261e7a316ec7f6ad76b72328d30d2ee (diff) | |
download | openpower-occ-control-774f9af9a2d861f49c878d9eeca9830bef44127b.tar.gz openpower-occ-control-774f9af9a2d861f49c878d9eeca9830bef44127b.zip |
Fix error attribute naming for Linux 5.0
There was a slight change to one of the error attributes as part of the
OCC driver upstreaming process. This commit also adds unit tests for the
error attributes. This required some refactoring to support the unit
tests.
Resolves openbmc/openbmc#3505
Signed-off-by: Eddie James <eajames@us.ibm.com>
Change-Id: I665b46e44b18befc8a728f7246bcda82f1f1a71c
Diffstat (limited to 'occ_device.cpp')
-rw-r--r-- | occ_device.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/occ_device.cpp b/occ_device.cpp index b05dc09..6cd6a1f 100644 --- a/occ_device.cpp +++ b/occ_device.cpp @@ -12,10 +12,31 @@ namespace occ fs::path Device::bindPath = fs::path(OCC_HWMON_PATH) / "bind"; fs::path Device::unBindPath = fs::path(OCC_HWMON_PATH) / "unbind"; +std::string Device::getPathBack(const fs::path& path) +{ + if (path.empty()) + return std::string(); + + // Points to the last element in the path + auto conf = --path.end(); + + // The last element will be '.' if the path ends in '/' + // This behavior differs between filesystem and experimental::filesystem + // Verify there is an element before too + if (!conf->compare(".") && conf != path.begin()) + { + return *(--conf); + } + else + { + return *conf; + } +} + bool Device::master() const { int master; - auto masterFile = fs::path(DEV_PATH) / config / "occ_master"; + auto masterFile = devPath / "occ_master"; std::ifstream file(masterFile, std::ios::in); if (!file) |