The user space signature of the ioctl(2) system call is as follows:
#include <sys/ioctl.h>
int ioctl(int fd, unsigned long request, ...);
Here, we can see that it takes a variable argument list; the arguments to ioctl are as follows:
- First parameter: The file descriptor of the file or device (as it will be in our case) to perform the ioctl operation on (we get fd by performing an open on the device file).
- Second parameter: The request or command being issued to the underlying device driver (or filesystem or whatever fd represents).
- An optional third (or more) parameter(s): Often, the third parameter is an integer (or a pointer to an integer or data structure); we use this method to either pass some additional information to the driver, when issuing a set kind of command, or to retrieve some information from the driver via the well-understood pass-by-reference C paradigm, where we pass the pointer and have the driver...