Subject: Re: IOCTL implementation and kernel/userland addresses
To: None <tech-kern@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 02/15/2005 04:09:12
> ioctls should either sleep or not sleep.  I do not think the behavior
> of a given ioctl should change depending on the calling context.

Well, whether I agree depends on whether you count using copyout versus
bcopy counts as changing the behaviour.

Actually, even that aside, I'm not sure I agree.  For example, if the
ioctl has to malloc something, it may want to use M_WAITOK when called
by userland and M_NOWAIT if called by someone that can't sleep.  (Of
course, it currently doesn't have any good way to tell whether it's
called by a can't-sleep context, but all that means is that a certain
thing which is relatively reasonable can't be done at present.)

> If we need a sleeping and a non-sleeping variant, we should have two
> calls. :-)

When they share all their code except for, say, a flag bit for malloc,
I have to wonder if the code duplication is worth it.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B