next up previous
Next: Integrating FUSD With Your Up: Writing ioctl Callbacks Previous: Using macros to generate

Example client calls and driver callbacks

Program 7 shows a client program that executes ioctls using the ioctl command numbers defined in Program 6. The ioctl_data_t is application-specific; our simple test program defines it as a structure containing two arrays of characters. The first ioctl call (line 10) sends the command IOCTL_TEST3, which retrieves strings from the driver. The second ioctl uses the command IOCTL_TEST4 (line 18), which sends strings to the driver.


\begin{Program}
% latex2html id marker 586\listinginput[5]{1}{ioctl-client.c.e...
....c: A program that makes {\tt ioctl} requests on
a file descriptor}\end{Program}

The portion of the FUSD driver that services these calls is shown in Program 8.


\begin{Program}
% latex2html id marker 593\listinginput[5]{1}{ioctl-server.c.e...
...caption{ioctl-server.c: A driver that handles {\tt ioctl} requests}\end{Program}

The ioctl example header file and test programs shown in this document (Programs 6, 7, and 8) are actually contained in a larger, single example program included in the FUSD distribution called ioctl.c. That source code shows other variations on calling and servicing ioctl commands.



Jeremy Elson 2003-08-20