Made SCSI logger permanent and controllable via API call

This commit is contained in:
Thomas Schmitt 2009-11-12 17:54:06 +00:00
parent ce3d4dbed3
commit 0f37170759
5 changed files with 93 additions and 26 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2009.11.11.105028" #define Cdrskin_timestamP "2009.11.12.175514"

View File

@ -75,6 +75,13 @@ burn_abort_handler_t burn_global_signal_handler = NULL;
/* ts A70223 : wether implemented untested profiles are supported */ /* ts A70223 : wether implemented untested profiles are supported */
int burn_support_untested_profiles = 0; int burn_support_untested_profiles = 0;
/* ts A91111 :
whether to log SCSI commands (to be implemented in sg-*.c)
bit0= log in /tmp/libburn_sg_command_log
bit1= log to stderr
bit2= flush every line
*/
int burn_sg_log_scsi = 0;
/* ts A60925 : ticket 74 */ /* ts A60925 : ticket 74 */
/** Create the messenger object for libburn. */ /** Create the messenger object for libburn. */
@ -414,3 +421,9 @@ int burn_set_messenger(void *messenger)
return 1; return 1;
} }
/* ts A91111 API */
void burn_set_scsi_logging(int flag)
{
burn_sg_log_scsi = flag & 7;
}

View File

@ -762,6 +762,19 @@ int burn_abort_pacifier(void *handle, int patience, int elapsed);
*/ */
void burn_set_verbosity(int level); void burn_set_verbosity(int level);
/* ts A91111 */
/** Enable resp. disable logging of SCSI commands (currently Linux only).
This call can be made at any time - even before burn_initialize().
It is in effect for all active drives and currently not very thread
safe for multiple drives.
@param flag Bitfield for control purposes. The default is 0.
bit0= log to file /tmp/libburn_sg_command_log
bit1= log to stderr
bit2= flush output after each line
@since 0.7.4
*/
void burn_set_scsi_logging(int flag);
/* ts A60813 */ /* ts A60813 */
/** Set parameters for behavior on opening device files. To be called early /** Set parameters for behavior on opening device files. To be called early
after burn_initialize() and before any bus scan. But not mandatory at all. after burn_initialize() and before any bus scan. But not mandatory at all.
@ -2772,12 +2785,21 @@ BURN_END_DECLS
# define Libburn_pioneer_dvr_216d_get_evenT 1 # define Libburn_pioneer_dvr_216d_get_evenT 1
*/ */
/* Probing of CD write modes hampers ejecting of the drive tray. /* ts A91112 */
Needed is a more intelligent management of probing. /* Do not probe CD modes but declare only data and audio modes supported.
Note to myself: check whether feature interpretation can replace probing For other modes resp. real probing one has to call
burn_drive_probe_cd_write_modes().
# define Libburn_pioneer_dvr_216d_no_probe_wM 1 # define Libburn_pioneer_dvr_216d_dummy_probe_wM 1
*/ */
#ifdef Libburn_pioneer_dvr_216d_dummy_probe_wM
/* Probe available CD write modes and block types.
@param drive_info drive object to be inquired
*/
int burn_drive_probe_cd_write_modes(struct burn_drive_info *drive_info)
#endif /* Libburn_pioneer_dvr_216d_dummy_probe_wM */
#endif /*LIBBURN_H*/ #endif /*LIBBURN_H*/

View File

@ -1,5 +1,11 @@
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */ /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/* <<< ts A91112 : experiments to get better speed with USB
#define Libburn_sgio_as_growisofS 1
*/
/* /*
This is the main operating system dependent SCSI part of libburn. It implements This is the main operating system dependent SCSI part of libburn. It implements
@ -196,17 +202,25 @@ static void enumerate_common(char *fname, int bus_no, int host_no,
/* ts A60813 : storage objects are in libburn/init.c /* ts A60813 : storage objects are in libburn/init.c
wether to use O_EXCL with open(2) of devices whether to use O_EXCL with open(2) of devices
wether to use fcntl(,F_SETLK,) after open(2) of devices whether to use fcntl(,F_SETLK,) after open(2) of devices
what device family to use : 0=default, 1=sr, 2=scd, (3=st), 4=sg what device family to use : 0=default, 1=sr, 2=scd, (3=st), 4=sg
wether to use O_NOBLOCK with open(2) on devices whether to use O_NOBLOCK with open(2) on devices
wether to take O_EXCL rejection as fatal error */ whether to take O_EXCL rejection as fatal error
*/
extern int burn_sg_open_o_excl; extern int burn_sg_open_o_excl;
extern int burn_sg_fcntl_f_setlk; extern int burn_sg_fcntl_f_setlk;
extern int burn_sg_use_family; extern int burn_sg_use_family;
extern int burn_sg_open_o_nonblock; extern int burn_sg_open_o_nonblock;
extern int burn_sg_open_abort_busy; extern int burn_sg_open_abort_busy;
/* ts A91111 :
whether to log SCSI commands:
bit0= log in /tmp/libburn_sg_command_log
bit1= log to stderr
bit2= flush every line
*/
extern int burn_sg_log_scsi;
/* ts A60821 /* ts A60821
debug: for tracing calls which might use open drive fds debug: for tracing calls which might use open drive fds
@ -1642,6 +1656,7 @@ int sg_release(struct burn_drive *d)
} }
/* <<< ts A91111: on its way out */
/** ts A70518: /** ts A70518:
Debugging log facility. Controlled by existence of macros: Debugging log facility. Controlled by existence of macros:
Libburn_log_sg_commandS enables logging to file Libburn_log_sg_commandS enables logging to file
@ -1650,10 +1665,11 @@ int sg_release(struct burn_drive *d)
Libburn_log_sg_command_stderR enables additional log to stderr Libburn_log_sg_command_stderR enables additional log to stderr
*/ */
/* /*
ts A91111: now enabled by default and controlled burn_sg_log_scsi
*/
#define Libburn_log_sg_commandS 1 #define Libburn_log_sg_commandS 1
#define Libburn_fflush_log_sg_commandS 1 #define Libburn_fflush_log_sg_commandS 1
#define Libburn_log_sg_command_stderR 1 #define Libburn_log_sg_command_stderR 1
*/
#ifdef Libburn_log_sg_commandS #ifdef Libburn_log_sg_commandS
@ -1661,16 +1677,16 @@ int sg_release(struct burn_drive *d)
/** Logs command (before execution) */ /** Logs command (before execution) */
static int sg_log_cmd(struct command *c, FILE *fp, int flag) static int sg_log_cmd(struct command *c, FILE *fp, int flag)
{ {
if (fp != NULL && (fp == stderr || (burn_sg_log_scsi & 1))) {
if (fp != NULL) {
scsi_show_cmd_text(c, fp, 0); scsi_show_cmd_text(c, fp, 0);
#ifdef Libburn_fflush_log_sg_commandS #ifdef Libburn_fflush_log_sg_commandS
fflush(fp); if (burn_sg_log_scsi & 4)
fflush(fp);
#endif #endif
} }
#ifdef Libburn_log_sg_command_stderR #ifdef Libburn_log_sg_command_stderR
if (fp == stderr) if (fp == stderr || !(burn_sg_log_scsi & 2))
return 1; return 1;
sg_log_cmd(c, stderr, flag); sg_log_cmd(c, stderr, flag);
#endif #endif
@ -1683,7 +1699,7 @@ static int sg_log_err(struct command *c, FILE *fp,
sg_io_hdr_t *s, sg_io_hdr_t *s,
int flag) int flag)
{ {
if(fp!=NULL) { if(fp != NULL && (fp == stderr || (burn_sg_log_scsi & 1))) {
if(flag & 1) { if(flag & 1) {
fprintf(fp, fprintf(fp,
"+++ key=%X asc=%2.2Xh ascq=%2.2Xh (%6d ms)\n", "+++ key=%X asc=%2.2Xh ascq=%2.2Xh (%6d ms)\n",
@ -1693,11 +1709,12 @@ static int sg_log_err(struct command *c, FILE *fp,
fprintf(fp,"%6d ms\n", s->duration); fprintf(fp,"%6d ms\n", s->duration);
} }
#ifdef Libburn_fflush_log_sg_commandS #ifdef Libburn_fflush_log_sg_commandS
fflush(fp); if (burn_sg_log_scsi & 4)
fflush(fp);
#endif #endif
} }
#ifdef Libburn_log_sg_command_stderR #ifdef Libburn_log_sg_command_stderR
if (fp == stderr) if (fp == stderr || !(burn_sg_log_scsi & 2))
return 1; return 1;
sg_log_err(c, stderr, s, flag); sg_log_err(c, stderr, s, flag);
#endif #endif
@ -1738,11 +1755,15 @@ int sg_issue_command(struct burn_drive *d, struct command *c)
#ifdef Libburn_log_sg_commandS #ifdef Libburn_log_sg_commandS
/* ts A61030 */ /* ts A61030 */
if(fp==NULL) { if (burn_sg_log_scsi & 1) {
fp= fopen("/tmp/libburn_sg_command_log","a"); if (fp == NULL) {
fprintf(fp,"\n-----------------------------------------\n"); fp= fopen("/tmp/libburn_sg_command_log", "a");
fprintf(fp,
"\n-----------------------------------------\n");
}
} }
sg_log_cmd(c,fp,0); if (burn_sg_log_scsi & 3)
sg_log_cmd(c,fp,0);
#endif /* Libburn_log_sg_commandS */ #endif /* Libburn_log_sg_commandS */
@ -1757,6 +1778,13 @@ int sg_issue_command(struct burn_drive *d, struct command *c)
s.interface_id = 'S'; s.interface_id = 'S';
#ifdef Libburn_sgio_as_growisofS
/* ??? ts A91112 : does this speed up USB ? (from growisofs)
--- did not help
*/
s.flags = SG_FLAG_DIRECT_IO;
#endif /* Libburn_sgio_as_growisofS */
if (c->dir == TO_DRIVE) if (c->dir == TO_DRIVE)
s.dxfer_direction = SG_DXFER_TO_DEV; s.dxfer_direction = SG_DXFER_TO_DEV;
else if (c->dir == FROM_DRIVE) else if (c->dir == FROM_DRIVE)
@ -1879,7 +1907,8 @@ ex:;
} }
#ifdef Libburn_log_sg_commandS #ifdef Libburn_log_sg_commandS
sg_log_err(c, fp, &s, c->error != 0); if (burn_sg_log_scsi & 3)
sg_log_err(c, fp, &s, c->error != 0);
#endif /* Libburn_log_sg_commandS */ #endif /* Libburn_log_sg_commandS */
return 1; return 1;

View File

@ -1255,7 +1255,7 @@ int burn_dvd_write_track(struct burn_write_opts *o,
struct buffer *out = d->buffer; struct buffer *out = d->buffer;
int sectors; int sectors;
int i, open_ended = 0, ret= 0, is_flushed = 0; int i, open_ended = 0, ret= 0, is_flushed = 0;
int first_buf_cap = 0, further_cap = 0; int first_buf_cap = 0, further_cap = 0, buf_cap_step = 256;
/* ts A70213 : eventually expand size of track to max */ /* ts A70213 : eventually expand size of track to max */
burn_track_apply_fillup(t, d->media_capacity_remaining, 0); burn_track_apply_fillup(t, d->media_capacity_remaining, 0);
@ -1314,7 +1314,8 @@ int burn_dvd_write_track(struct burn_write_opts *o,
before the drive buffer is full. See above DVD- before the drive buffer is full. See above DVD-
*/ */
if (i == first_buf_cap || if (i == first_buf_cap ||
((i % 256) == 0 && (i >= further_cap || further_cap < 0))) { ((i % buf_cap_step) == 0 &&
(i >= further_cap || further_cap < 0))) {
d->read_buffer_capacity(d); d->read_buffer_capacity(d);
if (further_cap < 0) if (further_cap < 0)
further_cap = further_cap =
@ -1787,8 +1788,10 @@ int burn_dvd_write_sync(struct burn_write_opts *o,
/* <<< test only : Does this increase effective speed with USB ? /* <<< test only : Does this increase effective speed with USB ?
ts A90801 : 64kB: speed with 16x DVD-R is 12 rather than 8 ts A90801 : 64kB: speed with 16x DVD-R is 12 rather than 8
>>> next try is 128 kB 128kB: glibc complains about double free
o->obs = 128 * 1024; BURN_OS_TRANSPORT_BUFFER_SIZE would need to
be enlarged anyway.
o->obs = 64 * 1024;
*/ */