chiark / gitweb /
service: introduce Type=idle and use it for gettys
[elogind.git] / src / core / swap.c
index 9c72732b9470bfb2f482f7f1a25ad0148b9a565f..fea3f6887a882977b5fba6c58cfcd4fb3c7227e8 100644 (file)
@@ -6,16 +6,16 @@
   Copyright 2010 Lennart Poettering
 
   systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
   (at your option) any later version.
 
   systemd is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
+  Lesser General Public License for more details.
 
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
@@ -182,7 +182,6 @@ static int swap_add_target_links(Swap *s) {
 
         if (!p->noauto &&
             !p->nofail &&
-            (p->handle || UNIT(s)->manager->swap_auto) &&
             s->from_etc_fstab &&
             UNIT(s)->manager->running_as == MANAGER_SYSTEM)
                 if ((r = unit_add_dependency(tu, UNIT_WANTS, UNIT(s), true)) < 0)
@@ -322,7 +321,6 @@ int swap_add_one(
                 int priority,
                 bool noauto,
                 bool nofail,
-                bool handle,
                 bool set_flags) {
 
         Unit *u = NULL;
@@ -420,7 +418,6 @@ int swap_add_one(
         p->priority = priority;
         p->noauto = noauto;
         p->nofail = nofail;
-        p->handle = handle;
 
         unit_add_to_dbus_queue(u);
 
@@ -457,8 +454,9 @@ static int swap_process_new_swap(Manager *m, const char *device, int prio, bool
                 if (!(d = udev_device_new_from_devnum(m->udev, 'b', st.st_rdev)))
                         return -ENOMEM;
 
-                if ((dn = udev_device_get_devnode(d)))
-                        r = swap_add_one(m, dn, device, prio, false, false, false, set_flags);
+                dn = udev_device_get_devnode(d);
+                if (dn)
+                        r = swap_add_one(m, dn, device, prio, false, false, set_flags);
 
                 /* Add additional units for all symlinks */
                 first = udev_device_get_devlinks_list_entry(d);
@@ -475,14 +473,16 @@ static int swap_process_new_swap(Manager *m, const char *device, int prio, bool
                                 if ((!S_ISBLK(st.st_mode)) || st.st_rdev != udev_device_get_devnum(d))
                                         continue;
 
-                        if ((k = swap_add_one(m, p, device, prio, false, false, false, set_flags)) < 0)
+                        k = swap_add_one(m, p, device, prio, false, false, set_flags);
+                        if (k < 0)
                                 r = k;
                 }
 
                 udev_device_unref(d);
         }
 
-        if ((k = swap_add_one(m, device, device, prio, false, false, false, set_flags)) < 0)
+        k = swap_add_one(m, device, device, prio, false, false, set_flags);
+        if (k < 0)
                 r = k;
 
         return r;
@@ -576,7 +576,6 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
                 "%sPriority: %i\n"
                 "%sNoAuto: %s\n"
                 "%sNoFail: %s\n"
-                "%sHandle: %s\n"
                 "%sFrom /etc/fstab: %s\n"
                 "%sFrom /proc/swaps: %s\n"
                 "%sFrom fragment: %s\n",
@@ -586,7 +585,6 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
                 prefix, p->priority,
                 prefix, yes_no(p->noauto),
                 prefix, yes_no(p->nofail),
-                prefix, yes_no(p->handle),
                 prefix, yes_no(s->from_etc_fstab),
                 prefix, yes_no(s->from_proc_swaps),
                 prefix, yes_no(s->from_fragment));
@@ -621,6 +619,8 @@ static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) {
                             UNIT(s)->manager->confirm_spawn,
                             UNIT(s)->cgroup_bondings,
                             UNIT(s)->cgroup_attributes,
+                            NULL,
+                            NULL,
                             &pid)) < 0)
                 goto fail;
 
@@ -690,7 +690,8 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
                                 if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
                                         goto fail;
 
-                        if ((r = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, sig, true, pid_set)) < 0) {
+                        r = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, sig, true, pid_set, NULL);
+                        if (r < 0) {
                                 if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
                                         log_warning("Failed to kill control group: %s", strerror(-r));
                         } else if (r > 0)
@@ -1321,7 +1322,8 @@ static int swap_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *
                                 goto finish;
                         }
 
-                if ((q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, pid_set)) < 0)
+                q = cgroup_bonding_kill_list(UNIT(s)->cgroup_bondings, signo, false, pid_set, NULL);
+                if (q < 0)
                         if (q != -EAGAIN && q != -ESRCH && q != -ENOENT)
                                 r = q;
         }