Skip to content

Commit 6e7fceb

Browse files
committed
libnvme/linux: allow /dev/ngX device as character device
Previously the nvmeX device name id and ns was not checked. But currently those checked as if the device character or block. Therefore add to check the ngX device name as the character device. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 8a4df2b commit 6e7fceb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

libnvme/src/nvme/linux.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ static int __nvme_transport_handle_open_direct(struct nvme_transport_handle *hdl
9090
hdl->type = NVME_TRANSPORT_HANDLE_TYPE_DIRECT;
9191

9292
ret = sscanf(name, "nvme%dn%d", &id, &ns);
93-
if (ret != 1 && ret != 2)
94-
return -EINVAL;
93+
if (ret != 1 && ret != 2) {
94+
if (sscanf(name, "ng%dn%d", &id, &ns) != 2)
95+
return -EINVAL;
96+
ret = 1;
97+
}
98+
9599
c = ret == 1;
96100

97101
ret = asprintf(&path, "%s/%s", "/dev", name);

0 commit comments

Comments
 (0)