Reporting sense data with burn_set_scsi_logging()

This commit is contained in:
Thomas Schmitt 2010-08-02 10:07:09 +00:00
parent bee991fd3d
commit 831fe8df23
6 changed files with 32 additions and 48 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2010.07.29.164100"
#define Cdrskin_timestamP "2010.08.02.100630"

View File

@ -964,8 +964,9 @@ int sg_issue_command(struct burn_drive *d, struct command *c)
if (burn_sg_log_scsi & 3) {
/* >>> Need own duration time
measurement. Then remove bit1 */
scsi_log_err(c, fp, c->sense, 0,
(c->error != 0) | 2);
scsi_log_err(c, fp, c->sense,
sense_len > 0 ? sense_len : 18,
0, (c->error != 0) | 2);
scsi_log_cmd(c,fp,0);
}
break;
@ -985,7 +986,8 @@ ex:;
if (burn_sg_log_scsi & 3)
/* >>> Need own duration time measurement. Then remove bit1 */
scsi_log_err(c, fp, c->sense, 0, (c->error != 0) | 2);
scsi_log_err(c, fp, c->sense, sense_len > 0 ? sense_len : 18,
0, (c->error != 0) | 2);
cam_freeccb(ccb);
return ret;

View File

@ -697,7 +697,7 @@ int sg_issue_command(struct burn_drive *d, struct command *c)
if (burn_sg_log_scsi & 3) {
/* >>> Need own duration time
measurement. Then remove bit1 */
scsi_log_err(c, fp, c->sense, 0,
scsi_log_err(c, fp, c->sense, 18, 0,
(c->error != 0) | 2);
scsi_log_cmd(c,fp,0);
}
@ -727,7 +727,7 @@ ex:;
if (burn_sg_log_scsi & 3)
/* >>> Need own duration time measurement. Then remove bit1 */
scsi_log_err(c, fp, c->sense, 0, (c->error != 0) | 2);
scsi_log_err(c, fp, c->sense, 18, 0, (c->error != 0) | 2);
return 1;
}

View File

@ -1773,36 +1773,6 @@ int sg_release(struct burn_drive *d)
}
#ifdef NIX
/* <<< now in spc.c as scsi_log_err */
/** logs outcome of a sg command. flag&1 causes an error message */
static int sg_log_err(struct command *c, FILE *fp,
sg_io_hdr_t *s,
int flag)
{
if(fp != NULL && (fp == stderr || (burn_sg_log_scsi & 1))) {
if(flag & 1) {
fprintf(fp,
"+++ key=%X asc=%2.2Xh ascq=%2.2Xh (%6d ms)\n",
s->sbp[2], s->sbp[12], s->sbp[13],s->duration);
} else {
scsi_show_cmd_reply(c, fp, 0);
fprintf(fp,"%6d ms\n", s->duration);
}
if (burn_sg_log_scsi & 4)
fflush(fp);
}
if (fp == stderr || !(burn_sg_log_scsi & 2))
return 1;
sg_log_err(c, stderr, s, flag);
return 1;
}
#endif /* NIX */
/** Sends a SCSI command to the drive, receives reply and evaluates wether
the command succeeded or shall be retried or finally failed.
Returned SCSI errors shall not lead to a return value indicating failure.
@ -1933,8 +1903,8 @@ int sg_issue_command(struct burn_drive *d, struct command *c)
case RETRY:
done = 0;
if (burn_sg_log_scsi & 3) {
scsi_log_err(c, fp, s.sbp, s.duration,
c->error != 0);
scsi_log_err(c, fp, s.sbp, s.sb_len_wr,
s.duration, c->error != 0);
scsi_log_cmd(c,fp,0);
}
break;
@ -1981,8 +1951,8 @@ ex:;
msg, 0, 0);
}
if (burn_sg_log_scsi & 3)
/* <<< sg_log_err(c, fp, &s, c->error != 0); */
scsi_log_err(c, fp, s.sbp, s.duration, c->error != 0);
scsi_log_err(c, fp, s.sbp, s.sb_len_wr,
s.duration, c->error != 0);
return 1;
}

View File

@ -1520,19 +1520,31 @@ int scsi_log_cmd(struct command *c, void *fp_in, int flag)
bit1 do not print duration
*/
int scsi_log_err(struct command *c, void *fp_in, unsigned char sense[18],
int duration, int flag)
int sense_len, int duration, int flag)
{
char durtxt[20];
FILE *fp = fp_in;
int key, asc, ascq, i, l;
if(fp != NULL && (fp == stderr || (burn_sg_log_scsi & 1))) {
if(flag & 1) {
if (fp != NULL && (fp == stderr || (burn_sg_log_scsi & 1))) {
if (flag & 1) {
durtxt[0] = 0;
if (!(flag & 2))
sprintf(durtxt, " (%6d ms)\n",duration);
sprintf(durtxt, " (%6d ms)", duration);
spc_decode_sense(sense, 0, &key, &asc, &ascq);
fprintf(fp, "+++ key=%X asc=%2.2Xh ascq=%2.2Xh%s\n",
sense[2], sense[12], sense[13], durtxt);
(unsigned int) key, (unsigned int) asc,
(unsigned int) ascq, durtxt);
l = 18;
if ((sense[0] & 0x7f) == 0x72 ||
(sense[0] & 0x7f) == 0x73)
l = sense[7] + 7 + 1; /* SPC-5 4.5.2. */
if (l > sense_len)
l = sense_len;
fprintf(fp, "+++ sense data =");
for (i = 0 ; i < l; i++)
fprintf(fp, " %2.2X", sense[i]);
fprintf(fp, "\n");
} else {
scsi_show_cmd_reply(c, fp, 0);
if (!(flag & 2))
@ -1543,7 +1555,7 @@ int scsi_log_err(struct command *c, void *fp_in, unsigned char sense[18],
}
if (fp == stderr || !(burn_sg_log_scsi & 2))
return 1;
scsi_log_err(c, stderr, sense, duration, flag);
scsi_log_err(c, stderr, sense, sense_len, duration, flag);
return 1;
}

View File

@ -78,7 +78,7 @@ int scsi_log_cmd(struct command *c, void *fp, int flag);
/* ts A91221 (former sg_log_err ts A91108) */
/** Logs outcome of a sg command. */
int scsi_log_err(struct command *c, void *fp, unsigned char sense[18],
int duration, int flag);
int sense_len, int duration, int flag);
/* ts B00728 */
int spc_decode_sense(unsigned char *sense, int senselen,