Messages in this thread | | | Date | Thu, 25 Mar 1999 16:50:28 -0500 | From | Brian Gerst <> | Subject | Re: what about _IOC_SIZE ?? |
| |
Fabien Klein wrote: > > Hello > > Can someone tell me the meaning of the _IOC_SIZE(cmd) value?
The ioctl numbers encode 4 values: direction (read/write) type (usually related to the major number) command size (size of argument)
Having the size of the parameter of an ioctl makes it easy to use verify_{read,write} without needing to use a switch statement for each ioctl.
For example, from <asm-i386/ioctls.h>: #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
This means that the parameter passed via ioctl is a pointer to an unsigned int, and thus will have a size of 4 (on an i386).
An even better example, using a variable size for a string buffer, from <linux/joystick.h>: #define JSIOCGNAME(len) _IOC(_IOC_READ, 'j', 0x13, len)
This allows you to pass the length of your string buffer to the ioctl, instead of having to use something a parameter block.
--
Brian Gerst
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |