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 in scull/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 the SHIFTs, but they’re mainly for internal use. _IOC_SIZEBITS is 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_READ and _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 ...

Get Linux Device Drivers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.