Fwd: Question about kernel interfaces

Siddhartha De siddhartha.de87 at gmail.com
Fri Jan 16 14:37:31 EST 2015

FYI ...

---------- Forwarded message ----------
From: One Thousand Gnomes <gnomes at lxorguk.ukuu.org.uk>
Date: Wed, Jan 14, 2015 at 10:03 PM
Subject: Re: Question about kernel interfaces
To: Siddhartha De <siddhartha.de87 at gmail.com>
Cc: linux-kernel <linux-kernel at vger.kernel.org>

> Just wanted to point out something  :-
> Quoting from makelinux website :-
> http://www.makelinux.net/books/lkd2/ch17lev1sec8
> "The sysfs filesystem is currently the place for implementing
> functionality previously reserved for ioctl() calls on device nodes or
> the procfs filesystem. These days, the chic thing to do is implement
> such functionality as sysfs attributes in the appropriate directory.
> For example, instead of a new ioctl() on a device node, add a sysfs
> attribute in the driver's sysfs directory. Such an approach avoids the
> type-unsafe use of obscure ioctl() arguments and the haphazard mess of
> /proc. "

And is wrong. Certainly rather clueless people had the idea they could
make ioctl go away using sysfs, and then everyone wrote about it. Anyone
who actually thought about the problem realised immediately they are not
semantically equivalent.

> sysfs is the new ioctl

And as was pointed out even then they are not semantically equivalent so
everyone who was talking about "sysfs being the new ioctl" was basically
talking out the wrong end.

What was done was to stop filling drivers with ioctls for pieces of
general information which didn't have a context attached to it or
sequence. Things like power state, what type it is, what bus it is on
etc. That avoided having zillions of ioctls but at the cost of memory.

> Taking this idea further , could we also expose driver IOCTL's over
> the network ?
> For eg to open the cd rom drive we would be calling the following url :-

You could but why would you make the network visible. If you look at real
clustered systems they all hide the network. You don't care where it is,
often you don't even care where the drive is.

eject /dev/cdrom

on such a system lets the kernel figure out who to ask to eject it.

The job of an OS is to abstract details like that. In a clustered OS I
want to be able to type

        mount mydisk

and I don't care who, where or how it gets mounted so long as it appears.


More information about the Kernelnewbies mailing list