From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Pjotr Kourzanov <peter.kourzanov@xs4all.nl>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: ioctl assignment strategy?
Date: Tue, 21 Dec 2004 00:32:11 +0000 [thread overview]
Message-ID: <1103589129.32548.10.camel@localhost.localdomain> (raw)
In-Reply-To: <41C756CA.5080504@xs4all.nl>
On Llu, 2004-12-20 at 22:48, Pjotr Kourzanov wrote:
> /That/ is exactly what FS API is good for: returning error values is
> done via read(/sys/mystuff/errno,&err,4), getting handles is done via
> open(/sys/mystuff/mycomp) and doing new calls is just calling FS API
> with the *file* handle. Registration, depending on your definition of it
Except in the real world when little things come up like
synchronization or complex API's that don't fit read/write terribly well
(committing sets of changes, synchronous object replies)
> can be viewed as a link(/sys/mystuff/object,/sys/mystuff/subsystem) or
> as a write(/sys/mystuff/subsystem/registered,"object"). Take a peek into
> Plan9 from Bell Labs for inspiration...
And everything can be implemented in purest lisp on a turing machine.
You forgot the usefulness test.
> > What's the big problem with ioctls anyways? I mean, in a closed
> > environment where I'm writing both the userspace and the kernelspace
> > side of things.
<rant>
It offends the plan 9 bigots and their pet religion. Not that they don't
have a good point in many cases 8)
Ioctls do have some serious problems that make them nice to avoid
1. Each ioctl handler has its own data structures. While you could write
XML objects to encapsulate this in write() it is also true in many cases
that there is a simple logical expression of the operation - eg
configuration options tend to fit well into files as you can see with
/sysfs - unless they need to be atomic transactions with rollback at
which point the same people who decry ioctl will hate embedding sqlite
in the kernel
Seriously however - multiple structures means multiple validation
functions means more new code and more errors. It's a lot easier to get
ioctls wrong. There are a lot of things that don't need to be ioctl. A
look at security history says in general "ioctls cause bugs"
2. Ioctl structures tend to be binary. Welcome to 32/64bit emulation
hell. Good design can avoid this. Good design is not XML for this
purpose.
3. Ioctl is unstructured and so each ioctl is a new mystery to the
programmer. We all know how write works and in many cases echo "451" >
/proc/sys/vm/blah is quite obvious.
4. It's hard to ioctl from the command line or scripts
The "ioctls are evil" blind hate department really annoy me however
because like all extreme views the truth very rarely fits their model
</rant>
next prev parent reply other threads:[~2004-12-21 1:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-14 23:31 ioctl assignment strategy? Al Hooton
2004-12-15 0:46 ` Greg KH
2004-12-15 14:53 ` Chris Friesen
2004-12-17 23:48 ` Greg KH
2004-12-20 17:37 ` Chris Friesen
2004-12-20 22:48 ` Pjotr Kourzanov
2004-12-21 0:32 ` Alan Cox [this message]
2004-12-21 2:06 ` Lee Revell
2004-12-21 12:51 ` Olivier Galibert
2004-12-21 17:24 ` Greg KH
2004-12-22 17:16 ` Al Hooton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1103589129.32548.10.camel@localhost.localdomain \
--to=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.kourzanov@xs4all.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox