From: Franck Bui Date: Wed, 13 Sep 2017 09:04:17 +0000 (+0200) Subject: shutdown: don't be fooled when detaching DM devices with BTRFS X-Git-Tag: v235~125^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6811%2Fhead;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/core/umount.c b/src/core/umount.c index 75f9779edcb..7e9ea203881 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);