Quick Reference
This chapter introduced 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>.-
_IOC_NRBITS,_IOC_TYPEBITS,_IOC_SIZEBITS,_IOC_DIRBITS The number of bits available for the different bitfields 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 OR’d 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 <asm/uaccess.h>,int access_ok(int type, const void *addr, unsigned long size); This function checks that a pointer to user space is actually usable. access_ok returns a nonzero value if the access should be allowed.
-
VERIFY_READ,VERIFY_WRITE The possible values for the
typeargument in access_ok.VERIFY_WRITEis a superset ofVERIFY_READ.-
#include <asm/uaccess.h>,int put_user(datum,ptr); ...
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