Made use of SCSI_IOCTL_GET_BUS_NUMBER in hope of cdrecord compatibility
This commit is contained in:
parent
1fe7f68b43
commit
b6831605b2
@ -1472,9 +1472,9 @@ int Cdrpreskin__cdrecord_to_dev(char *adr, char device_adr[Cdrskin_adrleN],
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(busno<0 || busno>255) {
|
if(busno<0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"cdrskin: FATAL : dev=[Prefix:]Bus,Target,Lun expects Bus out of {0..255}\n");
|
"cdrskin: FATAL : dev=[Prefix:]Bus,Target,Lun expects Bus number >= 0\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if((strncmp(adr,"ATA",3)==0 && (adr[3]==0 || adr[3]==':')) ||
|
if((strncmp(adr,"ATA",3)==0 && (adr[3]==0 || adr[3]==':')) ||
|
||||||
@ -1487,7 +1487,8 @@ int Cdrpreskin__cdrecord_to_dev(char *adr, char device_adr[Cdrskin_adrleN],
|
|||||||
} else {
|
} else {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret= burn_drive_convert_scsi_adr(busno,-1,*driveno,lun_no,device_adr);
|
ret= burn_drive_convert_scsi_adr(busno,-1,-1,*driveno,lun_no,
|
||||||
|
device_adr);
|
||||||
if(ret==0) {
|
if(ret==0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"cdrskin: FATAL : Cannot find /dev/sgN with Bus,Target,Lun = %d,%d,%d\n",
|
"cdrskin: FATAL : Cannot find /dev/sgN with Bus,Target,Lun = %d,%d,%d\n",
|
||||||
@ -2910,8 +2911,8 @@ wrong_devno:;
|
|||||||
pseudo transport groups:
|
pseudo transport groups:
|
||||||
0 volatile drive number,
|
0 volatile drive number,
|
||||||
1 /dev/sgN, 2 /dev/hdX,
|
1 /dev/sgN, 2 /dev/hdX,
|
||||||
1000+busno = non-pseudo SCSI bus
|
1000000+busno = non-pseudo SCSI bus
|
||||||
2000+busno = pseudo-ATA|ATAPI SCSI bus (currently busno==2)
|
2000000+busno = pseudo-ATA|ATAPI SCSI bus (currently busno==2)
|
||||||
*/
|
*/
|
||||||
int Cdrskin_driveno_to_btldev(struct CdrskiN *skin, int driveno,
|
int Cdrskin_driveno_to_btldev(struct CdrskiN *skin, int driveno,
|
||||||
char btldev[Cdrskin_adrleN], int flag)
|
char btldev[Cdrskin_adrleN], int flag)
|
||||||
@ -2936,21 +2937,24 @@ int Cdrskin_driveno_to_btldev(struct CdrskiN *skin, int driveno,
|
|||||||
|
|
||||||
#ifdef Cdrskin_libburn_has_convert_scsi_adR
|
#ifdef Cdrskin_libburn_has_convert_scsi_adR
|
||||||
if(!skin->preskin->old_pseudo_scsi_adr) {
|
if(!skin->preskin->old_pseudo_scsi_adr) {
|
||||||
int host_no= -1,channel_no= -1,target_no= -1,lun_no= -1;
|
int host_no= -1,channel_no= -1,target_no= -1,lun_no= -1, bus_no= -1;
|
||||||
|
|
||||||
ret= burn_drive_obtain_scsi_adr(loc,&host_no,&channel_no,&target_no,
|
ret= burn_drive_obtain_scsi_adr(loc,&bus_no,&host_no,&channel_no,
|
||||||
&lun_no);
|
&target_no,&lun_no);
|
||||||
if(ret<=0) {
|
if(ret<=0) {
|
||||||
if(strncmp(loc,"/dev/hd",7)==0)
|
if(strncmp(loc,"/dev/hd",7)==0)
|
||||||
if(loc[7]>='a' && loc[7]<='z')
|
if(loc[7]>='a' && loc[7]<='z')
|
||||||
if(loc[8]==0) {
|
if(loc[8]==0) {
|
||||||
|
|
||||||
|
/* >>> implement new ATA enumeration here */
|
||||||
|
|
||||||
sprintf(btldev,"2,%d,0",loc[7]-'a');
|
sprintf(btldev,"2,%d,0",loc[7]-'a');
|
||||||
{ret= 2002; goto adr_translation;}
|
{ret= 2000002; goto adr_translation;}
|
||||||
}
|
}
|
||||||
goto fallback;
|
goto fallback;
|
||||||
} else {
|
} else {
|
||||||
sprintf(btldev,"%d,%d,%d",host_no,target_no,lun_no);
|
sprintf(btldev,"%d,%d,%d",bus_no,target_no,lun_no);
|
||||||
ret= 1000+host_no;
|
ret= 1000000+bus_no;
|
||||||
goto adr_translation;
|
goto adr_translation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3034,9 +3038,14 @@ int Cdrskin_scanbus(struct CdrskiN *skin, int flag)
|
|||||||
{
|
{
|
||||||
int ret,i,busno,first_on_bus,pseudo_transport_group= 0,skipped_devices= 0;
|
int ret,i,busno,first_on_bus,pseudo_transport_group= 0,skipped_devices= 0;
|
||||||
char shellsafe[5*Cdrskin_strleN+2],perms[40],btldev[Cdrskin_adrleN];
|
char shellsafe[5*Cdrskin_strleN+2],perms[40],btldev[Cdrskin_adrleN];
|
||||||
char adr[Cdrskin_adrleN],*raw_dev;
|
char adr[Cdrskin_adrleN],*raw_dev,*drives_shown= NULL;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
|
|
||||||
|
drives_shown= malloc(skin->n_drives+1);
|
||||||
|
if(drives_shown==NULL)
|
||||||
|
{ret= -1; goto ex;}
|
||||||
|
for(i=0;i<skin->n_drives;i++)
|
||||||
|
drives_shown[i]= 0;
|
||||||
if(flag&1) {
|
if(flag&1) {
|
||||||
printf("cdrskin: Overview of accessible drives (%d found) :\n",
|
printf("cdrskin: Overview of accessible drives (%d found) :\n",
|
||||||
skin->n_drives);
|
skin->n_drives);
|
||||||
@ -3074,43 +3083,43 @@ int Cdrskin_scanbus(struct CdrskiN *skin, int flag)
|
|||||||
printf("-----------------------------------------------------------------------------\n");
|
printf("-----------------------------------------------------------------------------\n");
|
||||||
} else {
|
} else {
|
||||||
if(!skin->preskin->old_pseudo_scsi_adr) {
|
if(!skin->preskin->old_pseudo_scsi_adr) {
|
||||||
pseudo_transport_group= 1000;
|
pseudo_transport_group= 1000000;
|
||||||
raw_dev= skin->preskin->raw_device_adr;
|
raw_dev= skin->preskin->raw_device_adr;
|
||||||
if(strncmp(raw_dev,"ATA",3)==0 && (raw_dev[3]==0 || raw_dev[3]==':'))
|
if(strncmp(raw_dev,"ATA",3)==0 && (raw_dev[3]==0 || raw_dev[3]==':'))
|
||||||
pseudo_transport_group= 2000;
|
pseudo_transport_group= 2000000;
|
||||||
if(strncmp(raw_dev,"ATAPI",5)==0 && (raw_dev[5]==0 || raw_dev[5]==':'))
|
if(strncmp(raw_dev,"ATAPI",5)==0 && (raw_dev[5]==0 || raw_dev[5]==':'))
|
||||||
pseudo_transport_group= 2000;
|
pseudo_transport_group= 2000000;
|
||||||
if(pseudo_transport_group==2000) {
|
if(pseudo_transport_group==2000000) {
|
||||||
fprintf(stderr,"scsidev: 'ATA'\ndevname: 'ATA'\n");
|
fprintf(stderr,"scsidev: 'ATA'\ndevname: 'ATA'\n");
|
||||||
fprintf(stderr,"scsibus: -2 target: -2 lun: -2\n");
|
fprintf(stderr,"scsibus: -2 target: -2 lun: -2\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* >>> fprintf(stderr,"Linux sg driver version: 3.1.25\n"); */
|
/* >>> fprintf(stderr,"Linux sg driver version: 3.1.25\n"); */
|
||||||
printf("Using libburn version '%s'.\n", Cdrskin_libburn_versioN);
|
printf("Using libburn version '%s'.\n", Cdrskin_libburn_versioN);
|
||||||
if(pseudo_transport_group!=1000)
|
if(pseudo_transport_group!=1000000)
|
||||||
printf(
|
printf(
|
||||||
"cdrskin: NOTE : The printed addresses are not cdrecord compatible !\n");
|
"cdrskin: NOTE : The printed addresses are not cdrecord compatible !\n");
|
||||||
|
|
||||||
for(busno= 0;busno<16;busno++) {
|
for(busno= 0;busno<=16;busno++) {
|
||||||
first_on_bus= 1;
|
first_on_bus= 1;
|
||||||
for(i=0;i<skin->n_drives;i++) {
|
for(i=0;i<skin->n_drives;i++) {
|
||||||
ret= Cdrskin_driveno_to_btldev(skin,i,btldev,1);
|
ret= Cdrskin_driveno_to_btldev(skin,i,btldev,1);
|
||||||
if(ret==pseudo_transport_group + busno)
|
if(busno==16 && drives_shown[i]==0) {
|
||||||
ret= busno;
|
if(ret/1000000 != pseudo_transport_group) {
|
||||||
if(ret!=busno) {
|
|
||||||
if((ret%1000)==busno) {
|
|
||||||
skipped_devices++;
|
skipped_devices++;
|
||||||
if(skin->verbosity>=Cdrskin_verbose_debuG)
|
if(skin->verbosity>=Cdrskin_verbose_debuG)
|
||||||
ClN(fprintf(stderr,"cdrskin_debug: skipping drive '%s%s'\n",
|
ClN(fprintf(stderr,"cdrskin_debug: skipping drive '%s%s'\n",
|
||||||
((ret/1000)==2?"ATA:":""), btldev));
|
((ret/1000000)==2?"ATA:":""), btldev));
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else if(ret != pseudo_transport_group + busno)
|
||||||
|
continue;
|
||||||
if(first_on_bus)
|
if(first_on_bus)
|
||||||
printf("scsibus%d:\n",busno);
|
printf("scsibus%d:\n",busno);
|
||||||
first_on_bus= 0;
|
first_on_bus= 0;
|
||||||
printf("\t%s\t %d) '%-8s' '%-16s' '%-4s' Removable CD-ROM\n",
|
printf("\t%s\t %d) '%-8s' '%-16s' '%-4s' Removable CD-ROM\n",
|
||||||
btldev,i,skin->drives[i].vendor,skin->drives[i].product,"?..?");
|
btldev,i,skin->drives[i].vendor,skin->drives[i].product,"?..?");
|
||||||
|
drives_shown[i]= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3121,10 +3130,14 @@ int Cdrskin_scanbus(struct CdrskiN *skin, int flag)
|
|||||||
else
|
else
|
||||||
printf("cdrskin: NOTE : There was 1 drives not shown.\n");
|
printf("cdrskin: NOTE : There was 1 drives not shown.\n");
|
||||||
printf("cdrskin: HINT : To surely see all drives try option: --devices\n");
|
printf("cdrskin: HINT : To surely see all drives try option: --devices\n");
|
||||||
if(pseudo_transport_group!=2000)
|
if(pseudo_transport_group!=2000000)
|
||||||
printf("cdrskin: HINT : or try options: dev=ATA -scanbus\n");
|
printf("cdrskin: HINT : or try options: dev=ATA -scanbus\n");
|
||||||
}
|
}
|
||||||
return(1);
|
ret= 1;
|
||||||
|
ex:;
|
||||||
|
if(drives_shown!=NULL)
|
||||||
|
free((char *) drives_shown);
|
||||||
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
#define Cdrskin_timestamP "2006.10.03.162719"
|
#define Cdrskin_timestamP "2006.10.05.142628"
|
||||||
|
@ -806,7 +806,8 @@ int burn_drive_find_devno(dev_t devno, char adr[])
|
|||||||
/** Try to obtain host,channel,target,lun from path.
|
/** Try to obtain host,channel,target,lun from path.
|
||||||
@return 1 = success , 0 = failure , -1 = severe error
|
@return 1 = success , 0 = failure , -1 = severe error
|
||||||
*/
|
*/
|
||||||
int burn_drive_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
|
int burn_drive_obtain_scsi_adr(char *path,
|
||||||
|
int *bus_no, int *host_no, int *channel_no,
|
||||||
int *target_no, int *lun_no)
|
int *target_no, int *lun_no)
|
||||||
{
|
{
|
||||||
int ret, i;
|
int ret, i;
|
||||||
@ -824,6 +825,7 @@ int burn_drive_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
|
|||||||
*channel_no = drive_array[i].channel;
|
*channel_no = drive_array[i].channel;
|
||||||
*target_no = drive_array[i].id;
|
*target_no = drive_array[i].id;
|
||||||
*lun_no = drive_array[i].lun;
|
*lun_no = drive_array[i].lun;
|
||||||
|
*bus_no = drive_array[i].bus_no;
|
||||||
if (*host_no < 0 || *channel_no < 0 ||
|
if (*host_no < 0 || *channel_no < 0 ||
|
||||||
*target_no < 0 || *lun_no < 0)
|
*target_no < 0 || *lun_no < 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -831,21 +833,22 @@ int burn_drive_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sg_obtain_scsi_adr(path, host_no, channel_no, target_no, lun_no);
|
ret = sg_obtain_scsi_adr(path, bus_no, host_no, channel_no,
|
||||||
|
target_no, lun_no);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ts A60923 */
|
/* ts A60923 */
|
||||||
int burn_drive_convert_scsi_adr(int host_no, int channel_no, int target_no,
|
int burn_drive_convert_scsi_adr(int bus_no, int host_no, int channel_no,
|
||||||
int lun_no, char adr[])
|
int target_no, int lun_no, char adr[])
|
||||||
{
|
{
|
||||||
char fname[4096],msg[4096+100];
|
char fname[4096],msg[4096+100];
|
||||||
int i, ret = 0, first = 1;
|
int i, ret = 0, first = 1, i_bus_no = -1;
|
||||||
int i_host_no = -1, i_channel_no = -1, i_target_no = -1, i_lun_no = -1;
|
int i_host_no = -1, i_channel_no = -1, i_target_no = -1, i_lun_no = -1;
|
||||||
|
|
||||||
|
|
||||||
sprintf(msg,"burn_drive_convert_scsi_adr( %d,%d,%d,%d )",
|
sprintf(msg,"burn_drive_convert_scsi_adr( %d,%d,%d,%d,%d )",
|
||||||
host_no, channel_no, target_no, lun_no);
|
bus_no, host_no, channel_no, target_no, lun_no);
|
||||||
burn_drive_adr_debug_msg(msg, NULL);
|
burn_drive_adr_debug_msg(msg, NULL);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -853,9 +856,11 @@ int burn_drive_convert_scsi_adr(int host_no, int channel_no, int target_no,
|
|||||||
if(ret <= 0)
|
if(ret <= 0)
|
||||||
break;
|
break;
|
||||||
first = 0;
|
first = 0;
|
||||||
ret = burn_drive_obtain_scsi_adr(fname, &i_host_no,
|
ret = burn_drive_obtain_scsi_adr(fname, &i_bus_no, &i_host_no,
|
||||||
&i_channel_no, &i_target_no, &i_lun_no);
|
&i_channel_no, &i_target_no, &i_lun_no);
|
||||||
if(ret <= 0)
|
if(ret <= 0)
|
||||||
|
continue;
|
||||||
|
if(bus_no >=0 && i_bus_no != bus_no)
|
||||||
continue;
|
continue;
|
||||||
if(host_no >=0 && i_host_no != host_no)
|
if(host_no >=0 && i_host_no != host_no)
|
||||||
continue;
|
continue;
|
||||||
@ -881,10 +886,10 @@ int burn_drive_convert_scsi_adr(int host_no, int channel_no, int target_no,
|
|||||||
int burn_drive_find_scsi_equiv(char *path, char adr[])
|
int burn_drive_find_scsi_equiv(char *path, char adr[])
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int host_no, channel_no, target_no, lun_no;
|
int bus_no, host_no, channel_no, target_no, lun_no;
|
||||||
char msg[4096];
|
char msg[4096];
|
||||||
|
|
||||||
ret = burn_drive_obtain_scsi_adr(path, &host_no, &channel_no,
|
ret = burn_drive_obtain_scsi_adr(path, &bus_no, &host_no, &channel_no,
|
||||||
&target_no, &lun_no);
|
&target_no, &lun_no);
|
||||||
if(ret <= 0) {
|
if(ret <= 0) {
|
||||||
sprintf(msg,"burn_drive_obtain_scsi_adr( %s ) returns %d\n",
|
sprintf(msg,"burn_drive_obtain_scsi_adr( %s ) returns %d\n",
|
||||||
@ -892,11 +897,11 @@ int burn_drive_find_scsi_equiv(char *path, char adr[])
|
|||||||
burn_drive_adr_debug_msg(msg, NULL);
|
burn_drive_adr_debug_msg(msg, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sprintf(msg, "burn_drive_find_scsi_equiv( %s ) : %d,%d,%d,%d",
|
sprintf(msg, "burn_drive_find_scsi_equiv( %s ) : (%d),%d,%d,%d,%d",
|
||||||
path, host_no, channel_no, target_no, lun_no);
|
path, bus_no, host_no, channel_no, target_no, lun_no);
|
||||||
burn_drive_adr_debug_msg(msg, NULL);
|
burn_drive_adr_debug_msg(msg, NULL);
|
||||||
|
|
||||||
ret= burn_drive_convert_scsi_adr(host_no, channel_no, target_no,
|
ret= burn_drive_convert_scsi_adr(-1, host_no, channel_no, target_no,
|
||||||
lun_no, adr);
|
lun_no, adr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -568,27 +568,27 @@ int burn_drive_is_enumerable_adr(char *adr);
|
|||||||
int burn_drive_convert_fs_adr(char *path, char adr[]);
|
int burn_drive_convert_fs_adr(char *path, char adr[]);
|
||||||
|
|
||||||
/* ts A60923 */
|
/* ts A60923 */
|
||||||
/** Try to convert a given SCSI address of bus, channel, target, lun into
|
/** Try to convert a given SCSI address of bus,host,channel,target,lun into
|
||||||
a persistent drive address. If a SCSI address component parameter is < 0
|
a persistent drive address. If a SCSI address component parameter is < 0
|
||||||
then it is not decisive and the first enumerated address which matches
|
then it is not decisive and the first enumerated address which matches
|
||||||
the >= 0 parameters is taken as result.
|
the >= 0 parameters is taken as result.
|
||||||
|
Note: bus and (host,channel) are supposed to be redundant.
|
||||||
@param adr An application provided array of at least BURN_DRIVE_ADR_LEN
|
@param adr An application provided array of at least BURN_DRIVE_ADR_LEN
|
||||||
characters size. The persistent address gets copied to it.
|
characters size. The persistent address gets copied to it.
|
||||||
@return 1 = success , 0 = failure , -1 = severe error
|
@return 1 = success , 0 = failure , -1 = severe error
|
||||||
*/
|
*/
|
||||||
int burn_drive_convert_scsi_adr(int host_no, int channel_no, int target_no,
|
int burn_drive_convert_scsi_adr(int bus_no, int host_no, int channel_no,
|
||||||
int lun_no, char adr[]);
|
int target_no, int lun_no, char adr[]);
|
||||||
|
|
||||||
/* ts A60923 */
|
/* ts A60923 - A61005 */
|
||||||
/** Try to obtain host,channel,target,lun from path. If there is an SCSI
|
/** Try to obtain bus,host,channel,target,lun from path. If there is an SCSI
|
||||||
address at all, then this call should succeed with a persistent
|
address at all, then this call should succeed with a persistent
|
||||||
drive address obtained via burn_drive_get_adr(). It is also supposed to
|
drive address obtained via burn_drive_get_adr(). It is also supposed to
|
||||||
succeed with any device file of a (possibly emulated) SCSI device.
|
succeed with any device file of a (possibly emulated) SCSI device.
|
||||||
@return 1 = success , 0 = failure , -1 = severe error
|
@return 1 = success , 0 = failure , -1 = severe error
|
||||||
*/
|
*/
|
||||||
int burn_drive_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
|
int burn_drive_obtain_scsi_adr(char *path, int *bus_no, int *host_no,
|
||||||
int *target_no, int *lun_no);
|
int *channel_no, int *target_no, int *lun_no);
|
||||||
|
|
||||||
|
|
||||||
/** Grab a drive. This must be done before the drive can be used (for reading,
|
/** Grab a drive. This must be done before the drive can be used (for reading,
|
||||||
writing, etc).
|
writing, etc).
|
||||||
|
54
libburn/sg.c
54
libburn/sg.c
@ -26,8 +26,8 @@
|
|||||||
#include "libdax_msgs.h"
|
#include "libdax_msgs.h"
|
||||||
extern struct libdax_msgs *libdax_messenger;
|
extern struct libdax_msgs *libdax_messenger;
|
||||||
|
|
||||||
static void enumerate_common(char *fname, int host_no, int channel_no,
|
static void enumerate_common(char *fname, int bus_no, int host_no,
|
||||||
int target_no, int lun_no);
|
int channel_no, int target_no, int lun_no);
|
||||||
|
|
||||||
/* ts A51221 */
|
/* ts A51221 */
|
||||||
int burn_drive_is_banned(char *device_address);
|
int burn_drive_is_banned(char *device_address);
|
||||||
@ -156,9 +156,6 @@ int sg_is_enumerable_adr(char *adr)
|
|||||||
ret= sg_give_next_adr(&i, fname, sizeof(fname), first);
|
ret= sg_give_next_adr(&i, fname, sizeof(fname), first);
|
||||||
if(ret <= 0)
|
if(ret <= 0)
|
||||||
break;
|
break;
|
||||||
/* <<<
|
|
||||||
fprintf(stderr,"libburn experimental: idx %d : %s\n",i,fname);
|
|
||||||
*/
|
|
||||||
first = 0;
|
first = 0;
|
||||||
if (strcmp(adr, fname) == 0)
|
if (strcmp(adr, fname) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
@ -243,7 +240,7 @@ int sg_open_scsi_siblings(char *path, int driveno,
|
|||||||
int sibling_fds[], int *sibling_count,
|
int sibling_fds[], int *sibling_count,
|
||||||
int host_no, int channel_no, int id_no, int lun_no)
|
int host_no, int channel_no, int id_no, int lun_no)
|
||||||
{
|
{
|
||||||
int tld, i, ret, fd;
|
int tld, i, ret, fd, i_bus_no = -1;
|
||||||
int i_host_no = -1, i_channel_no = -1, i_target_no = -1, i_lun_no = -1;
|
int i_host_no = -1, i_channel_no = -1, i_target_no = -1, i_lun_no = -1;
|
||||||
char msg[161], fname[81];
|
char msg[161], fname[81];
|
||||||
|
|
||||||
@ -257,7 +254,7 @@ int sg_open_scsi_siblings(char *path, int driveno,
|
|||||||
for (tld = 0; tldev[tld][0] != 0; tld++) {
|
for (tld = 0; tldev[tld][0] != 0; tld++) {
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
sprintf(fname, tldev[tld], i);
|
sprintf(fname, tldev[tld], i);
|
||||||
ret = sg_obtain_scsi_adr(fname, &i_host_no,
|
ret = sg_obtain_scsi_adr(fname, &i_bus_no, &i_host_no,
|
||||||
&i_channel_no, &i_target_no, &i_lun_no);
|
&i_channel_no, &i_target_no, &i_lun_no);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
continue;
|
continue;
|
||||||
@ -340,7 +337,7 @@ void ata_enumerate(void)
|
|||||||
}
|
}
|
||||||
if (sg_close_drive_fd(fname, -1, &fd, 1) <= 0)
|
if (sg_close_drive_fd(fname, -1, &fd, 1) <= 0)
|
||||||
continue;
|
continue;
|
||||||
enumerate_common(fname, -1, -1, -1, -1);
|
enumerate_common(fname, -1, -1, -1, -1, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +345,7 @@ 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 bus_no = -1;
|
||||||
char fname[10];
|
char fname[10];
|
||||||
|
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
@ -362,6 +360,13 @@ void sg_enumerate(void)
|
|||||||
|
|
||||||
/* found a drive */
|
/* found a drive */
|
||||||
ioctl(fd, SG_GET_SCSI_ID, &sid);
|
ioctl(fd, SG_GET_SCSI_ID, &sid);
|
||||||
|
|
||||||
|
#ifdef SCSI_IOCTL_GET_BUS_NUMBER
|
||||||
|
/* Hearsay A61005 */
|
||||||
|
if (ioctl(fd, SCSI_IOCTL_GET_BUS_NUMBER, &bus_no) == -1)
|
||||||
|
bus_no = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sg_close_drive_fd(fname, -1, &fd,
|
if (sg_close_drive_fd(fname, -1, &fd,
|
||||||
sid.scsi_type == TYPE_ROM ) <= 0)
|
sid.scsi_type == TYPE_ROM ) <= 0)
|
||||||
continue;
|
continue;
|
||||||
@ -381,20 +386,27 @@ void sg_enumerate(void)
|
|||||||
/* the final occupation will be done in sg_grab() */
|
/* the final occupation will be done in sg_grab() */
|
||||||
sg_release_siblings(sibling_fds, &sibling_count);
|
sg_release_siblings(sibling_fds, &sibling_count);
|
||||||
}
|
}
|
||||||
|
#ifdef SCSI_IOCTL_GET_BUS_NUMBER
|
||||||
enumerate_common(fname, sid.host_no, sid.channel,
|
if(bus_no == -1)
|
||||||
|
bus_no = 1000 * (sid.host_no + 1) + sid.channel;
|
||||||
|
#else
|
||||||
|
bus_no = sid.host_no;
|
||||||
|
#endif
|
||||||
|
enumerate_common(fname, bus_no, sid.host_no, sid.channel,
|
||||||
sid.scsi_id, sid.lun);
|
sid.scsi_id, sid.lun);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* ts A60923 : introduced new SCSI parameters */
|
|
||||||
static void enumerate_common(char *fname, int host_no, int channel_no,
|
/* ts A60923 - A61005 : introduced new SCSI parameters */
|
||||||
int target_no, int lun_no)
|
static void enumerate_common(char *fname, int bus_no, int host_no,
|
||||||
|
int channel_no, int target_no, int lun_no)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct burn_drive *t;
|
struct burn_drive *t;
|
||||||
struct burn_drive out;
|
struct burn_drive out;
|
||||||
|
|
||||||
/* ts A60923 */
|
/* ts A60923 */
|
||||||
|
out.bus_no = bus_no;
|
||||||
out.host = host_no;
|
out.host = host_no;
|
||||||
out.id = target_no;
|
out.id = target_no;
|
||||||
out.channel = channel_no;
|
out.channel = channel_no;
|
||||||
@ -731,7 +743,7 @@ enum response scsi_error(struct burn_drive *d, unsigned char *sense,
|
|||||||
/** Try to obtain SCSI address parameters.
|
/** Try to obtain SCSI address parameters.
|
||||||
@return 1 is success , 0 is failure
|
@return 1 is success , 0 is failure
|
||||||
*/
|
*/
|
||||||
int sg_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
|
int sg_obtain_scsi_adr(char *path, int *bus_no, int *host_no, int *channel_no,
|
||||||
int *target_no, int *lun_no)
|
int *target_no, int *lun_no)
|
||||||
{
|
{
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
@ -749,8 +761,14 @@ int sg_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
|
|||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#ifdef SCSI_IOCTL_GET_BUS_NUMBER
|
||||||
|
/* Hearsay A61005 */
|
||||||
|
if (ioctl(fd, SCSI_IOCTL_GET_BUS_NUMBER, bus_no) == -1)
|
||||||
|
*bus_no = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* http://www.tldp.org/HOWTO/SCSI-Generic-HOWTO/scsi_g_idlun.html */
|
/* http://www.tldp.org/HOWTO/SCSI-Generic-HOWTO/scsi_g_idlun.html */
|
||||||
ret= ioctl(fd, SCSI_IOCTL_GET_IDLUN, &idlun);
|
ret = ioctl(fd, SCSI_IOCTL_GET_IDLUN, &idlun);
|
||||||
|
|
||||||
sg_close_drive_fd(path, -1, &fd, 0);
|
sg_close_drive_fd(path, -1, &fd, 0);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
@ -759,5 +777,11 @@ int sg_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
|
|||||||
*channel_no= (idlun.x>>16)&255;
|
*channel_no= (idlun.x>>16)&255;
|
||||||
*target_no= (idlun.x)&255;
|
*target_no= (idlun.x)&255;
|
||||||
*lun_no= (idlun.x>>8)&255;
|
*lun_no= (idlun.x>>8)&255;
|
||||||
|
#ifdef SCSI_IOCTL_GET_BUS_NUMBER
|
||||||
|
if(*bus_no == -1)
|
||||||
|
*bus_no = 1000 * (*host_no + 1) + *channel_no;
|
||||||
|
#else
|
||||||
|
*bus_no= *host_no;
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ int sg_close_drive_fd(char *fname, int driveno, int *fd, int sorry);
|
|||||||
/* ts A60922 ticket 33 */
|
/* ts A60922 ticket 33 */
|
||||||
int sg_give_next_adr(int *idx, char adr[], int adr_size, int initialize);
|
int sg_give_next_adr(int *idx, char adr[], int adr_size, int initialize);
|
||||||
int sg_is_enumerable_adr(char *adr);
|
int sg_is_enumerable_adr(char *adr);
|
||||||
int sg_obtain_scsi_adr(char *path, int *host_no, int *channel_no,
|
int sg_obtain_scsi_adr(char *path, int *bus_no, int *host_no, int *channel_no,
|
||||||
int *target_no, int *lun_no);
|
int *target_no, int *lun_no);
|
||||||
|
|
||||||
/* ts A60926 : ticket 33 ++ */
|
/* ts A60926 : ticket 33 ++ */
|
||||||
|
@ -95,6 +95,7 @@ struct scsi_mode_data
|
|||||||
/** Gets initialized in enumerate_common() and burn_drive_register() */
|
/** Gets initialized in enumerate_common() and burn_drive_register() */
|
||||||
struct burn_drive
|
struct burn_drive
|
||||||
{
|
{
|
||||||
|
int bus_no;
|
||||||
int host;
|
int host;
|
||||||
int id;
|
int id;
|
||||||
int channel;
|
int channel;
|
||||||
|
Loading…
Reference in New Issue
Block a user