interview question how does application connects to device

Greg KH greg at kroah.com
Mon Jul 11 14:13:11 EDT 2011


On Mon, Jul 11, 2011 at 10:43:50AM -0700, StephanT wrote:
> Hi all,
> 
> ----- Original Message -----
> > From: Greg Freemyer <greg.freemyer at gmail.com>
> 
> 
> > 
> > Correct, ioctl is no longer preferred, but it is definitely still
> > used.  And the ext4 team is still adding new ioctl commands despite it
> > being discouraged.
> > 
> 
> 
> If ioctl is no longer preferred what is its preferred alternative ?

a virtual filesystem, sysfs, debugfs, configfs, or something else is
usually all you need.  As mentioned, netlink is also a good alternative,
and so is the connector interface.

> Could you, please explain why ioctl felt in disgrace.

It's essencially adding a brand new system call every single time,
32/64bit problems, pointer problems, structure problems, incorrect
bounds checking almost always happens and other nastyness.

That being said, there are still times when ioctl is the correct thing
to use, but you have to really know what you are doing and be able to
justify it.

hope this helps,

greg k-h



More information about the Kernelnewbies mailing list