Opening the controller device will fail if the controller is resetting,
so trying to open it during controller initialisation will fail, and
the controller will not displayed correctly.
So only try to open the controller device if required, allowing the
initialisation to continue.
Signed-off-by: Hannes Reinecke <hare@suse.de>
int nvme_ctrl_get_fd(nvme_ctrl_t c)
{
+ if (c->fd < 0) {
+ c->fd = nvme_open(c->name);
+ if (c->fd < 0)
+ nvme_msg(LOG_ERR, "Failed to open ctrl %s, errno %d\n",
+ c->name, errno);
+ }
return c->fd;
}
d = opendir(path);
if (!d) {
+ nvme_msg(LOG_ERR, "Failed to open ctrl dir %s, error %d\n",
+ path, errno);
errno = ENODEV;
return -1;
}
closedir(d);
- c->fd = nvme_open(name);
- if (c->fd < 0)
- return c->fd;
-
+ c->fd = -1;
c->name = strdup(name);
c->sysfs_dir = (char *)path;
c->firmware = nvme_get_ctrl_attr(c, "firmware_rev");