H316: Open LPT, PTP devices for append

This implements the principle of "least surprise", in that users won't
normally expect to start overwriting an existing file on these devices.
Real hardware didn't behave that way.  A new (empty) file can always
be created with the -N switch on the ATTACH.
This commit is contained in:
Mark Pizzolato 2020-04-30 05:18:47 -07:00
parent 323cd48244
commit 4099330616
3 changed files with 16 additions and 4 deletions

View file

@ -97,6 +97,7 @@ int32 lpt_stopioe = 0; /* stop on error */
int32 lptio (int32 inst, int32 fnc, int32 dat, int32 dev);
t_stat lpt_svc (UNIT *uptr);
t_stat lpt_reset (DEVICE *dptr);
t_stat lpt_attach (UNIT *uptr, CONST char *cptr);
/* LPT data structures
@ -135,7 +136,7 @@ DEVICE lpt_dev = {
"LPT", &lpt_unit, lpt_reg, NULL,
1, 10, 31, 1, 8, 8,
NULL, NULL, &lpt_reset,
NULL, NULL, NULL,
NULL, &lpt_attach, NULL,
&lpt_dib, DEV_DISABLE
};
@ -355,3 +356,11 @@ CLR_ENB (INT_LPT);
sim_cancel (&lpt_unit); /* deactivate unit */
return SCPE_OK;
}
/* Attach routine */
t_stat lpt_attach (UNIT *uptr, CONST char *cptr)
{
sim_switches |= SWMASK ('A'); /* Default to Append to existing file */
return attach_unit (uptr, cptr);
}

View file

@ -421,13 +421,16 @@ return SCPE_OK;
t_stat pt_attach (UNIT *uptr, CONST char *cptr)
{
t_stat r;
int32 saved_switches = sim_switches;
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)))
sim_switches &= ~SWMASK ('A');
if (strcmp ("PTP", sim_uname (uptr)) == 0) /* PTP is append default */
sim_switches |= SWMASK ('A');
if ((r = attach_unit (uptr, cptr)) != SCPE_OK)
return r;
sim_switches = saved_switches;
if (sim_switches & SWMASK ('A')) /* -a? ASCII */
uptr->flags |= UNIT_ASC;
else if (sim_switches & SWMASK ('U')) /* -u? Unix ASCII */

Binary file not shown.