interview question how does application connects to device

Greg Freemyer greg.freemyer at gmail.com
Mon Jul 11 14:14:14 EDT 2011


On Mon, Jul 11, 2011 at 1:43 PM, StephanT <stman937-linewbie at yahoo.com> 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 ?

For simple tasks related to processes procfs.  (I think procfs is read
only from user space)

For simple tasks related to devices sysfs  (sysfs is read / write from
userspace, but uses very simple data formats.  No structures as an
example.

For complex controls, netlink sockets:
http://www.linuxjournal.com/article/7356 is a 5 year article I found
with a quick grep.

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

I really don't recall the details, but I'm almost positive I've seen
new patches rejected because they were based on ioctl's.

Can someone else please confirm I'm not imagining things.

As I recall, it has to do with the various architectures not being
easily handled by the ioctl ABI.

==> Here's one quote I just found from lkml Feb. 2010

Can you describe what your driver is doing? One rule of thumb
is that if you already require a character device, using ioctl
is the right answer, but you shouldn't create a character device
if all you want to do over it is a single ioctl operation.

        Arnd
===

Greg



More information about the Kernelnewbies mailing list