October 2017
Intermediate to advanced
586 pages
14h 8m
English
When writing kernel modules, it is better to use designated initializers when it comes to statically initialize structures with their parameters. This consists of naming the member you need to assign a value to. The form is .member-name to designate which member should be initialized. This allows, among other things, initializing the members in an undefined order, or leaving the fields that we do not want to modify unchanged.
Once we have defined our functions, we just have to fill the structure as follows:
static const struct file_operations eep_fops = { .owner = THIS_MODULE, .read = eep_read, .write = eep_write, .open = eep_open, .release = eep_release, .llseek = eep_llseek, .poll = eep_poll, .unlocked_ioctl ...