From 33e8d8af1482fd94edf8a41462012468ba852687 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Wed, 13 Sep 2017 11:04:17 +0200 Subject: [PATCH] shutdown: don't be fooled when detaching DM devices with BTRFS Otherwise we would try to detach the DM device hosting the rootfs with BTRFS which is doomed to fail. --- src/core/umount.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/umount.c b/src/core/umount.c index 75f9779..7e9ea20 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -517,22 +517,22 @@ static int loopback_points_list_detach(MountPoint **head, bool *changed) { static int dm_points_list_detach(MountPoint **head, bool *changed) { MountPoint *m, *n; - int n_failed = 0, k; - struct stat root_st; + int n_failed = 0, r; + dev_t rootdev; assert(head); - k = lstat("/", &root_st); + r = get_block_device("/", &rootdev); + if (r <= 0) + rootdev = 0; LIST_FOREACH_SAFE(mount_point, m, n, *head) { - int r; - if (k >= 0 && - major(root_st.st_dev) != 0 && - root_st.st_dev == m->devnum) { - n_failed++; - continue; - } + if (major(rootdev) != 0) + if (rootdev == m->devnum) { + n_failed ++; + continue; + } log_info("Detaching DM %u:%u.", major(m->devnum), minor(m->devnum)); r = delete_dm(m->devnum); -- 2.7.4