]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shutdown: don't be fooled when detaching DM devices with BTRFS 6811/head
authorFranck Bui <fbui@suse.com>
Wed, 13 Sep 2017 09:04:17 +0000 (11:04 +0200)
committerFranck Bui <fbui@suse.com>
Wed, 13 Sep 2017 09:59:46 +0000 (11:59 +0200)
Otherwise we would try to detach the DM device hosting the rootfs with BTRFS
which is doomed to fail.

src/core/umount.c

index 75f9779edcbd447f7c67f9cf8e110038c025c6db..7e9ea2038816cdd3b71ba6964e86ea95ea5d1862 100644 (file)
@@ -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);