From 5efd8fe1b5a2d592c15fb3f606f11e8ca13b9364 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 2 Feb 2012 07:30:40 -0800 Subject: [PATCH] Fixed bug in save command. The issue is that attached units which are buffered in memory should also be flushed to storage as part of the save operation to make all the components of the save 'snapshot' consistent. --- scp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scp.c b/scp.c index 86a8680e..3e5dd88b 100644 --- a/scp.c +++ b/scp.c @@ -2725,8 +2725,18 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* loop thru devices */ WRITE_I (uptr->u6); WRITE_I (uptr->flags); /* [V2.10] flags */ WRITE_I (uptr->capac); /* [V3.5] capacity */ - if (uptr->flags & UNIT_ATT) + if (uptr->flags & UNIT_ATT) { fputs (uptr->filename, sfile); + if ((uptr->flags & UNIT_BUF) && /* writable buffered */ + uptr->hwmark && /* files need to be */ + ((uptr->flags & UNIT_RO) == 0)) { /* written on save */ + uint32 cap = (uptr->hwmark + dptr->aincr - 1) / dptr->aincr; + rewind (uptr->fileref); + sim_fwrite (uptr->filebuf, SZ_D (dptr), cap, uptr->fileref); + fclose (uptr->fileref); /* flush data and state */ + uptr->fileref = sim_fopen (uptr->filename, "rb+");/* reopen r/w */ + } + } fputc ('\n', sfile); if (((uptr->flags & (UNIT_FIX + UNIT_ATTABLE)) == UNIT_FIX) && (dptr->examine != NULL) &&