device-util: introduce several more helper functions

This also makes device_in_subsystem() and device_is_devtype() return
negative error on critical error
This commit is contained in:
Yu Watanabe
2025-05-14 02:06:02 +09:00
parent b7d60b2966
commit ab1bd9daed
30 changed files with 533 additions and 237 deletions
+3 -6
View File
@@ -37,15 +37,12 @@ int blockdev_list(BlockDevListFlags flags) {
}
if (FLAGS_SET(flags, BLOCKDEV_LIST_IGNORE_ZRAM)) {
const char *dn;
r = sd_device_get_sysname(dev, &dn);
r = device_sysname_startswith(dev, "zram");
if (r < 0) {
log_warning_errno(r, "Failed to get device name of discovered block device '%s', ignoring: %m", node);
log_warning_errno(r, "Failed to check device name of discovered block device '%s', ignoring: %m", node);
continue;
}
if (startswith(dn, "zram"))
if (r > 0)
continue;
}