Skip to content

Commit eb3a33b

Browse files
author
Kou Wenqi
committed
nvme: make "nvme list" do not report an error when the modules
are not loaded On nvme-cli 1.x, "nvme list" is no-ops when the nvme_core module isn't loaded. But on nvme-cli 2.x, it fails when trying to open the nonexistent /sys/class/nvme. It would be better if 2.x behaved the same way. Signed-off-by: Kou Wenqi <[email protected]>
1 parent d16e8d8 commit eb3a33b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

nvme.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,6 +3501,12 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugi
35013501
}
35023502
err = nvme_scan_topology(r, NULL, NULL);
35033503
if (err < 0) {
3504+
/* Do not report an error when the modules are not loaded */
3505+
if (errno == ENOENT) {
3506+
nvme_show_list_items(r, flags);
3507+
return 0;
3508+
}
3509+
35043510
nvme_show_error("Failed to scan topology: %s", nvme_strerror(errno));
35053511
return err;
35063512
}

0 commit comments

Comments
 (0)