I am an absolute newbie on Linux kernel. Sincere apologies if this has been answered. I have spent many hours and could not resolve it and hence decided to ask (reading Linux device drivers book as well). My problem statement: I would like to read a proc file (/proc/pid/maps) in my kernel module (a few more). There are numerous examples on proc_create which create a file and then write/read to it. I just want a read to the existing proc file. It appears all the previous options have been deprecated (read_proc, create_proc_read_entry and so on). An option that I read is to call proc_pid_maps_operations from task_mmu.c. This is involved when /proc/pid/maps is called? Is that the right approach? Or I can abstract it.
Code snippet of proc_create from various tutorials is here. The moment I change the name to an existing file, insmod fails.
if (!proc_create( "testcpuinfo", // define ENTRY_NAME "hello_world"
0, // permissions 0644
NULL, // proc directory
&fops)) // file_operations
{
printk("ERROR! proc_create\n");
remove_proc_entry(ENTRY_NAME, NULL);
return -ENOMEM;
}