I have a Linux standard header file e.g.
/usr/src/linux-headers-3.2.0-35/include/linux/usbdevice_fs.h
which contain define statements as follows:
#define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
#define USBDEVFS_DISCARDURB _IO('U', 11)
#define USBDEVFS_REAPURB _IOW('U', 12, void *)
What does ‘_IOR’, ‘_IO’ and ‘_IOW’ mean? What value is actually given e.g. to USBDEVFS_DISCARDURB?
They define ioctl numbers, based on ioctl function and input parameters.
The are defined in kernel, in
include/asm-generic/ioctl.h.You need to include
<linux/ioctl.h>(orlinux/asm-generic/ioctl.h) in your program. Before including/usr/src/linux-headers-3.2.0-35/include/linux/usbdevice_fs.hYou can’t “precompile” this values (e.g.
USBDEVFS_DISCARDURB), because they can be different on other platforms. For example, you are developing your code on plain old x86, but then someone will try to use it on x86_64/arm/mips/etc. So you should always include kernel’sioctl.hto make sure, you are using right values.