File Operations on Character Devices (Screenplay)¶
Hooks Necessary¶
# cat /dev/my_driver-0
cat: /dev/my_driver-0: Invalid argument
# strace cat /dev/my_driver-0
...
openat(AT_FDCWD, "/dev/my_driver-0", O_RDONLY) = 3
...
read(3, 0x7f3d11330000, 131072) = -1 EINVAL (Invalid argument)
...
Implement open()
, read()
, write()
¶
Only debug output; no access to device (or any state held by it)
read()
andwrite()
initially just like/dev/null
ioctl()
¶
request
parameter: like protocol identifierignore data for now
Userspace test program
Use
request = 666
as ioctl request ⟶ Inappropriate ioctl for device (ENOTTY
)