Writing data

The write call back function allows a userland process to write data to the kernel, so it has some kind of control over the kernel. The write function should have the following format:

int write_func(struct file* file, const char* buffer, unsigned long count, void* data);

The write function should read count bytes at maximum from the buffer. Note that the buffer doesn't live in the kernel's memory space, so it should first be copied to kernel space with copy_from_user. The file parameter is usually ignored. the section called “A single call back for many files” shows how to use the data parameter.

Again, Chapter 5, Example shows how to use this call back function.