问题
I am writing a module in which I am accessing the nvme device using major and minor number.
The code for the function is
src_disk = get_gendisk(MKDEV(si->src_major, si->src_minor), &part);
my_nvme_ns = (struct nvme_ns *)src_disk->private_data;
for (i = 0; i <= 15; i++)
{
printk(KERN_CONT "%02x", my_nvme_ns->head.ids.nvme_ns_ids.nguid[i]);
}
Now, when I try to acces my_nvme_ns
, it fails with error
error: dereferencing pointer to incomplete type ‘struct nvme_ns’
printk(KERN_CONT "%02x", my_nvme_ns->head.ids.nvme_ns_ids.nguid[i]);
I have included all the relevant files, including
#include <linux/nvme.h>
#include <linux/nvme_ioctl.h>
#include <linux/types.h>
Using kernel 5.0.0
what am I missing here?
来源:https://stackoverflow.com/questions/58262330/linux-kernel-module-not-able-to-find-nvme-ns-struct