Re: F_CTRLFD (was Re: Why side-effects on open(2) are evil.)

Edgar Toernig (froese@gmx.de)
Sun, 20 May 2001 17:47:02 +0200


Alexander Viro wrote:
>
> For the latter, though,
> we need to write commands into files and here your miscdevices (or procfs
> files, or /dev/foo/ctl - whatever) is needed.

IMHO any scheme that requires a special name to perform ioctl like
functions will not work. Often you don't known the name of the
device you're talking to and then you're lost.

So, if you want an additional communication channel to a device why
not introduce an fcntl or system call like

cltrfd = fcntl(fd, F_CTRLFD) or openctrl(fd) ?

That way you can always get access to the control channel and use
regular read/write for communication [1]. To make it more versatile,
you may want to extent the shell syntax, i.e. a '@' in redirection
operators get the control fd:

echo "eject" >@/dev/cdrom
{ echo "b19200,onlcr" >@1 ; echo "Hello World!" ; } >/dev/ttyS0

Yes, requires support in user space apps but doesn't mess around
with the file namespace. It's too precious to sacrifice ;-)

I don't know how much infrastructure in the kernel is required for this
- i.e. add readctrl/writectrl methods or create virtual inodes/devices
on the fly? There are more capable people than me to judge on that...

Ciao, ET.

[1] If you want you can even allow this flag as an open mode to
open the ctrl channel without opening the dev.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/