From 5a99bcf18539e464bc6c392a19552fd86428b933 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 12 Jan 2016 09:52:14 -0800 Subject: [PATCH] SCP: Assure that files attached honor the unit Read-Only flag in addition to -R switches. --- scp.c | 6 ++++-- sim_disk.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scp.c b/scp.c index b0a03524..50cb21a5 100644 --- a/scp.c +++ b/scp.c @@ -5183,8 +5183,10 @@ uptr->filename = (char *) calloc (CBUFSIZE, sizeof (char)); /* alloc name buf */ if (uptr->filename == NULL) return SCPE_MEM; strncpy (uptr->filename, cptr, CBUFSIZE); /* save name */ -if (sim_switches & SWMASK ('R')) { /* read only? */ - if ((uptr->flags & UNIT_ROABLE) == 0) /* allowed? */ +if ((sim_switches & SWMASK ('R')) || /* read only? */ + ((uptr->flags & UNIT_RO) != 0)) { + if (((uptr->flags & UNIT_ROABLE) == 0) && /* allowed? */ + ((uptr->flags & UNIT_RO) == 0)) return attach_err (uptr, SCPE_NORO); /* no, error */ uptr->fileref = sim_fopen (cptr, "rb"); /* open rd only */ if (uptr->fileref == NULL) /* open fail? */ diff --git a/sim_disk.c b/sim_disk.c index ce310c64..9509812d 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -1076,8 +1076,10 @@ ctx->dbit = dbit; /* save debug bit */ sim_debug (ctx->dbit, ctx->dptr, "sim_disk_attach(unit=%d,filename='%s')\n", (int)(uptr-ctx->dptr->units), uptr->filename); ctx->auto_format = auto_format; /* save that we auto selected format */ ctx->storage_sector_size = (uint32)sector_size; /* Default */ -if (sim_switches & SWMASK ('R')) { /* read only? */ - if ((uptr->flags & UNIT_ROABLE) == 0) /* allowed? */ +if ((sim_switches & SWMASK ('R')) || /* read only? */ + ((uptr->flags & UNIT_RO) != 0)) { + if (((uptr->flags & UNIT_ROABLE) == 0) && /* allowed? */ + ((uptr->flags & UNIT_RO) == 0)) return _err_return (uptr, SCPE_NORO); /* no, error */ uptr->fileref = open_function (cptr, "rb"); /* open rd only */ if (uptr->fileref == NULL) /* open fail? */