Re: interview question how does application connects to device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Tue, Jul 5, 2011 at 1:21 PM, Abhijit Pawar <apawar.linux@xxxxxxxxx> wrote:


On 5 July 2011 13:01, Mandeep Sandhu <mandeepsandhu.chd@xxxxxxxxx> wrote:
Oops, accidentally pressed send...

On Tue, Jul 5, 2011 at 12:58 PM, Mandeep Sandhu
<mandeepsandhu.chd@xxxxxxxxx> wrote:
> On Tue, Jul 5, 2011 at 12:29 PM, Paraneetharan Chandrasekaran
> <paraneetharanc@xxxxxxxxx> wrote:
>> I think the thread originator is asking about how the application knows
>> which device file to read or write.
>> This is done by h/w management system udev. udev creates/manages device
>> nodes in /dev/ dir and notifes applications based on the udev rules written
>> (via HAL events or DBUS signals).
>
> I don't think udev is involved in the read/write file ops. Udev is
> responsible for handling hotplug events, doing certain actions based
> on events (as indicated by udev rules),persistent naming of devices
> etc...but not file i/o.
>
> That, I think, is handled by the VFS layer. Each device node is
> uniquely identified by it's MAJOR-MINOR number combo. I guess the VFS
> layer uses this to pick the correct file-ops struct to communicate
> with the device.

>Eg; when we try to open a device, say /dev/ttyS0, it's major-minor
>numbers (eg: 64-4 on my machine) are used to lookup the file-ops
>struct and from then on, the VFS passes the read/write calls to this
>device driver.

Yes. whenever we read or write to the device, the file operations structure would be invoked for the device. And this device is identified by the Major and Minor number combination.
The device driver / kernel module at registration time mention what major and minor it would be servicing.

This is what I think it should work. Good to get confirmation though.

Udev creates the device node and loads the corresponding driver based on the major/minor no. So after this step udev is out of the picture and control goes on particular device node and then file-operation will come into picture for read and write. It will try to read the data from cache (buffer cache) and if not avilable there then from disk...
 

Regards,
Abhijit

HTH,
-mandeep
>
> My info is a little dated, so plz CMIIW.
>
> HTH,
> -mandeep
>

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux