From mboxrd@z Thu Jan 1 00:00:00 1970 From: mandeepsandhu.chd@gmail.com (Mandeep Sandhu) Date: Tue, 5 Jul 2011 13:01:48 +0530 Subject: interview question how does application connects to device In-Reply-To: References: <4E12B46C.3070909@gate-nine.de> Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Oops, accidentally pressed send... On Tue, Jul 5, 2011 at 12:58 PM, Mandeep Sandhu wrote: > On Tue, Jul 5, 2011 at 12:29 PM, Paraneetharan Chandrasekaran > 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. HTH, -mandeep > > My info is a little dated, so plz CMIIW. > > HTH, > -mandeep >