On working with LKMs includes Privileged kernel information, The ‘/proc’ directory, The ‘cat’ command, Our own ‘cat’ workalike, Creating our own ‘/proc’ files, Our module’s organization, register/unregister. | On working with LKMs Using Linux Kernel Modules to quickly export privileged kernel information to ordinary users Privileged kernel information • Users ordinarily are prohibited from seeing what goes on inside a running Linux kernel • But we can use kernel modules to override normal restrictions on kernel data access • The handiest mechanism for doing this is to employ the so-called ‘/proc’ file system • Linux actually encourages this by offering quite a few examples, built in by default The ‘/proc’ directory • In addition to the normal files stored on a hard disk, UNIX systems support several types of ‘special’ files: – Directories and sub-directories (aka ‘folders’) – Symbolic links (., placeholders for pointers) – Device files (providing access to ‘peripherals’) – ‘Pseudo’ files (for data created ‘on-demand’) • Such ‘pseudo’ files are usually in ‘/proc’ The ‘cat’ command • This standard UNIX command offers users a quick way to view the text in a ‘/proc’ file • It’s not necessary to write an application program that will open, read, and display the transient contents of a ‘pseudo’ file • The file-concatenation operation transfers data from any file(s) to ‘standard output’ • Example: $ cat /proc/version More ‘/proc’ examples • • • • • • $ cat /proc/cpuinfo $ cat /proc/modules $ cat /proc/meminfo $ cat /proc/iomem $ cat /proc/devices $ cat /proc/self/maps [Read the ‘man-page’ for details: $ man .