Skip to content

Commit dee83c1

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 f9c90d0 commit dee83c1

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
@@ -7350,6 +7350,28 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi
73507350
if (err)
73517351
return err;
73527352

7353+
if (nvme_transport_handle_is_chardev(hdl)) {
7354+
_cleanup_free_ char *cdev = NULL;
7355+
7356+
if (!cfg.namespace_id) {
7357+
nvme_show_error("char device not supported without --namespace-id");
7358+
return -EINVAL;
7359+
}
7360+
7361+
if (asprintf(&cdev, "/dev/%sn%d",
7362+
nvme_transport_handle_get_name(hdl),
7363+
cfg.namespace_id) < 0)
7364+
return -ENOMEM;
7365+
7366+
nvme_close(hdl);
7367+
7368+
err = nvme_open(ctx, cdev, &hdl);
7369+
if (err) {
7370+
nvme_show_error("could open %s", cdev);
7371+
return err;
7372+
}
7373+
}
7374+
73537375
err = validate_output_format(nvme_cfg.output_format, &flags);
73547376
if (err < 0) {
73557377
nvme_show_error("Invalid output format");

0 commit comments

Comments
 (0)