All: Fix devices that attach files and have special meaning for -A switch

The -A attach time switch implicitly means to open files in append
mode.

Some devices used -A to indicate ASCII data or AUTOSIZE of disk or
fixed size tapes - DECtape.  These devices are either read only devices
(Paper tape readers or card readers), so explicit forcing of the attach
to be -R avoids unexpected positioning errors.  The random access
Disk and fixed sized tapes buffer the container contents in memory
so append mode isn't relevant, but care must be taken to assure that
the buffer reading starts at the beginning of the file without regard
to the explicit open mode.

As reported in #821
This commit is contained in:
Mark Pizzolato 2020-03-22 09:54:54 -07:00
parent 17a3219d0a
commit 614ad52091
11 changed files with 13 additions and 0 deletions

View file

@ -424,6 +424,8 @@ t_stat r;
if (!(uptr->flags & UNIT_ATTABLE)) /* not tti,tto */
return SCPE_NOFNC;
if (strcmp ("PTR", sim_uname (uptr)) == 0) /* PTR is read only */
sim_switches |= SWMASK ('R');
if ((r = attach_unit (uptr, cptr)))
return r;
if (sim_switches & SWMASK ('A')) /* -a? ASCII */

View file

@ -618,6 +618,8 @@ t_stat tap_attach (UNIT *uptr, CONST char *cptr)
{
t_stat r;
if (strcmp ("PTR", sim_uname (uptr)) == 0)
sim_switches |= SWMASK ('R'); /* PTR is read only */
if ((r = attach_unit (uptr,cptr)) != SCPE_OK)
return r;
if ((sim_switches & SWMASK ('F')) ||

View file

@ -1023,6 +1023,7 @@ else if (uptr->flags & UNIT_11FMT)
sim_printf ("16b format");
else sim_printf ("18b/36b format");
sim_printf (", buffering file in memory\n");
sim_fseek (uptr->fileref, 0, SEEK_SET); /* start at the beginning of file */
if (uptr->flags & UNIT_8FMT) { /* 12b? */
for (ba = 0; ba < uptr->capac; ) { /* loop thru file */
k = fxread (pdp8b, sizeof (uint16), D8_NBSIZE, uptr->fileref);

View file

@ -458,6 +458,7 @@ ptr_leader = PTR_LEADER; /* set up leader */
if (sim_switches & SWMASK ('A'))
uptr->flags = uptr->flags | UNIT_ASCII;
else uptr->flags = uptr->flags & ~UNIT_ASCII;
sim_switches |= SWMASK ('R');
return attach_unit (uptr, cptr);
}

View file

@ -1182,6 +1182,7 @@ t_stat dt_attach (UNIT *uptr, CONST char *cptr)
sim_printf ("16b format");
else sim_printf ("18b/36b format");
sim_printf (", buffering file in memory\n");
(void)sim_fseek (uptr->fileref, 0, SEEK_SET); /* start at the beginning of file */
uptr->io_flush = dt_flush;
if (uptr->flags & UNIT_8FMT) { /* 12b? */
for (ba = 0; ba < uptr->capac; ) { /* loop thru file */

View file

@ -1194,6 +1194,7 @@ dtc_attach (UNIT *uptr, CONST char *cptr)
sim_printf ("16b format");
else sim_printf ("18b/36b format");
sim_printf (", buffering file in memory\n");
(void)sim_fseek (uptr->fileref, 0, SEEK_SET); /* start at the beginning of file */
uptr->WRITTEN = 0;
uptr->io_flush = dtc_flush;
if (uptr->flags & UNIT_8FMT) { /* 12b? */

View file

@ -1299,6 +1299,7 @@ else if (uptr->flags & UNIT_11FMT)
sim_printf ("16b format");
else sim_printf ("18b/36b format");
sim_printf (", buffering file in memory\n");
(void)sim_fseek (uptr->fileref, 0, SEEK_SET); /* start at the beginning of file */
uptr->io_flush = dt_flush;
if (uptr->flags & UNIT_8FMT) { /* 12b? */
for (ba = 0; ba < uptr->capac; ) { /* loop thru file */

View file

@ -1458,6 +1458,7 @@ else if (uptr->flags & UNIT_11FMT)
sim_printf ("16b format");
else sim_printf ("18b/36b format");
sim_printf (", buffering file in memory\n");
(void)sim_fseek (uptr->fileref, 0, SEEK_SET); /* start at the beginning of file */
uptr->io_flush = dt_flush;
if (uptr->flags & UNIT_8FMT) { /* 12b? */
for (ba = 0; ba < uptr->capac; ) { /* loop thru file */

View file

@ -651,6 +651,7 @@ t_stat ptr_attach (UNIT *uptr, CONST char *cptr)
{
t_stat reason;
sim_switches |= SWMASK ('R');
reason = attach_unit (uptr, cptr);
if (reason != SCPE_OK)
return reason;

View file

@ -1248,6 +1248,7 @@ else if (uptr->flags & UNIT_11FMT)
sim_printf ("16b format");
else sim_printf ("18b/36b format");
sim_printf (", buffering file in memory\n");
(void)sim_fseek (uptr->fileref, 0, SEEK_SET); /* start at the beginning of file */
uptr->io_flush = dt_flush;
if (uptr->flags & UNIT_8FMT) /* 12b? */
uptr->hwmark = fxread (uptr->filebuf, sizeof (uint16),

View file

@ -808,6 +808,7 @@ else if (uptr->flags & UNIT_11FMT)
sim_printf ("16b format");
else sim_printf ("18b/36b format");
sim_printf (", buffering file in memory\n");
(void)sim_fseek (uptr->fileref, 0, SEEK_SET); /* start at the beginning of file */
uptr->io_flush = td_flush;
if (uptr->flags & UNIT_8FMT) /* 12b? */
uptr->hwmark = fxread (uptr->filebuf, sizeof (uint16),