X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore%2Fswap.c;h=ba4413bd3ccc76659c9c7f0e9e49d043b1cea637;hb=c69182961b00707d977957cf81d5c41cfbeab429;hp=6331864d8ca5b3f00520729f222b522cadc1604b;hpb=5430f7f2bc7330f3088b894166bf3524a067e3d8;p=elogind.git diff --git a/src/core/swap.c b/src/core/swap.c index 6331864d8..ba4413bd3 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -38,6 +38,7 @@ #include "bus-errors.h" #include "exit-status.h" #include "def.h" +#include "path-util.h" static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = { [SWAP_DEAD] = UNIT_INACTIVE, @@ -182,7 +183,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) @@ -212,9 +212,9 @@ static int swap_add_device_links(Swap *s) { UNIT(s)->manager->running_as == MANAGER_SYSTEM); else /* File based swap devices need to be ordered after - * remount-rootfs.service, since they might need a + * systemd-remount-fs.service, since they might need a * writable file system. */ - return unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_REMOUNT_ROOTFS_SERVICE, NULL, true); + return unit_add_dependency_by_name(UNIT(s), UNIT_AFTER, SPECIAL_REMOUNT_FS_SERVICE, NULL, true); } static int swap_add_default_dependencies(Swap *s) { @@ -322,7 +322,6 @@ int swap_add_one( int priority, bool noauto, bool nofail, - bool handle, bool set_flags) { Unit *u = NULL; @@ -420,7 +419,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 +455,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 +474,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 +577,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 +586,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 +620,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 +691,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, false, 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 +1323,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, false, pid_set, NULL); + if (q < 0) if (q != -EAGAIN && q != -ESRCH && q != -ENOENT) r = q; } @@ -1375,7 +1378,6 @@ const UnitVTable swap_vtable = { .no_alias = true, .no_instances = true, - .show_status = true, .init = swap_init, .load = swap_load, @@ -1411,5 +1413,23 @@ const UnitVTable swap_vtable = { .following_set = swap_following_set, .enumerate = swap_enumerate, - .shutdown = swap_shutdown + .shutdown = swap_shutdown, + + .status_message_formats = { + .starting_stopping = { + [0] = "Activating swap %s...", + [1] = "Deactivating swap %s...", + }, + .finished_start_job = { + [JOB_DONE] = "Activated swap %s.", + [JOB_FAILED] = "Failed to activate swap %s.", + [JOB_DEPENDENCY] = "Dependency failed for %s.", + [JOB_TIMEOUT] = "Timed out activating swap %s.", + }, + .finished_stop_job = { + [JOB_DONE] = "Deactivated swap %s.", + [JOB_FAILED] = "Failed deactivating swap %s.", + [JOB_TIMEOUT] = "Timed out deactivating swap %s.", + }, + }, };