Skip to content

Commit d171b0f

Browse files
committed
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 <[email protected]>
1 parent 9b8188c commit d171b0f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

libnvme/src/nvme/tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ int nvme_scan(const char *config_file, struct nvme_global_ctx **ctxp)
355355
return -ENOMEM;
356356

357357
ret = nvme_scan_topology(ctx, NULL, NULL);
358-
if (ret)
358+
if (ret && ret != -ENOENT)
359359
goto err;
360360
if (config_file) {
361361
ret = nvme_read_config(ctx, config_file);

0 commit comments

Comments
 (0)