sid@linus.UUCP (Sid Stuart) (03/08/85)
We are trying to modify the keyboard translation table in the sun keyboard driver. The KB(4S) manual entry claims that the ioctl call struct kiockey key err = ioctl(fd, KIOCSETKEY, &key) will allow one to change the translation for one key. When we compile this in a program, we get the error message that "k" is undefined. The definition of KIOCSETKEY in <sundev/kbio.h> is: #define KIOCSETKEY _IOW(k, 1, struct kiockey) Okay, so there is the "k" that is undefined, but now I am lost. I thought the second entry to an ioctl was supposed to be an integer. Well, maybe _IOW returns an integer, but then what should "k" be defined as, and what should it be initialized to? We looked around and we cannot find any mention of it in the documentation. We can't find any mention of it in the .h files either. It looks like I will have to go into the code for the kernal and see if I can find what _IOW is and does. I won't be able to do this till next week though. If anybody out there has a helpful hint, I would really like to hear it. BTW, replys that tell me to call up Sun's much touted software support number will be laughed at. The "engineer" I talked to there wasn't much help. He did not know anything about it. He did know of a consultant that knew about it, but he said the consultant did not like to talk to people. The "engineer" is sending me a copy of a program the consultant wrote that may do what I want done, but I won't know that until it arrives via snail mail. Confused as usual, sid at linus
chris@umcp-cs.UUCP (Chris Torek) (03/10/85)
Probably you forgot to include <sys/ioctl.h> (<sundev/kbio.h> doesn't do it for you, though there's no reason it can't). 4.2BSD uses the "Reiserism" #define _IOW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y) which is why there's an unquoted ``k'' in _IOW(k,1,struct kiockey). (Personally, I think this is incredibly ugly.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (03/12/85)
> #define KIOCSETKEY _IOW(k, 1, struct kiockey)
This is a macro Berkeley introduced that evaluates to the (int)
ioctl code (second argument to ioctl(2)) for ioctl functions that
involve sending data from user process space into the kernel.
The macro is defined in /usr/include/sys/ioctl.h. Unfortunately,
they are making use of a Reiser C preprocessor trick to take the
"k" and make a character constant 'k' out of it (then combine that
with the constant "1" and the sizeof(struct kiockey)). If you are
having trouble, first check that you're #including <sys/ioctl.h>.
One objection I have to the _IOWR macros is that not every ioctl
fits this model. There are some "xt" driver ioctls for which the
sizeof the transfered data simply does not fit the alloted space.