April 2012
Intermediate to advanced
352 pages
8h
English
Example 1-2 is a complete character driver (based on code written by Murray Stokely and Søren Straarup) that manipulates a memory area as though it were a device. This pseudo (or memory) device lets you write and read a single character string to and from it.
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 1-2. echo.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> #define BUFFER_SIZE 256 /* Forward declarations. */ static d_open_t echo_open; static d_close_t echo_close; static d_read_t echo_read; static d_write_t ...
Read now
Unlock full access