As a user if we want to look into what the kernel is up to, we would need our application to read the data in kernel space. But applications running in the user space can not access the data in the kernel space, in such situations the proc file system comes to rescue.
The proc file system is an interface between the kernel and the userspace. Every entry in the proc file system provides some information from the kernel.
For eg: The entry meminfo gives the details of the memory being used in the system. To read the data in this entry just run cat /proc/meminfo
Similarly the modules entry gives details of all the modules that are currently a part of the kernel. cat /proc/modules
The proc file system is also very useful when we want to debug a kernel module. While debugging we might want to know the values of various variables in the module or may be the data that module is handling. In such situations we can create a proc entry for ourselves and dump what ever data we want to look into the entry.
The proc entry can also be used to pass data to the kernel by writing into the kernel, so there can be two kinds of proc entries
An entry that only reads data from the kernel space
An entry that reads as well as writes data into and from kernel space.
We will start by creating a proc entry for only reading first and then move to a a proc entry for write.