summaryrefslogtreecommitdiffstats
path: root/src/shared/loop-util.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/shared/loop-util.c35
1 files changed, 7 insertions, 28 deletions
diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c
index a5ad914577..fa71086741 100644
--- a/src/shared/loop-util.c
+++ b/src/shared/loop-util.c
@@ -73,7 +73,6 @@ static int get_current_uevent_seqnum(uint64_t *ret) {
static int device_has_block_children(sd_device *d) {
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
const char *main_ss, *main_dt;
- sd_device *q;
int r;
assert(d);
@@ -107,35 +106,15 @@ static int device_has_block_children(sd_device *d) {
if (r < 0)
return r;
- FOREACH_DEVICE(e, q) {
- const char *ss, *dt;
-
- r = sd_device_get_subsystem(q, &ss);
- if (r < 0) {
- log_device_debug_errno(q, r, "Failed to get subsystem of child, ignoring: %m");
- continue;
- }
-
- if (!streq(ss, "block")) {
- log_device_debug(q, "Skipping child that is not a block device (subsystem=%s).", ss);
- continue;
- }
-
- r = sd_device_get_devtype(q, &dt);
- if (r < 0) {
- log_device_debug_errno(q, r, "Failed to get devtype of child, ignoring: %m");
- continue;
- }
-
- if (!streq(dt, "partition")) {
- log_device_debug(q, "Skipping non-partition child (devtype=%s).", dt);
- continue;
- }
+ r = sd_device_enumerator_add_match_subsystem(e, "block", /* match = */ true);
+ if (r < 0)
+ return r;
- return true; /* we have block device children */
- }
+ r = sd_device_enumerator_add_match_property(e, "DEVTYPE", "partition");
+ if (r < 0)
+ return r;
- return false;
+ return !!sd_device_enumerator_get_device_first(e);
}
static int loop_configure(