diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-12-20 16:59:42 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-12-20 18:15:59 +0100 |
commit | 88287615e631d2023ff337a08b6ff45b1cfa58ee (patch) | |
tree | ad9e9738c72a0985d1afea44d7d46397c369d73e /src/shutdown/umount.c | |
parent | 610f9a42c4a8c34d9b3a2b6c6289e8c45b57283f (diff) | |
download | systemd-88287615e631d2023ff337a08b6ff45b1cfa58ee.tar.gz |
umount: show correct error message
We fucked up errno vs. r two times, let's correct that.
While we are at it, let's handle the error first, like we usually do,
and the clean case without indentation.
Diffstat (limited to 'src/shutdown/umount.c')
-rw-r--r-- | src/shutdown/umount.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c index 0b8044dacb..51ed05cb6a 100644 --- a/src/shutdown/umount.c +++ b/src/shutdown/umount.c @@ -515,13 +515,14 @@ static int swap_points_list_off(MountPoint **head, bool *changed) { LIST_FOREACH_SAFE(mount_point, m, n, *head) { log_info("Deactivating swap %s.", m->path); - if (swapoff(m->path) == 0) { - *changed = true; - mount_point_free(head, m); - } else { + if (swapoff(m->path) < 0) { log_warning_errno(errno, "Could not deactivate swap %s: %m", m->path); n_failed++; + continue; } + + *changed = true; + mount_point_free(head, m); } return n_failed; @@ -551,15 +552,15 @@ static int loopback_points_list_detach(MountPoint **head, bool *changed, int umo log_info("Detaching loopback %s.", m->path); r = delete_loopback(m->path); - if (r >= 0) { - if (r > 0) - *changed = true; - - mount_point_free(head, m); - } else { - log_full_errno(umount_log_level, errno, "Could not detach loopback %s: %m", m->path); + if (r < 0) { + log_full_errno(umount_log_level, r, "Could not detach loopback %s: %m", m->path); n_failed++; + continue; } + if (r > 0) + *changed = true; + + mount_point_free(head, m); } return n_failed; @@ -584,23 +585,24 @@ static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_lo continue; } - log_info("Detaching DM %u:%u.", major(m->devnum), minor(m->devnum)); + log_info("Detaching DM %s (%u:%u).", m->path, major(m->devnum), minor(m->devnum)); r = delete_dm(m->devnum); - if (r >= 0) { - *changed = true; - mount_point_free(head, m); - } else { - log_full_errno(umount_log_level, errno, "Could not detach DM %s: %m", m->path); + if (r < 0) { + log_full_errno(umount_log_level, r, "Could not detach DM %s: %m", m->path); n_failed++; + continue; } + + *changed = true; + mount_point_free(head, m); } return n_failed; } static int umount_all_once(bool *changed, int umount_log_level) { - int r; _cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head); + int r; assert(changed); |