Sharing between different processes using driver
Posted on 2004-08-17
I've created a memory module that gets installed as a driver. I create a node for this module on the filesystem. Some applications open the node and write to it, while others read from it. Whenever a process writes to it, the module stores it in kernel memory, however when another process goes to read, it doesn't appear to see the same memory that was written, as if it has a separate instance of the module. How can I make it so it sees the same memory?
Code Example for the module:
char * data;
data =(char *) kmalloc(100,GFP_KERNEL);
read(char * buf,.....)
So if "init_module" is called during the insert the module, it creates the memory space for the global variable "data", but then when process A tries to call read, it gets a segmentation fault, as if the memory had never been allocated. Can anyone explain this?