Commit 295771dc authored by Eric Cano's avatar Eric Cano
Browse files

Created the inquiry CDB structure and replaced some hardcoding.

parent 7190813a
......@@ -87,16 +87,16 @@ namespace Tape {
void SCSI_inquiry(int fd) {
unsigned char dataBuff[130];
unsigned char senseBuff[256];
unsigned char cdb[6];
SCSI::Structures::inquiryCDB_t cdb;
memset(&cdb, 0, sizeof (cdb));
memset(&dataBuff, 0, sizeof (dataBuff));
/* Build command */
cdb[0] = SCSI::Commands::INQUIRY;
cdb.opCode = SCSI::Commands::INQUIRY;
sg_io_hdr_t sgh;
memset(&sgh, 0, sizeof (sgh));
sgh.interface_id = 'S';
sgh.cmdp = cdb;
sgh.cmdp = (unsigned char *)&cdb;
sgh.cmd_len = sizeof (cdb);
sgh.sbp = senseBuff;
sgh.mx_sb_len = 255;
......
......@@ -29,8 +29,31 @@
#include <arpa/inet.h>
namespace SCSI {
/**
* Structures as defined in the SCSI specifications, and helper functions for them.
* SPC-4 (SCSI primary commands) can be found at:
* http://hackipedia.org/Hardware/SCSI/Primary%20Commands/SCSI%20Primary%20Commands%20-%204.pdf
*
* and SSC-3 (SCSI stream commands, i.e. tape drives) at:
* http://hackipedia.org/Hardware/SCSI/Stream%20Commands/SCSI%20Stream%20Commands%20-%203.pdf
*/
namespace Structures {
/*
* Inquiry CDB as described in SPC-4.
*/
typedef struct {
unsigned char opCode;
unsigned char EVPD : 1;
unsigned char : 7;
unsigned char pageCode;
char allocationLength[2];
unsigned char control;
} inquiryCDB_t;
/*
* Inquiry data as described in SPC-4.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment