Skip to content

Commit 9c218af

Browse files
committed
nvme: add fallback support for block vs char device to dsm command
The dsm command is only supported by the block device. The kernel has support to map NVME_IOCTL_IO_CMD when user spaces uses the char device. Though for NVME_IOCTL_IO64_CMD this support is missing and wont be added to the kernel. Thus add the fallback code to userland. Signed-off-by: Daniel Wagner <[email protected]>
1 parent fca3dd6 commit 9c218af

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

nvme.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7364,6 +7364,28 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi
73647364
if (err)
73657365
return err;
73667366

7367+
if (nvme_transport_handle_is_chardev(hdl)) {
7368+
_cleanup_free_ char *cdev = NULL;
7369+
7370+
if (!cfg.namespace_id) {
7371+
nvme_show_error("char device not supported without --namespace-id");
7372+
return -EINVAL;
7373+
}
7374+
7375+
if (asprintf(&cdev, "/dev/%sn%d",
7376+
nvme_transport_handle_get_name(hdl),
7377+
cfg.namespace_id) < 0)
7378+
return -ENOMEM;
7379+
7380+
nvme_close(hdl);
7381+
7382+
err = nvme_open(ctx, cdev, &hdl);
7383+
if (err) {
7384+
nvme_show_error("could not open %s", cdev);
7385+
return err;
7386+
}
7387+
}
7388+
73677389
err = validate_output_format(nvme_cfg.output_format, &flags);
73687390
if (err < 0) {
73697391
nvme_show_error("Invalid output format");

0 commit comments

Comments
 (0)