I have a Linux kernel module that during it's initilisation routine writes a struct, 4KB in size into kernel memory. What I would like to do is make this memory shared, so that a single userspace process can have read-only access to this struct.
I've been told to avoid using IOCTLS as they aren't the best way to go about doing this, so from what I've read the best way to do it would be to use the function mmap
, however I'm a bit confused over how to implement what I need in C.
I did look at using the function shmget
, but it seems that this is designed for userspace apps that need IPC functionality.
Any advice, or even better a simple example would be greatly appreciated.
Thanks!