April 2012
Intermediate to advanced
352 pages
8h
English
Example 3-1 is a revision of Example 2-1 that adds in a d_ioctl function. As you’ll see, this d_ioctl function handles two ioctl commands.
Take a quick look at this code and try to discern some of its structure. If you don’t understand all of it, don’t worry; an explanation follows.
Example 3-1. echo-3.0.c
#include <sys/param.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> #include <sys/conf.h> #include <sys/uio.h> #include <sys/malloc.h> #include <sys/ioccom.h> MALLOC_DEFINE(M_ECHO, "echo_buffer", "buffer for echo driver");#define ECHO_CLEAR_BUFFER _IO('E', 1) #define ECHO_SET_BUFFER_SIZE _IOW('E', ...