File Operations: Open, Read, Write and Release
A driver publishes a table of functions, one per thing a program can do to its file: open when someone opens it, read and write when they move bytes, release when the last user closes it. The kernel calls into that table when the matching system call arrives, so those functions are literally where your driver's behaviour lives. Anything you allocate in open you are responsible for freeing in release, because nothing else will.
Questions this Concept answers
- Why is anything a driver allocates in `open` its own responsibility to free in `release`?
Kernel Structures and the SCULL Character Device Driver in Linux
A Linux character device driver is built around four core kernel structures — the inode (device identity, shared across all openers), the file (per-open-instance state, distinct for each process/file…