loop-util: move device_has_block_children() to blockdev-util.c

As the function is not only for loopback block device.

No actual code changes, just refactoring.
This commit is contained in:
Yu Watanabe
2022-09-07 20:45:24 +09:00
parent af15ee0368
commit aa0295f1d9
3 changed files with 17 additions and 48 deletions
+15
View File
@@ -621,3 +621,18 @@ int block_device_remove_all_partitions(sd_device *dev, int fd) {
return k;
}
int block_device_has_partitions(sd_device *dev) {
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
int r;
assert(dev);
/* Checks if the specified device currently has partitions. */
r = partition_enumerator_new(dev, &e);
if (r < 0)
return r;
return !!sd_device_enumerator_get_device_first(e);
}