xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

spc.c File Reference
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include <stdlib.h>
#include "libburn.h"
#include "transport.h"
#include "spc.h"
#include "mmc.h"
#include "sbc.h"
#include "drive.h"
#include "debug.h"
#include "options.h"
#include "init.h"
#include "util.h"
#include "libdax_msgs.h"
Include dependency graph for spc.c:

Go to the source code of this file.

Functions

int scsi_init_command (struct command *c, unsigned char *opcode, int oplen)
 
int spc_decode_sense (unsigned char *sense, int senselen, int *key, int *asc, int *ascq)
 
int spc_test_unit_ready_r (struct burn_drive *d, int *key, int *asc, int *ascq, int *progress)
 
int spc_test_unit_ready (struct burn_drive *d)
 
int spc_wait_unit_attention (struct burn_drive *d, int max_sec, char *cmd_text, int flag)
 
void spc_request_sense (struct burn_drive *d, struct buffer *buf)
 
static int spc_report_async_error (struct burn_drive *d, int key, int asc, int ascq, int flag)
 
int spc_get_erase_progress (struct burn_drive *d)
 
void spc_inquiry (struct burn_drive *d)
 
void spc_prevent (struct burn_drive *d)
 
void spc_allow (struct burn_drive *d)
 
static int spc_try_get_performance (struct burn_drive *d, int flag)
 
static int spc_sense_caps_al (struct burn_drive *d, int *alloc_len, int flag)
 
void spc_sense_caps (struct burn_drive *d)
 
void spc_sense_error_params (struct burn_drive *d)
 
void spc_select_error_params (struct burn_drive *d, const struct burn_read_opts *o)
 
void spc_sense_write_params (struct burn_drive *d)
 
void spc_select_write_params (struct burn_drive *d, struct burn_session *s, int tnum, const struct burn_write_opts *o)
 
void spc_getcaps (struct burn_drive *d)
 
void spc_probe_write_modes (struct burn_drive *d)
 
int spc_block_type (enum burn_block_types b)
 
int spc_setup_drive (struct burn_drive *d)
 
int burn_scsi_setup_drive (struct burn_drive *d, int bus_no, int host_no, int channel_no, int target_no, int lun_no, int flag)
 
enum response scsi_error_msg (struct burn_drive *d, unsigned char *sense, int senselen, char msg_data[161], int *key, int *asc, int *ascq)
 
enum response scsi_error (struct burn_drive *d, unsigned char *sense, int senselen)
 
static char * scsi_command_name (unsigned int c, int flag)
 
char * spc_command_name (unsigned int c, int flag)
 
void spc_register_retry (struct command *c)
 
int spc_human_readable_cmd (struct command *c, char *msg, int msg_max, int flag)
 
int scsi_notify_error (struct burn_drive *d, struct command *c, unsigned char *sense, int senselen, int flag)
 
int scsi_show_command (unsigned char *opcode, int oplen, int dir, unsigned char *data, int bytes, void *fp_in, int flag)
 
int scsi_show_cmd_text (struct command *c, void *fp_in, int flag)
 
int scsi_show_command_reply (unsigned char *opcode, int data_dir, unsigned char *data, int dxfer_len, void *fp_in, int flag)
 
int scsi_log_command (unsigned char *opcode, int oplen, int data_dir, unsigned char *data, int bytes, void *fp_in, int flag)
 
int scsi_log_text (char *text, void *fp_in, int flag)
 
int scsi_log_cmd (struct command *c, void *fp_in, int flag)
 
int scsi_log_reply (unsigned char *opcode, int data_dir, unsigned char *data, int dxfer_len, void *fp_in, unsigned char sense[18], int sense_len, double duration, int flag)
 
int scsi_log_err (struct burn_drive *d, struct command *c, void *fp_in, unsigned char sense[18], int sense_len, int flag)
 
int scsi_log_message (struct burn_drive *d, void *fp_in, char *msg, int flag)
 
int scsi_eval_cmd_outcome (struct burn_drive *d, struct command *c, void *fp, unsigned char *sense, int sense_len, time_t start_time, int timeout_ms, int loop_count, int flag)
 
int spc_confirm_cd_drive (struct burn_drive *d, int flag)
 

Variables

struct libdax_msgs * libdax_messenger
 
int burn_sg_log_scsi
 
static unsigned char SPC_INQUIRY [] = { 0x12, 0, 0, 0, 36, 0 }
 
static unsigned char SPC_PREVENT [] = { 0x1e, 0, 0, 0, 1, 0 }
 
static unsigned char SPC_ALLOW [] = { 0x1e, 0, 0, 0, 0, 0 }
 
static unsigned char SPC_MODE_SENSE [] = { 0x5a, 0, 0, 0, 0, 0, 0, 16, 0, 0 }
 
static unsigned char SPC_MODE_SELECT [] = { 0x55, 16, 0, 0, 0, 0, 0, 0, 0, 0 }
 
static unsigned char SPC_REQUEST_SENSE [] = { 0x03, 0, 0, 0, 18, 0 }
 
static unsigned char SPC_TEST_UNIT_READY [] = { 0x00, 0, 0, 0, 0, 0 }
 

Function Documentation

◆ burn_scsi_setup_drive()

◆ scsi_command_name()

static char* scsi_command_name ( unsigned int  c,
int  flag 
)
static

Definition at line 1687 of file spc.c.

Referenced by scsi_notify_error(), scsi_show_command(), and spc_command_name().

◆ scsi_error()

enum response scsi_error ( struct burn_drive d,
unsigned char *  sense,
int  senselen 
)

Definition at line 1213 of file spc.c.

Referenced by scsi_eval_cmd_outcome(), and sg_issue_command().

◆ scsi_error_msg()

enum response scsi_error_msg ( struct burn_drive d,
unsigned char *  sense,
int  senselen,
char  msg_data[161],
int *  key,
int *  asc,
int *  ascq 
)

◆ scsi_eval_cmd_outcome()

int scsi_eval_cmd_outcome ( struct burn_drive d,
struct command c,
void *  fp_in,
unsigned char *  sense,
int  sense_len,
time_t  start_time,
int  timeout_ms,
int  loop_count,
int  flag 
)

◆ scsi_init_command()

◆ scsi_log_cmd()

int scsi_log_cmd ( struct command c,
void *  fp_in,
int  flag 
)

Logs command (before execution)

Definition at line 2002 of file spc.c.

References buffer::bytes, buffer::data, command::dir, command::opcode, command::oplen, command::page, and scsi_log_command().

Referenced by scsi_eval_cmd_outcome(), and sg_issue_command().

◆ scsi_log_command()

int scsi_log_command ( unsigned char *  opcode,
int  oplen,
int  data_dir,
unsigned char *  data,
int  bytes,
void *  fp_in,
int  flag 
)

Logs command (before execution)

Definition at line 1964 of file spc.c.

References burn_sg_log_scsi, command::opcode, command::oplen, and scsi_show_command().

Referenced by scsi_log_cmd(), and sgio_log_cmd().

◆ scsi_log_err()

int scsi_log_err ( struct burn_drive d,
struct command c,
void *  fp_in,
unsigned char  sense[18],
int  sense_len,
int  flag 
)

Legacy frontend to scsi_log_reply().

Parameters
flagbit0 causes an error message bit1 do not print duration

Definition at line 2070 of file spc.c.

References buffer::data, command::dir, command::dxfer_len, command::end_time, command::opcode, command::page, scsi_log_reply(), command::sense, command::sense_len, and command::start_time.

Referenced by scsi_eval_cmd_outcome().

◆ scsi_log_message()

int scsi_log_message ( struct burn_drive d,
void *  fp_in,
char *  msg,
int  flag 
)

Definition at line 2087 of file spc.c.

References burn_sg_log_scsi.

Referenced by evaluate_transport_success(), react_on_drive_loss(), and sg_issue_command().

◆ scsi_log_reply()

int scsi_log_reply ( unsigned char *  opcode,
int  data_dir,
unsigned char *  data,
int  dxfer_len,
void *  fp_in,
unsigned char  sense[18],
int  sense_len,
double  duration,
int  flag 
)

Logs outcome of a sg command.

Parameters
flagbit0 causes an error message bit1 do not print duration

Definition at line 2022 of file spc.c.

References burn_get_time(), burn_sg_log_scsi, command::dxfer_len, lib_start_time, command::opcode, scsi_show_command_reply(), command::sense, command::sense_len, and spc_decode_sense().

Referenced by scsi_log_err(), and sgio_log_reply().

◆ scsi_log_text()

int scsi_log_text ( char *  text,
void *  fp_in,
int  flag 
)

Definition at line 1984 of file spc.c.

References burn_sg_log_scsi.

Referenced by sg_issue_command().

◆ scsi_notify_error()

◆ scsi_show_cmd_text()

int scsi_show_cmd_text ( struct command c,
void *  fp_in,
int  flag 
)

◆ scsi_show_command()

int scsi_show_command ( unsigned char *  opcode,
int  oplen,
int  dir,
unsigned char *  data,
int  bytes,
void *  fp_in,
int  flag 
)

◆ scsi_show_command_reply()

int scsi_show_command_reply ( unsigned char *  opcode,
int  data_dir,
unsigned char *  data,
int  dxfer_len,
void *  fp_in,
int  flag 
)

Definition at line 1936 of file spc.c.

References command::dxfer_len, FROM_DRIVE, and command::opcode.

Referenced by scsi_log_reply().

◆ spc_allow()

◆ spc_block_type()

◆ spc_command_name()

char* spc_command_name ( unsigned int  c,
int  flag 
)

Definition at line 1768 of file spc.c.

References scsi_command_name().

Referenced by spc_human_readable_cmd().

◆ spc_confirm_cd_drive()

◆ spc_decode_sense()

int spc_decode_sense ( unsigned char *  sense,
int  senselen,
int *  key,
int *  asc,
int *  ascq 
)

◆ spc_get_erase_progress()

int spc_get_erase_progress ( struct burn_drive d)

◆ spc_getcaps()

◆ spc_human_readable_cmd()

◆ spc_inquiry()

◆ spc_prevent()

◆ spc_probe_write_modes()

◆ spc_register_retry()

void spc_register_retry ( struct command c)

◆ spc_report_async_error()

static int spc_report_async_error ( struct burn_drive d,
int  key,
int  asc,
int  ascq,
int  flag 
)
static

◆ spc_request_sense()

◆ spc_select_error_params()

◆ spc_select_write_params()

◆ spc_sense_caps()

void spc_sense_caps ( struct burn_drive d)

◆ spc_sense_caps_al()

static int spc_sense_caps_al ( struct burn_drive d,
int *  alloc_len,
int  flag 
)
static
Parameters
flagbit0= do only inquire alloc_len
Returns
1=ok , <=0 error , 2=Block Descriptor Length > 0, retry with flag bit1

Definition at line 483 of file spc.c.

References BUFFER_SIZE, scsi_mode_data::buffer_size, BURN_ALLOC_MEM, BURN_DRIVE_ADR_LEN, BURN_FREE_MEM, burn_mdata_free_subs(), burn_speed_descriptor_new(), buffer::bytes, scsi_mode_data::c2_pointers, scsi_mode_data::cdr_read, scsi_mode_data::cdr_write, scsi_mode_data::cdrw_read, scsi_mode_data::cdrw_write, scsi_mode_data::cur_read_speed, scsi_mode_data::cur_write_speed, burn_drive::current_profile, burn_drive::current_profile_text, buffer::data, burn_drive::devname, command::dir, scsi_mode_data::dvdr_read, scsi_mode_data::dvdr_write, scsi_mode_data::dvdram_read, scsi_mode_data::dvdram_write, scsi_mode_data::dvdrom_read, command::dxfer_len, command::error, FROM_DRIVE, burn_drive::global_index, burn_drive::issue_command, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_PRIO_LOW, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_SEV_SORRY, libdax_msgs_submit(), scsi_mode_data::max_end_lba, scsi_mode_data::max_read_speed, scsi_mode_data::max_write_speed, burn_drive::mdata, scsi_mode_data::min_end_lba, scsi_mode_data::min_write_speed, command::opcode, scsi_mode_data::p2a_valid, command::page, burn_speed_descriptor::profile_loaded, burn_speed_descriptor::profile_name, command::retry, scsi_init_command(), buffer::sectors, scsi_mode_data::simulate, burn_speed_descriptor::source, SPC_MODE_SENSE, scsi_mode_data::speed_descriptors, scsi_mode_data::underrun_proof, burn_speed_descriptor::wrc, and burn_speed_descriptor::write_speed.

Referenced by spc_sense_caps().

◆ spc_sense_error_params()

◆ spc_sense_write_params()

◆ spc_setup_drive()

◆ spc_test_unit_ready()

int spc_test_unit_ready ( struct burn_drive d)

Definition at line 143 of file spc.c.

References spc_test_unit_ready_r().

Referenced by mmc_format_unit(), and spc_setup_drive().

◆ spc_test_unit_ready_r()

int spc_test_unit_ready_r ( struct burn_drive d,
int *  key,
int *  asc,
int *  ascq,
int *  progress 
)

◆ spc_try_get_performance()

static int spc_try_get_performance ( struct burn_drive d,
int  flag 
)
static

◆ spc_wait_unit_attention()

int spc_wait_unit_attention ( struct burn_drive d,
int  max_sec,
char *  cmd_text,
int  flag 
)
Parameters
flagbit0=do not wait 0.1 seconds before first test unit ready bit1=do not issue success message Wait until the drive state becomes clear or until max_usec elapsed

Definition at line 156 of file spc.c.

References BURN_ALLOC_MEM, BURN_FREE_MEM, burn_drive::cancel, burn_drive::global_index, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_PRIO_LOW, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_SEV_SORRY, libdax_msgs_submit(), scsi_error_msg(), command::sense, and spc_test_unit_ready_r().

Referenced by mmc_close(), mmc_sync_cache(), sbc_load(), sbc_start_unit_flag(), and sbc_stop_unit().

Variable Documentation

◆ burn_sg_log_scsi

int burn_sg_log_scsi
extern

◆ libdax_messenger

struct libdax_msgs* libdax_messenger
extern

PORTING : ----— OS dependent headers and definitions ---— PORTING : ---— libburn portable headers and definitions --—

Definition at line 42 of file init.c.

Referenced by burn_scsi_setup_drive(), scsi_eval_cmd_outcome(), scsi_notify_error(), spc_confirm_cd_drive(), spc_report_async_error(), spc_sense_caps_al(), and spc_wait_unit_attention().

◆ SPC_ALLOW

unsigned char SPC_ALLOW[] = { 0x1e, 0, 0, 0, 0, 0 }
static

Definition at line 56 of file spc.c.

Referenced by spc_allow().

◆ SPC_INQUIRY

unsigned char SPC_INQUIRY[] = { 0x12, 0, 0, 0, 36, 0 }
static

Definition at line 52 of file spc.c.

Referenced by spc_inquiry().

◆ SPC_MODE_SELECT

unsigned char SPC_MODE_SELECT[] = { 0x55, 16, 0, 0, 0, 0, 0, 0, 0, 0 }
static

Definition at line 58 of file spc.c.

Referenced by spc_probe_write_modes(), spc_select_error_params(), and spc_select_write_params().

◆ SPC_MODE_SENSE

unsigned char SPC_MODE_SENSE[] = { 0x5a, 0, 0, 0, 0, 0, 0, 16, 0, 0 }
static

◆ SPC_PREVENT

unsigned char SPC_PREVENT[] = { 0x1e, 0, 0, 0, 1, 0 }
static

Definition at line 55 of file spc.c.

Referenced by spc_prevent().

◆ SPC_REQUEST_SENSE

unsigned char SPC_REQUEST_SENSE[] = { 0x03, 0, 0, 0, 18, 0 }
static

Definition at line 59 of file spc.c.

Referenced by spc_request_sense().

◆ SPC_TEST_UNIT_READY

unsigned char SPC_TEST_UNIT_READY[] = { 0x00, 0, 0, 0, 0, 0 }
static

Definition at line 60 of file spc.c.

Referenced by spc_test_unit_ready_r().