From 08ba0e8de72dafbd7afbad421b8c1758f5a75626 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 10 Oct 2006 17:55:34 +0000 Subject: [PATCH] Got rid of assert() in sg.c by soft means --- trunk/cdrskin/cdrskin_timestamp.h | 2 +- trunk/libburn/libdax_msgs.h | 2 +- trunk/libburn/sg.c | 45 ++++++++++++++++++++++--------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/trunk/cdrskin/cdrskin_timestamp.h b/trunk/cdrskin/cdrskin_timestamp.h index 1213f227..6fb361f6 100644 --- a/trunk/cdrskin/cdrskin_timestamp.h +++ b/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2006.10.10.112545" +#define Cdrskin_timestamP "2006.10.10.175444" diff --git a/trunk/libburn/libdax_msgs.h b/trunk/libburn/libdax_msgs.h index 40464dba..e3bd263f 100644 --- a/trunk/libburn/libdax_msgs.h +++ b/trunk/libburn/libdax_msgs.h @@ -317,7 +317,7 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff 0x00020109 (FATAL,HIGH) = Library not running 0x0002010a (FATAL,HIGH) = Unsuitable track mode 0x0002010b (FATAL,HIGH) = Burn run failed - 0x0002010c + 0x0002010c (FATAL,HIGH) = Failed to transfer command to drive 0x0002010d 0x0002010e 0x0002010f diff --git a/trunk/libburn/sg.c b/trunk/libburn/sg.c index 4047eb94..9d71cfe8 100644 --- a/trunk/libburn/sg.c +++ b/trunk/libburn/sg.c @@ -1,6 +1,8 @@ /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */ -#include +/* ts A61010 */ +/* #include */ + #include #include #include @@ -616,7 +618,6 @@ int sg_issue_command(struct burn_drive *d, struct command *c) int err; sg_io_hdr_t s; - /* ts A60821 <<< debug: for tracing calls which might use open drive fds */ char buf[161]; @@ -624,17 +625,13 @@ int sg_issue_command(struct burn_drive *d, struct command *c) d->fd,d->released); mmc_function_spy(buf); + /* ts A61010 : with no fd there is no chance to send an ioctl */ + if (d->fd < 0) { + c->error = 1; + return 0; + } c->error = 0; -/* -this is valid during the mode probe in scan - if (d->fd < 1 || d->released) { - burn_print(1, - "command issued on ungrabbed drive, chaos.\n"); - burn_print(1, "fd = %d, released = %d\n", d->fd, - d->released); - } -*/ memset(&s, 0, sizeof(sg_io_hdr_t)); s.interface_id = 'S'; @@ -663,7 +660,14 @@ this is valid during the mode probe in scan /* touch page so we can use valgrind */ memset(c->page->data, 0, BUFFER_SIZE); } else { - assert(c->page->bytes > 0); + + /* ts A61010 */ + /* a ssert(c->page->bytes > 0); */ + if (c->page->bytes <= 0) { + c->error = 1; + return 0; + } + s.dxfer_len = c->page->bytes; } } else { @@ -674,7 +678,22 @@ this is valid during the mode probe in scan do { err = ioctl(d->fd, SG_IO, &s); - assert(err != -1); + + /* ts A61010 */ + /* a ssert(err != -1); */ + if (err == -1) { + libdax_msgs_submit(libdax_messenger, + d->global_index, 0x0002010c, + LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH, + "Failed to transfer command to drive", + errno, 0); + sg_close_drive(d); + d->released = 1; + d->busy = BURN_DRIVE_IDLE; + c->error = 1; + return -1; + } + if (s.sb_len_wr) { if (!c->retry) { c->error = 1;