Reacted better on failing ioctl(SG_GET_SCSI_ID)

This commit is contained in:
Thomas Schmitt 2006-12-11 16:20:54 +00:00
parent d40e0f8fa6
commit 40794e68fa
2 changed files with 14 additions and 4 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2006.12.11.145332" #define Cdrskin_timestamP "2006.12.11.161952"

View File

@ -438,6 +438,7 @@ static void sg_enumerate(void)
{ {
struct sg_scsi_id sid; struct sg_scsi_id sid;
int i, fd, sibling_fds[LIBBURN_SG_MAX_SIBLINGS], sibling_count= 0, ret; int i, fd, sibling_fds[LIBBURN_SG_MAX_SIBLINGS], sibling_count= 0, ret;
int sid_ret = 0;
int bus_no= -1, host_no= -1, channel_no= -1, target_no= -1, lun_no= -1; int bus_no= -1, host_no= -1, channel_no= -1, target_no= -1, lun_no= -1;
char fname[10]; char fname[10];
@ -471,7 +472,11 @@ static void sg_enumerate(void)
} }
/* found a drive */ /* found a drive */
ioctl(fd, SG_GET_SCSI_ID, &sid); sid_ret = ioctl(fd, SG_GET_SCSI_ID, &sid);
if (sid_ret == -1 && linux_sg_enumerate_debug)
fprintf(stderr,
"ioctl(SG_GET_SCSI_ID) failed, errno=%d '%s' , ",
errno, strerror(errno));
#ifdef SCSI_IOCTL_GET_BUS_NUMBER #ifdef SCSI_IOCTL_GET_BUS_NUMBER
/* Hearsay A61005 */ /* Hearsay A61005 */
@ -487,14 +492,15 @@ static void sg_enumerate(void)
errno, strerror(errno)); errno, strerror(errno));
continue; continue;
} }
if (sid.scsi_type != TYPE_ROM && !linux_sg_accept_any_type) { if ( (sid_ret == -1 || sid.scsi_type != TYPE_ROM)
&& !linux_sg_accept_any_type) {
if (linux_sg_enumerate_debug) if (linux_sg_enumerate_debug)
fprintf(stderr, "sid.scsi_type = %d (!= TYPE_ROM)\n", fprintf(stderr, "sid.scsi_type = %d (!= TYPE_ROM)\n",
sid.scsi_type); sid.scsi_type);
continue; continue;
} }
if (sid.scsi_type != TYPE_ROM) { if (sid_ret == -1) {
/* ts A61211 : employ a more general ioctl */ /* ts A61211 : employ a more general ioctl */
ret = sg_obtain_scsi_adr(fname, &bus_no, &host_no, ret = sg_obtain_scsi_adr(fname, &bus_no, &host_no,
&channel_no, &target_no, &lun_no); &channel_no, &target_no, &lun_no);
@ -503,6 +509,10 @@ static void sg_enumerate(void)
sid.channel = channel_no; sid.channel = channel_no;
sid.scsi_id = target_no; sid.scsi_id = target_no;
sid.lun = lun_no; sid.lun = lun_no;
} else {
if (linux_sg_enumerate_debug)
fprintf(stderr,
"sg_obtain_scsi_adr() failed\n");
} }
} }