chiark / gitweb /
systemctl: rename a few status lines
[elogind.git] / src / swap.c
index de468a0434ee0e0e4dfcaace2ff6cfa8111168ee..4a672fbdffe047560ab2430bfc620ce973c28f4e 100644 (file)
@@ -1,4 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
 /***
   This file is part of systemd.
@@ -195,7 +195,9 @@ static int swap_load(Unit *u) {
                         if ((r = unit_set_description(u, s->what)) < 0)
                                 return r;
 
-                if ((r = unit_add_node_link(u, s->what, u->meta.manager->running_as == MANAGER_SYSTEM)) < 0)
+                if ((r = unit_add_node_link(u, s->what,
+                                            u->meta.manager->running_as == MANAGER_SYSTEM &&
+                                            u->meta.manager->swap_on_plug)) < 0)
                         return r;
 
                 if ((r = swap_add_mount_links(s)) < 0)
@@ -400,7 +402,7 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
 static void swap_enter_dead(Swap *s, bool success) {
         assert(s);
 
-        swap_set_state(s, success ? SWAP_MAINTENANCE : SWAP_DEAD);
+        swap_set_state(s, success ? SWAP_DEAD : SWAP_MAINTENANCE);
 }
 
 static int swap_start(Unit *u) {
@@ -542,14 +544,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 +558,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",
 
@@ -590,7 +601,11 @@ const UnitVTable swap_vtable = {
 
         .check_gc = swap_check_gc,
 
+        .bus_interface = "org.freedesktop.systemd1.Swap",
         .bus_message_handler = bus_swap_message_handler,
+        .bus_invalidating_properties =  bus_swap_invalidating_properties,
+
+        .reset_maintenance = swap_reset_maintenance,
 
         .enumerate = swap_enumerate,
         .shutdown = swap_shutdown