Removed dependencies on Wine internal functions.
This commit is contained in:
parent
4cecd4ae7d
commit
e8e7d1eca5
|
@ -4,7 +4,6 @@ SRCDIR = @srcdir@
|
|||
VPATH = @srcdir@
|
||||
MODULE = wnaspi32
|
||||
ALTNAMES = winaspi
|
||||
IMPORTS = ntdll
|
||||
|
||||
LDDLLFLAGS = @LDDLLFLAGS@
|
||||
SYMBOLFILE = $(MODULE).tmp.o
|
||||
|
|
|
@ -36,7 +36,6 @@ HKEY_DYN_DATA
|
|||
#include "winreg.h"
|
||||
#include "winerror.h"
|
||||
#include "winescsi.h"
|
||||
#include "file.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(aspi);
|
||||
|
||||
|
@ -49,6 +48,59 @@ static void
|
|||
SCSI_MapHCtoController();
|
||||
#endif
|
||||
|
||||
static void set_last_error(void)
|
||||
{
|
||||
int save_errno = errno; /* errno gets overwritten by printf */
|
||||
switch (errno)
|
||||
{
|
||||
case EAGAIN:
|
||||
SetLastError( ERROR_SHARING_VIOLATION );
|
||||
break;
|
||||
case EBADF:
|
||||
SetLastError( ERROR_INVALID_HANDLE );
|
||||
break;
|
||||
case ENOSPC:
|
||||
SetLastError( ERROR_HANDLE_DISK_FULL );
|
||||
break;
|
||||
case EACCES:
|
||||
case EPERM:
|
||||
case EROFS:
|
||||
SetLastError( ERROR_ACCESS_DENIED );
|
||||
break;
|
||||
case EBUSY:
|
||||
SetLastError( ERROR_LOCK_VIOLATION );
|
||||
break;
|
||||
case ENOENT:
|
||||
SetLastError( ERROR_FILE_NOT_FOUND );
|
||||
break;
|
||||
case EISDIR:
|
||||
SetLastError( ERROR_CANNOT_MAKE );
|
||||
break;
|
||||
case ENFILE:
|
||||
case EMFILE:
|
||||
SetLastError( ERROR_NO_MORE_FILES );
|
||||
break;
|
||||
case EEXIST:
|
||||
SetLastError( ERROR_FILE_EXISTS );
|
||||
break;
|
||||
case EINVAL:
|
||||
case ESPIPE:
|
||||
SetLastError( ERROR_SEEK );
|
||||
break;
|
||||
case ENOTEMPTY:
|
||||
SetLastError( ERROR_DIR_NOT_EMPTY );
|
||||
break;
|
||||
case ENOEXEC:
|
||||
SetLastError( ERROR_BAD_FORMAT );
|
||||
break;
|
||||
default:
|
||||
WARN( "unknown file error: %s", strerror(save_errno) );
|
||||
SetLastError( ERROR_GEN_FAILURE );
|
||||
break;
|
||||
}
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
/* Exported functions */
|
||||
void
|
||||
SCSI_Init()
|
||||
|
@ -199,7 +251,7 @@ linux_hack:
|
|||
if( fd < 0 )
|
||||
{
|
||||
int len = strlen(devstr);
|
||||
FILE_SetDosError(); /* SetLastError() to errno */
|
||||
set_last_error(); /* SetLastError() to errno */
|
||||
TRACE("Open failed (%s)\n", strerror(errno));
|
||||
|
||||
/* in case of "/dev/sgX", convert from sga to sg0
|
||||
|
@ -255,7 +307,7 @@ SCSI_LinuxSetTimeout( int fd, int timeout )
|
|||
}
|
||||
|
||||
/* This function takes care of the write/read to the linux sg device.
|
||||
* It returns TRUE or FALSE and uses FILE_SetDosError() to convert
|
||||
* It returns TRUE or FALSE and uses set_last_error() to convert
|
||||
* UNIX errno to Windows GetLastError(). The reason for that is that
|
||||
* several programs will check that error and we might as well set
|
||||
* it here. We also return the value of the read call in
|
||||
|
@ -274,9 +326,10 @@ SCSI_LinuxDeviceIo( int fd,
|
|||
dwBytes = write( fd, lpInBuffer, cbInBuffer );
|
||||
if( dwBytes != cbInBuffer )
|
||||
{
|
||||
FILE_SetDosError();
|
||||
set_last_error();
|
||||
save_error = GetLastError();
|
||||
WARN("Not enough bytes written to scsi device. bytes=%ld .. %ld\n", cbInBuffer, dwBytes );
|
||||
/* FIXME: set_last_error() never sets error to ERROR_NOT_ENOUGH_MEMORY... */
|
||||
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)");
|
||||
WARN("error= %ld\n", save_error );
|
||||
|
@ -288,7 +341,7 @@ SCSI_LinuxDeviceIo( int fd,
|
|||
*lpcbBytesReturned = read( fd, lpOutBuffer, cbOutBuffer );
|
||||
if( *lpcbBytesReturned != cbOutBuffer )
|
||||
{
|
||||
FILE_SetDosError();
|
||||
set_last_error();
|
||||
save_error = GetLastError();
|
||||
WARN("Not enough bytes read from scsi device. bytes=%ld .. %ld\n", cbOutBuffer, *lpcbBytesReturned);
|
||||
WARN("error= %ld\n", save_error );
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
#include "winbase.h"
|
||||
#include "wine/windef16.h"
|
||||
#include "winreg.h"
|
||||
#include "aspi.h"
|
||||
#include "winescsi.h"
|
||||
#include "wine/winaspi.h"
|
||||
#include "options.h"
|
||||
#include "heap.h"
|
||||
#include "debugtools.h"
|
||||
#include "selectors.h"
|
||||
|
@ -45,8 +45,9 @@ static WORD HA_Count = 1; /* host adapter count; FIXME: detect it */
|
|||
static int
|
||||
ASPI_OpenDevice16(SRB_ExecSCSICmd16 *prb)
|
||||
{
|
||||
HKEY hkey;
|
||||
int fd;
|
||||
char idstr[20];
|
||||
char idstr[50];
|
||||
char device_str[50];
|
||||
ASPI_DEVICE_INFO *curr;
|
||||
|
||||
|
@ -64,9 +65,19 @@ ASPI_OpenDevice16(SRB_ExecSCSICmd16 *prb)
|
|||
}
|
||||
|
||||
/* device wasn't cached, go ahead and open it */
|
||||
sprintf(idstr, "scsi c%1dt%1dd%1d", prb->SRB_HaId, prb->SRB_Target, prb->SRB_Lun);
|
||||
sprintf( idstr, "Software\\Wine\\Wine\\Config\\scsi c%1dt%1dd%1d",
|
||||
prb->SRB_HaId, prb->SRB_Target, prb->SRB_Lun);
|
||||
|
||||
if (!PROFILE_GetWineIniString(idstr, "Device", "", device_str, sizeof(device_str))) {
|
||||
device_str[0] = 0;
|
||||
if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE, idstr, 0, KEY_ALL_ACCESS, &hkey ))
|
||||
{
|
||||
DWORD type, count = sizeof(device_str);
|
||||
if (RegQueryValueExA( hkey, "Device", 0, &type, device_str, &count )) device_str[0] = 0;
|
||||
RegCloseKey( hkey );
|
||||
}
|
||||
|
||||
if (!device_str[0])
|
||||
{
|
||||
TRACE("Trying to open unlisted scsi device %s\n", idstr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -107,7 +118,7 @@ ASPI_DebugPrintCmd(SRB_ExecSCSICmd16 *prb, UINT16 mode)
|
|||
case ASPI_DOS:
|
||||
/* translate real mode address */
|
||||
if (prb->SRB_BufPointer)
|
||||
lpBuf = (BYTE *)DOSMEM_MapRealToLinear((UINT)prb->SRB_BufPointer);
|
||||
lpBuf = PTR_REAL_TO_LIN( SELECTOROF(prb->SRB_BufPointer), OFFSETOF(prb->SRB_BufPointer));
|
||||
break;
|
||||
case ASPI_WIN16:
|
||||
lpBuf = PTR_SEG_TO_LIN(prb->SRB_BufPointer);
|
||||
|
@ -196,7 +207,7 @@ ASPI_DebugPrintResult(SRB_ExecSCSICmd16 *prb, UINT16 mode)
|
|||
case ASPI_DOS:
|
||||
/* translate real mode address */
|
||||
if (prb->SRB_BufPointer)
|
||||
lpBuf = (BYTE *)DOSMEM_MapRealToLinear((UINT)prb->SRB_BufPointer);
|
||||
lpBuf = PTR_REAL_TO_LIN( SELECTOROF(prb->SRB_BufPointer), OFFSETOF(prb->SRB_BufPointer));
|
||||
break;
|
||||
case ASPI_WIN16:
|
||||
lpBuf = PTR_SEG_TO_LIN(prb->SRB_BufPointer);
|
||||
|
@ -228,7 +239,7 @@ ASPI_ExecScsiCmd(DWORD ptrPRB, UINT16 mode)
|
|||
{
|
||||
case ASPI_DOS:
|
||||
if (ptrPRB)
|
||||
lpPRB = (SRB_ExecSCSICmd16 *)DOSMEM_MapRealToLinear(ptrPRB);
|
||||
lpPRB = PTR_REAL_TO_LIN( SELECTOROF(ptrPRB), OFFSETOF(ptrPRB));
|
||||
break;
|
||||
case ASPI_WIN16:
|
||||
lpPRB = PTR_SEG_TO_LIN(ptrPRB);
|
||||
|
@ -254,7 +265,8 @@ ASPI_ExecScsiCmd(DWORD ptrPRB, UINT16 mode)
|
|||
case ASPI_DOS:
|
||||
/* translate real mode address */
|
||||
if (ptrPRB)
|
||||
lpBuf = (BYTE *)DOSMEM_MapRealToLinear((UINT)lpPRB->SRB_BufPointer);
|
||||
lpBuf = PTR_REAL_TO_LIN( SELECTOROF(lpPRB->SRB_BufPointer),
|
||||
OFFSETOF(lpPRB->SRB_BufPointer));
|
||||
break;
|
||||
case ASPI_WIN16:
|
||||
lpBuf = PTR_SEG_TO_LIN(lpPRB->SRB_BufPointer);
|
||||
|
@ -413,7 +425,7 @@ DWORD ASPI_SendASPICommand(DWORD ptrSRB, UINT16 mode)
|
|||
{
|
||||
case ASPI_DOS:
|
||||
if (ptrSRB)
|
||||
lpSRB = (LPSRB16)DOSMEM_MapRealToLinear(ptrSRB);
|
||||
lpSRB = PTR_REAL_TO_LIN( SELECTOROF(ptrSRB), OFFSETOF(ptrSRB));
|
||||
break;
|
||||
case ASPI_WIN16:
|
||||
lpSRB = PTR_SEG_TO_LIN(ptrSRB);
|
||||
|
|
Loading…
Reference in New Issue