Log the failing sysfs filename
Add the name of the sysfs path an access failed
on to the journal when an error log is created.
This is useful for debug.
An example of the path in the journal metadata is:
FILE=/sys/class/hwmon/hwmon7/temp1_input
Change-Id: I4bc3548619e561cd3acc95ba3ecc778fb08c7104
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/fan_speed.cpp b/fan_speed.cpp
index c156258..13aa266 100644
--- a/fan_speed.cpp
+++ b/fan_speed.cpp
@@ -37,6 +37,16 @@
WriteFailure::CALLOUT_ERRNO(e.code().value()),
xyz::openbmc_project::Control::Device::
WriteFailure::CALLOUT_DEVICE_PATH(devPath.c_str()));
+
+ auto file = sysfs::make_sysfs_path(
+ ioAccess.path(),
+ type,
+ id,
+ entry::target);
+
+ log<level::INFO>("Logging failing sysfs file",
+ phosphor::logging::entry("FILE=%s", file.c_str()));
+
exit(EXIT_FAILURE);
}
}
@@ -76,6 +86,10 @@
WriteFailure::CALLOUT_ERRNO(e.code().value()),
xyz::openbmc_project::Control::Device::
WriteFailure::CALLOUT_DEVICE_PATH(devPath.c_str()));
+
+ log<level::INFO>("Logging failing sysfs file",
+ phosphor::logging::entry("FILE=%s", fullPath.c_str()));
+
exit(EXIT_FAILURE);
}
}
diff --git a/mainloop.cpp b/mainloop.cpp
index ead9612..6a8e569 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -199,6 +199,15 @@
xyz::openbmc_project::Sensor::Device::
ReadFailure::CALLOUT_DEVICE_PATH(devPath.c_str()));
+ auto file = sysfs::make_sysfs_path(
+ ioAccess.path(),
+ sensor.first,
+ sensor.second,
+ hwmon::entry::cinput);
+
+ log<level::INFO>("Logging failing sysfs file",
+ entry("FILE=%s", file.c_str()));
+
return static_cast<std::shared_ptr<ValueObject>>(nullptr);
}
@@ -442,6 +451,16 @@
xyz::openbmc_project::Sensor::Device::
ReadFailure::CALLOUT_DEVICE_PATH(
_devPath.c_str()));
+
+ auto file = sysfs::make_sysfs_path(
+ ioAccess.path(),
+ i.first.first,
+ i.first.second,
+ hwmon::entry::cinput);
+
+ log<level::INFO>("Logging failing sysfs file",
+ entry("FILE=%s", file.c_str()));
+
#ifdef REMOVE_ON_FAIL
destroy.push_back(i.first);
#else