Skip to content

Commit d907d7e

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

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
@@ -931,11 +931,19 @@ static int netapp_smdevices(int argc, char **argv, struct command *command,
931931

932932
if (devname) {
933933
int subsys_num, nsid;
934+
struct stat st;
935+
char path[512];
934936

935937
if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) {
936938
fprintf(stderr, "Invalid device name %s\n", devname);
937939
return -EINVAL;
938940
}
941+
942+
sprintf(path, "/dev/%s", devname);
943+
if (stat(path, &st) != 0) {
944+
fprintf(stderr, "%s does not exist\n", path);
945+
return -EINVAL;
946+
}
939947
}
940948

941949
smdevices = calloc(num, sizeof(*smdevices));

0 commit comments

Comments
 (0)