Loading .clang-format +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ AllowShortIfStatementsOnASingleLine: true ColumnLimit: 100 CommentPragmas: NOLINT:.* DerivePointerAlignment: false IncludeBlocks: Preserve IndentWidth: 2 PointerAlignment: Left TabWidth: 2 Loading edify/include/edify/updater_runtime_interface.h +3 −0 Original line number Diff line number Diff line Loading @@ -71,4 +71,7 @@ class UpdaterRuntimeInterface { virtual bool MapPartitionOnDeviceMapper(const std::string& partition_name, std::string* path) = 0; virtual bool UnmapPartitionOnDeviceMapper(const std::string& partition_name) = 0; virtual bool UpdateDynamicPartitions(const std::string_view op_list_value) = 0; // On devices supports A/B, add current slot suffix to arg. Otherwise, return |arg| as is. virtual std::string AddSlotSuffix(const std::string_view arg) const = 0; }; updater/include/updater/simulator_runtime.h +1 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ class SimulatorRuntime : public UpdaterRuntimeInterface { bool MapPartitionOnDeviceMapper(const std::string& partition_name, std::string* path) override; bool UnmapPartitionOnDeviceMapper(const std::string& partition_name) override; bool UpdateDynamicPartitions(const std::string_view op_list_value) override; std::string AddSlotSuffix(const std::string_view arg) const override; private: std::string FindBlockDeviceName(const std::string_view name) const override; Loading updater/include/updater/updater_runtime.h +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ class UpdaterRuntime : public UpdaterRuntimeInterface { bool MapPartitionOnDeviceMapper(const std::string& partition_name, std::string* path) override; bool UnmapPartitionOnDeviceMapper(const std::string& partition_name) override; bool UpdateDynamicPartitions(const std::string_view op_list_value) override; std::string AddSlotSuffix(const std::string_view arg) const override; private: struct selabel_handle* sehandle_{ nullptr }; Loading updater/install.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -852,6 +852,20 @@ Value* Tune2FsFn(const char* name, State* state, const std::vector<std::unique_p return StringValue("t"); } Value* AddSlotSuffixFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { if (argv.size() != 1) { return ErrorAbort(state, kArgsParsingFailure, "%s() expects 1 arg, got %zu", name, argv.size()); } std::vector<std::string> args; if (!ReadArgs(state, argv, &args)) { return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name); } const std::string& arg = args[0]; auto updater_runtime = state->updater->GetRuntime(); return StringValue(updater_runtime->AddSlotSuffix(arg)); } void RegisterInstallFunctions() { RegisterFunction("mount", MountFn); RegisterFunction("is_mounted", IsMountedFn); Loading Loading @@ -885,4 +899,6 @@ void RegisterInstallFunctions() { RegisterFunction("enable_reboot", EnableRebootFn); RegisterFunction("tune2fs", Tune2FsFn); RegisterFunction("add_slot_suffix", AddSlotSuffixFn); } Loading
.clang-format +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ AllowShortIfStatementsOnASingleLine: true ColumnLimit: 100 CommentPragmas: NOLINT:.* DerivePointerAlignment: false IncludeBlocks: Preserve IndentWidth: 2 PointerAlignment: Left TabWidth: 2 Loading
edify/include/edify/updater_runtime_interface.h +3 −0 Original line number Diff line number Diff line Loading @@ -71,4 +71,7 @@ class UpdaterRuntimeInterface { virtual bool MapPartitionOnDeviceMapper(const std::string& partition_name, std::string* path) = 0; virtual bool UnmapPartitionOnDeviceMapper(const std::string& partition_name) = 0; virtual bool UpdateDynamicPartitions(const std::string_view op_list_value) = 0; // On devices supports A/B, add current slot suffix to arg. Otherwise, return |arg| as is. virtual std::string AddSlotSuffix(const std::string_view arg) const = 0; };
updater/include/updater/simulator_runtime.h +1 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ class SimulatorRuntime : public UpdaterRuntimeInterface { bool MapPartitionOnDeviceMapper(const std::string& partition_name, std::string* path) override; bool UnmapPartitionOnDeviceMapper(const std::string& partition_name) override; bool UpdateDynamicPartitions(const std::string_view op_list_value) override; std::string AddSlotSuffix(const std::string_view arg) const override; private: std::string FindBlockDeviceName(const std::string_view name) const override; Loading
updater/include/updater/updater_runtime.h +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ class UpdaterRuntime : public UpdaterRuntimeInterface { bool MapPartitionOnDeviceMapper(const std::string& partition_name, std::string* path) override; bool UnmapPartitionOnDeviceMapper(const std::string& partition_name) override; bool UpdateDynamicPartitions(const std::string_view op_list_value) override; std::string AddSlotSuffix(const std::string_view arg) const override; private: struct selabel_handle* sehandle_{ nullptr }; Loading
updater/install.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -852,6 +852,20 @@ Value* Tune2FsFn(const char* name, State* state, const std::vector<std::unique_p return StringValue("t"); } Value* AddSlotSuffixFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { if (argv.size() != 1) { return ErrorAbort(state, kArgsParsingFailure, "%s() expects 1 arg, got %zu", name, argv.size()); } std::vector<std::string> args; if (!ReadArgs(state, argv, &args)) { return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name); } const std::string& arg = args[0]; auto updater_runtime = state->updater->GetRuntime(); return StringValue(updater_runtime->AddSlotSuffix(arg)); } void RegisterInstallFunctions() { RegisterFunction("mount", MountFn); RegisterFunction("is_mounted", IsMountedFn); Loading Loading @@ -885,4 +899,6 @@ void RegisterInstallFunctions() { RegisterFunction("enable_reboot", EnableRebootFn); RegisterFunction("tune2fs", Tune2FsFn); RegisterFunction("add_slot_suffix", AddSlotSuffixFn); }