summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-04-10 19:35:55 -0400
committerIan Moffett <ian@osmora.org>2024-04-10 19:35:55 -0400
commit7bec3248baf2ee5b2e01ba17639f969aa471dc35 (patch)
tree1ff0c1d8befbab1a583c2773d5d366bc48172be9 /sys/dev/ic
parented47f732435b446b2ae0a3f50b87b511684fa029 (diff)
kernel: nvme: Create device file
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/nvme.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c
index dcdb5a8..4dd5f8e 100644
--- a/sys/dev/ic/nvme.c
+++ b/sys/dev/ic/nvme.c
@@ -36,6 +36,7 @@
#include <dev/ic/nvmevar.h>
#include <vm/dynalloc.h>
#include <vm/vm.h>
+#include <fs/devfs.h>
#include <string.h>
__MODULE_NAME("nvme");
@@ -378,6 +379,7 @@ nvme_id_ns(struct nvme_state *s, struct nvme_id_ns *id_ns, uint16_t nsid)
static int
nvme_init_ns(struct nvme_state *state, uint16_t nsid)
{
+ char devname[128];
struct nvme_ns *ns = NULL;
struct nvme_id_ns *id_ns = NULL;
struct device *dev;
@@ -407,7 +409,13 @@ nvme_init_ns(struct nvme_state *state, uint16_t nsid)
dev = DEVICE_ALLOC();
dev->read = nvme_dev_read;
dev->write = nvme_dev_write;
- ns->dev_id = create_dev(dev, state->major, nsid);
+ dev->blocksize = ns->lba_bsize;
+ ns->dev_id = device_create(dev, state->major, nsid);
+
+ snprintf(devname, sizeof(devname), "nvme0n%d", nsid);
+ if (devfs_add_blkdev(devname, dev) != 0) {
+ KERR("Failed to create /dev/%s\n", devname);
+ }
TAILQ_INSERT_TAIL(&namespaces, ns, link);
done: