Browse Source

Restructured SCSI search, removed a potential bug with hdX

trunk@386
Thomas Schmitt 16 years ago
parent
commit
3f7289d104
  1. 2
      cdrskin/cdrskin_timestamp.h
  2. 61
      libburn/drive.c

2
cdrskin/cdrskin_timestamp.h

@ -1 +1 @@
#define Cdrskin_timestamP "2006.09.22.203939"
#define Cdrskin_timestamP "2006.09.23.080015"

61
libburn/drive.c

@ -733,26 +733,18 @@ fprintf(stderr,"libburn experimental: burn_drive_find_devno( 0x%lX ) found %s\n"
}
/* ts A60922 ticket 33 */
/* Try to find an enumerated address with the same host,channel,target,lun
as path */
int burn_drive_find_scsi_adr(char *path, char adr[])
/* Try to find an enumerated address with the same host,channel,target,lun.
If a _no parameter is < 0 then it matches any number.
*/
int burn_drive_convert_scsi_adr(int host_no, int channel_no, int target_no,
int lun_no, char adr[])
{
char fname[4096];
int i, ret = 0, first = 1;
int host_no, channel_no, target_no, lun_no;
int i_host_no, i_channel_no, i_target_no, i_lun_no;
int i_host_no = -1, i_channel_no = -1, i_target_no = -1, i_lun_no = -1;
ret = sg_obtain_scsi_adr(path, &host_no, &channel_no, &target_no,
&lun_no);
if(ret <= 0) {
fprintf(stderr,"libburn experimental: sg_obtain_scsi_adr( %s ) returns %d\n", path, ret);
return 0;
}
fprintf(stderr,"libburn experimental: burn_drive_find_scsi_adr( %s ) : %d,%d,%d,%d\n", path, host_no, channel_no, target_no, lun_no);
fprintf(stderr,"libburn experimental: burn_drive_convert_scsi_adr( %d,%d,%d,%d )\n", host_no, channel_no, target_no, lun_no);
while (1) {
ret= sg_give_next_adr(&i, fname, sizeof(fname), first);
@ -761,15 +753,20 @@ fprintf(stderr,"libburn experimental: burn_drive_find_scsi_adr( %s ) : %d,%d,%d,
first = 0;
ret = sg_obtain_scsi_adr(fname, &i_host_no, &i_channel_no,
&i_target_no, &i_lun_no);
if(ret == -1)
if(ret <= 0)
continue;
if(i_host_no != host_no || i_channel_no != channel_no ||
i_target_no != target_no || i_lun_no != lun_no)
if(host_no >=0 && i_host_no != host_no)
continue;
if(channel_no >= 0 && i_channel_no != channel_no)
continue;
if(target_no >= 0 && i_target_no != target_no)
continue;
if(lun_no >= 0 && i_lun_no != lun_no)
continue;
if(strlen(fname) >= BURN_DRIVE_ADR_LEN)
return -1;
fprintf(stderr,"libburn experimental: burn_drive_find_scsi_adr( %s ) found %s\n", path, fname);
fprintf(stderr,"libburn experimental: burn_drive_convert_scsi_adr() found %s\n", fname);
strcpy(adr, fname);
return 1;
@ -777,6 +774,30 @@ fprintf(stderr,"libburn experimental: burn_drive_find_scsi_adr( %s ) found %s\n"
return 0;
}
/* ts A60922 ticket 33 */
/* Try to find an enumerated address with the same host,channel,target,lun
as path */
int burn_drive_find_scsi_equiv(char *path, char adr[])
{
int ret = 0;
int host_no, channel_no, target_no, lun_no;
ret = sg_obtain_scsi_adr(path, &host_no, &channel_no, &target_no,
&lun_no);
if(ret <= 0) {
fprintf(stderr,"libburn experimental: sg_obtain_scsi_adr( %s ) returns %d\n", path, ret);
return 0;
}
fprintf(stderr,"libburn experimental: burn_drive_find_scsi_equiv( %s ) : %d,%d,%d,%d\n", path, host_no, channel_no, target_no, lun_no);
ret= burn_drive_convert_scsi_adr(host_no, channel_no, target_no,
lun_no, adr);
return ret;
}
/* ts A60922 ticket 33 */
/** Try to convert a given existing filesystem address into a persistent drive
@ -814,7 +835,7 @@ fprintf(stderr,"libburn experimental: lstat( %s ) returns -1\n",path);
ret = burn_drive_find_devno(stbuf.st_rdev, adr);
if(ret > 0)
return 1;
ret = burn_drive_find_scsi_adr(path, adr);
ret = burn_drive_find_scsi_equiv(path, adr);
if(ret > 0)
return 1;
}

Loading…
Cancel
Save