shutdown: Move busy mounts to not block parent mounts
There is a case that confuses systemd-shutdown: a filesystem has been moved to a mount point which is part of another filesystem from an image from that former filesystem. systemd-shutdown cannot unmount any of those two filesystems. It needs first to move the filesystem containing the image of the other out of the tree of that image. Here we move leaf mount points when they are busy so that they do not block parent mounts. We can only move leafs at each iteration since moving mount points also move sub mount points which would invalidate we read from `/proc/self/mountinfo`.
This commit is contained in:
@@ -38,3 +38,22 @@ int libmount_parse(
|
||||
*ret_iter = TAKE_PTR(iter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int libmount_is_leaf(
|
||||
struct libmnt_table *table,
|
||||
struct libmnt_fs *fs) {
|
||||
int r;
|
||||
|
||||
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter_children = NULL;
|
||||
iter_children = mnt_new_iter(MNT_ITER_FORWARD);
|
||||
if (!iter_children)
|
||||
return log_oom();
|
||||
|
||||
/* We care only whether it exists, it is unused */
|
||||
_unused_ struct libmnt_fs *child;
|
||||
r = mnt_table_next_child_fs(table, iter_children, fs, &child);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return r == 1;
|
||||
}
|
||||
|
||||
@@ -14,3 +14,7 @@ int libmount_parse(
|
||||
FILE *source,
|
||||
struct libmnt_table **ret_table,
|
||||
struct libmnt_iter **ret_iter);
|
||||
|
||||
int libmount_is_leaf(
|
||||
struct libmnt_table *table,
|
||||
struct libmnt_fs *fs);
|
||||
|
||||
Reference in New Issue
Block a user