From: Daan De Meyer Date: Thu, 19 Oct 2023 14:41:52 +0000 (+0200) Subject: swap: Move two functions to swap.h X-Git-Tag: v255-rc1~182^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f57cc32fa1c74c1eaecc52a085133a38952a255f;p=thirdparty%2Fsystemd.git swap: Move two functions to swap.h --- diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c index 443f84aab40..7230352e9cb 100644 --- a/src/core/dbus-swap.c +++ b/src/core/dbus-swap.c @@ -11,27 +11,6 @@ #include "swap.h" #include "unit.h" -static int swap_get_priority(Swap *s) { - assert(s); - - if (s->from_proc_swaps && s->parameters_proc_swaps.priority_set) - return s->parameters_proc_swaps.priority; - - if (s->from_fragment && s->parameters_fragment.priority_set) - return s->parameters_fragment.priority; - - return -1; -} - -static const char *swap_get_options(Swap *s) { - assert(s); - - if (s->from_fragment) - return s->parameters_fragment.options; - - return NULL; -} - static BUS_DEFINE_PROPERTY_GET(property_get_priority, "i", Swap, swap_get_priority); static BUS_DEFINE_PROPERTY_GET(property_get_options, "s", Swap, swap_get_options); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, swap_result, SwapResult); diff --git a/src/core/swap.c b/src/core/swap.c index d0aae9a5343..3a9f0e798dd 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -1559,6 +1559,27 @@ static int swap_can_start(Unit *u) { return 1; } +int swap_get_priority(const Swap *s) { + assert(s); + + if (s->from_proc_swaps && s->parameters_proc_swaps.priority_set) + return s->parameters_proc_swaps.priority; + + if (s->from_fragment && s->parameters_fragment.priority_set) + return s->parameters_fragment.priority; + + return -1; +} + +const char* swap_get_options(const Swap *s) { + assert(s); + + if (s->from_fragment) + return s->parameters_fragment.options; + + return NULL; +} + static const char* const swap_exec_command_table[_SWAP_EXEC_COMMAND_MAX] = { [SWAP_EXEC_ACTIVATE] = "ExecActivate", [SWAP_EXEC_DEACTIVATE] = "ExecDeactivate", diff --git a/src/core/swap.h b/src/core/swap.h index f2cae6766b8..ef20f0f7647 100644 --- a/src/core/swap.h +++ b/src/core/swap.h @@ -91,6 +91,9 @@ extern const UnitVTable swap_vtable; int swap_process_device_new(Manager *m, sd_device *dev); int swap_process_device_remove(Manager *m, sd_device *dev); +int swap_get_priority(const Swap *s); +const char* swap_get_options(const Swap *s); + const char* swap_exec_command_to_string(SwapExecCommand i) _const_; SwapExecCommand swap_exec_command_from_string(const char *s) _pure_;