From a50dca0ff0461010ce61bfeacc6d60d5bbe56847 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 4 Mar 2022 21:13:37 -0800 Subject: [PATCH] SCP: Normalize writelock/read only behavior Setting a unit to write locked specifically allows only read access. - If this is done while a unit is attached, it is up to device logic to limit write activity until it is detached. - If this is done while a unit is not attached, a subsequent attach opens the container read only. --- scp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scp.c b/scp.c index d45f658d..b540caa9 100644 --- a/scp.c +++ b/scp.c @@ -8011,14 +8011,17 @@ t_stat set_writelock (UNIT *uptr, int32 val, CONST char *cptr, void *desc) { if (((uptr->flags & UNIT_WPRT) != 0) == val) /* Already set as desired? */ return SCPE_OK; /* Do nothing */ -if (val) /* Lock? */ +if (val) { /* Lock? */ uptr->flags |= UNIT_WLK; /* Do it. */ + if ((uptr->flags & UNIT_ATT) == 0) + uptr->flags |= UNIT_RO; /* Next attach will be Read-Only. */ + } else /* Unlock */ if (((uptr->flags & UNIT_ATT) != 0) && /* Transition from Locked to Unlock while attached read-only? */ ((uptr->flags & UNIT_RO) != 0)) return sim_messagef (SCPE_ALATT, "%s: Can't enable write when attached read only\n", sim_uname (uptr)); else - uptr->flags &= ~UNIT_WLK; + uptr->flags &= ~UNIT_WPRT; return SCPE_OK; }