Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

what about _IOC_SIZE ??

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


fabklein at hotmail

Mar 25, 1999, 10:27 AM

Post #1 of 2 (22 views)
Permalink
what about _IOC_SIZE ??

Hello
Can someone tell me the meaning of the _IOC_SIZE(cmd) value?
ex:
on the user side:
ioctl(fd,_MY_IOCTL,&buffer) (sizeof buffer = 1000)
on the kernel side
ioctl_function(struct inode *inode, struct file *filp, unsigned int cmd,
ulong arg)
..
size = _IOC_SIZE(cmd)
and here size = 4 ??? I would expected 1000...no?
Perhaps my ioctl process is totaly wrong?
Fabien
Get Your Private, Free Email at http://www.hotmail.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
Please read the FAQ at http://www.tux.org/lkml/


bgerst at quark

Mar 25, 1999, 2:50 PM

Post #2 of 2 (20 views)
Permalink
Re: what about _IOC_SIZE ?? [In reply to]

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 [at] vger
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.