From 9022de500d6f952d18054396dafc8e02cab220f1 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 5 Mar 2014 12:53:32 -0800 Subject: [PATCH 1/8] SCP: Removed the irrelevant sim_deb_PC variable since it duplicates the role sim_PC simulator variable. --- scp.c | 7 +++---- scp.h | 1 - sim_console.c | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/scp.c b/scp.c index fa7f1238..1122e901 100644 --- a/scp.c +++ b/scp.c @@ -484,7 +484,6 @@ FILEREF *sim_log_ref = NULL; /* log file file referen FILE *sim_deb = NULL; /* debug file */ FILEREF *sim_deb_ref = NULL; /* debug file file reference */ int32 sim_deb_switches = 0; /* debug switches */ -REG *sim_deb_PC = NULL; /* debug PC register pointer */ struct timespec sim_deb_basetime; /* debug timestamp relative base time */ char *sim_prompt = NULL; /* prompt string */ static FILE *sim_gotofile; /* the currently open do file */ @@ -7826,9 +7825,9 @@ if (sim_deb_switches & SWMASK ('P')) { if (sim_vm_pc_value) val = (*sim_vm_pc_value)(); else - val = get_rval (sim_deb_PC, 0); - sprintf(pc_s, "-%s:", sim_deb_PC->name); - sprint_val (&pc_s[strlen(pc_s)], val, sim_deb_PC->radix, sim_deb_PC->width, sim_deb_PC->flags & REG_FMT); + val = get_rval (sim_PC, 0); + sprintf(pc_s, "-%s:", sim_PC->name); + sprint_val (&pc_s[strlen(pc_s)], val, sim_PC->radix, sim_PC->width, sim_PC->flags & REG_FMT); } sprintf(debug_line_prefix, "DBG(%s%s%.0f%s)%s> %s %s: ", tim_t, tim_a, sim_gtime(), pc_s, AIO_MAIN_THREAD ? "" : "+", dptr->name, debug_type); return debug_line_prefix; diff --git a/scp.h b/scp.h index 1ab76aa8..fbd28c4b 100644 --- a/scp.h +++ b/scp.h @@ -180,7 +180,6 @@ extern FILE *sim_deb; /* debug file */ extern FILEREF *sim_deb_ref; /* debug file file reference */ extern int32 sim_deb_switches; /* debug display flags */ extern struct timespec sim_deb_basetime; /* debug base time for relative time output */ -extern REG *sim_deb_PC; /* debug PC register */ extern UNIT *sim_clock_queue; extern int32 sim_is_running; extern char *sim_prompt; /* prompt string */ diff --git a/sim_console.c b/sim_console.c index c393a7f2..28eaa7a1 100644 --- a/sim_console.c +++ b/sim_console.c @@ -1063,8 +1063,6 @@ if (sim_deb_switches & SWMASK ('R')) { if (!(sim_deb_switches & (SWMASK ('A') | SWMASK ('T')))) sim_deb_switches |= SWMASK ('T'); } -if (sim_deb_switches & SWMASK ('P')) - sim_deb_PC = find_reg ("PC", NULL, sim_dflt_dev); if (!sim_quiet) { printf ("Debug output to \"%s\"\n", sim_logfile_name (sim_deb, sim_deb_ref)); @@ -1126,7 +1124,6 @@ if (sim_deb == NULL) /* no debug? */ sim_close_logfile (&sim_deb_ref); sim_deb = NULL; sim_deb_switches = 0; -sim_deb_PC = NULL; if (!sim_quiet) { printf ("Debug output disabled\n"); if (sim_log) From a100c88f1dd0a74a5bfe284ace95ca31be177a21 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sat, 8 Mar 2014 05:56:40 -0800 Subject: [PATCH 2/8] PDP10, PDP11, VAX: Fix compile error due to C++ variable declaration being used instead of C. --- PDP11/pdp11_cr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PDP11/pdp11_cr.c b/PDP11/pdp11_cr.c index 9f020aac..06e6ff18 100644 --- a/PDP11/pdp11_cr.c +++ b/PDP11/pdp11_cr.c @@ -1013,6 +1013,8 @@ t_stat cr_wr ( int32 data, int32 PA, int32 access ) { + int curr_crs = crs; /* Save current crs to recover status */ + switch ((PA >> 1) & 03) { case 0: if (CR11_CTL(&cr_unit)) { @@ -1024,7 +1026,6 @@ t_stat cr_wr ( int32 data, data = (crs & ~0377) | (data & 0377); if (!(data & CSR_IE)) CLR_INT (CR); - int curr_crs = crs; /* Save current crs to recover status */ crs = (crs & ~CRCSR_RW) | (data & CRCSR_RW); /* Clear status bits after CSR load */ crs &= ~(CSR_ERR | CRCSR_ONLINE | CRCSR_CRDDONE | CRCSR_TIMERR); From 93b68432f2e7d3cd87663a44ca73b1adc9d645d2 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sat, 8 Mar 2014 06:01:21 -0800 Subject: [PATCH 3/8] AltairZ80, PDP10, PDP11, VAX: Fix incorrect sense of test on expression value in th ASSURE macro. Fix issue #126 --- sim_defs.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sim_defs.h b/sim_defs.h index 743097c6..d2cfd5c7 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -747,10 +747,11 @@ typedef struct sim_bitfield BITFIELD; /* This replaces any references to "assert()" which should never be invoked */ /* with an expression which causes side effects (i.e. must be executed for */ /* the program to work correctly) */ -#define ASSURE(_Expression) if (_Expression) {fprintf(stderr, "%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \ - if (sim_log) fprintf(sim_log, "%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \ - if (sim_deb) fprintf(sim_deb, "%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \ - abort();} else (void)0 +#define ASSURE(_Expression) if (!(_Expression)) {char *_exp = #_Expression; char *_file = __FILE__; \ + fprintf(stderr, "%s failed at %s line %d\n", _exp, _file, __LINE__); \ + if (sim_log) fprintf(sim_log, "%s failed at %s line %d\n", _exp, _file, __LINE__); \ + if (sim_deb) fprintf(sim_deb, "%s failed at %s line %d\n", _exp, _file, __LINE__); \ + abort();} else (void)0 /* Asynch/Threaded I/O support */ From 194b35f6e883ea42fcaf0eee8bfea032bb405f87 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 11 Mar 2014 19:30:28 -0700 Subject: [PATCH 4/8] TMXR: avoid calling strcpy with overlapping arguments --- sim_tmxr.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sim_tmxr.c b/sim_tmxr.c index c6153cfa..4443c1c5 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -831,7 +831,7 @@ if (mp->buffered) if (mp->logfiletmpl[0]) /* logfile info */ sprintf (growstring(&tptr, 7 + strlen (mp->logfiletmpl)), ",Log=%s", mp->logfiletmpl); while ((*tptr == ',') || (*tptr == ' ')) - strcpy(tptr, tptr+1); + memcpy (tptr, tptr+1, strlen(tptr+1)+1); for (i=0; ilines; ++i) { char *lptr; lp = mp->ldsc + i; @@ -844,7 +844,7 @@ for (i=0; ilines; ++i) { } if (mp->lines == 1) while ((*tptr == ',') || (*tptr == ' ')) - strcpy(tptr, tptr+1); + memcpy (tptr, tptr+1, strlen(tptr+1)+1); if (*tptr == '\0') { free (tptr); tptr = NULL; @@ -2124,7 +2124,7 @@ while (*tptr) { } if (0 == MATCH_CMD (gbuf, "BUFFERED")) { if ((NULL == cptr) || ('\0' == *cptr)) - strcpy(buffered, "32768"); + strcpy (buffered, "32768"); else { i = (int32) get_uint (cptr, 10, 1024*1024, &r); if ((r != SCPE_OK) || (i == 0)) @@ -2203,7 +2203,7 @@ while (*tptr) { return SCPE_ARG; cptr = hostport; } - strcpy(destination, cptr); + strcpy (destination, cptr); continue; } cptr = get_glyph (gbuf, port, ';'); @@ -2229,7 +2229,7 @@ while (*tptr) { return SCPE_OPENERR; sim_close_sock (sock, 1); sim_os_ms_sleep (2); /* let the close finish (required on some platforms) */ - strcpy(listen, port); + strcpy (listen, port); cptr = get_glyph (cptr, option, ';'); if (option[0]) { if (0 == MATCH_CMD (option, "NOTELNET")) @@ -2254,10 +2254,10 @@ while (*tptr) { if (mp->lines > 1) sprintf(lp->txlogname, "%s_%d", mp->logfiletmpl, i); else - strcpy(lp->txlogname, mp->logfiletmpl); + strcpy (lp->txlogname, mp->logfiletmpl); r = sim_open_logfile (lp->txlogname, TRUE, &lp->txlog, &lp->txlogref); if (r == SCPE_OK) - setvbuf(lp->txlog, NULL, _IOFBF, 65536); + setvbuf (lp->txlog, NULL, _IOFBF, 65536); else { free (lp->txlogname); lp->txlogname = NULL; @@ -2384,7 +2384,7 @@ while (*tptr) { if (datagram) { if (listen[0]) { lp->port = (char *)realloc (lp->port, 1 + strlen (listen)); - strcpy(lp->port, listen); /* save port */ + strcpy (lp->port, listen); /* save port */ } else return SCPE_ARG; @@ -2419,7 +2419,7 @@ while (*tptr) { sim_close_logfile (&lp->txlogref); lp->txlog = NULL; lp->txlogname = (char *)realloc (lp->txlogname, 1 + strlen (logfiletmpl)); - strcpy(lp->txlogname, mp->logfiletmpl); + strcpy (lp->txlogname, mp->logfiletmpl); r = sim_open_logfile (lp->txlogname, TRUE, &lp->txlog, &lp->txlogref); if (r == SCPE_OK) setvbuf(lp->txlog, NULL, _IOFBF, 65536); @@ -2467,7 +2467,7 @@ while (*tptr) { if (sim_log) fprintf (sim_log, "Line %d Listening on port %s\n", line, listen); lp->port = (char *)realloc (lp->port, 1 + strlen (listen)); - strcpy(lp->port, listen); /* save port */ + strcpy (lp->port, listen); /* save port */ lp->master = sock; /* save master socket */ if (listennotelnet != mp->notelnet) lp->notelnet = listennotelnet; @@ -2497,7 +2497,7 @@ while (*tptr) { if (datagram) { if (listen[0]) { lp->port = (char *)realloc (lp->port, 1 + strlen (listen)); - strcpy(lp->port, listen); /* save port */ + strcpy (lp->port, listen); /* save port */ } else return SCPE_ARG; From 98ac7af6fa1904e0663417b7baec79461343f627 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 16 Mar 2014 01:11:35 -0700 Subject: [PATCH 5/8] PDP11, VAX: Fix differencing virtual disk corruption during creation problems --- scp.c | 1 + sim_defs.h | 3 +- sim_disk.c | 83 +++++++++++++++++++++++++++++++----------------------- 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/scp.c b/scp.c index 1122e901..734f8533 100644 --- a/scp.c +++ b/scp.c @@ -567,6 +567,7 @@ const struct scp_error { {"STALL", "Console Telnet output stall"}, {"AFAIL", "Assertion failed"}, {"INVREM", "Invalid remote console command"}, + {"NOTATT", "Not attached"}, }; const size_t size_map[] = { sizeof (int8), diff --git a/sim_defs.h b/sim_defs.h index d2cfd5c7..bbcf5373 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -304,8 +304,9 @@ typedef uint32 t_addr; #define SCPE_STALL (SCPE_BASE + 41) /* Telnet conn stall */ #define SCPE_AFAIL (SCPE_BASE + 42) /* assert failed */ #define SCPE_INVREM (SCPE_BASE + 43) /* invalid remote console command */ +#define SCPE_NOTATT (SCPE_BASE + 44) /* not attached */ -#define SCPE_MAX_ERR (SCPE_BASE + 44) /* Maximum SCPE Error Value */ +#define SCPE_MAX_ERR (SCPE_BASE + 45) /* Maximum SCPE Error Value */ #define SCPE_KFLAG 0x1000 /* tti data flag */ #define SCPE_BREAK 0x2000 /* tti break flag */ #define SCPE_NOMESSAGE 0x10000000 /* message display supression flag */ diff --git a/sim_disk.c b/sim_disk.c index 422f9784..9fcb6330 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -1198,7 +1198,7 @@ FILE *fileref; t_bool auto_format; if ((uptr == NULL) || !(uptr->flags & UNIT_ATT)) - return SCPE_IERR; + return SCPE_NOTATT; ctx = (struct disk_context *)uptr->disk_ctx; fileref = uptr->fileref; @@ -1322,7 +1322,7 @@ fprintf (st, " Volume Serial Number is F8DE-510C\n\n"); fprintf (st, " Directory of H:\\Data\n\n"); fprintf (st, " 04/14/2011 12:57 PM 5,120 RA92.vhd\n"); fprintf (st, " 1 File(s) 5,120 bytes\n"); -fprintf (st, " sim> atta rq3 -c RA92-1.vhd RA92.vhd\n"); +fprintf (st, " sim> atta rq3 -d RA92-1-Diff.vhd RA92.vhd\n"); fprintf (st, " sim> atta rq3 -c RA92-1.vhd RA92.vhd\n"); fprintf (st, " RQ3: creating new virtual disk 'RA92-1.vhd'\n"); fprintf (st, " RQ3: Copied 1505MB. 99%% complete.\n"); @@ -3541,6 +3541,7 @@ hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataLength = NtoHl ((uint32)(2*str hVHD->Dynamic.ParentLocatorEntries[4].Reserved = 0; hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); ++LocatorsWritten; +hVHD->Dynamic.TableOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); hVHD->Dynamic.Checksum = NtoHl (CalculateVhdFooterChecksum (&hVHD->Dynamic, sizeof(hVHD->Dynamic))); hVHD->Footer.Checksum = 0; hVHD->Footer.DiskType = NtoHl (VHD_DT_Differencing); @@ -3563,6 +3564,14 @@ if (WriteFilePosition (hVHD->File, Status = errno; goto Cleanup_Return; } +if (WriteFilePosition (hVHD->File, + hVHD->BAT, + BytesPerSector*((NtoHl (hVHD->Dynamic.MaxTableEntries)*sizeof(*hVHD->BAT)+BytesPerSector-1)/BytesPerSector), + NULL, + NtoHll (hVHD->Dynamic.TableOffset))) { + Status = errno; + goto Cleanup_Return; + } if (WriteFilePosition (hVHD->File, &hVHD->Footer, sizeof (hVHD->Footer), @@ -3571,38 +3580,42 @@ if (WriteFilePosition (hVHD->File, Status = errno; goto Cleanup_Return; } -if (WriteFilePosition (hVHD->File, - RelativeParentVHDPath, - BytesPerSector, - NULL, - NtoHll (hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataOffset))) { - Status = errno; - goto Cleanup_Return; - } -if (WriteFilePosition (hVHD->File, - FullParentVHDPath, - BytesPerSector, - NULL, - NtoHll (hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataOffset))) { - Status = errno; - goto Cleanup_Return; - } -if (WriteFilePosition (hVHD->File, - RelativeParentVHDPathUnicode, - BytesPerSector, - NULL, - NtoHll (hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataOffset))) { - Status = errno; - goto Cleanup_Return; - } -if (WriteFilePosition (hVHD->File, - FullParentVHDPathUnicode, - BytesPerSector, - NULL, - NtoHll (hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataOffset))) { - Status = errno; - goto Cleanup_Return; - } +if (hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataLength) + if (WriteFilePosition (hVHD->File, + RelativeParentVHDPath, + BytesPerSector, + NULL, + NtoHll (hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataOffset))) { + Status = errno; + goto Cleanup_Return; + } +if (hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataLength) + if (WriteFilePosition (hVHD->File, + FullParentVHDPath, + BytesPerSector, + NULL, + NtoHll (hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataOffset))) { + Status = errno; + goto Cleanup_Return; + } +if (hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataLength) + if (WriteFilePosition (hVHD->File, + RelativeParentVHDPathUnicode, + BytesPerSector, + NULL, + NtoHll (hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataOffset))) { + Status = errno; + goto Cleanup_Return; + } +if (hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataLength) + if (WriteFilePosition (hVHD->File, + FullParentVHDPathUnicode, + BytesPerSector, + NULL, + NtoHll (hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataOffset))) { + Status = errno; + goto Cleanup_Return; + } Cleanup_Return: free (RelativeParentVHDPath); @@ -3613,7 +3626,7 @@ free (FullVHDPath); sim_vhd_disk_close ((FILE *)hVHD); hVHD = NULL; if (Status) { - if (EEXIST != Status) + if ((EEXIST != Status) && (ENOENT != Status)) remove (szVHDPath); } else { From b2134a01cf1484745987a0dc7fcafd4bdd9f5416 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 16 Mar 2014 08:33:15 -0700 Subject: [PATCH 6/8] PDP11, VAX: Fix failure to create differencing VHDs when the parent VHD is larger than 2GB. --- sim_disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim_disk.c b/sim_disk.c index 9fcb6330..31b55ae4 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -2670,7 +2670,7 @@ if (!File) { goto Return_Cleanup; } if (ModifiedTimeStamp) { - if (stat (szVHDPath, &statb)) { + if (fstat (fileno (File), &statb)) { Return = errno; goto Return_Cleanup; } From 3b1b7d6aaf526080af97190f4e9286435e09a83a Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 17 Mar 2014 08:43:54 -0700 Subject: [PATCH 7/8] PDP11, VAX: Fix VHD Differencing disk parent locator descriptors and removed deprecated descriptor types --- sim_disk.c | 74 +++++++++++++++++------------------------------------- 1 file changed, 23 insertions(+), 51 deletions(-) diff --git a/sim_disk.c b/sim_disk.c index 31b55ae4..4ee7e759 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -3516,32 +3516,22 @@ for (i=0; i < strlen(RelativeParentVHDPath); i++) RelativeParentVHDPathUnicode[i*2] = RelativeParentVHDPath[i]; hVHD->Dynamic.ParentTimeStamp = ParentTimeStamp; memcpy (hVHD->Dynamic.ParentUniqueID, ParentFooter.UniqueID, sizeof (hVHD->Dynamic.ParentUniqueID)); -hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataSpace = NtoHl (BytesPerSector); -hVHD->Dynamic.ParentLocatorEntries[7].Reserved = 0; -hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); -++LocatorsWritten; -memcpy (hVHD->Dynamic.ParentLocatorEntries[6].PlatformCode, "Wi2k", 4); -hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataSpace = NtoHl (BytesPerSector); -hVHD->Dynamic.ParentLocatorEntries[6].Reserved = 0; -hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); +/* There are two potential parent locators on current vhds */ +memcpy (hVHD->Dynamic.ParentLocatorEntries[0].PlatformCode, "W2ku", 4); +hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataSpace = NtoHl (BytesPerSector); +hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataLength = NtoHl ((uint32)(2*strlen(FullParentVHDPath))); +hVHD->Dynamic.ParentLocatorEntries[0].Reserved = 0; +hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); ++LocatorsWritten; if (RelativeMatch) { - memcpy (hVHD->Dynamic.ParentLocatorEntries[7].PlatformCode, "Wi2r", 4); - hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataLength = NtoHl ((uint32)(strlen(RelativeParentVHDPath))); - memcpy (hVHD->Dynamic.ParentLocatorEntries[5].PlatformCode, "W2ru", 4); - hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataSpace = NtoHl (BytesPerSector); - hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataLength = NtoHl ((uint32)(2*strlen(RelativeParentVHDPath))); - hVHD->Dynamic.ParentLocatorEntries[5].Reserved = 0; - hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); + memcpy (hVHD->Dynamic.ParentLocatorEntries[1].PlatformCode, "W2ru", 4); + hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataSpace = NtoHl (BytesPerSector); + hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataLength = NtoHl ((uint32)(2*strlen(RelativeParentVHDPath))); + hVHD->Dynamic.ParentLocatorEntries[1].Reserved = 0; + hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); ++LocatorsWritten; } -memcpy (hVHD->Dynamic.ParentLocatorEntries[4].PlatformCode, "W2ku", 4); -hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataSpace = NtoHl (BytesPerSector); -hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataLength = NtoHl ((uint32)(2*strlen(FullParentVHDPath))); -hVHD->Dynamic.ParentLocatorEntries[4].Reserved = 0; -hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); -++LocatorsWritten; -hVHD->Dynamic.TableOffset = NtoHll (LocatorPosition+LocatorsWritten*BytesPerSector); +hVHD->Dynamic.TableOffset = NtoHll (((LocatorPosition+LocatorsWritten*BytesPerSector + VHD_DATA_BLOCK_ALIGNMENT - 1)/VHD_DATA_BLOCK_ALIGNMENT)*VHD_DATA_BLOCK_ALIGNMENT); hVHD->Dynamic.Checksum = NtoHl (CalculateVhdFooterChecksum (&hVHD->Dynamic, sizeof(hVHD->Dynamic))); hVHD->Footer.Checksum = 0; hVHD->Footer.DiskType = NtoHl (VHD_DT_Differencing); @@ -3580,39 +3570,21 @@ if (WriteFilePosition (hVHD->File, Status = errno; goto Cleanup_Return; } -if (hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataLength) - if (WriteFilePosition (hVHD->File, - RelativeParentVHDPath, - BytesPerSector, - NULL, - NtoHll (hVHD->Dynamic.ParentLocatorEntries[7].PlatformDataOffset))) { - Status = errno; - goto Cleanup_Return; - } -if (hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataLength) - if (WriteFilePosition (hVHD->File, - FullParentVHDPath, - BytesPerSector, - NULL, - NtoHll (hVHD->Dynamic.ParentLocatorEntries[6].PlatformDataOffset))) { - Status = errno; - goto Cleanup_Return; - } -if (hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataLength) - if (WriteFilePosition (hVHD->File, - RelativeParentVHDPathUnicode, - BytesPerSector, - NULL, - NtoHll (hVHD->Dynamic.ParentLocatorEntries[5].PlatformDataOffset))) { - Status = errno; - goto Cleanup_Return; - } -if (hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataLength) +if (hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataLength) if (WriteFilePosition (hVHD->File, FullParentVHDPathUnicode, BytesPerSector, NULL, - NtoHll (hVHD->Dynamic.ParentLocatorEntries[4].PlatformDataOffset))) { + NtoHll (hVHD->Dynamic.ParentLocatorEntries[0].PlatformDataOffset))) { + Status = errno; + goto Cleanup_Return; + } +if (hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataLength) + if (WriteFilePosition (hVHD->File, + RelativeParentVHDPathUnicode, + BytesPerSector, + NULL, + NtoHll (hVHD->Dynamic.ParentLocatorEntries[1].PlatformDataOffset))) { Status = errno; goto Cleanup_Return; } From 090b2f83f287291ec71c1f7196249984f756b8f3 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 17 Mar 2014 08:48:02 -0700 Subject: [PATCH 8/8] PDP10, PDP11, VAX: Avoid corrupting a DMC/DMR unit attach string when a line state transitions --- PDP11/pdp11_dmc.c | 4 +++- sim_tmxr.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/PDP11/pdp11_dmc.c b/PDP11/pdp11_dmc.c index 4ded456d..653ed6b0 100644 --- a/PDP11/pdp11_dmc.c +++ b/PDP11/pdp11_dmc.c @@ -3574,7 +3574,9 @@ uint32 i, j; sim_debug(DBG_TRC, dptr, "dmc_reset(%s)\n", dptr->name); dmc_desc.packet = TRUE; +dmc_desc.buffered = 16384; dmp_desc.packet = TRUE; +dmp_desc.buffered = 16384; /* Connect structures together */ for (i=0; i < DMC_NUMDEVICE; i++) { dmc_csrs[i].sel0 = &dmc_sel0[i]; @@ -3738,7 +3740,7 @@ if (!peer[0]) { fprintf (sim_log, "Peer must be specified before attach\n"); return SCPE_ARG; } -sprintf (attach_string, "Line=%d,Buffered=16384,Connect=%s,%s", dmc, peer, cptr); +sprintf (attach_string, "Line=%d,Connect=%s,%s", dmc, peer, cptr); ans = tmxr_open_master (mp, attach_string); /* open master socket */ if (ans != SCPE_OK) return ans; diff --git a/sim_tmxr.c b/sim_tmxr.c index 4443c1c5..9f34f976 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -1238,13 +1238,6 @@ if ((lp->destination) && (!lp->serport)) { } } tmxr_init_line (lp); /* initialize line state */ -if (lp->mp->uptr) { - /* Revise the unit's connect string to reflect the current attachments */ - lp->mp->uptr->filename = tmxr_mux_attach_string (lp->mp->uptr->filename, lp->mp); - /* No connections or listeners exist, then we're equivalent to being fully detached. We should reflect that */ - if (lp->mp->uptr->filename == NULL) - tmxr_detach (lp->mp, lp->mp->uptr); - } return SCPE_OK; } @@ -2014,7 +2007,7 @@ if (lp->sock) { /* if existing tcp, drop it */ if (close_connecting) { free (lp->destination); lp->destination = NULL; - if (lp->connecting) { /* if existing outgoing tcp, drop it */ + if (lp->connecting) { /* if existing outgoing tcp, drop it */ lp->sock = lp->connecting; lp->connecting = 0; tmxr_reset_ln (lp); @@ -2031,6 +2024,13 @@ if (lp->serport) { /* close current serial connection * lp->destination = NULL; } tmxr_set_line_loopback (lp, FALSE); +if ((lp->mp->uptr) && ((lp->uptr == NULL) || (lp->uptr == lp->mp->uptr))) { + /* Revise the unit's connect string to reflect the current attachments */ + lp->mp->uptr->filename = tmxr_mux_attach_string (lp->mp->uptr->filename, lp->mp); + /* No connections or listeners exist, then we're equivalent to being fully detached. We should reflect that */ + if (lp->mp->uptr->filename == NULL) + tmxr_detach (lp->mp, lp->mp->uptr); + } } t_stat tmxr_detach_ln (TMLN *lp)