Reading
All of Chapter 3
Study Questions
-
Understand the difference between driver and device. Does each device have it’s own driver?
-
(T or F) Character drivers are generally the most suitable class of drivers for most simple hardware devices.
-
How do you identify character drivers?
-
What are the differences between major and minor numbers?
-
How many major numbers will a driver have? How many minor numbers?
-
What is the purpose of the dev_t data type? How do you access its members? How do you create one?
-
Contrast dynamic allocation of major device numbers (alloc_chrdev_region) versus using register_chrdev_region().
-
How many device numbers does alloc_chrdev_region reserve? What should you pass in to the dev argument?
-
What is the purpose of the file_operations struct? What does it contain?
-
What happens if you set members of file_operations to be NULL? Which struct members need to be set? What is tagged structure initialization syntax in C?
-
(T or F) When you call the open() system call from user space, it directly invokes the .open() function provided by the driver in file_operations.
-
(T or F) .release() is called every time user space calls the close() system call on the device file.
-
What is the file structure? What is the inode structure.
-
What do you need to do to register a device?
-
Some file_operations functions, such as open() provide a
struct inode *inode
argument. How do you use this pointer to get a pointer back to yourstruct cdev
? -
How do we copy data to/from user-kernel?
-
Why can’t you dereference a user space pointer?
-
How do copy_to_user and copy_from_user indicate an error?
-
(T or F) The file position (*offp) is automatically updated during .read() and .write().
-
How do you return errors from .read() and .write()?