summaryrefslogtreecommitdiff
path: root/src/shutdown.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-10-14 02:33:09 +0200
committerLennart Poettering <lennart@poettering.net>2010-10-14 02:33:09 +0200
commitd48141ba0bed2866e05261cf06f0a6adfb11f349 (patch)
treef0e297a6283e367995dbf14a5939a4fbc3d2458b /src/shutdown.c
parent2ca1b422530e0e1c3d354b2e95a82723fe3f7702 (diff)
umount: try to get rid of DM devices
Diffstat (limited to 'src/shutdown.c')
-rw-r--r--src/shutdown.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/shutdown.c b/src/shutdown.c
index be3fff41c7..2c14371df2 100644
--- a/src/shutdown.c
+++ b/src/shutdown.c
@@ -200,7 +200,7 @@ finish:
int main(int argc, char *argv[]) {
int cmd, r, retries;
- bool need_umount = true, need_swapoff = true, need_loop_detach = true;
+ bool need_umount = true, need_swapoff = true, need_loop_detach = true, need_dm_detach = true;
log_parse_environment();
log_set_target(LOG_TARGET_CONSOLE); /* syslog will die if not gone yet */
@@ -248,7 +248,7 @@ int main(int argc, char *argv[]) {
/* Unmount all mountpoints, swaps, and loopback devices */
retries = FINALIZE_ATTEMPTS;
- while (need_umount || need_swapoff || need_loop_detach) {
+ for (;;) {
if (need_umount) {
log_info("Unmounting filesystems.");
r = umount_all();
@@ -280,10 +280,20 @@ int main(int argc, char *argv[]) {
log_warning("Not all loop devices detached, %d left.", r);
else
log_error("Error detaching loop devices: %s", strerror(-r));
+ }
+ if (need_dm_detach) {
+ log_info("Detaching DM devices.");
+ r = dm_detach_all();
+ if (r == 0)
+ need_dm_detach = false;
+ else if (r > 0)
+ log_warning("Not all dm devices detached, %d left.", r);
+ else
+ log_error("Error detaching dm devices: %s", strerror(-r));
}
- if (need_umount || need_swapoff || need_loop_detach) {
+ if (need_umount || need_swapoff || need_loop_detach || need_dm_detach) {
retries--;
if (retries == FINALIZE_CRITICAL_ATTEMPTS) {
@@ -295,11 +305,12 @@ int main(int argc, char *argv[]) {
if (retries > 0)
log_info("Action still required, %d tries left.", retries);
else {
- log_error("Giving up. Actions left: Umount=%s, Swap off=%s, Loop detach=%s",
- yes_no(need_umount), yes_no(need_swapoff), yes_no(need_loop_detach));
+ log_error("Giving up. Actions left: Umount=%s, Swap off=%s, Loop detach=%s, dm detach=%s",
+ yes_no(need_umount), yes_no(need_swapoff), yes_no(need_loop_detach), yes_no(need_dm_detach));
break;
}
- }
+ } else
+ break;
}
sync();