DISK: Properly allow/disallow containers of reasonable/unreasonavle sizes
As reported in #1065
This commit is contained in:
parent
e6611c61b3
commit
b4fa00cebf
1 changed files with 30 additions and 18 deletions
24
sim_disk.c
24
sim_disk.c
|
@ -2875,19 +2875,30 @@ if (container_size && (container_size != (t_offset)-1)) {
|
|||
sim_messagef (SCPE_OK, "%s: No File System found on '%s', skipping autosizing\n", sim_uname (uptr), cptr);
|
||||
}
|
||||
}
|
||||
if ((container_size != current_unit_size) &&
|
||||
((DKUF_F_VHD == DK_GET_FMT (uptr)) || (0 != (uptr->flags & UNIT_RO)) ||
|
||||
(ctx->footer))) {
|
||||
if (filesystem_size != (t_offset)-1) {
|
||||
if (filesystem_size > current_unit_size) {
|
||||
if (!sim_quiet) {
|
||||
uptr->capac = (t_addr)(filesystem_size/(ctx->capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1)));
|
||||
sim_printf ("%s: The file system on the %s disk container is larger than simulated device (%s > ", sim_uname (uptr), cptr, sprint_capac (dptr, uptr));
|
||||
uptr->capac = saved_capac;
|
||||
sim_printf ("%s)\n", sprint_capac (dptr, uptr));
|
||||
}
|
||||
sim_disk_detach (uptr);
|
||||
return SCPE_FSSIZE;
|
||||
}
|
||||
}
|
||||
if ((container_size != current_unit_size)) {
|
||||
if ((DKUF_F_VHD == DK_GET_FMT (uptr)) &&
|
||||
(0 == (uptr->flags & UNIT_RO))) {
|
||||
if (!sim_quiet) {
|
||||
int32 saved_switches = sim_switches;
|
||||
const char *container_dtype = ctx->footer ? (const char *)ctx->footer->DriveType : "";
|
||||
|
||||
sim_switches = SWMASK ('R');
|
||||
uptr->capac = (t_addr)(container_size/(ctx->capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1)));
|
||||
sim_printf ("%s: non expandable %s%sdisk container '%s' is %s than simulated device (%s %s ",
|
||||
sim_printf ("%s: non expandable %s%sdisk container '%s' is smaller than simulated device (%s < ",
|
||||
sim_uname (uptr), container_dtype, (*container_dtype != '\0') ? " " : "", cptr,
|
||||
(container_size < current_unit_size) ? "smaller" : "larger", sprint_capac (dptr, uptr),
|
||||
(container_size < current_unit_size) ? "<" : ">");
|
||||
sprint_capac (dptr, uptr));
|
||||
uptr->capac = saved_capac;
|
||||
sim_printf ("%s)\n", sprint_capac (dptr, uptr));
|
||||
sim_switches = saved_switches;
|
||||
|
@ -2896,6 +2907,7 @@ if (container_size && (container_size != (t_offset)-1)) {
|
|||
return SCPE_OPENERR;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* Autosize by changing capacity */
|
||||
if (filesystem_size != (t_offset)-1) { /* Known file system data size AND */
|
||||
if (filesystem_size > container_size) /* Data size greater than container size? */
|
||||
|
|
Loading…
Add table
Reference in a new issue