diff options
Diffstat (limited to 'src/swap.c')
-rw-r--r-- | src/swap.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/swap.c b/src/swap.c index de468a0434..6765a4ae30 100644 --- a/src/swap.c +++ b/src/swap.c @@ -542,14 +542,6 @@ static void swap_shutdown(Manager *m) { } } -static const char* const swap_state_table[_SWAP_STATE_MAX] = { - [SWAP_DEAD] = "dead", - [SWAP_ACTIVE] = "active", - [SWAP_MAINTENANCE] = "maintenance" -}; - -DEFINE_STRING_TABLE_LOOKUP(swap_state, SwapState); - static int swap_enumerate(Manager *m) { int r; assert(m); @@ -564,6 +556,23 @@ static int swap_enumerate(Manager *m) { return r; } +static void swap_reset_maintenance(Unit *u) { + Swap *s = SWAP(u); + + assert(s); + + if (s->state == SWAP_MAINTENANCE) + swap_set_state(s, SWAP_DEAD); +} + +static const char* const swap_state_table[_SWAP_STATE_MAX] = { + [SWAP_DEAD] = "dead", + [SWAP_ACTIVE] = "active", + [SWAP_MAINTENANCE] = "maintenance" +}; + +DEFINE_STRING_TABLE_LOOKUP(swap_state, SwapState); + const UnitVTable swap_vtable = { .suffix = ".swap", @@ -592,6 +601,8 @@ const UnitVTable swap_vtable = { .bus_message_handler = bus_swap_message_handler, + .reset_maintenance = swap_reset_maintenance, + .enumerate = swap_enumerate, .shutdown = swap_shutdown }; |