2008年5月6日 星期二

ioctl communication between kernel and user space

use block device as example:

user space program:
struct Test_info  test_info;
ioctl ( fd,  ADD,  &test_info);


driver:
1. define a function to deal with ioctl operation & assign this function 
    to struct block_device_operations
     ex: 
     define a function  test_ioctl
     struct block_device_operations test_ops;
     test_ops.ioctl = test_ioctl       

2.  define the function to deal with ioctl operation
     it will receive two important parameters.
     One is command, the other is argument.
     From out example,  the command received is ADD, the parameter received is &test_info

3.  copy data from user space to kernel space
     use copy_from_user

沒有留言: