To help clearly illustrate the usage of procfs as an interfacing technology, we will have our kernel module create a directory under /proc. Within that directory, it will create four procfs (pseudo) files. Note that, by default, all procfs files have their owner:group attributes as root:root. Now, create a directory called /proc/proc_simple_intf and, under it, create four (pseudo) files. The names and attributes of the four procfs (pseudo) files under the /proc/proc_simple_intf directory, are shown in the following table:
Name of procfs 'file' | R: action on read callback, invoked via user space read | W: action on write callback, invoked via user space write | Procfs 'file' permissions |
llkdproc_dbg_level | Retrieves (to the user space) the current value of the global variable; that is, debug_level |
Updates the debug_level global variable to the value written by the user space | 0644 |
llkdproc_show_pgoff | Retrieves... |