mirror of
https://github.com/systemd/systemd
synced 2024-10-14 20:17:52 +00:00
loop-util: use filter provided by sd_device_enumerator
This commit is contained in:
parent
989e350218
commit
5c467ef4fb
|
@ -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_enumerator_add_match_subsystem(e, "block", /* match = */ true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
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;
|
||||
}
|
||||
r = sd_device_enumerator_add_match_property(e, "DEVTYPE", "partition");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return true; /* we have block device children */
|
||||
}
|
||||
|
||||
return false;
|
||||
return !!sd_device_enumerator_get_device_first(e);
|
||||
}
|
||||
|
||||
static int loop_configure(
|
||||
|
|
Loading…
Reference in a new issue