Character Device Drivers in deep

Linux Kernel Programming – Character Device Drivers

Updated on Oct 10: Added Downloads section

What you’ll learn

  • Write character device driver from scratch.
  • Understand the various file operations provided by character driver.

Course Content

  • Introduction –> 22 lectures • 53min.
  • File Operations –> 36 lectures • 1hr 48min.
  • IOCTL –> 18 lectures • 57min.
  • Access Control and Capabilities –> 9 lectures • 35min.
  • Misc Driver –> 2 lectures • 7min.
  • Resources –> 1 lecture • 1min.

Character Device Drivers in deep

Requirements

  • Should be able to write/compile/load/unload Hello World Linux Kernel Modules.

Updated on Oct 10: Added Downloads section

What will you learn from this course?

  • Introduction to character drivers
  • What is device number and device file
  • Allocating device number – statically and dynamically
  • Creating device file – Manually(mknod) and automatically (udev)
  • Registering character device and its file operation with Kernel
  • Copying data from user space to kernel space and vice versa
  • Understanding the various structures – struct file and struct inode
  • Implementation of open, release, read, write, llseek, ioctl file operations
  • How to create multiple device nodes and add support for private data
  • Flow of write system call from kernel system call entry point to driver write file operations
  • Handling all the error cases in ioctl implementation
  • Sending a signal to user space from kernel space
  • Various access control mechanisms and capabilities
  • Misc Driver

API’s covered in this course:

  • MAJOR
  • MINOR
  • MKDEV
  • register_chrdev_region
  • alloc_chrdev_region
  • class_create
  • device_create
  • class_destroy
  • device_destroy
  • unregister_chrdev_region
  • imajor
  • iminor
  • copy_from_user
  • copy_to_user
  • put_user
  • get_user
  • print_dev_t
  • format_dev_t
  • strnlen_user
  • container_of
  • access_ok

Commands used in this course:

  • mknod
  • udevadm monitor