SCP: Add natural Windows support for RAW device names. Fixes issue raised in #67.
Also avoid confusion when processing -F switch while also copying/creating a VHD
This commit is contained in:
parent
047a6b856f
commit
133572908f
1 changed files with 17 additions and 0 deletions
17
sim_disk.c
17
sim_disk.c
|
@ -837,6 +837,7 @@ if (sim_switches & SWMASK ('F')) { /* format spec? */
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
if (sim_disk_set_fmt (uptr, 0, gbuf, NULL) != SCPE_OK)
|
if (sim_disk_set_fmt (uptr, 0, gbuf, NULL) != SCPE_OK)
|
||||||
return SCPE_ARG;
|
return SCPE_ARG;
|
||||||
|
sim_switches = sim_switches & ~(SWMASK ('F')); /* Record Format specifier already processed */
|
||||||
}
|
}
|
||||||
if (sim_switches & SWMASK ('D')) { /* create difference disk? */
|
if (sim_switches & SWMASK ('D')) { /* create difference disk? */
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
|
@ -1652,6 +1653,22 @@ 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;
|
||||||
|
/* SCP Command Line parsing replaces \\ with \ presuming this is an
|
||||||
|
escape sequence. This only affecdts RAW device names and UNC paths.
|
||||||
|
We handle the RAW device name case here by prepending paths beginning
|
||||||
|
with \.\ with an extra \. */
|
||||||
|
if (!memcmp ("\\.\\", rawdevicename, 3)) {
|
||||||
|
char *tmpname = malloc (2 + strlen (rawdevicename));
|
||||||
|
|
||||||
|
if (tmpname == NULL)
|
||||||
|
return NULL;
|
||||||
|
*tmpname = '\\';
|
||||||
|
strcpy (tmpname + 1, rawdevicename);
|
||||||
|
Handle = CreateFileA (tmpname, DesiredAccess, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS|FILE_FLAG_WRITE_THROUGH, NULL);
|
||||||
|
free (tmpname);
|
||||||
|
if (Handle != INVALID_HANDLE_VALUE)
|
||||||
|
return (FILE *)Handle;
|
||||||
|
}
|
||||||
Handle = CreateFileA (rawdevicename, DesiredAccess, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS|FILE_FLAG_WRITE_THROUGH, 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 ());
|
||||||
|
|
Loading…
Add table
Reference in a new issue