HOWTO Use the Linux /proc filesystem for debug output Randy Dunlap 2002-April-15 This directory contains three examples of using /proc fs for presenting debug output from a Linux kernel module. This is an alternative to using printk(). The first example (procmod.c) uses the traditional proc_read() and proc_write() interfaces for the /proc/numbers file. The second example (procseq.c) uses the seq_file interface for output (instead of proc_read) but still uses proc_write() for writing to the /proc/numseq file. Both examples use proc_write() just to reset the data values that are printed by the read() methods. The third example is based on procmod.c and adds a 64-bit divide/remainder function (divrem64()). The 64-bit numbers aren't interesting; it's just an example. See the source files for more information. ====================================================================== Output from procmod.o via /proc/numbers: module_name: numbers-debug version: 0.1 number_current: 1 Output from procseq.o via /proc/numseq: module_name: numseq-debug version: 0.1 [0] = 1 [1] = 2 [2] = 3 [3] = 4 [4] = 5 ===== Output from procdiv64.o via /proc/numbers64: module_name: div64-example version: 0.1 pages, ctxtsw, t1, t2: 1910057, 122199444, 15, 77065340 pages, jifs, t1, t2: 1910057, 5327393, 358, 2850306 ctxtsw, jifs, t1, t2: 122199444, 5327393, 22937, 5030759 ### end ###