Skip to content

Commit 36e9b4c

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 36e9b4c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

libnvme/src/nvme/linux.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,15 @@ static int __nvme_transport_handle_open_direct(struct nvme_transport_handle *hdl
8585
_cleanup_free_ char *path = NULL;
8686
char *name = basename(devname);
8787
int ret, id, ns;
88-
bool c;
88+
bool c = true;
8989

9090
hdl->type = NVME_TRANSPORT_HANDLE_TYPE_DIRECT;
9191

9292
ret = sscanf(name, "nvme%dn%d", &id, &ns);
93-
if (ret != 1 && ret != 2)
93+
if (ret == 2)
94+
c = false;
95+
else if (ret != 1 && sscanf(name, "ng%dn%d", &id, &ns) != 2)
9496
return -EINVAL;
95-
c = ret == 1;
9697

9798
ret = asprintf(&path, "%s/%s", "/dev", name);
9899
if (ret < 0)

0 commit comments

Comments
 (0)