I'm trying to get a user-level program to communicate with the kernel via /proc.
I followed the instructions on tldp, and was successfully able to create a custom proc file, load it dynamically with insmod and read (cat) and write (echo) to the proc file from userland.
Now my question is how do I access the /proc variable (it's a byte buffer) from within another part of the kernel, say the system call infrastructure? Since the custom proc file is dynamically loaded and linked, how can I reference it from statically compiled kernel code?
System specs: Ubuntu 10.10 running in VMWare Fusion on a MacBook Pro 13" (2009).
Edit: Pertinent code (by request) -
procfile.c
//This function is called when the module is loaded
int init_module()
{
/* create the /proc file */
EXPORT_SYMBOL(procfs_buffer);
EXPORT_SYMBOL(procfs_buffer_size);
...
...
}
get_procvariable.c (In another part of the kernel)
//The buffer used to store character for this module
extern char * procfs_buffer;
//The size of the buffer
extern unsigned long procfs_buffer_size;
int get_procvariable(void)
{
.. do something
return procfs_buffer; // LD Error: Undefined reference
}
Do let me know in the comments, if you need further details. Thanks in advance.