Quick Reference
This chapter introduced you to the following symbols and header files:
-
#include <linux/ioctl.h> This header declares all the macros used to define ioctl commands. It is currently included by
<linux/fs.h>. Linux 1.2 doesn’t declare the fancy macros introduced in this chapter; if backward compatibility is needed, I’d suggest looking inscull/sysdep.h, which defines the correct symbols for old kernel versions.-
_IOC_NRBITS,_IOC_TYPEBITS,_IOC_SIZEBITS,_IOC_DIRBITS The number of bits available for the different bit fields of ioctl commands. There are also four macros that specify the
MASKs and four that specify theSHIFTs, but they’re mainly for internal use._IOC_SIZEBITSis an important value to check, because it changes across architectures.-
_IOC_NONE,_IOC_READ,_IOC_WRITE The possible values for the ``direction'' bitfield. ``Read'' and ``write'' are different bits and can be ORed to specify read/write. The values are 0-based.
-
_IOC(dir,type,nr,size),_IO(type,nr),_IOR(type,nr,size),_IOW(type,nr,size),_IOWR(type,nr,size) Macros used to create an ioctl command.
-
_IOC_DIR(nr),_IOC_TYPE(nr),_IOC_NR(nr),_IOC_SIZE(nr) Macros used to decode a command. In particular,
_IOC_TYPE(nr)is an OR-combination of_IOC_READand_IOC_WRITE.-
#include <linux/mm.h>,int verify_area(int mode, const void *ptr,,unsigned long extent); This function checks that a pointer in the user space is actually usable. verify_area deals with page ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access