How do I use ioctl() to manipulate my kernel module?

后端 未结 3 1126
别那么骄傲
别那么骄傲 2020-12-08 03:45

So I\'m trying to write a kernel module that uses the linux/timer.h file. I got it to work inside just the module, and now I am trying to get it to work from a user program.

3条回答
  •  攒了一身酷
    2020-12-08 03:58

    You are missing a .open function pointer in your file_operations structure to specify the function to be called when a process attempts to open the device file. You will need to specify a .ioctl function pointer for your ioctl function as well.

    Try reading through The Linux Kernel Module Programming Guide, specifically chapters 4 (Character Device Files) and 7 (Talking to Device Files).

    Chapter 4 introduces the file_operations structure, which holds pointers to functions defined by the module/driver that perform various operations such as open or ioctl.

    Chapter 7 provides information on communicating with a module/drive via ioctls.

    Linux Device Drivers, Third Edition is another good resource.

提交回复
热议问题