ERR("Could not open HEKY_DYN_DATA\\%s\n",KEYNAME_SCSI);
ERR("Could not open HKEY_DYN_DATA\\%s\n",KEYNAME_SCSI);
SetLastError(error);
returnhc;
}
...
...
@@ -183,6 +184,7 @@ SCSI_OpenDevice( int h, int c, int t, int d )
chardevstr[20];
DWORDcbData=20;
intfd=-1;
chardainbread_linux_hack=1;
if(!SCSI_GetDeviceName(h,c,t,d,devstr,&cbData))
{
...
...
@@ -190,14 +192,33 @@ SCSI_OpenDevice( int h, int c, int t, int d )
return-1;
}
linux_hack:
TRACE("Opening device %s mode O_RDWR\n",devstr);
fd=open(devstr,O_RDWR);
if(fd<0)
{
TRACE("open failed\n");
intlen=strlen(devstr);
FILE_SetDosError();/* SetLastError() to errno */
TRACE("GetLastError: %ld\n",GetLastError());
TRACE("Open failed (%s)\n",strerror(errno));
/* in case of "/dev/sgX", convert from sga to sg0
* and the other way around.
* FIXME: remove it if the distributions
* finally manage to agree on something.
* The best would probably be a complete
* rewrite of the Linux SCSI layer
* to use CAM + devfs :-) */
if((dainbread_linux_hack)&&
(len>=3)&&
(devstr[len-3]=='s')&&(devstr[len-2]=='g'))
{
char*p=&devstr[len-1];
*p=(*p>='a')?*p-'a'+'0':*p-'0'+'a';
dainbread_linux_hack=0;
TRACE("Retry with \"equivalent\" Linux device '%s'\n",devstr);
gotolinux_hack;
}
}
returnfd;
}
...
...
@@ -227,7 +248,7 @@ SCSI_LinuxSetTimeout( int fd, int timeout )
retval=ioctl(fd,SG_SET_TIMEOUT,&timeout);
if(retval)
{
WARN("Could not set timeout errno=%d!\n",errno);
WARN("Could not set timeout ! (%s)\n",strerror(errno));
}
returnretval;
...
...
@@ -249,7 +270,7 @@ SCSI_LinuxDeviceIo( int fd,
DWORDdwBytes;
DWORDsave_error;
TRACE("Writing to Liunx sg device\n");
TRACE("Writing to Linux sg device\n");
dwBytes=write(fd,lpInBuffer,cbInBuffer);
if(dwBytes!=cbInBuffer)
{
...
...
@@ -257,7 +278,7 @@ SCSI_LinuxDeviceIo( int fd,
save_error=GetLastError();
WARN("Not enough bytes written to scsi device. bytes=%ld .. %ld\n",cbInBuffer,dwBytes);
if(save_error==ERROR_NOT_ENOUGH_MEMORY)
MESSAGE("Your Linux kernel was not able to handle the amount of data sent to the scsi device. Try recompiling with a larger SG_BIG_BUFF value (kernel 2.0.x sg.h");
MESSAGE("Your Linux kernel was not able to handle the amount of data sent to the scsi device. Try recompiling with a larger SG_BIG_BUFF value (kernel 2.0.x sg.h)");
MESSAGE("WARNING: You don't have any /dev/sgX generic scsi devices ! \"man MAKEDEV\" !\n");
return0;
}
return1;
}
staticvoid
SCSI_GetProcinfo()
/* I'll admit, this function is somewhat of a mess... it was originally
...
...
@@ -441,8 +483,10 @@ SCSI_GetProcinfo()
*/
{
#ifdef linux
staticconstcharprocname[]="/proc/scsi/scsi";
FILE*procfile=NULL;
charread_line[40],read1[10]="\0",read2[10]="\0";
intresult=0;
structLinuxProcScsiDevicedev;
...
...
@@ -456,23 +500,35 @@ SCSI_GetProcinfo()
HKEYhkeyScsi;
DWORDdisposition;
procfile=fopen("/proc/scsi/scsi","r");
/* Check whether user has generic scsi devices at all */
if(!(SCSI_Linux_CheckDevices()))
return;
procfile=fopen(procname,"r");
if(!procfile)
{
ERR("Could not open /proc/scsi/scsi\n");
ERR("Could not open %s\n",procname);
return;
}
fgets(read_line,40,procfile);
sscanf(read_line,"Attached %9s %9s",read1,read2);
if(strcmp(read1,"devices:"))
{
ERR("Incorrect %s format\n",procname);
return;
}
result=fscanf(procfile,"Attached devices: \n");
if(result!=0)
if(!(strcmp(read2,"none")))
{
ERR("Incorrect /proc/scsi/scsi format");
ERR("No devices found in %s. Make sure you loaded your SCSI driver or set up ide-scsi emulation for your IDE device if this app needs it !\n",procname);