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
10
sim_disk.c
10
sim_disk.c
|
@ -1335,7 +1335,7 @@ if (strchr (openmode, 'r'))
|
||||||
DesiredAccess |= GENERIC_READ;
|
DesiredAccess |= GENERIC_READ;
|
||||||
if (strchr (openmode, 'w') || strchr (openmode, '+'))
|
if (strchr (openmode, 'w') || strchr (openmode, '+'))
|
||||||
DesiredAccess |= GENERIC_WRITE;
|
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) {
|
if (Handle == INVALID_HANDLE_VALUE) {
|
||||||
_set_errno_from_status (GetLastError ());
|
_set_errno_from_status (GetLastError ());
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1421,7 +1421,10 @@ static t_stat sim_os_disk_unload_raw (FILE *Disk)
|
||||||
{
|
{
|
||||||
#ifdef IOCTL_STORAGE_EJECT_MEDIA
|
#ifdef IOCTL_STORAGE_EJECT_MEDIA
|
||||||
DWORD BytesReturned;
|
DWORD BytesReturned;
|
||||||
|
uint32 Removable = FALSE;
|
||||||
|
|
||||||
|
sim_os_disk_info_raw (Disk, NULL, &Removable);
|
||||||
|
if (Removable) {
|
||||||
if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
||||||
IOCTL_STORAGE_EJECT_MEDIA, /* dwIoControlCode */
|
IOCTL_STORAGE_EJECT_MEDIA, /* dwIoControlCode */
|
||||||
NULL, /* lpInBuffer */
|
NULL, /* lpInBuffer */
|
||||||
|
@ -1433,6 +1436,7 @@ if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
||||||
_set_errno_from_status (GetLastError ());
|
_set_errno_from_status (GetLastError ());
|
||||||
return SCPE_IOERR;
|
return SCPE_IOERR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
#else
|
#else
|
||||||
return SCPE_NOFNC;
|
return SCPE_NOFNC;
|
||||||
|
@ -1443,7 +1447,10 @@ static t_bool sim_os_disk_isavailable_raw (FILE *Disk)
|
||||||
{
|
{
|
||||||
#ifdef IOCTL_STORAGE_EJECT_MEDIA
|
#ifdef IOCTL_STORAGE_EJECT_MEDIA
|
||||||
DWORD BytesReturned;
|
DWORD BytesReturned;
|
||||||
|
uint32 Removable = FALSE;
|
||||||
|
|
||||||
|
sim_os_disk_info_raw (Disk, NULL, &Removable);
|
||||||
|
if (Removable) {
|
||||||
if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
||||||
IOCTL_STORAGE_CHECK_VERIFY, /* dwIoControlCode */
|
IOCTL_STORAGE_CHECK_VERIFY, /* dwIoControlCode */
|
||||||
NULL, /* lpInBuffer */
|
NULL, /* lpInBuffer */
|
||||||
|
@ -1455,6 +1462,7 @@ if (!DeviceIoControl((HANDLE)Disk, /* handle to disk */
|
||||||
_set_errno_from_status (GetLastError ());
|
_set_errno_from_status (GetLastError ());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue