Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions plugins/netapp/netapp-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,19 @@ static int netapp_smdevices(int argc, char **argv, struct command *command,

if (devname) {
int subsys_num, nsid;
struct stat st;
char path[512];

if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) {
fprintf(stderr, "Invalid device name %s\n", devname);
return -EINVAL;
}

sprintf(path, "/dev/%s", devname);
if (stat(path, &st) != 0) {
fprintf(stderr, "%s does not exist\n", path);
return -EINVAL;
}
}

smdevices = calloc(num, sizeof(*smdevices));
Expand Down Expand Up @@ -1023,11 +1031,19 @@ static int netapp_ontapdevices(int argc, char **argv, struct command *command,

if (devname) {
int subsys_num, nsid;
struct stat st;
char path[512];

if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) {
fprintf(stderr, "Invalid device name %s\n", devname);
return -EINVAL;
}

sprintf(path, "/dev/%s", devname);
if (stat(path, &st) != 0) {
fprintf(stderr, "%s does not exist\n", path);
return -EINVAL;
}
}

num = scandir(dev_path, &devices, netapp_nvme_filter, alphasort);
Expand Down