diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-08-27 08:24:49 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-08-27 13:32:11 +0200 |
commit | 5c467ef4fb364468356d3f3bada7bb5751a7ee8e (patch) | |
tree | 06df5d4b12deaa418310a447dbb4725e503a76ed /src/shared/loop-util.c | |
parent | Merge pull request #24468 from yuwata/test-udev-debug (diff) | |
download | systemd-5c467ef4fb364468356d3f3bada7bb5751a7ee8e.tar.xz systemd-5c467ef4fb364468356d3f3bada7bb5751a7ee8e.zip |
loop-util: use filter provided by sd_device_enumerator
Diffstat (limited to '')
-rw-r--r-- | src/shared/loop-util.c | 35 |
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( |