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.
This commit is contained in:
Lennart Poettering 2019-12-20 16:59:42 +01:00
parent 610f9a42c4
commit 88287615e6

View file

@ -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);