From d171b0f969ed1186983c92bc882ad6e9bbb7dd70 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Tue, 10 Mar 2026 12:44:16 +0000 Subject: [PATCH] tree: gracefully handle empty dirs When no devices are present, /sys/class/nvme and /sys/class/nvme-subsystem directories may not exist. scandir returns -1 with errno set to ENOENT. nvme_scan treats this as a fatal error instead it should just ignore it. There is just nothing to scan. This fixes the python-create-ctrl-object and python-sigsegv-during-gc tests that fail when no NVMe devices are present in the test environment. Signed-off-by: Daniel Wagner --- libnvme/src/nvme/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index 8cdc1321ef..ea9fb3a230 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -355,7 +355,7 @@ int nvme_scan(const char *config_file, struct nvme_global_ctx **ctxp) return -ENOMEM; ret = nvme_scan_topology(ctx, NULL, NULL); - if (ret) + if (ret && ret != -ENOENT) goto err; if (config_file) { ret = nvme_read_config(ctx, config_file);