Chapter 3. Communicating with userland

Table of Contents

Reading data
Writing data
A single call back for many files

Instead of reading (or writing) information directly from kernel memory, procfs works with call back functions for files: functions that are called when a specific file is being read or written. Such functions have to be initialised after the procfs file is created by setting the read_proc and/or write_proc fields in the struct proc_dir_entry* that the function create_proc_entry returned:

struct proc_dir_entry* entry;

entry->read_proc = read_proc_foo;
entry->write_proc = write_proc_foo;
    

If you only want to use a the read_proc, the function create_proc_read_entry described in the section called “Convenience functions” may be used to create and initialise the procfs entry in one single call.