#include "blockdev-util.h"
#include "device-private.h"
#include "device-util.h"
+#include "devnum-util.h"
#include "errno-util.h"
#include "string-util.h"
#include "strv.h"
size_t n = 0;
CLEANUP_ARRAY(l, n, block_device_array_free);
- dev_t root_devno = 0;
- if (FLAGS_SET(flags, BLOCKDEV_LIST_IGNORE_ROOT))
- if (blockdev_get_root(LOG_DEBUG, &root_devno) > 0) {
- r = block_get_whole_disk(root_devno, &root_devno);
+ dev_t root_devno = 0, whole_root_devno = 0;
+ if (FLAGS_SET(flags, BLOCKDEV_LIST_IGNORE_ROOT)) {
+ r = blockdev_get_root(LOG_DEBUG, &root_devno);
+ if (r < 0)
+ log_debug_errno(r, "Failed to get block device of root device, ignoring: %m");
+ else if (r > 0) {
+ r = block_get_whole_disk(root_devno, &whole_root_devno);
if (r < 0)
- log_debug_errno(r, "Failed to get whole block device of root device: %m");
+ log_debug_errno(r, "Failed to get whole block device of root device, ignoring: %m");
}
+ /* It's fine if root_devno/whole_root_devno are zero here as devnum_set_and_equal() will
+ * happily take that into account – it is in fact its primary raison d'etre. */
+ }
+
if (sd_device_enumerator_new(&e) < 0)
return log_oom();
continue;
}
- if (devno == root_devno)
+ if (devnum_set_and_equal(devno, root_devno) ||
+ devnum_set_and_equal(devno, whole_root_devno))
continue;
}