Skip to content

Commit 5bc3ead

Browse files
martin-gpyigaw
authored andcommitted
netapp-ontapdev: update invalid device handling
Error out with an appropriate message if an invalid or non-existent device is passed to the NetApp ontapdevices plugin. Signed-off-by: Martin George <[email protected]>
1 parent d16e8d8 commit 5bc3ead

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

plugins/netapp/netapp-nvme.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,11 +1023,19 @@ static int netapp_ontapdevices(int argc, char **argv, struct command *command,
10231023

10241024
if (devname) {
10251025
int subsys_num, nsid;
1026+
struct stat st;
1027+
char path[512];
10261028

10271029
if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) {
10281030
fprintf(stderr, "Invalid device name %s\n", devname);
10291031
return -EINVAL;
10301032
}
1033+
1034+
sprintf(path, "/dev/%s", devname);
1035+
if (stat(path, &st) != 0) {
1036+
fprintf(stderr, "%s does not exist\n", path);
1037+
return -EINVAL;
1038+
}
10311039
}
10321040

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

0 commit comments

Comments
 (0)