ContainerTracer  0.1
Macros | Enumerations | Functions | Variables
sgio.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <linux/fs.h>
#include <scsi/scsi.h>
#include <scsi/sg.h>
#include <hdparm.h>
Include dependency graph for sgio.c:

Macros

#define SG_READ   0
 
#define SG_WRITE   1
 
#define SG_CHECK_CONDITION   0x02
 
#define SG_DRIVER_SENSE   0x08
 
#define SG_ATA_16   0x85
 
#define SG_ATA_16_LEN   16
 
#define SG_ATA_LBA48   1
 
#define SG_ATA_PROTO_NON_DATA   (3 << 1)
 
#define SG_ATA_PROTO_PIO_IN   (4 << 1)
 
#define SG_ATA_PROTO_PIO_OUT   (5 << 1)
 
#define SG_ATA_PROTO_DMA   (6 << 1)
 
#define SG_ATA_PROTO_UDMA_IN   (11 << 1) /* not yet supported in libata */
 
#define SG_ATA_PROTO_UDMA_OUT   (12 << 1) /* not yet supported in libata */
 
#define ATA_USING_LBA   (1 << 6)
 

Enumerations

enum  {
  SG_CDB2_TLEN_NODATA = 0 << 0, SG_CDB2_TLEN_FEAT = 1 << 0, SG_CDB2_TLEN_NSECT = 2 << 0, SG_CDB2_TLEN_BYTES = 0 << 2,
  SG_CDB2_TLEN_SECTORS = 1 << 2, SG_CDB2_TDIR_TO_DEV = 0 << 3, SG_CDB2_TDIR_FROM_DEV = 1 << 3, SG_CDB2_CHECK_COND = 1 << 5
}
 

Functions

void tf_init (struct ata_tf *tf, __u8 ata_op, __u64 lba, unsigned int nsect)
 
__u64 tf_to_lba (struct ata_tf *tf)
 
static void dump_bytes (const char *prefix, unsigned char *p, int len)
 
static int bad_sense (unsigned char *sb, int len)
 
int sg16 (int fd, int rw, struct ata_tf *tf, void *data, unsigned int data_bytes, unsigned int timeout_secs)
 
int do_drive_cmd (int fd, unsigned char *args)
 

Variables

int verbose
 

Macro Definition Documentation

◆ ATA_USING_LBA

#define ATA_USING_LBA   (1 << 6)

◆ SG_ATA_16

#define SG_ATA_16   0x85

◆ SG_ATA_16_LEN

#define SG_ATA_16_LEN   16

◆ SG_ATA_LBA48

#define SG_ATA_LBA48   1

◆ SG_ATA_PROTO_DMA

#define SG_ATA_PROTO_DMA   (6 << 1)

◆ SG_ATA_PROTO_NON_DATA

#define SG_ATA_PROTO_NON_DATA   (3 << 1)

◆ SG_ATA_PROTO_PIO_IN

#define SG_ATA_PROTO_PIO_IN   (4 << 1)

◆ SG_ATA_PROTO_PIO_OUT

#define SG_ATA_PROTO_PIO_OUT   (5 << 1)

◆ SG_ATA_PROTO_UDMA_IN

#define SG_ATA_PROTO_UDMA_IN   (11 << 1) /* not yet supported in libata */

◆ SG_ATA_PROTO_UDMA_OUT

#define SG_ATA_PROTO_UDMA_OUT   (12 << 1) /* not yet supported in libata */

◆ SG_CHECK_CONDITION

#define SG_CHECK_CONDITION   0x02

◆ SG_DRIVER_SENSE

#define SG_DRIVER_SENSE   0x08

◆ SG_READ

#define SG_READ   0

◆ SG_WRITE

#define SG_WRITE   1

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SG_CDB2_TLEN_NODATA 
SG_CDB2_TLEN_FEAT 
SG_CDB2_TLEN_NSECT 
SG_CDB2_TLEN_BYTES 
SG_CDB2_TLEN_SECTORS 
SG_CDB2_TDIR_TO_DEV 
SG_CDB2_TDIR_FROM_DEV 
SG_CDB2_CHECK_COND 

Function Documentation

◆ bad_sense()

static int bad_sense ( unsigned char *  sb,
int  len 
)
static
Here is the call graph for this function:

◆ do_drive_cmd()

int do_drive_cmd ( int  fd,
unsigned char *  args 
)
Here is the call graph for this function:

◆ dump_bytes()

static void dump_bytes ( const char *  prefix,
unsigned char *  p,
int  len 
)
static

◆ sg16()

int sg16 ( int  fd,
int  rw,
struct ata_tf tf,
void *  data,
unsigned int  data_bytes,
unsigned int  timeout_secs 
)
Here is the call graph for this function:

◆ tf_init()

void tf_init ( struct ata_tf tf,
__u8  ata_op,
__u64  lba,
unsigned int  nsect 
)

◆ tf_to_lba()

__u64 tf_to_lba ( struct ata_tf tf)

Variable Documentation

◆ verbose

int verbose