Enable clang code format
Change-Id: I4490e930459a7eab6f6dd15198418c5314755d3f
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..bbc1bb1
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,85 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: true
+PointerAlignment: Left
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IndentCaseLabels: true
+IndentWidth: 4
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: false
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp11
+TabWidth: 4
+UseTab: Never
+...
+
diff --git a/activation.cpp b/activation.cpp
index 40acc89..350bf5a 100755
--- a/activation.cpp
+++ b/activation.cpp
@@ -17,15 +17,13 @@
using namespace phosphor::logging;
-constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
-constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
+constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
+constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
void Activation::subscribeToSystemdSignals()
{
- auto method = this->bus.new_method_call(SYSTEMD_SERVICE,
- SYSTEMD_OBJ_PATH,
- SYSTEMD_INTERFACE,
- "Subscribe");
+ auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
+ SYSTEMD_INTERFACE, "Subscribe");
this->bus.call_noreply(method);
return;
@@ -33,10 +31,8 @@
void Activation::unsubscribeFromSystemdSignals()
{
- auto method = this->bus.new_method_call(SYSTEMD_SERVICE,
- SYSTEMD_OBJ_PATH,
- SYSTEMD_INTERFACE,
- "Unsubscribe");
+ auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
+ SYSTEMD_INTERFACE, "Unsubscribe");
this->bus.call_noreply(method);
return;
@@ -50,24 +46,20 @@
if (!activationProgress)
{
- activationProgress = std::make_unique<ActivationProgress>(
- bus, path);
+ activationProgress = std::make_unique<ActivationProgress>(bus, path);
}
if (!activationBlocksTransition)
{
activationBlocksTransition =
- std::make_unique<ActivationBlocksTransition>(bus, path);
+ std::make_unique<ActivationBlocksTransition>(bus, path);
}
constexpr auto ubimountService = "obmc-flash-bios-ubimount@";
- auto ubimountServiceFile = std::string(ubimountService) +
- versionId + ".service";
- auto method = bus.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
+ auto ubimountServiceFile =
+ std::string(ubimountService) + versionId + ".service";
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
method.append(ubimountServiceFile, "replace");
bus.call_noreply(method);
@@ -81,8 +73,8 @@
// Set Redundancy Priority before setting to Active
if (!redundancyPriority)
{
- redundancyPriority = std::make_unique<RedundancyPriority>(
- bus, path, *this, 0);
+ redundancyPriority =
+ std::make_unique<RedundancyPriority>(bus, path, *this, 0);
}
activationProgress->progress(100);
@@ -98,8 +90,7 @@
parent.createActiveAssociation(path);
}
-auto Activation::activation(Activations value) ->
- Activations
+auto Activation::activation(Activations value) -> Activations
{
if (value != softwareServer::Activation::Activations::Active)
@@ -130,14 +121,14 @@
{
Activation::finishActivation();
return softwareServer::Activation::activation(
- softwareServer::Activation::Activations::Active);
+ softwareServer::Activation::Activations::Active);
}
else
{
activationBlocksTransition.reset(nullptr);
activationProgress.reset(nullptr);
return softwareServer::Activation::activation(
- softwareServer::Activation::Activations::Failed);
+ softwareServer::Activation::Activations::Failed);
}
}
}
@@ -150,23 +141,22 @@
return softwareServer::Activation::activation(value);
}
-auto Activation::requestedActivation(RequestedActivations value) ->
- RequestedActivations
+auto Activation::requestedActivation(RequestedActivations value)
+ -> RequestedActivations
{
ubiVolumesCreated = false;
if ((value == softwareServer::Activation::RequestedActivations::Active) &&
(softwareServer::Activation::requestedActivation() !=
- softwareServer::Activation::RequestedActivations::Active))
+ softwareServer::Activation::RequestedActivations::Active))
{
if ((softwareServer::Activation::activation() ==
- softwareServer::Activation::Activations::Ready) ||
+ softwareServer::Activation::Activations::Ready) ||
(softwareServer::Activation::activation() ==
- softwareServer::Activation::Activations::Failed))
+ softwareServer::Activation::Activations::Failed))
{
Activation::activation(
- softwareServer::Activation::Activations::Activating);
-
+ softwareServer::Activation::Activations::Activating);
}
}
return softwareServer::Activation::requestedActivation(value);
@@ -175,14 +165,12 @@
void Activation::deleteImageManagerObject()
{
// Get the Delete object for <versionID> inside image_manager
- auto method = this->bus.new_method_call(MAPPER_BUSNAME,
- MAPPER_PATH,
- MAPPER_INTERFACE,
- "GetObject");
+ auto method = this->bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
+ MAPPER_INTERFACE, "GetObject");
method.append(path);
- method.append(std::vector<std::string>({
- "xyz.openbmc_project.Object.Delete"}));
+ method.append(
+ std::vector<std::string>({"xyz.openbmc_project.Object.Delete"}));
auto mapperResponseMsg = bus.call(method);
if (mapperResponseMsg.is_method_error())
{
@@ -200,13 +188,12 @@
}
// Call the Delete object for <versionID> inside image_manager
- method = this->bus.new_method_call((mapperResponse.begin()->first).c_str(),
- path.c_str(),
- "xyz.openbmc_project.Object.Delete",
- "Delete");
+ method = this->bus.new_method_call(
+ (mapperResponse.begin()->first).c_str(), path.c_str(),
+ "xyz.openbmc_project.Object.Delete", "Delete");
mapperResponseMsg = bus.call(method);
- //Check that the bus call didn't result in an error
+ // Check that the bus call didn't result in an error
if (mapperResponseMsg.is_method_error())
{
log<level::ERR>("Error in Deleting image from image manager",
@@ -224,30 +211,30 @@
void Activation::unitStateChange(sdbusplus::message::message& msg)
{
- uint32_t newStateID {};
+ uint32_t newStateID{};
sdbusplus::message::object_path newStateObjPath;
std::string newStateUnit{};
std::string newStateResult{};
- //Read the msg and populate each variable
+ // Read the msg and populate each variable
msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
auto ubimountServiceFile =
- "obmc-flash-bios-ubimount@" + versionId + ".service";
+ "obmc-flash-bios-ubimount@" + versionId + ".service";
- if(newStateUnit == ubimountServiceFile && newStateResult == "done")
+ if (newStateUnit == ubimountServiceFile && newStateResult == "done")
{
ubiVolumesCreated = true;
activationProgress->progress(activationProgress->progress() + 50);
}
- if(ubiVolumesCreated)
+ if (ubiVolumesCreated)
{
Activation::activation(
- softwareServer::Activation::Activations::Activating);
+ softwareServer::Activation::Activations::Activating);
}
- if((newStateUnit == ubimountServiceFile) &&
+ if ((newStateUnit == ubimountServiceFile) &&
(newStateResult == "failed" || newStateResult == "dependency"))
{
Activation::activation(softwareServer::Activation::Activations::Failed);
diff --git a/activation.hpp b/activation.hpp
index ed077ae..2edbca5 100755
--- a/activation.hpp
+++ b/activation.hpp
@@ -16,13 +16,14 @@
{
using AssociationList =
- std::vector<std::tuple<std::string, std::string, std::string>>;
+ std::vector<std::tuple<std::string, std::string, std::string>>;
using ActivationInherit = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Software::server::ExtendedVersion,
sdbusplus::xyz::openbmc_project::Software::server::Activation,
sdbusplus::org::openbmc::server::Associations>;
using ActivationBlocksTransitionInherit = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>;
+ sdbusplus::xyz::openbmc_project::Software::server::
+ ActivationBlocksTransition>;
using RedundancyPriorityInherit = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>;
using ActivationProgressInherit = sdbusplus::server::object::object<
@@ -41,59 +42,54 @@
*/
class RedundancyPriority : public RedundancyPriorityInherit
{
- public:
- /** @brief Constructs RedundancyPriority.
- *
- * @param[in] bus - The Dbus bus object
- * @param[in] path - The Dbus object path
- * @param[in] parent - Parent object.
- * @param[in] value - The redundancyPriority value
- */
- RedundancyPriority(sdbusplus::bus::bus& bus,
- const std::string& path,
- Activation& parent,
- uint8_t value) :
- RedundancyPriorityInherit(bus,
- path.c_str(), true),
- parent(parent),
- bus(bus),
- path(path)
- {
- // Set Property
- priority(value);
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_added(path.c_str(), interfaces);
- }
+ public:
+ /** @brief Constructs RedundancyPriority.
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - The Dbus object path
+ * @param[in] parent - Parent object.
+ * @param[in] value - The redundancyPriority value
+ */
+ RedundancyPriority(sdbusplus::bus::bus& bus, const std::string& path,
+ Activation& parent, uint8_t value) :
+ RedundancyPriorityInherit(bus, path.c_str(), true),
+ parent(parent), bus(bus), path(path)
+ {
+ // Set Property
+ priority(value);
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_added(path.c_str(), interfaces);
+ }
- ~RedundancyPriority()
- {
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_removed(path.c_str(), interfaces);
- }
+ ~RedundancyPriority()
+ {
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_removed(path.c_str(), interfaces);
+ }
- /** @brief Overloaded Priority property set function
- *
- * @param[in] value - uint8_t
- *
- * @return Success or exception thrown
- */
- uint8_t priority(uint8_t value) override;
+ /** @brief Overloaded Priority property set function
+ *
+ * @param[in] value - uint8_t
+ *
+ * @return Success or exception thrown
+ */
+ uint8_t priority(uint8_t value) override;
- /** @brief Priority property get function
- *
- * @returns uint8_t - The Priority value
- */
- using RedundancyPriorityInherit::priority;
+ /** @brief Priority property get function
+ *
+ * @returns uint8_t - The Priority value
+ */
+ using RedundancyPriorityInherit::priority;
- /** @brief Parent Object. */
- Activation& parent;
+ /** @brief Parent Object. */
+ Activation& parent;
- private:
- // TODO Remove once openbmc/openbmc#1975 is resolved
- static constexpr auto interface =
- "xyz.openbmc_project.Software.RedundancyPriority";
- sdbusplus::bus::bus& bus;
- std::string path;
+ private:
+ // TODO Remove once openbmc/openbmc#1975 is resolved
+ static constexpr auto interface =
+ "xyz.openbmc_project.Software.RedundancyPriority";
+ sdbusplus::bus::bus& bus;
+ std::string path;
};
/** @class ActivationBlocksTransition
@@ -103,67 +99,63 @@
*/
class ActivationBlocksTransition : public ActivationBlocksTransitionInherit
{
- public:
- /** @brief Constructs ActivationBlocksTransition.
- *
- * @param[in] bus - The Dbus bus object
- * @param[in] path - The Dbus object path
- */
- ActivationBlocksTransition(sdbusplus::bus::bus& bus,
- const std::string& path) :
- ActivationBlocksTransitionInherit(bus, path.c_str(), true),
- bus(bus),
- path(path)
- {
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_added(path.c_str(), interfaces);
- }
+ public:
+ /** @brief Constructs ActivationBlocksTransition.
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - The Dbus object path
+ */
+ ActivationBlocksTransition(sdbusplus::bus::bus& bus,
+ const std::string& path) :
+ ActivationBlocksTransitionInherit(bus, path.c_str(), true),
+ bus(bus), path(path)
+ {
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_added(path.c_str(), interfaces);
+ }
- ~ActivationBlocksTransition()
- {
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_removed(path.c_str(), interfaces);
- }
+ ~ActivationBlocksTransition()
+ {
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_removed(path.c_str(), interfaces);
+ }
- private:
- // TODO Remove once openbmc/openbmc#1975 is resolved
- static constexpr auto interface =
- "xyz.openbmc_project.Software.ActivationBlocksTransition";
- sdbusplus::bus::bus& bus;
- std::string path;
+ private:
+ // TODO Remove once openbmc/openbmc#1975 is resolved
+ static constexpr auto interface =
+ "xyz.openbmc_project.Software.ActivationBlocksTransition";
+ sdbusplus::bus::bus& bus;
+ std::string path;
};
class ActivationProgress : public ActivationProgressInherit
{
- public:
- /** @brief Constructs ActivationProgress.
- *
- * @param[in] bus - The Dbus bus object
- * @param[in] path - The Dbus object path
- */
- ActivationProgress(sdbusplus::bus::bus& bus,
- const std::string& path) :
- ActivationProgressInherit(bus, path.c_str(), true),
- bus(bus),
- path(path)
- {
- progress(0);
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_added(path.c_str(), interfaces);
- }
+ public:
+ /** @brief Constructs ActivationProgress.
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - The Dbus object path
+ */
+ ActivationProgress(sdbusplus::bus::bus& bus, const std::string& path) :
+ ActivationProgressInherit(bus, path.c_str(), true), bus(bus), path(path)
+ {
+ progress(0);
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_added(path.c_str(), interfaces);
+ }
- ~ActivationProgress()
- {
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_removed(path.c_str(), interfaces);
- }
+ ~ActivationProgress()
+ {
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_removed(path.c_str(), interfaces);
+ }
- private:
- // TODO Remove once openbmc/openbmc#1975 is resolved
- static constexpr auto interface =
- "xyz.openbmc_project.Software.ActivationProgress";
- sdbusplus::bus::bus& bus;
- std::string path;
+ private:
+ // TODO Remove once openbmc/openbmc#1975 is resolved
+ static constexpr auto interface =
+ "xyz.openbmc_project.Software.ActivationProgress";
+ sdbusplus::bus::bus& bus;
+ std::string path;
};
/** @class Activation
@@ -173,148 +165,141 @@
*/
class Activation : public ActivationInherit
{
- public:
- /** @brief Constructs Activation Software Manager
- *
- * @param[in] bus - The Dbus bus object
- * @param[in] path - The Dbus object path
- * @param[in] parent - Parent object.
- * @param[in] versionId - The software version id
- * @param[in] extVersion - The extended version
- * @param[in] activationStatus - The status of Activation
- * @param[in] assocs - Association objects
- */
- Activation(sdbusplus::bus::bus& bus, const std::string& path,
- ItemUpdater& parent,
- std::string& versionId,
- std::string& extVersion,
- sdbusplus::xyz::openbmc_project::Software::
- server::Activation::Activations activationStatus,
- AssociationList& assocs) :
- ActivationInherit(bus, path.c_str(), true),
- bus(bus),
- path(path),
- parent(parent),
- versionId(versionId),
- systemdSignals(
- bus,
- sdbusRule::type::signal() +
- sdbusRule::member("JobRemoved") +
- sdbusRule::path("/org/freedesktop/systemd1") +
- sdbusRule::interface(
- "org.freedesktop.systemd1.Manager"),
- std::bind(std::mem_fn(&Activation::unitStateChange),
- this, std::placeholders::_1))
- {
- // Enable systemd signals
- subscribeToSystemdSignals();
- // Set Properties.
- extendedVersion(extVersion);
- activation(activationStatus);
- associations(assocs);
+ public:
+ /** @brief Constructs Activation Software Manager
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - The Dbus object path
+ * @param[in] parent - Parent object.
+ * @param[in] versionId - The software version id
+ * @param[in] extVersion - The extended version
+ * @param[in] activationStatus - The status of Activation
+ * @param[in] assocs - Association objects
+ */
+ Activation(sdbusplus::bus::bus& bus, const std::string& path,
+ ItemUpdater& parent, std::string& versionId,
+ std::string& extVersion,
+ sdbusplus::xyz::openbmc_project::Software::server::Activation::
+ Activations activationStatus,
+ AssociationList& assocs) :
+ ActivationInherit(bus, path.c_str(), true),
+ bus(bus), path(path), parent(parent), versionId(versionId),
+ systemdSignals(
+ bus,
+ sdbusRule::type::signal() + sdbusRule::member("JobRemoved") +
+ sdbusRule::path("/org/freedesktop/systemd1") +
+ sdbusRule::interface("org.freedesktop.systemd1.Manager"),
+ std::bind(std::mem_fn(&Activation::unitStateChange), this,
+ std::placeholders::_1))
+ {
+ // Enable systemd signals
+ subscribeToSystemdSignals();
+ // Set Properties.
+ extendedVersion(extVersion);
+ activation(activationStatus);
+ associations(assocs);
- // Emit deferred signal.
- emit_object_added();
- }
+ // Emit deferred signal.
+ emit_object_added();
+ }
- /** @brief Activation property get function
- *
- * @returns One of Activation::Activations
- */
- using ActivationInherit::activation;
+ /** @brief Activation property get function
+ *
+ * @returns One of Activation::Activations
+ */
+ using ActivationInherit::activation;
- /** @brief Overloaded Activation property setter function
- *
- * @param[in] value - One of Activation::Activations
- *
- * @return Success or exception thrown
- */
- Activations activation(Activations value) override;
+ /** @brief Overloaded Activation property setter function
+ *
+ * @param[in] value - One of Activation::Activations
+ *
+ * @return Success or exception thrown
+ */
+ Activations activation(Activations value) override;
- /** @brief Overloaded requestedActivation property setter function
- *
- * @param[in] value - One of Activation::RequestedActivations
- *
- * @return Success or exception thrown
- */
- RequestedActivations requestedActivation(RequestedActivations value)
- override;
+ /** @brief Overloaded requestedActivation property setter function
+ *
+ * @param[in] value - One of Activation::RequestedActivations
+ *
+ * @return Success or exception thrown
+ */
+ RequestedActivations
+ requestedActivation(RequestedActivations value) override;
- /** @brief Check if systemd state change is relevant to this object
- *
- * Instance specific interface to handle the detected systemd state
- * change
- *
- * @param[in] msg - Data associated with subscribed signal
- *
- */
- void unitStateChange(sdbusplus::message::message& msg);
+ /** @brief Check if systemd state change is relevant to this object
+ *
+ * Instance specific interface to handle the detected systemd state
+ * change
+ *
+ * @param[in] msg - Data associated with subscribed signal
+ *
+ */
+ void unitStateChange(sdbusplus::message::message& msg);
- /**
- * @brief subscribe to the systemd signals
- *
- * This object needs to capture when it's systemd targets complete
- * so it can keep it's state updated
- *
- **/
- void subscribeToSystemdSignals();
+ /**
+ * @brief subscribe to the systemd signals
+ *
+ * This object needs to capture when it's systemd targets complete
+ * so it can keep it's state updated
+ *
+ **/
+ void subscribeToSystemdSignals();
- /**
- * @brief unsubscribe from the systemd signals
- *
- * Once the activation process has completed successfully, we can
- * safely unsubscribe from systemd signals.
- *
- **/
- void unsubscribeFromSystemdSignals();
+ /**
+ * @brief unsubscribe from the systemd signals
+ *
+ * Once the activation process has completed successfully, we can
+ * safely unsubscribe from systemd signals.
+ *
+ **/
+ void unsubscribeFromSystemdSignals();
- /** @brief Persistent sdbusplus DBus bus connection */
- sdbusplus::bus::bus& bus;
+ /** @brief Persistent sdbusplus DBus bus connection */
+ sdbusplus::bus::bus& bus;
- /** @brief Persistent DBus object path */
- std::string path;
+ /** @brief Persistent DBus object path */
+ std::string path;
- /** @brief Parent Object. */
- ItemUpdater& parent;
+ /** @brief Parent Object. */
+ ItemUpdater& parent;
- /** @brief Version id */
- std::string versionId;
+ /** @brief Version id */
+ std::string versionId;
- /** @brief Persistent ActivationBlocksTransition dbus object */
- std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition;
+ /** @brief Persistent ActivationBlocksTransition dbus object */
+ std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition;
- /** @brief Persistent ActivationProgress dbus object */
- std::unique_ptr<ActivationProgress> activationProgress;
+ /** @brief Persistent ActivationProgress dbus object */
+ std::unique_ptr<ActivationProgress> activationProgress;
- /** @brief Persistent RedundancyPriority dbus object */
- std::unique_ptr<RedundancyPriority> redundancyPriority;
+ /** @brief Persistent RedundancyPriority dbus object */
+ std::unique_ptr<RedundancyPriority> redundancyPriority;
- /** @brief Used to subscribe to dbus systemd signals **/
- sdbusplus::bus::match_t systemdSignals;
+ /** @brief Used to subscribe to dbus systemd signals **/
+ sdbusplus::bus::match_t systemdSignals;
- /** @brief Tracks whether the read-only & read-write volumes have been
- *created as part of the activation process. **/
- bool ubiVolumesCreated = false;
+ /** @brief Tracks whether the read-only & read-write volumes have been
+ *created as part of the activation process. **/
+ bool ubiVolumesCreated = false;
- /** @brief activation status property get function
- *
- * @returns Activations - The activation value
- */
- using ActivationInherit::activation;
+ /** @brief activation status property get function
+ *
+ * @returns Activations - The activation value
+ */
+ using ActivationInherit::activation;
- private:
+ private:
+ /**
+ * @brief Deletes the version from Image Manager and the
+ * untar image from image upload dir.
+ */
+ void deleteImageManagerObject();
- /**
- * @brief Deletes the version from Image Manager and the
- * untar image from image upload dir.
- */
- void deleteImageManagerObject();
+ /** @brief Member function for clarity & brevity at activation start */
+ void startActivation();
- /** @brief Member function for clarity & brevity at activation start */
- void startActivation();
-
- /** @brief Member function for clarity & brevity at activation end */
- void finishActivation();
+ /** @brief Member function for clarity & brevity at activation end */
+ void finishActivation();
};
} // namespace updater
diff --git a/item_updater.cpp b/item_updater.cpp
index 7b7995e..ad8f264 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -40,8 +40,8 @@
namespace variant_ns = msg::variant_ns;
sdbusplus::message::object_path objPath;
- std::map<std::string,
- std::map<std::string, msg::variant<std::string>>> interfaces;
+ std::map<std::string, std::map<std::string, msg::variant<std::string>>>
+ interfaces;
m.read(objPath, interfaces);
std::string path(std::move(objPath));
@@ -59,7 +59,7 @@
{
// Only process the Host and System images
auto value = SVersion::convertVersionPurposeFromString(
- variant_ns::get<std::string>(property.second));
+ variant_ns::get<std::string>(property.second));
if (value == VersionPurpose::Host ||
value == VersionPurpose::System)
@@ -110,41 +110,29 @@
activationState = server::Activation::Activations::Ready;
// Create an association to the host inventory item
associations.emplace_back(std::make_tuple(
- ACTIVATION_FWD_ASSOCIATION,
- ACTIVATION_REV_ASSOCIATION,
- HOST_INVENTORY_PATH));
+ ACTIVATION_FWD_ASSOCIATION, ACTIVATION_REV_ASSOCIATION,
+ HOST_INVENTORY_PATH));
}
fs::path manifestPath(filePath);
manifestPath /= MANIFEST_FILE;
- std::string extendedVersion = (Version::getValue(manifestPath.string(),
- std::map<std::string, std::string>
- {{"extended_version", ""}})).begin()->second;
+ std::string extendedVersion =
+ (Version::getValue(
+ manifestPath.string(),
+ std::map<std::string, std::string>{{"extended_version", ""}}))
+ .begin()
+ ->second;
activations.insert(std::make_pair(
- versionId,
- std::make_unique<Activation>(
- bus,
- path,
- *this,
- versionId,
- extendedVersion,
- activationState,
- associations)));
+ versionId, std::make_unique<Activation>(
+ bus, path, *this, versionId, extendedVersion,
+ activationState, associations)));
auto versionPtr = std::make_unique<Version>(
- bus,
- path,
- *this,
- versionId,
- version,
- purpose,
- filePath,
- std::bind(&ItemUpdater::erase,
- this,
- std::placeholders::_1));
+ bus, path, *this, versionId, version, purpose, filePath,
+ std::bind(&ItemUpdater::erase, this, std::placeholders::_1));
versionPtr->deleteObject =
- std::make_unique<Delete>(bus, path, *versionPtr);
+ std::make_unique<Delete>(bus, path, *versionPtr);
versions.insert(std::make_pair(versionId, std::move(versionPtr)));
}
return;
@@ -162,8 +150,8 @@
static const auto PNOR_RW_PREFIX_LEN = strlen(PNOR_RW_PREFIX);
// Check if the PNOR_RO_PREFIX is the prefix of the iter.path
- if (0 == iter.path().native().compare(0, PNOR_RO_PREFIX_LEN,
- PNOR_RO_PREFIX))
+ if (0 ==
+ iter.path().native().compare(0, PNOR_RO_PREFIX_LEN, PNOR_RO_PREFIX))
{
// The versionId is extracted from the path
// for example /media/pnor-ro-2a1022fe.
@@ -176,10 +164,8 @@
ItemUpdater::erase(id);
continue;
}
- auto keyValues =
- Version::getValue(pnorTOC,
- {{ "version", "" },
- { "extended_version", "" } });
+ auto keyValues = Version::getValue(
+ pnorTOC, {{"version", ""}, {"extended_version", ""}});
auto& version = keyValues.at("version");
if (version.empty())
{
@@ -204,25 +190,18 @@
{
// Create an association to the host inventory item
associations.emplace_back(std::make_tuple(
- ACTIVATION_FWD_ASSOCIATION,
- ACTIVATION_REV_ASSOCIATION,
- HOST_INVENTORY_PATH));
+ ACTIVATION_FWD_ASSOCIATION, ACTIVATION_REV_ASSOCIATION,
+ HOST_INVENTORY_PATH));
// Create an active association since this image is active
createActiveAssociation(path);
}
// Create Activation instance for this version.
- activations.insert(std::make_pair(
- id,
- std::make_unique<Activation>(
- bus,
- path,
- *this,
- id,
- extendedVersion,
- activationState,
- associations)));
+ activations.insert(
+ std::make_pair(id, std::make_unique<Activation>(
+ bus, path, *this, id, extendedVersion,
+ activationState, associations)));
// If Active, create RedundancyPriority instance for this version.
if (activationState == server::Activation::Activations::Active)
@@ -234,33 +213,20 @@
entry("VERSIONID=%s", id));
}
activations.find(id)->second->redundancyPriority =
- std::make_unique<RedundancyPriority>(
- bus,
- path,
- *(activations.find(id)->second),
- priority);
+ std::make_unique<RedundancyPriority>(
+ bus, path, *(activations.find(id)->second), priority);
}
// Create Version instance for this version.
auto versionPtr = std::make_unique<Version>(
- bus,
- path,
- *this,
- id,
- version,
- purpose,
- "",
- std::bind(&ItemUpdater::erase,
- this,
- std::placeholders::_1));
+ bus, path, *this, id, version, purpose, "",
+ std::bind(&ItemUpdater::erase, this, std::placeholders::_1));
versionPtr->deleteObject =
- std::make_unique<Delete>(bus, path, *versionPtr);
- versions.insert(std::make_pair(
- id,
- std::move(versionPtr)));
+ std::make_unique<Delete>(bus, path, *versionPtr);
+ versions.insert(std::make_pair(id, std::move(versionPtr)));
}
else if (0 == iter.path().native().compare(0, PNOR_RW_PREFIX_LEN,
- PNOR_RW_PREFIX))
+ PNOR_RW_PREFIX))
{
auto id = iter.path().native().substr(PNOR_RW_PREFIX_LEN);
auto roDir = PNOR_RO_PREFIX + id;
@@ -298,32 +264,24 @@
void ItemUpdater::removeReadOnlyPartition(std::string versionId)
{
- auto serviceFile = "obmc-flash-bios-ubiumount-ro@" + versionId +
- ".service";
+ auto serviceFile = "obmc-flash-bios-ubiumount-ro@" + versionId + ".service";
- // Remove the read-only partitions.
- auto method = bus.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
- method.append(serviceFile, "replace");
- bus.call_noreply(method);
+ // Remove the read-only partitions.
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ method.append(serviceFile, "replace");
+ bus.call_noreply(method);
}
void ItemUpdater::removeReadWritePartition(std::string versionId)
{
- auto serviceFile = "obmc-flash-bios-ubiumount-rw@" + versionId +
- ".service";
+ auto serviceFile = "obmc-flash-bios-ubiumount-rw@" + versionId + ".service";
- // Remove the read-write partitions.
- auto method = bus.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
- method.append(serviceFile, "replace");
- bus.call_noreply(method);
+ // Remove the read-write partitions.
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
+ method.append(serviceFile, "replace");
+ bus.call_noreply(method);
}
void ItemUpdater::reset()
@@ -339,40 +297,34 @@
for (const auto& it : activations)
{
- auto serviceFile = "obmc-flash-bios-ubiclear@pnor-rw-" + it.first +
- ".service";
+ auto serviceFile =
+ "obmc-flash-bios-ubiclear@pnor-rw-" + it.first + ".service";
// Clear the read-write partitions.
- auto method = bus.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
method.append(serviceFile, "replace");
auto reply = bus.call(method);
if (reply.is_method_error())
{
log<level::ERR>("Failed to clear read-write partitions",
- entry("SERVICE_FILE=%s", serviceFile));
+ entry("SERVICE_FILE=%s", serviceFile));
elog<InternalFailure>();
}
}
static constexpr auto serviceFile =
- "obmc-flash-bios-ubiclear@pnor-prsv.service";
+ "obmc-flash-bios-ubiclear@pnor-prsv.service";
// Clear the preserved partition.
- auto method = bus.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
method.append(serviceFile, "replace");
auto reply = bus.call(method);
if (reply.is_method_error())
{
log<level::ERR>("Failed to clear preserved partition",
- entry("SERVICE_FILE=%s", serviceFile));
+ entry("SERVICE_FILE=%s", serviceFile));
elog<InternalFailure>();
}
@@ -404,11 +356,8 @@
bool ItemUpdater::isChassisOn()
{
- auto mapperCall = bus.new_method_call(
- MAPPER_BUSNAME,
- MAPPER_PATH,
- MAPPER_INTERFACE,
- "GetObject");
+ auto mapperCall = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
+ MAPPER_INTERFACE, "GetObject");
mapperCall.append(CHASSIS_STATE_PATH,
std::vector<std::string>({CHASSIS_STATE_OBJ}));
@@ -429,8 +378,7 @@
auto method = bus.new_method_call((mapperResponse.begin()->first).c_str(),
CHASSIS_STATE_PATH,
- SYSTEMD_PROPERTY_INTERFACE,
- "Get");
+ SYSTEMD_PROPERTY_INTERFACE, "Get");
method.append(CHASSIS_STATE_OBJ, "CurrentPowerState");
auto response = bus.call(method);
if (response.is_method_error())
@@ -449,7 +397,7 @@
void ItemUpdater::freePriority(uint8_t value, const std::string& versionId)
{
- //TODO openbmc/openbmc#1896 Improve the performance of this function
+ // TODO openbmc/openbmc#1896 Improve the performance of this function
for (const auto& intf : activations)
{
if (intf.second->redundancyPriority)
@@ -480,10 +428,12 @@
void ItemUpdater::erase(std::string entryId)
{
- if (isVersionFunctional(entryId) && isChassisOn()) {
- log<level::ERR>(("Error: Version " + entryId + \
- " is currently active and running on the host." \
- " Unable to remove.").c_str());
+ if (isVersionFunctional(entryId) && isChassisOn())
+ {
+ log<level::ERR>(("Error: Version " + entryId +
+ " is currently active and running on the host."
+ " Unable to remove.")
+ .c_str());
return;
}
// Remove priority persistence file
@@ -497,9 +447,10 @@
auto it = versions.find(entryId);
if (it == versions.end())
{
- log<level::ERR>(("Error: Failed to find version " + entryId + \
- " in item updater versions map." \
- " Unable to remove.").c_str());
+ log<level::ERR>(("Error: Failed to find version " + entryId +
+ " in item updater versions map."
+ " Unable to remove.")
+ .c_str());
}
else
{
@@ -510,9 +461,10 @@
auto ita = activations.find(entryId);
if (ita == activations.end())
{
- log<level::ERR>(("Error: Failed to find version " + entryId + \
- " in item updater activations map." \
- " Unable to remove.").c_str());
+ log<level::ERR>(("Error: Failed to find version " + entryId +
+ " in item updater activations map."
+ " Unable to remove.")
+ .c_str());
}
else
{
@@ -533,11 +485,8 @@
// Remove any remaining pnor-ro- or pnor-rw- volumes that do not match
// the current version.
- auto method = bus.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
method.append("obmc-flash-bios-cleanup.service", "replace");
bus.call_noreply(method);
}
@@ -548,12 +497,14 @@
// Versions with the highest priority in front
std::priority_queue<std::pair<int, std::string>,
std::vector<std::pair<int, std::string>>,
- std::less<std::pair<int, std::string>>> versionsPQ;
+ std::less<std::pair<int, std::string>>>
+ versionsPQ;
std::size_t count = 0;
for (const auto& iter : activations)
{
- if (iter.second.get()->activation() == server::Activation::Activations::Active)
+ if (iter.second.get()->activation() ==
+ server::Activation::Activations::Active)
{
count++;
// Don't put the functional version on the queue since we can't
@@ -563,8 +514,8 @@
continue;
}
versionsPQ.push(std::make_pair(
- iter.second->redundancyPriority.get()->priority(),
- iter.second->versionId));
+ iter.second->redundancyPriority.get()->priority(),
+ iter.second->versionId));
}
}
@@ -580,9 +531,8 @@
void ItemUpdater::createActiveAssociation(const std::string& path)
{
- assocs.emplace_back(std::make_tuple(ACTIVE_FWD_ASSOCIATION,
- ACTIVE_REV_ASSOCIATION,
- path));
+ assocs.emplace_back(
+ std::make_tuple(ACTIVE_FWD_ASSOCIATION, ACTIVE_REV_ASSOCIATION, path));
associations(assocs);
}
@@ -601,8 +551,7 @@
}
}
assocs.emplace_back(std::make_tuple(FUNCTIONAL_FWD_ASSOCIATION,
- FUNCTIONAL_REV_ASSOCIATION,
- path));
+ FUNCTIONAL_REV_ASSOCIATION, path));
associations(assocs);
}
@@ -651,11 +600,8 @@
path /= "GUARD";
std::vector<uint8_t> mboxdArgs;
- auto dbusCall = bus.new_method_call(
- MBOXD_INTERFACE,
- MBOXD_PATH,
- MBOXD_INTERFACE,
- "cmd");
+ auto dbusCall = bus.new_method_call(MBOXD_INTERFACE, MBOXD_PATH,
+ MBOXD_INTERFACE, "cmd");
// Suspend mboxd - no args required.
dbusCall.append(static_cast<uint8_t>(3), mboxdArgs);
@@ -672,11 +618,8 @@
fs::remove(path);
}
- dbusCall = bus.new_method_call(
- MBOXD_INTERFACE,
- MBOXD_PATH,
- MBOXD_INTERFACE,
- "cmd");
+ dbusCall = bus.new_method_call(MBOXD_INTERFACE, MBOXD_PATH, MBOXD_INTERFACE,
+ "cmd");
// Resume mboxd with arg 1, indicating that the flash is modified.
mboxdArgs.push_back(1);
diff --git a/item_updater.hpp b/item_updater.hpp
index 7b37e4d..90441c4 100755
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -16,17 +16,17 @@
{
using ItemUpdaterInherit = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Common::server::FactoryReset,
- sdbusplus::org::openbmc::server::Associations,
- sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
+ sdbusplus::xyz::openbmc_project::Common::server::FactoryReset,
+ sdbusplus::org::openbmc::server::Associations,
+ sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
using GardResetInherit = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Common::server::FactoryReset>;
+ sdbusplus::xyz::openbmc_project::Common::server::FactoryReset>;
using ObjectEnable = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Object::server::Enable>;
+ sdbusplus::xyz::openbmc_project::Object::server::Enable>;
namespace MatchRules = sdbusplus::bus::match::rules;
using AssociationList =
- std::vector<std::tuple<std::string, std::string, std::string>>;
+ std::vector<std::tuple<std::string, std::string, std::string>>;
constexpr auto GARD_PATH = "/org/open_power/control/gard";
constexpr static auto volatilePath = "/org/open_power/control/volatile";
@@ -38,39 +38,35 @@
*/
class GardReset : public GardResetInherit
{
- public:
- /** @brief Constructs GardReset.
- *
- * @param[in] bus - The Dbus bus object
- * @param[in] path - The Dbus object path
- */
- GardReset(sdbusplus::bus::bus& bus,
- const std::string& path) :
- GardResetInherit(bus, path.c_str(), true),
- bus(bus),
- path(path)
- {
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_added(path.c_str(), interfaces);
- }
+ public:
+ /** @brief Constructs GardReset.
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - The Dbus object path
+ */
+ GardReset(sdbusplus::bus::bus& bus, const std::string& path) :
+ GardResetInherit(bus, path.c_str(), true), bus(bus), path(path)
+ {
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_added(path.c_str(), interfaces);
+ }
- ~GardReset()
- {
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_removed(path.c_str(), interfaces);
- }
+ ~GardReset()
+ {
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_removed(path.c_str(), interfaces);
+ }
- private:
- // TODO Remove once openbmc/openbmc#1975 is resolved
- static constexpr auto interface =
- "xyz.openbmc_project.Common.FactoryReset";
- sdbusplus::bus::bus& bus;
- std::string path;
+ private:
+ // TODO Remove once openbmc/openbmc#1975 is resolved
+ static constexpr auto interface = "xyz.openbmc_project.Common.FactoryReset";
+ sdbusplus::bus::bus& bus;
+ std::string path;
- /**
- * @brief GARD factory reset - clears the PNOR GARD partition.
- */
- void reset() override;
+ /**
+ * @brief GARD factory reset - clears the PNOR GARD partition.
+ */
+ void reset() override;
};
/** @class ItemUpdater
@@ -78,180 +74,176 @@
*/
class ItemUpdater : public ItemUpdaterInherit
{
- public:
- /** @brief Constructs ItemUpdater
- *
- * @param[in] bus - The D-Bus bus object
- * @param[in] path - The D-Bus path
- */
- ItemUpdater(sdbusplus::bus::bus& bus, const std::string& path) :
- ItemUpdaterInherit(bus, path.c_str()),
- bus(bus),
- versionMatch(
- bus,
- MatchRules::interfacesAdded() +
- MatchRules::path("/xyz/openbmc_project/software"),
- std::bind(
- std::mem_fn(&ItemUpdater::createActivation),
- this,
- std::placeholders::_1))
- {
- processPNORImage();
- gardReset = std::make_unique<GardReset>(bus, GARD_PATH);
- volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);
+ public:
+ /** @brief Constructs ItemUpdater
+ *
+ * @param[in] bus - The D-Bus bus object
+ * @param[in] path - The D-Bus path
+ */
+ ItemUpdater(sdbusplus::bus::bus& bus, const std::string& path) :
+ ItemUpdaterInherit(bus, path.c_str()), bus(bus),
+ versionMatch(bus,
+ MatchRules::interfacesAdded() +
+ MatchRules::path("/xyz/openbmc_project/software"),
+ std::bind(std::mem_fn(&ItemUpdater::createActivation),
+ this, std::placeholders::_1))
+ {
+ processPNORImage();
+ gardReset = std::make_unique<GardReset>(bus, GARD_PATH);
+ volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);
- // Emit deferred signal.
- emit_object_added();
- }
+ // Emit deferred signal.
+ emit_object_added();
+ }
- /** @brief Sets the given priority free by incrementing
- * any existing priority with the same value by 1
- *
- * @param[in] value - The priority that needs to be set free.
- * @param[in] versionId - The Id of the version for which we
- * are trying to free up the priority.
- * @return None
- */
- void freePriority(uint8_t value, const std::string& versionId);
+ /** @brief Sets the given priority free by incrementing
+ * any existing priority with the same value by 1
+ *
+ * @param[in] value - The priority that needs to be set free.
+ * @param[in] versionId - The Id of the version for which we
+ * are trying to free up the priority.
+ * @return None
+ */
+ void freePriority(uint8_t value, const std::string& versionId);
- /** @brief Determine is the given priority is the lowest
- *
- * @param[in] value - The priority that needs to be checked.
- *
- * @return boolean corresponding to whether the given
- * priority is lowest.
- */
- bool isLowestPriority(uint8_t value);
+ /** @brief Determine is the given priority is the lowest
+ *
+ * @param[in] value - The priority that needs to be checked.
+ *
+ * @return boolean corresponding to whether the given
+ * priority is lowest.
+ */
+ bool isLowestPriority(uint8_t value);
- /**
- * @brief Create and populate the active PNOR Version.
- */
- void processPNORImage();
+ /**
+ * @brief Create and populate the active PNOR Version.
+ */
+ void processPNORImage();
- /** @brief Deletes version
- *
- * @param[in] entryId - Id of the version to delete
- *
- * @return None
- */
- void erase(std::string entryId);
+ /** @brief Deletes version
+ *
+ * @param[in] entryId - Id of the version to delete
+ *
+ * @return None
+ */
+ void erase(std::string entryId);
- /**
- * @brief Erases any non-active pnor versions.
- */
- void deleteAll();
+ /**
+ * @brief Erases any non-active pnor versions.
+ */
+ void deleteAll();
- /** @brief Brings the total number of active PNOR versions to
- * ACTIVE_PNOR_MAX_ALLOWED -1. This function is intended to be
- * run before activating a new PNOR version. If this function
- * needs to delete any PNOR version(s) it will delete the
- * version(s) with the highest priority, skipping the
- * functional PNOR version.
- */
- void freeSpace();
+ /** @brief Brings the total number of active PNOR versions to
+ * ACTIVE_PNOR_MAX_ALLOWED -1. This function is intended to be
+ * run before activating a new PNOR version. If this function
+ * needs to delete any PNOR version(s) it will delete the
+ * version(s) with the highest priority, skipping the
+ * functional PNOR version.
+ */
+ void freeSpace();
- /** @brief Determine the software version id
- * from the symlink target (e.g. /media/ro-2a1022fe).
- *
- * @param[in] symlinkPath - The path of the symlink.
- * @param[out] id - The version id as a string.
- */
- static std::string determineId(const std::string& symlinkPath);
+ /** @brief Determine the software version id
+ * from the symlink target (e.g. /media/ro-2a1022fe).
+ *
+ * @param[in] symlinkPath - The path of the symlink.
+ * @param[out] id - The version id as a string.
+ */
+ static std::string determineId(const std::string& symlinkPath);
- /** @brief Creates an active association to the
- * newly active software image
- *
- * @param[in] path - The path to create the association to.
- */
- void createActiveAssociation(const std::string& path);
+ /** @brief Creates an active association to the
+ * newly active software image
+ *
+ * @param[in] path - The path to create the association to.
+ */
+ void createActiveAssociation(const std::string& path);
- /** @brief Updates the functional association to the
- * new "running" PNOR image
- *
- * @param[in] path - The path to update the association to.
- */
- void updateFunctionalAssociation(const std::string& path);
+ /** @brief Updates the functional association to the
+ * new "running" PNOR image
+ *
+ * @param[in] path - The path to update the association to.
+ */
+ void updateFunctionalAssociation(const std::string& path);
- /** @brief Removes an active association to the software image
- *
- * @param[in] path - The path to remove the association from.
- */
- void removeActiveAssociation(const std::string& path);
+ /** @brief Removes an active association to the software image
+ *
+ * @param[in] path - The path to remove the association from.
+ */
+ void removeActiveAssociation(const std::string& path);
- /** @brief Persistent GardReset dbus object */
- std::unique_ptr<GardReset> gardReset;
+ /** @brief Persistent GardReset dbus object */
+ std::unique_ptr<GardReset> gardReset;
- /** @brief Check whether the provided image id is the functional one
- *
- * @param[in] - versionId - The id of the image to check.
- *
- * @return - Returns true if this version is currently functional.
- */
- static bool isVersionFunctional(const std::string& versionId);
+ /** @brief Check whether the provided image id is the functional one
+ *
+ * @param[in] - versionId - The id of the image to check.
+ *
+ * @return - Returns true if this version is currently functional.
+ */
+ static bool isVersionFunctional(const std::string& versionId);
- /** @brief Persistent ObjectEnable D-Bus object */
- std::unique_ptr<ObjectEnable> volatileEnable;
+ /** @brief Persistent ObjectEnable D-Bus object */
+ std::unique_ptr<ObjectEnable> volatileEnable;
- private:
- /** @brief Callback function for Software.Version match.
- * @details Creates an Activation D-Bus object.
- *
- * @param[in] msg - Data associated with subscribed signal
- */
- void createActivation(sdbusplus::message::message& msg);
+ private:
+ /** @brief Callback function for Software.Version match.
+ * @details Creates an Activation D-Bus object.
+ *
+ * @param[in] msg - Data associated with subscribed signal
+ */
+ void createActivation(sdbusplus::message::message& msg);
- /**
- * @brief Validates the presence of SquashFS image in the image dir.
- *
- * @param[in] filePath - The path to the SquashFS image.
- * @param[out] result - 0 --> if validation was successful
- * - -1--> Otherwise
- */
- static int validateSquashFSImage(const std::string& filePath);
+ /**
+ * @brief Validates the presence of SquashFS image in the image dir.
+ *
+ * @param[in] filePath - The path to the SquashFS image.
+ * @param[out] result - 0 --> if validation was successful
+ * - -1--> Otherwise
+ */
+ static int validateSquashFSImage(const std::string& filePath);
- /** @brief Persistent sdbusplus D-Bus bus connection. */
- sdbusplus::bus::bus& bus;
+ /** @brief Persistent sdbusplus D-Bus bus connection. */
+ sdbusplus::bus::bus& bus;
- /** @brief Persistent map of Activation D-Bus objects and their
- * version id */
- std::map<std::string, std::unique_ptr<Activation>> activations;
+ /** @brief Persistent map of Activation D-Bus objects and their
+ * version id */
+ std::map<std::string, std::unique_ptr<Activation>> activations;
- /** @brief Persistent map of Version D-Bus objects and their
- * version id */
- std::map<std::string, std::unique_ptr<Version>> versions;
+ /** @brief Persistent map of Version D-Bus objects and their
+ * version id */
+ std::map<std::string, std::unique_ptr<Version>> versions;
- /** @brief sdbusplus signal match for Software.Version */
- sdbusplus::bus::match_t versionMatch;
+ /** @brief sdbusplus signal match for Software.Version */
+ sdbusplus::bus::match_t versionMatch;
- /** @brief This entry's associations */
- AssociationList assocs = {};
+ /** @brief This entry's associations */
+ AssociationList assocs = {};
- /** @brief Clears read only PNOR partition for
- * given Activation D-Bus object
- *
- * @param[in] versionId - The id of the ro partition to remove.
- */
- void removeReadOnlyPartition(std::string versionId);
+ /** @brief Clears read only PNOR partition for
+ * given Activation D-Bus object
+ *
+ * @param[in] versionId - The id of the ro partition to remove.
+ */
+ void removeReadOnlyPartition(std::string versionId);
- /** @brief Clears read write PNOR partition for
- * given Activation D-Bus object
- *
- * @param[in] versionId - The id of the rw partition to remove.
- */
- void removeReadWritePartition(std::string versionId);
+ /** @brief Clears read write PNOR partition for
+ * given Activation D-Bus object
+ *
+ * @param[in] versionId - The id of the rw partition to remove.
+ */
+ void removeReadWritePartition(std::string versionId);
- /** @brief Clears preserved PNOR partition */
- void removePreservedPartition();
+ /** @brief Clears preserved PNOR partition */
+ void removePreservedPartition();
- /** @brief Host factory reset - clears PNOR partitions for each
- * Activation D-Bus object */
- void reset() override;
+ /** @brief Host factory reset - clears PNOR partitions for each
+ * Activation D-Bus object */
+ void reset() override;
- /** @brief Check whether the host is running
- *
- * @return - Returns true if the Chassis is powered on.
- */
- bool isChassisOn();
+ /** @brief Check whether the host is running
+ *
+ * @return - Returns true if the Chassis is powered on.
+ */
+ bool isChassisOn();
};
} // namespace updater
diff --git a/item_updater_main.cpp b/item_updater_main.cpp
index 0933505..db7cae4 100755
--- a/item_updater_main.cpp
+++ b/item_updater_main.cpp
@@ -30,11 +30,9 @@
try
{
openpower::software::updater::Watch watch(
- loop,
- std::bind(std::mem_fn(
- &ItemUpdater::updateFunctionalAssociation),
- &updater,
- std::placeholders::_1));
+ loop,
+ std::bind(std::mem_fn(&ItemUpdater::updateFunctionalAssociation),
+ &updater, std::placeholders::_1));
bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
auto rc = sd_event_loop(loop);
if (rc < 0)
diff --git a/serialize.cpp b/serialize.cpp
index 595a970..d96bf0b 100644
--- a/serialize.cpp
+++ b/serialize.cpp
@@ -40,12 +40,9 @@
// lastly, store the priority as an environment variable pnor-[versionId]
std::string serviceFile = "obmc-flash-bmc-setenv@pnor\\x2d" + versionId +
- "\\x3d" + std::to_string(priority) + ".service";
- auto method = bus.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
+ "\\x3d" + std::to_string(priority) + ".service";
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
method.append(serviceFile, "replace");
bus.call_noreply(method);
}
@@ -107,7 +104,9 @@
}
}
}
- catch (const std::exception& e){}
+ catch (const std::exception& e)
+ {
+ }
return false;
}
@@ -117,13 +116,10 @@
auto bus = sdbusplus::bus::new_default();
// Clear the environment variable pnor-[versionId].
- std::string serviceFile = "obmc-flash-bmc-setenv@pnor\\x2d" + versionId +
- ".service";
- auto method = bus.new_method_call(
- SYSTEMD_BUSNAME,
- SYSTEMD_PATH,
- SYSTEMD_INTERFACE,
- "StartUnit");
+ std::string serviceFile =
+ "obmc-flash-bmc-setenv@pnor\\x2d" + versionId + ".service";
+ auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
+ SYSTEMD_INTERFACE, "StartUnit");
method.append(serviceFile, "replace");
bus.call_noreply(method);
diff --git a/test/utest.cpp b/test/utest.cpp
index 7ce738e..e27655a 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -14,10 +14,10 @@
SHA512_Init(&ctx);
SHA512_Update(&ctx, version, strlen(version));
SHA512_Final(digest, &ctx);
- char mdString[SHA512_DIGEST_LENGTH*2+1];
+ char mdString[SHA512_DIGEST_LENGTH * 2 + 1];
for (int i = 0; i < SHA512_DIGEST_LENGTH; i++)
{
- snprintf(&mdString[i*2], 3, "%02x", (unsigned int)digest[i]);
+ snprintf(&mdString[i * 2], 3, "%02x", (unsigned int)digest[i]);
}
std::string hexId = std::string(mdString);
hexId = hexId.substr(0, 8);
diff --git a/version.cpp b/version.cpp
index c8fe7cf..23f90f4 100644
--- a/version.cpp
+++ b/version.cpp
@@ -36,10 +36,10 @@
SHA512_Init(&ctx);
SHA512_Update(&ctx, version.c_str(), strlen(version.c_str()));
SHA512_Final(digest, &ctx);
- char mdString[SHA512_DIGEST_LENGTH*2+1];
+ char mdString[SHA512_DIGEST_LENGTH * 2 + 1];
for (int i = 0; i < SHA512_DIGEST_LENGTH; i++)
{
- snprintf(&mdString[i*2], 3, "%02x", (unsigned int)digest[i]);
+ snprintf(&mdString[i * 2], 3, "%02x", (unsigned int)digest[i]);
}
// Only need 8 hex digits.
@@ -47,8 +47,9 @@
return (hexId.substr(0, 8));
}
-std::map<std::string, std::string> Version::getValue(
- const std::string& filePath, std::map<std::string, std::string> keys)
+std::map<std::string, std::string>
+ Version::getValue(const std::string& filePath,
+ std::map<std::string, std::string> keys)
{
if (filePath.empty())
{
@@ -59,8 +60,7 @@
std::ifstream efile;
std::string line;
- efile.exceptions(std::ifstream::failbit |
- std::ifstream::badbit |
+ efile.exceptions(std::ifstream::failbit | std::ifstream::badbit |
std::ifstream::eofbit);
try
@@ -68,7 +68,7 @@
efile.open(filePath);
while (getline(efile, line))
{
- for(auto& key : keys)
+ for (auto& key : keys)
{
auto value = key.first + "=";
auto keySize = value.length();
diff --git a/version.hpp b/version.hpp
index 13b42ea..8a07ae0 100644
--- a/version.hpp
+++ b/version.hpp
@@ -18,10 +18,10 @@
typedef std::function<void(std::string)> eraseFunc;
using VersionInherit = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Software::server::Version,
- sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
+ sdbusplus::xyz::openbmc_project::Software::server::Version,
+ sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
using DeleteInherit = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Object::server::Delete>;
+ sdbusplus::xyz::openbmc_project::Object::server::Delete>;
namespace sdbusRule = sdbusplus::bus::match::rules;
@@ -32,51 +32,45 @@
* @brief OpenBMC Delete implementation.
* @details A concrete implementation for xyz.openbmc_project.Object.Delete
* D-Bus API.
-*/
+ */
class Delete : public DeleteInherit
{
- public:
- /** @brief Constructs Delete.
- *
- * @param[in] bus - The D-Bus bus object
- * @param[in] path - The D-Bus object path
- * @param[in] parent - Parent object.
- */
- Delete(sdbusplus::bus::bus& bus,
- const std::string& path,
- Version& parent) :
- DeleteInherit(bus, path.c_str(), true),
- parent(parent),
- bus(bus),
- path(path)
- {
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_added(path.c_str(), interfaces);
- }
+ public:
+ /** @brief Constructs Delete.
+ *
+ * @param[in] bus - The D-Bus bus object
+ * @param[in] path - The D-Bus object path
+ * @param[in] parent - Parent object.
+ */
+ Delete(sdbusplus::bus::bus& bus, const std::string& path, Version& parent) :
+ DeleteInherit(bus, path.c_str(), true), parent(parent), bus(bus),
+ path(path)
+ {
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_added(path.c_str(), interfaces);
+ }
- ~Delete()
- {
- std::vector<std::string> interfaces({interface});
- bus.emit_interfaces_removed(path.c_str(), interfaces);
- }
+ ~Delete()
+ {
+ std::vector<std::string> interfaces({interface});
+ bus.emit_interfaces_removed(path.c_str(), interfaces);
+ }
- /**
- * @brief Delete the D-Bus object.
- * Overrides the default delete function by calling
- * Version class erase Method.
- **/
- void delete_() override;
+ /**
+ * @brief Delete the D-Bus object.
+ * Overrides the default delete function by calling
+ * Version class erase Method.
+ **/
+ void delete_() override;
- private:
+ private:
+ /** @brief Parent Object. */
+ Version& parent;
- /** @brief Parent Object. */
- Version& parent;
-
- // TODO Remove once openbmc/openbmc#1975 is resolved
- static constexpr auto interface =
- "xyz.openbmc_project.Object.Delete";
- sdbusplus::bus::bus& bus;
- std::string path;
+ // TODO Remove once openbmc/openbmc#1975 is resolved
+ static constexpr auto interface = "xyz.openbmc_project.Object.Delete";
+ sdbusplus::bus::bus& bus;
+ std::string path;
};
/** @class Version
@@ -86,115 +80,106 @@
*/
class Version : public VersionInherit
{
- public:
- /** @brief Constructs Version Software Manager.
- *
- * @param[in] bus - The D-Bus bus object
- * @param[in] objPath - The D-Bus object path
- * @param[in] parent - Parent object.
- * @param[in] versionId - The version Id
- * @param[in] versionString - The version string
- * @param[in] versionPurpose - The version purpose
- * @param[in] filePath - The image filesystem path
- * @param[in] callback - The eraseFunc callback
- */
- Version(sdbusplus::bus::bus& bus,
- const std::string& objPath,
- ItemUpdater& parent,
- const std::string& versionId,
- const std::string& versionString,
- VersionPurpose versionPurpose,
- const std::string& filePath, eraseFunc callback) :
- VersionInherit(bus, (objPath).c_str(), true),
- bus(bus),
- objPath(objPath),
- parent(parent),
- versionId(versionId),
- versionStr(versionString),
- chassisStateSignals(
- bus,
- sdbusRule::type::signal() +
- sdbusRule::member("PropertiesChanged") +
- sdbusRule::path(CHASSIS_STATE_PATH) +
- sdbusRule::argN(0, CHASSIS_STATE_OBJ) +
- sdbusRule::interface(SYSTEMD_PROPERTY_INTERFACE),
- std::bind(std::mem_fn(
- &Version::updateDeleteInterface), this,
- std::placeholders::_1))
- {
- // Bind erase method
- eraseCallback = callback;
- // Set properties.
- purpose(versionPurpose);
- version(versionString);
- path(filePath);
+ public:
+ /** @brief Constructs Version Software Manager.
+ *
+ * @param[in] bus - The D-Bus bus object
+ * @param[in] objPath - The D-Bus object path
+ * @param[in] parent - Parent object.
+ * @param[in] versionId - The version Id
+ * @param[in] versionString - The version string
+ * @param[in] versionPurpose - The version purpose
+ * @param[in] filePath - The image filesystem path
+ * @param[in] callback - The eraseFunc callback
+ */
+ Version(sdbusplus::bus::bus& bus, const std::string& objPath,
+ ItemUpdater& parent, const std::string& versionId,
+ const std::string& versionString, VersionPurpose versionPurpose,
+ const std::string& filePath, eraseFunc callback) :
+ VersionInherit(bus, (objPath).c_str(), true),
+ bus(bus), objPath(objPath), parent(parent), versionId(versionId),
+ versionStr(versionString),
+ chassisStateSignals(
+ bus,
+ sdbusRule::type::signal() + sdbusRule::member("PropertiesChanged") +
+ sdbusRule::path(CHASSIS_STATE_PATH) +
+ sdbusRule::argN(0, CHASSIS_STATE_OBJ) +
+ sdbusRule::interface(SYSTEMD_PROPERTY_INTERFACE),
+ std::bind(std::mem_fn(&Version::updateDeleteInterface), this,
+ std::placeholders::_1))
+ {
+ // Bind erase method
+ eraseCallback = callback;
+ // Set properties.
+ purpose(versionPurpose);
+ version(versionString);
+ path(filePath);
- // Emit deferred signal.
- emit_object_added();
- }
+ // Emit deferred signal.
+ emit_object_added();
+ }
- /**
- * @brief Update the Object.Delete interface for this activation
- *
- * Update the delete interface based on whether or not this
- * activation is currently functional. A functional activation
- * will have no Object.Delete, while a non-functional activation
- * will have one.
- *
- * @param[in] msg - Data associated with subscribed signal
- */
- void updateDeleteInterface(sdbusplus::message::message& msg);
+ /**
+ * @brief Update the Object.Delete interface for this activation
+ *
+ * Update the delete interface based on whether or not this
+ * activation is currently functional. A functional activation
+ * will have no Object.Delete, while a non-functional activation
+ * will have one.
+ *
+ * @param[in] msg - Data associated with subscribed signal
+ */
+ void updateDeleteInterface(sdbusplus::message::message& msg);
- /**
- * @brief Read the manifest file to get the value of the key.
- *
- * @param[in] filePath - The path to the file which contains the value
- * of keys.
- * @param[in] keys - A map of keys with empty values.
- *
- * @return The map of keys with filled values.
- **/
- static std::map<std::string, std::string> getValue(
- const std::string& filePath,
- std::map<std::string, std::string> keys);
+ /**
+ * @brief Read the manifest file to get the value of the key.
+ *
+ * @param[in] filePath - The path to the file which contains the value
+ * of keys.
+ * @param[in] keys - A map of keys with empty values.
+ *
+ * @return The map of keys with filled values.
+ **/
+ static std::map<std::string, std::string>
+ getValue(const std::string& filePath,
+ std::map<std::string, std::string> keys);
- /**
- * @brief Calculate the version id from the version string.
- *
- * @details The version id is a unique 8 hexadecimal digit id
- * calculated from the version string.
- *
- * @param[in] version - The image version string (e.g. v1.99.10-19).
- *
- * @return The id.
- */
- static std::string getId(const std::string& version);
+ /**
+ * @brief Calculate the version id from the version string.
+ *
+ * @details The version id is a unique 8 hexadecimal digit id
+ * calculated from the version string.
+ *
+ * @param[in] version - The image version string (e.g. v1.99.10-19).
+ *
+ * @return The id.
+ */
+ static std::string getId(const std::string& version);
- /** @brief Persistent Delete D-Bus object */
- std::unique_ptr<Delete> deleteObject;
+ /** @brief Persistent Delete D-Bus object */
+ std::unique_ptr<Delete> deleteObject;
- /** @brief The parent's erase callback. */
- eraseFunc eraseCallback;
+ /** @brief The parent's erase callback. */
+ eraseFunc eraseCallback;
- private:
- /** @brief Persistent sdbusplus DBus bus connection */
- sdbusplus::bus::bus& bus;
+ private:
+ /** @brief Persistent sdbusplus DBus bus connection */
+ sdbusplus::bus::bus& bus;
- /** @brief Persistent DBus object path */
- std::string objPath;
+ /** @brief Persistent DBus object path */
+ std::string objPath;
- /** @brief Parent Object. */
- ItemUpdater& parent;
+ /** @brief Parent Object. */
+ ItemUpdater& parent;
- /** @brief This Version's version Id */
- const std::string versionId;
+ /** @brief This Version's version Id */
+ const std::string versionId;
- /** @brief This Version's version string */
- const std::string versionStr;
+ /** @brief This Version's version string */
+ const std::string versionStr;
- /** @brief Used to subscribe to chassis power state changes **/
- sdbusplus::bus::match_t chassisStateSignals;
-
+ /** @brief Used to subscribe to chassis power state changes **/
+ sdbusplus::bus::match_t chassisStateSignals;
};
} // namespace updater
diff --git a/watch.cpp b/watch.cpp
index e076450..9402057 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -23,8 +23,8 @@
Watch::Watch(sd_event* loop,
std::function<void(std::string&)> functionalCallback) :
- functionalCallback(functionalCallback),
- fd(inotifyInit())
+ functionalCallback(functionalCallback),
+ fd(inotifyInit())
{
// Create PNOR_ACTIVE_PATH if doesn't exist.
@@ -37,25 +37,18 @@
if (-1 == wd)
{
auto error = errno;
- throw std::system_error(error,
- std::generic_category(),
+ throw std::system_error(error, std::generic_category(),
"Error occurred during the inotify_init1");
}
decltype(eventSource.get()) sourcePtr = nullptr;
- auto rc = sd_event_add_io(loop,
- &sourcePtr,
- fd(),
- EPOLLIN,
- callback,
- this);
+ auto rc = sd_event_add_io(loop, &sourcePtr, fd(), EPOLLIN, callback, this);
eventSource.reset(sourcePtr);
if (0 > rc)
{
- throw std::system_error(-rc,
- std::generic_category(),
+ throw std::system_error(-rc, std::generic_category(),
"Error occurred during the inotify_init1");
}
}
@@ -68,9 +61,7 @@
}
}
-int Watch::callback(sd_event_source* s,
- int fd,
- uint32_t revents,
+int Watch::callback(sd_event_source* s, int fd, uint32_t revents,
void* userdata)
{
if (!(revents & EPOLLIN))
@@ -84,8 +75,7 @@
if (0 > bytes)
{
auto error = errno;
- throw std::system_error(error,
- std::generic_category(),
+ throw std::system_error(error, std::generic_category(),
"failed to read inotify event");
}
@@ -117,8 +107,7 @@
if (-1 == fd)
{
auto error = errno;
- throw std::system_error(error,
- std::generic_category(),
+ throw std::system_error(error, std::generic_category(),
"Error occurred during the inotify_init1");
}
diff --git a/watch.hpp b/watch.hpp
index bdea792..0ce5d0e 100644
--- a/watch.hpp
+++ b/watch.hpp
@@ -26,35 +26,37 @@
*/
struct CustomFd
{
- public:
- CustomFd() = delete;
- CustomFd(const CustomFd&) = delete;
- CustomFd& operator=(const CustomFd&) = delete;
- CustomFd(CustomFd&&) = delete;
- CustomFd& operator=(CustomFd&&) = delete;
+ public:
+ CustomFd() = delete;
+ CustomFd(const CustomFd&) = delete;
+ CustomFd& operator=(const CustomFd&) = delete;
+ CustomFd(CustomFd&&) = delete;
+ CustomFd& operator=(CustomFd&&) = delete;
- /** @brief Saves File descriptor and uses it to do file operation
- *
- * @param[in] fd - File descriptor
- */
- CustomFd(int fd) : fd(fd) {}
+ /** @brief Saves File descriptor and uses it to do file operation
+ *
+ * @param[in] fd - File descriptor
+ */
+ CustomFd(int fd) : fd(fd)
+ {
+ }
- ~CustomFd()
+ ~CustomFd()
+ {
+ if (fd >= 0)
{
- if (fd >= 0)
- {
- close(fd);
- }
+ close(fd);
}
+ }
- int operator()() const
- {
- return fd;
- }
+ int operator()() const
+ {
+ return fd;
+ }
- private:
- /** @brief File descriptor */
- int fd = -1;
+ private:
+ /** @brief File descriptor */
+ int fd = -1;
};
/** @class Watch
@@ -68,54 +70,51 @@
*/
class Watch
{
- public:
- /** @brief ctor - hook inotify watch with sd-event
- *
- * @param[in] loop - sd-event object
- * @param[in] functionalCallback - The callback function for updating
- * the functional associations.
- */
- Watch(sd_event* loop,
- std::function<void(std::string&)> functionalCallback);
+ public:
+ /** @brief ctor - hook inotify watch with sd-event
+ *
+ * @param[in] loop - sd-event object
+ * @param[in] functionalCallback - The callback function for updating
+ * the functional associations.
+ */
+ Watch(sd_event* loop, std::function<void(std::string&)> functionalCallback);
- Watch(const Watch&) = delete;
- Watch& operator=(const Watch&) = delete;
- Watch(Watch&&) = delete;
- Watch& operator=(Watch&&) = delete;
+ Watch(const Watch&) = delete;
+ Watch& operator=(const Watch&) = delete;
+ Watch(Watch&&) = delete;
+ Watch& operator=(Watch&&) = delete;
- /** @brief dtor - remove inotify watch
- */
- ~Watch();
+ /** @brief dtor - remove inotify watch
+ */
+ ~Watch();
- private:
- /** @brief sd-event callback
- *
- * @param[in] s - event source, floating (unused) in our case
- * @param[in] fd - inotify fd
- * @param[in] revents - events that matched for fd
- * @param[in] userdata - pointer to Watch object
- * @returns 0 on success, -1 on fail
- */
- static int callback(sd_event_source* s,
- int fd,
- uint32_t revents,
- void* userdata);
+ private:
+ /** @brief sd-event callback
+ *
+ * @param[in] s - event source, floating (unused) in our case
+ * @param[in] fd - inotify fd
+ * @param[in] revents - events that matched for fd
+ * @param[in] userdata - pointer to Watch object
+ * @returns 0 on success, -1 on fail
+ */
+ static int callback(sd_event_source* s, int fd, uint32_t revents,
+ void* userdata);
- /** initialize an inotify instance and returns file descriptor */
- int inotifyInit();
+ /** initialize an inotify instance and returns file descriptor */
+ int inotifyInit();
- /** @brief PNOR symlink file watch descriptor */
- int wd = -1;
+ /** @brief PNOR symlink file watch descriptor */
+ int wd = -1;
- /** @brief event source */
- EventSourcePtr eventSource;
+ /** @brief event source */
+ EventSourcePtr eventSource;
- /** @brief The callback function for updating the
- functional associations. */
- std::function<void(std::string&)> functionalCallback;
+ /** @brief The callback function for updating the
+ functional associations. */
+ std::function<void(std::string&)> functionalCallback;
- /** @brief inotify file descriptor */
- CustomFd fd;
+ /** @brief inotify file descriptor */
+ CustomFd fd;
};
} // namespace updater