summaryrefslogtreecommitdiff
path: root/src/shutdown/umount.c
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2022-06-09 16:50:54 +0200
committerJan Janssen <medhefgo@web.de>2022-06-09 16:50:54 +0200
commit5125b67742567de79c12e31f434a11d787b4f6b1 (patch)
tree0adb540fb464fcf423b703d2ff2fef0309031a30 /src/shutdown/umount.c
parent2299b1cae32c1fb8911da0ce26efced68032f4f8 (diff)
downloadsystemd-5125b67742567de79c12e31f434a11d787b4f6b1.tar.gz
shutdown: Rename umount_log_level and make it a bool
This was already effectively a bool because only ever two states were valid. To make the meaning of it more clear, also rename it to last_try.
Diffstat (limited to 'src/shutdown/umount.c')
-rw-r--r--src/shutdown/umount.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c
index 820aa8e286..fc09fde668 100644
--- a/src/shutdown/umount.c
+++ b/src/shutdown/umount.c
@@ -524,7 +524,7 @@ static bool nonunmountable_path(const char *path) {
|| path_startswith(path, "/run/initramfs");
}
-static int remount_with_timeout(MountPoint *m, int umount_log_level) {
+static int remount_with_timeout(MountPoint *m, bool last_try) {
pid_t pid;
int r;
@@ -543,7 +543,10 @@ static int remount_with_timeout(MountPoint *m, int umount_log_level) {
/* Start the mount operation here in the child */
r = mount(NULL, m->path, NULL, m->remount_flags, m->remount_options);
if (r < 0)
- log_full_errno(umount_log_level, errno, "Failed to remount '%s' read-only: %m", m->path);
+ log_full_errno(last_try ? LOG_ERR : LOG_INFO,
+ errno,
+ "Failed to remount '%s' read-only: %m",
+ m->path);
_exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -560,7 +563,7 @@ static int remount_with_timeout(MountPoint *m, int umount_log_level) {
return r;
}
-static int umount_with_timeout(MountPoint *m, int umount_log_level) {
+static int umount_with_timeout(MountPoint *m, bool last_try) {
pid_t pid;
int r;
@@ -585,7 +588,7 @@ static int umount_with_timeout(MountPoint *m, int umount_log_level) {
* than return EBUSY). */
r = umount2(m->path, MNT_FORCE);
if (r < 0)
- log_full_errno(umount_log_level, errno, "Failed to unmount %s: %m", m->path);
+ log_full_errno(last_try ? LOG_ERR : LOG_INFO, errno, "Failed to unmount %s: %m", m->path);
_exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -604,7 +607,7 @@ static int umount_with_timeout(MountPoint *m, int umount_log_level) {
/* This includes remounting readonly, which changes the kernel mount options. Therefore the list passed to
* this function is invalidated, and should not be reused. */
-static int mount_points_list_umount(MountPoint **head, bool *changed, int umount_log_level) {
+static int mount_points_list_umount(MountPoint **head, bool *changed, bool last_try) {
int n_failed = 0;
assert(head);
@@ -624,7 +627,7 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, int umount
*
* Since the remount can hang in the instance of remote filesystems, we remount
* asynchronously and skip the subsequent umount if it fails. */
- if (remount_with_timeout(m, umount_log_level) < 0) {
+ if (remount_with_timeout(m, last_try) < 0) {
/* Remount failed, but try unmounting anyway,
* unless this is a mount point we want to skip. */
if (nonunmountable_path(m->path)) {
@@ -640,7 +643,7 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, int umount
continue;
/* Trying to umount */
- if (umount_with_timeout(m, umount_log_level) < 0)
+ if (umount_with_timeout(m, last_try) < 0)
n_failed++;
else
*changed = true;
@@ -670,7 +673,7 @@ static int swap_points_list_off(MountPoint **head, bool *changed) {
return n_failed;
}
-static int loopback_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
+static int loopback_points_list_detach(MountPoint **head, bool *changed, bool last_try) {
int n_failed = 0, r;
dev_t rootdev = 0;
@@ -688,7 +691,7 @@ 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) {
- log_full_errno(umount_log_level, r, "Could not detach loopback %s: %m", m->path);
+ log_full_errno(last_try ? LOG_ERR : LOG_INFO, r, "Could not detach loopback %s: %m", m->path);
n_failed++;
continue;
}
@@ -701,7 +704,7 @@ static int loopback_points_list_detach(MountPoint **head, bool *changed, int umo
return n_failed;
}
-static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
+static int dm_points_list_detach(MountPoint **head, bool *changed, bool last_try) {
int n_failed = 0, r;
dev_t rootdev = 0;
@@ -719,7 +722,7 @@ static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_lo
log_info("Detaching DM %s (%u:%u).", m->path, major(m->devnum), minor(m->devnum));
r = delete_dm(m);
if (r < 0) {
- log_full_errno(umount_log_level, r, "Could not detach DM %s: %m", m->path);
+ log_full_errno(last_try ? LOG_ERR : LOG_INFO, r, "Could not detach DM %s: %m", m->path);
n_failed++;
continue;
}
@@ -731,7 +734,7 @@ static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_lo
return n_failed;
}
-static int md_points_list_detach(MountPoint **head, bool *changed, int umount_log_level) {
+static int md_points_list_detach(MountPoint **head, bool *changed, bool last_try) {
int n_failed = 0, r;
dev_t rootdev = 0;
@@ -749,7 +752,7 @@ static int md_points_list_detach(MountPoint **head, bool *changed, int umount_lo
log_info("Stopping MD %s (%u:%u).", m->path, major(m->devnum), minor(m->devnum));
r = delete_md(m);
if (r < 0) {
- log_full_errno(umount_log_level, r, "Could not stop MD %s: %m", m->path);
+ log_full_errno(last_try ? LOG_ERR : LOG_INFO, r, "Could not stop MD %s: %m", m->path);
n_failed++;
continue;
}
@@ -761,7 +764,7 @@ static int md_points_list_detach(MountPoint **head, bool *changed, int umount_lo
return n_failed;
}
-static int umount_all_once(bool *changed, int umount_log_level) {
+static int umount_all_once(bool *changed, bool last_try) {
_cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head);
int r;
@@ -772,10 +775,10 @@ static int umount_all_once(bool *changed, int umount_log_level) {
if (r < 0)
return r;
- return mount_points_list_umount(&mp_list_head, changed, umount_log_level);
+ return mount_points_list_umount(&mp_list_head, changed, last_try);
}
-int umount_all(bool *changed, int umount_log_level) {
+int umount_all(bool *changed, bool last_try) {
bool umount_changed;
int r;
@@ -787,7 +790,7 @@ int umount_all(bool *changed, int umount_log_level) {
do {
umount_changed = false;
- r = umount_all_once(&umount_changed, umount_log_level);
+ r = umount_all_once(&umount_changed, last_try);
if (umount_changed)
*changed = true;
} while (umount_changed);
@@ -810,7 +813,7 @@ int swapoff_all(bool *changed) {
return swap_points_list_off(&swap_list_head, changed);
}
-int loopback_detach_all(bool *changed, int umount_log_level) {
+int loopback_detach_all(bool *changed, bool last_try) {
_cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, loopback_list_head);
int r;
@@ -822,10 +825,10 @@ int loopback_detach_all(bool *changed, int umount_log_level) {
if (r < 0)
return r;
- return loopback_points_list_detach(&loopback_list_head, changed, umount_log_level);
+ return loopback_points_list_detach(&loopback_list_head, changed, last_try);
}
-int dm_detach_all(bool *changed, int umount_log_level) {
+int dm_detach_all(bool *changed, bool last_try) {
_cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, dm_list_head);
int r;
@@ -837,10 +840,10 @@ int dm_detach_all(bool *changed, int umount_log_level) {
if (r < 0)
return r;
- return dm_points_list_detach(&dm_list_head, changed, umount_log_level);
+ return dm_points_list_detach(&dm_list_head, changed, last_try);
}
-int md_detach_all(bool *changed, int umount_log_level) {
+int md_detach_all(bool *changed, bool last_try) {
_cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, md_list_head);
int r;
@@ -852,5 +855,5 @@ int md_detach_all(bool *changed, int umount_log_level) {
if (r < 0)
return r;
- return md_points_list_detach(&md_list_head, changed, umount_log_level);
+ return md_points_list_detach(&md_list_head, changed, last_try);
}