interview question how does application connects to device

Bond jamesbond.2k.g at gmail.com
Tue Jul 5 00:15:21 EDT 2011


This is an interview question.

I had written device driver for a char device so I know that code
structure looks like this

struct file_operations something {
 .owner=my_device_open;
 .read=my_device_read;
 .close=my_device_close;
 .write=my_device_write;

 }
When the device driver is active then in

/dev/mydevice
you can actually read and write into it. But what I was not clear is
how an application will read or write to this device. I know insmod
will insert the module to kernel,and register_chrdev(); will register
the driver in kernel but how will application program communicate with
this driver.


My answer was
In unix it simply opens the device node as a file and sends/receives
data and commands from it.

But he was expecting some thing more complex.



More information about the Kernelnewbies mailing list