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.
This commit is contained in:
Franck Bui
2017-09-13 11:59:46 +02:00
parent c43b2b9c71
commit 33e8d8af14
+10 -10
View 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);