From the course: Linux Device Drivers: Reading, Writing, and Debugging

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Block driver operations

Block driver operations

- [Instructor] Let's talk for a couple of minutes about the operations in a block driver. And the struct gendisk and like file operations for character drivers there's default, but the key operation that's probably most interesting for block devices in recent Linux kernels is the submit I/O operation. So like character drivers, there is a operation struct, a block_device_operations struct, and there's some similar looking functions, open(), release(), ioctl(), but we got the submit_bio operation. And when user space does stuff like mount or interacts with the file system, then those are going to get translated into operations. Most IO is going to be the submit_bio. And it's the struct gendisk that gets allocated for a block device that has the block_device_operations. So that again, the kernel will know where to get the operation for a particular device. So the gendisk for your driver, it's got the major number, minor numbers, it's got a name, and it's got the entry in there for the…

Contents