mirror of
https://github.com/simh/simh.git
synced 2026-01-25 19:56:25 +00:00
PDP11, VAX: Fix SET RPn BADBLOCK behavior and auto sizing.
BAD144 info was written correctly if the user answered Y when the disk image was created, but would not work if SET RPn BADBLOCK was entered later. Auto sizing would be potentially wrong if a disk had been created without writing the BAD144 data. Now, if the disk contains a file system that information along with the physical container's size is used to properly auto size the disk.
This commit is contained in:
@@ -921,44 +921,9 @@ return SCPE_OK;
|
||||
sta = status code
|
||||
*/
|
||||
|
||||
#include "sim_disk.h"
|
||||
|
||||
t_stat pdp11_bad_block (UNIT *uptr, int32 sec, int32 wds)
|
||||
{
|
||||
int32 i;
|
||||
t_addr da;
|
||||
uint16 *buf;
|
||||
char *namebuf, *c;
|
||||
uint32 packid;
|
||||
|
||||
if ((sec < 2) || (wds < 16))
|
||||
return SCPE_ARG;
|
||||
if ((uptr->flags & UNIT_ATT) == 0)
|
||||
return SCPE_UNATT;
|
||||
if (uptr->flags & UNIT_RO)
|
||||
return SCPE_RO;
|
||||
if (!get_yn ("Overwrite last track? [N]", FALSE))
|
||||
return SCPE_OK;
|
||||
da = (uptr->capac - (sec * wds)) * sizeof (uint16);
|
||||
if (sim_fseek (uptr->fileref, da, SEEK_SET))
|
||||
return SCPE_IOERR;
|
||||
if ((buf = (uint16 *) malloc (wds * sizeof (uint16))) == NULL)
|
||||
return SCPE_MEM;
|
||||
namebuf = uptr->filename;
|
||||
if ((c = strrchr (namebuf, '/')))
|
||||
namebuf = c+1;
|
||||
if ((c = strrchr (namebuf, '\\')))
|
||||
namebuf = c+1;
|
||||
if ((c = strrchr (namebuf, ']')))
|
||||
namebuf = c+1;
|
||||
packid = eth_crc32(0, namebuf, strlen (namebuf));
|
||||
buf[0] = (uint16)packid;
|
||||
buf[1] = (uint16)(packid >> 16) & 0x7FFF; /* Make sure MSB is clear */
|
||||
buf[2] = buf[3] = 0;
|
||||
for (i = 4; i < wds; i++)
|
||||
buf[i] = 0177777u;
|
||||
for (i = 0; (i < sec) && (i < 10); i++)
|
||||
sim_fwrite (buf, sizeof (uint16), wds, uptr->fileref);
|
||||
free (buf);
|
||||
if (ferror (uptr->fileref))
|
||||
return SCPE_IOERR;
|
||||
return SCPE_OK;
|
||||
return sim_disk_pdp11_bad_block (uptr, sec, wds);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user