Added support for concurrent sharing of raw disk images/drives between simulators
This commit is contained in:
parent
51525f7a3f
commit
7075a3ec5c
1 changed files with 29 additions and 21 deletions
50
sim_disk.c
50
sim_disk.c
|
@ -1335,7 +1335,7 @@ if (strchr (openmode, 'r'))
|
|||
DesiredAccess |= GENERIC_READ;
|
||||
if (strchr (openmode, 'w') || strchr (openmode, '+'))
|
||||
DesiredAccess |= GENERIC_WRITE;
|
||||
Handle = CreateFileA (rawdevicename, DesiredAccess, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL);
|
||||
Handle = CreateFileA (rawdevicename, DesiredAccess, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS|FILE_FLAG_WRITE_THROUGH, NULL);
|
||||
if (Handle == INVALID_HANDLE_VALUE) {
|
||||
_set_errno_from_status (GetLastError ());
|
||||
return NULL;
|
||||
|
@ -1421,17 +1421,21 @@ static t_stat sim_os_disk_unload_raw (FILE *Disk)
|
|||
{
|
||||
#ifdef IOCTL_STORAGE_EJECT_MEDIA
|
||||
DWORD BytesReturned;
|
||||
uint32 Removable = FALSE;
|
||||
|
||||
if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
||||
IOCTL_STORAGE_EJECT_MEDIA, /* dwIoControlCode */
|
||||
NULL, /* lpInBuffer */
|
||||
0, /* nInBufferSize */
|
||||
NULL, /* lpOutBuffer */
|
||||
0, /* nOutBufferSize */
|
||||
(LPDWORD) &BytesReturned, /* number of bytes returned */
|
||||
(LPOVERLAPPED) NULL)) { /* OVERLAPPED structure */
|
||||
_set_errno_from_status (GetLastError ());
|
||||
return SCPE_IOERR;
|
||||
sim_os_disk_info_raw (Disk, NULL, &Removable);
|
||||
if (Removable) {
|
||||
if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
||||
IOCTL_STORAGE_EJECT_MEDIA, /* dwIoControlCode */
|
||||
NULL, /* lpInBuffer */
|
||||
0, /* nInBufferSize */
|
||||
NULL, /* lpOutBuffer */
|
||||
0, /* nOutBufferSize */
|
||||
(LPDWORD) &BytesReturned, /* number of bytes returned */
|
||||
(LPOVERLAPPED) NULL)) { /* OVERLAPPED structure */
|
||||
_set_errno_from_status (GetLastError ());
|
||||
return SCPE_IOERR;
|
||||
}
|
||||
}
|
||||
return SCPE_OK;
|
||||
#else
|
||||
|
@ -1443,17 +1447,21 @@ static t_bool sim_os_disk_isavailable_raw (FILE *Disk)
|
|||
{
|
||||
#ifdef IOCTL_STORAGE_EJECT_MEDIA
|
||||
DWORD BytesReturned;
|
||||
uint32 Removable = FALSE;
|
||||
|
||||
if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
||||
IOCTL_STORAGE_CHECK_VERIFY, /* dwIoControlCode */
|
||||
NULL, /* lpInBuffer */
|
||||
0, /* nInBufferSize */
|
||||
NULL, /* lpOutBuffer */
|
||||
0, /* nOutBufferSize */
|
||||
(LPDWORD) &BytesReturned, /* number of bytes returned */
|
||||
(LPOVERLAPPED) NULL)) { /* OVERLAPPED structure */
|
||||
_set_errno_from_status (GetLastError ());
|
||||
return FALSE;
|
||||
sim_os_disk_info_raw (Disk, NULL, &Removable);
|
||||
if (Removable) {
|
||||
if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
||||
IOCTL_STORAGE_CHECK_VERIFY, /* dwIoControlCode */
|
||||
NULL, /* lpInBuffer */
|
||||
0, /* nInBufferSize */
|
||||
NULL, /* lpOutBuffer */
|
||||
0, /* nOutBufferSize */
|
||||
(LPDWORD) &BytesReturned, /* number of bytes returned */
|
||||
(LPOVERLAPPED) NULL)) { /* OVERLAPPED structure */
|
||||
_set_errno_from_status (GetLastError ());
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
|
|
Loading…
Add table
Reference in a new issue