return ret;
if (memcmp(id.mn, c->id.mn, sizeof(id.mn)) ||
- memcmp(id.sn, c->id.mn, sizeof(id.sn)))
+ memcmp(id.sn, c->id.sn, sizeof(id.sn)))
return -ENODEV;
return 0;
}
alphasort);
c->namespaces = calloc(c->nr_namespaces, sizeof(*n));
+ ret = asprintf(&path, "%s%s", dev, c->name);
+ if (ret < 0)
+ continue;
+ ret = 0;
+
+ fd = open(path, O_RDONLY);
+ if (fd > 0) {
+ nvme_identify_ctrl(fd, &c->id);
+ close(fd);
+ }
+ free(path);
+
for (j = 0; j < c->nr_namespaces; j++) {
n = &c->namespaces[j];
n->name = strdup(namespaces[j]->d_name);
while (j--)
free(namespaces[j]);
free(namespaces);
-
- ret = asprintf(&path, "%s%s", dev, c->name);
- if (ret < 0)
- continue;
- ret = 0;
-
- fd = open(path, O_RDONLY);
- if (fd > 0) {
- nvme_identify_ctrl(fd, &c->id);
- close(fd);
- }
- free(path);
}
free: