This structure describes how a SCSI command is to be processed and has
room to hold the results of the execution of the command. The
individual structure components will be discussed later in
section
sec-header
.

The general way of exchanging data with the generic driver is as
follows: to send a command to an opened generic device, write() a
block containing these three parts to it:

struct sg_header
SCSI command
data to be sent with the command

To obtain the result of a command, read() a block with this
(similar) block structure:

struct sg_header
data coming from the device

This is a general overview of the process. The following sections
describe each of the steps in more detail.

NOTE: Up to recent kernel versions, it is necessary to block the
SIGINT signal between the write() and the corresponding
read() call (i.e. via sigprocmask()). A return after the
write() part without any read() to fetch the results
will block on subsequent accesses. This signal blocking has not
yet been included in the example code. So better do not issue
SIGINT (a la ^C) when running these examples.