Add sensor instance id command line argument.
Introduce `-i|--sensor-id` flag to explicitly set sensor
suffix for dbus name.
Sample usage:
phosphor-hwmon-readd -i test_sensor_id -o /apb/...
Will register the service with the following busname:
xyz.openbmc_project.Hwmon-test_sensor_id.Hwmon1
This change required as a part of privilege separation work:
https://github.com/openbmc/openbmc/issues/3383
Signed-off-by: Anton D. Kachalov <gmouse@google.com>
Change-Id: I48ff9c3efe0edb84718ff8f695e7e932af5445de
diff --git a/mainloop.hpp b/mainloop.hpp
index b3de022..af92479 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -45,6 +45,7 @@
* @param[in] devPath - physical device sysfs path.
* @param[in] prefix - DBus busname prefix.
* @param[in] root - DBus sensors namespace root.
+ * @param[in] instanceId - override value to identify instance on d-bus.
*
* Any DBus objects are created relative to the DBus
* sensors namespace root.
@@ -55,6 +56,7 @@
MainLoop(sdbusplus::bus::bus&& bus, const std::string& param,
const std::string& path, const std::string& devPath,
const char* prefix, const char* root,
+ const std::string& instanceId,
const hwmonio::HwmonIOInterface* ioIntf);
/** @brief Setup polling timer in a sd event loop and attach to D-Bus
@@ -105,6 +107,8 @@
const char* _root;
/** @brief DBus object state. */
SensorState _state;
+ /** @brief DBus instance id specified by command line. */
+ std::string _instanceId;
/** @brief Sleep interval in microseconds. */
uint64_t _interval = default_interval;
/** @brief Hwmon sysfs access. */