Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion libnvme/src/nvme/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int nvme_verify_chr(struct nvme_transport_handle *hdl)
return -errno;

if (!S_ISCHR(nvme_stat.st_mode))
return -ENOTBLK;
return -EINVAL;
return 0;
}

Expand Down
22 changes: 19 additions & 3 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ static const char *namespace_desired = "desired namespace";
static const char *namespace_id_desired = "identifier of desired namespace";
static const char *namespace_id_optional = "optional namespace attached to controller";
static const char *nssf = "NVMe Security Specific Field";
static const char *only_char_dev = "Only character device is allowed";
static const char *prinfo = "PI and check field";
static const char *rae = "Retain an Asynchronous Event";
static const char *raw_directive = "show directive in binary format";
Expand Down Expand Up @@ -5349,6 +5350,11 @@ static int subsystem_reset(int argc, char **argv, struct command *acmd, struct p
if (err)
return err;

if (!nvme_transport_handle_is_chardev(hdl)) {
nvme_show_error(only_char_dev);
return -EINVAL;
}

err = nvme_subsystem_reset(hdl);
if (err < 0) {
if (errno == ENOTTY)
Expand All @@ -5375,6 +5381,11 @@ static int reset(int argc, char **argv, struct command *acmd, struct plugin *plu
if (err)
return err;

if (!nvme_transport_handle_is_chardev(hdl)) {
nvme_show_error(only_char_dev);
return -EINVAL;
}

err = nvme_ctrl_reset(hdl);
if (err < 0)
nvme_show_error("Reset: %s", nvme_strerror(err));
Expand All @@ -5399,6 +5410,11 @@ static int ns_rescan(int argc, char **argv, struct command *acmd, struct plugin
if (err)
return err;

if (!nvme_transport_handle_is_chardev(hdl)) {
nvme_show_error(only_char_dev);
return -EINVAL;
}

err = validate_output_format(nvme_cfg.output_format, &flags);
if (err < 0) {
nvme_show_error("Invalid output format");
Expand Down Expand Up @@ -5740,7 +5756,7 @@ static int show_registers(int argc, char **argv, struct command *acmd, struct pl
return err;

if (nvme_transport_handle_is_blkdev(hdl)) {
nvme_show_error("Only character device is allowed");
nvme_show_error(only_char_dev);
return -EINVAL;
}

Expand Down Expand Up @@ -6017,7 +6033,7 @@ static int get_register(int argc, char **argv, struct command *acmd, struct plug
return err;

if (nvme_transport_handle_is_blkdev(hdl)) {
nvme_show_error("Only character device is allowed");
nvme_show_error(only_char_dev);
return -EINVAL;
}

Expand Down Expand Up @@ -6321,7 +6337,7 @@ static int set_register(int argc, char **argv, struct command *acmd, struct plug
return err;

if (nvme_transport_handle_is_blkdev(hdl)) {
nvme_show_error("Only character device is allowed");
nvme_show_error(only_char_dev);
return -EINVAL;
}

Expand Down