Hello,
I would like to know what the macros _IOR and _IOW do?
Thanks,
Mahesh.
They're used to declare the commands used for the "request"Quote:>I would like to know what the macros _IOR and _IOW do?
--
James Raynard, Edinburgh, Scotland
http://www.freebsd.org/~jraynard/
> They're used to declare the commands used for the "request"
> argument of ioctl(2). _IOW is used for an 'in' parameter,
> _IOR for an 'out' parameter and there's an _IOWR macro that
> combines the two.
Unlike with SysV, the generic ioctl code in BSD normally handles
argument passing from/to user address space, including the bounds
checking. This way, the ioctl stub in the driver doesn't need to
copyin()/copyout() the arguments itself (as it must still do it in
SysV, if i'm not totally mistaken). However, in order to arrange for
this, the generic ioctl code needs to know the size and passing
direction of the arguments, so this information is encoded into the
ioctl command word. That's what these macros are for.
Btw., this has an additional advantage: if the size of some argument
structure has been changed, obsolete binaries that still use the old
struct will get an ENOTTY (Inappropriate ioctl for this device) since
the new command word is different. In SysV, they will simply read/
write garbage in this case, since the ioctl is still valid.
--
cheers, J"org
Never trust an operating system you don't have sources for. ;-)
Hello,
I would like to know what the macros _IOR and _IOW do?
Thanks,
Mahesh.
6. accessing cdrom of NT workstation from AIX
8. Libc-4.4.1 -> forced net-src recompile?