outsource from india chennai india programmers freelance php coder freelance outsource scripts programming complicated perl patterns php module installation
outsource from india perl installation and configuration php installation linux system administration US$15,US$19,US$11,US$10 cheap programmer
india outsource outsource india chennai india programmers php perl mysql freelance freelance programmer
SHOWCASE of php and perl scripts CONTACT US for php custom perl scripts
HOME
 
Next Previous Contents

6. Overview Of Device Programming

The header file include/scsi/sg.h contains a description of the interface (this is based on kernel version 1.3.98):

struct sg_header
 {
  int pack_len;
                   /* length of incoming packet (including header) */
  int reply_len;   /* maximum length of expected reply */
  int pack_id;     /* id number of packet */
  int result;      /* 0==ok, otherwise refer to errno codes */
  unsigned int twelve_byte:1;
               /* Force 12 byte command length for group 6 & 7 commands  */
  unsigned int other_flags:31;                  /* for future use */
  unsigned char sense_buffer[16]; /* used only by reads */
  /* command follows then data for command */
 };

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.


Next Previous Contents
Linux HOWTO full list
   This document, LDP HOWTO-INDEX, is copyrighted (c) 1995 - 2002 by Tim Bynum, Guylhem Aznar, Joshua Drake and Greg Ferguson. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is available at http://www.gnu.org/copyleft/fdl.html. If you have questions, please contact the LDP.
Web Design Copyright © 1999-2003. Chrisranjana Software Solutions Pvt Ltd. syndicate rss feed