SCP: Added simulator version checking while performing a RESTORE operation.

Added -Q switch to suppress version check messages
Added -D switch to disable the detach_all at the beginning of a restore and any actual attach operations during the restore
This commit is contained in:
Mark Pizzolato 2015-04-17 14:43:52 -07:00
parent 8204a203a1
commit 04142da99c
2 changed files with 21 additions and 6 deletions

Binary file not shown.

27
scp.c
View file

@ -759,7 +759,13 @@ static const char simh_help[] =
" The RESTORE command (abbreviation REST, alternately GET) restores a\n" " The RESTORE command (abbreviation REST, alternately GET) restores a\n"
" previously saved simulator state:\n\n" " previously saved simulator state:\n\n"
"++RESTORE <filename>\n" "++RESTORE <filename>\n"
"3Notes:\n" "4Switches\n"
" Switches can influence the output and behavior of the RESTORE command\n\n"
"++-Q Suppresses version warning messages\n"
"++-D Suppress detaching and attaching devices during a restore\n"
"++-F Overrides the related file timestamp validation check\n"
"\n"
"4Notes:\n"
" 1) SAVE file format compresses zeroes to minimize file size.\n" " 1) SAVE file format compresses zeroes to minimize file size.\n"
" 2) The simulator can't restore active incoming telnet sessions to\n" " 2) The simulator can't restore active incoming telnet sessions to\n"
" multiplexer devices, but the listening ports will be restored across a\n" " multiplexer devices, but the listening ports will be restored across a\n"
@ -5565,8 +5571,11 @@ DEVICE *dptr;
UNIT *uptr; UNIT *uptr;
REG *rptr; REG *rptr;
struct stat rstat; struct stat rstat;
t_bool force_restore = sim_switches & SWMASK ('F'); t_bool force_restore = ((sim_switches & SWMASK ('F')) != 0);
t_bool dont_detach_attach = ((sim_switches & SWMASK ('D')) != 0);
t_bool suppress_warning = ((sim_switches & SWMASK ('Q')) != 0);
sim_switches &= ~(SWMASK ('F') | SWMASK ('D') | SWMASK ('Q')); /* remove digested switches */
#define READ_S(xx) if (read_line ((xx), sizeof(xx), rfile) == NULL) \ #define READ_S(xx) if (read_line ((xx), sizeof(xx), rfile) == NULL) \
return SCPE_IOERR; return SCPE_IOERR;
#define READ_I(xx) if (sim_fread (&xx, sizeof (xx), 1, rfile) == 0) \ #define READ_I(xx) if (sim_fread (&xx, sizeof (xx), 1, rfile) == 0) \
@ -5585,6 +5594,10 @@ else if (strcmp (buf, save_ver30) != 0) { /* version 3.0? */
sim_printf ("Invalid file version: %s\n", buf); sim_printf ("Invalid file version: %s\n", buf);
return SCPE_INCOMP; return SCPE_INCOMP;
} }
if ((strcmp (buf, save_ver40) != 0) && (!sim_quiet) && (!suppress_warning)) {
sim_printf ("warning - attempting to restore a saved simulator image in %s image format.\n", buf);
sim_printf ("restore with the -Q switch to suppress this warning message\n");
}
READ_S (buf); /* read sim name */ READ_S (buf); /* read sim name */
if (strcmp (buf, sim_savename)) { /* name match? */ if (strcmp (buf, sim_savename)) { /* name match? */
sim_printf ("Wrong system type: %s\n", buf); sim_printf ("Wrong system type: %s\n", buf);
@ -5615,14 +5628,16 @@ if (v40) {
#define S_xstr(a) S_str(a) #define S_xstr(a) S_str(a)
#define S_str(a) #a #define S_str(a) #a
if ((memcmp (buf, "git commit id: " S_xstr(SIM_GIT_COMMIT_ID), 23)) && if ((memcmp (buf, "git commit id: " S_xstr(SIM_GIT_COMMIT_ID), 23)) &&
(!sim_quiet)) { (!sim_quiet) && (!suppress_warning)) {
sim_printf ("warning - different simulator git versions.\nSaved commit id: %8.8s, Running commit id: %8.8s", buf + 15, S_xstr(SIM_GIT_COMMIT_ID)); sim_printf ("warning - different simulator git versions.\nSaved commit id: %8.8s, Running commit id: %8.8s\n", buf + 15, S_xstr(SIM_GIT_COMMIT_ID));
sim_printf ("restore with the -Q switch to suppress this warning message\n");
} }
#undef S_str #undef S_str
#undef S_xstr #undef S_xstr
#endif #endif
} }
detach_all (0, 0); /* Detach everything to start from a consistent state */ if (!dont_detach_attach)
detach_all (0, 0); /* Detach everything to start from a consistent state */
for ( ;; ) { /* device loop */ for ( ;; ) { /* device loop */
READ_S (buf); /* read device name */ READ_S (buf); /* read device name */
if (buf[0] == 0) /* last? */ if (buf[0] == 0) /* last? */
@ -5778,7 +5793,7 @@ for ( ;; ) { /* device loop */
units which were originally attached. Some of these attach operations units which were originally attached. Some of these attach operations
may depend on the state of the device (in registers) to work correctly */ may depend on the state of the device (in registers) to work correctly */
for (j=0, r = SCPE_OK; j<attcnt; j++) { for (j=0, r = SCPE_OK; j<attcnt; j++) {
if (r == SCPE_OK) { if ((r == SCPE_OK) && (!dont_detach_attach)) {
struct stat fstat; struct stat fstat;
t_addr saved_pos; t_addr saved_pos;