DISK: Add better error reporting when differencing VHD attach fails
This commit is contained in:
parent
0a12499a44
commit
df80f22152
1 changed files with 30 additions and 14 deletions
44
sim_disk.c
44
sim_disk.c
|
@ -1040,6 +1040,8 @@ else
|
||||||
switch (DK_GET_FMT (uptr)) { /* case on format */
|
switch (DK_GET_FMT (uptr)) { /* case on format */
|
||||||
case DKUF_F_STD: /* SIMH format */
|
case DKUF_F_STD: /* SIMH format */
|
||||||
if (NULL == (uptr->fileref = sim_vhd_disk_open (cptr, "rb"))) {
|
if (NULL == (uptr->fileref = sim_vhd_disk_open (cptr, "rb"))) {
|
||||||
|
if (errno == EINVAL) /* VHD but broken */
|
||||||
|
return SCPE_OPENERR;
|
||||||
open_function = sim_fopen;
|
open_function = sim_fopen;
|
||||||
size_function = sim_fsize_ex;
|
size_function = sim_fsize_ex;
|
||||||
break;
|
break;
|
||||||
|
@ -2881,24 +2883,38 @@ if ((sDynamic) &&
|
||||||
strncpy (CheckPath+strlen(CheckPath), ParentName, sizeof (CheckPath)-(strlen (CheckPath)+1));
|
strncpy (CheckPath+strlen(CheckPath), ParentName, sizeof (CheckPath)-(strlen (CheckPath)+1));
|
||||||
}
|
}
|
||||||
VhdPathToHostPath (CheckPath, CheckPath, sizeof (CheckPath));
|
VhdPathToHostPath (CheckPath, CheckPath, sizeof (CheckPath));
|
||||||
if ((0 == GetVHDFooter(CheckPath,
|
if (0 == GetVHDFooter(CheckPath,
|
||||||
&sParentFooter,
|
&sParentFooter,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&ParentModificationTime,
|
&ParentModificationTime,
|
||||||
NULL,
|
NULL,
|
||||||
0)) &&
|
0)) {
|
||||||
(0 == memcmp (sDynamic->ParentUniqueID, sParentFooter.UniqueID, sizeof (sParentFooter.UniqueID))) &&
|
if ((0 == memcmp (sDynamic->ParentUniqueID, sParentFooter.UniqueID, sizeof (sParentFooter.UniqueID))) &&
|
||||||
((sDynamic->ParentTimeStamp == ParentModificationTime) ||
|
((sDynamic->ParentTimeStamp == ParentModificationTime) ||
|
||||||
((NtoHl(sDynamic->ParentTimeStamp)-NtoHl(ParentModificationTime)) == 3600) ||
|
((NtoHl(sDynamic->ParentTimeStamp)-NtoHl(ParentModificationTime)) == 3600) ||
|
||||||
(sim_switches & SWMASK ('O')))) {
|
(sim_switches & SWMASK ('O'))))
|
||||||
strncpy (szParentVHDPath, CheckPath, ParentVHDPathSize);
|
strncpy (szParentVHDPath, CheckPath, ParentVHDPathSize);
|
||||||
|
else {
|
||||||
|
sim_printf ("Error Invalid Parent VHD '%s' for Differencing VHD: %s\n", CheckPath, szVHDPath);
|
||||||
|
Return = EINVAL; /* File Corrupt/Invalid */
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
struct stat statb;
|
||||||
|
|
||||||
|
if (0 == stat (CheckPath, &statb)) {
|
||||||
|
sim_printf ("Parent VHD '%s' corrupt for Differencing VHD: %s\n", CheckPath, szVHDPath);
|
||||||
|
Return = EINVAL; /* File Corrupt/Invalid */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!*szParentVHDPath) {
|
if (!*szParentVHDPath) {
|
||||||
Return = EINVAL; /* File Corrupt */
|
if (Return != EINVAL) /* File Not Corrupt? */
|
||||||
sim_printf ("Error Invalid Parent VHD for Differencing VHD\n");
|
sim_printf ("Missing Parent VHD for Differencing VHD: %s\n", szVHDPath);
|
||||||
|
Return = EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue