[Simh] attaching a tape virtual file without stopping simulation - a solution!

Boucher, François boucher.francois at uqam.ca
Mon Feb 4 10:30:17 EST 2008


Hi to all.

First, thanks to everybody who gave me suggestions and advice about this question on the forum.

I would now like to share with the community a solution that I developed.
But first, a little warning: this is a little modification that is not perfect.   - It only renames the metatape File "tape.tap" to tapeYY_MM_DD_HH:MM:SS.tap each time the sim wants to detach (usually by an
unmount command issued by VMS if you are on the vax simulator).
It then automatically reattach itself to a new (empty!) TAPE.TAP file.
In the .ini file, an attach tq0 tape.tap 
needs to be present to activate this feature from boot, or it can be 
activated by manually issuing attach tq# tape.tap where # is in 0 - 3 range.
This auto attach feature will reattach itself to the same simulated tape
Drive device where tape.tap is initially attached.

The goal is to have the simulator always ready to write backups to a "virgin" tape, for automated backups.  In this solution, the virgin tape
is always named tape.tap and after unmount, it gets renamed with the 
actual date and hour, to make sure it does not get overwritten.
The tape type can be set to any simh supported type (TK50, TK70, TKUSER).

This is a cut and paste of it's effect, at the simh console level:

vax at Knoppix:/mnt/sda2/vax/simh/BIN$ ls
vax
vax at Knoppix:/mnt/sda2/vax/simh/BIN$ ./vax

VAX simulator V3.7-3
sim> sh tq
TQ, TK50 (94MB), address=20001940-20001943, no vector, 4 units
  TQ0, not attached, write enabled, SIMH format
  TQ1, not attached, write enabled, SIMH format
  TQ2, not attached, write enabled, SIMH format
  TQ3, not attached, write enabled, SIMH format
sim> attach tq0 tape.tap
TQ: creating new file
sim> sh tq
TQ, TK50 (94MB), address=20001940-20001943, no vector, 4 units
  TQ0, attached to tape.tap, write enabled, SIMH format
  TQ1, not attached, write enabled, SIMH format
  TQ2, not attached, write enabled, SIMH format
  TQ3, not attached, write enabled, SIMH format
sim> detach tq0
Metatape file successfully renamed tape8_2_4_9:37:52.tap
TQ: creating new file
sim> sh tq
TQ, TK50 (94MB), address=20001940-20001943, no vector, 4 units
  TQ0, attached to tape.tap, write enabled, SIMH format
  TQ1, not attached, write enabled, SIMH format
  TQ2, not attached, write enabled, SIMH format
  TQ3, not attached, write enabled, SIMH format
sim> exit
Goodbye
vax at Knoppix:/mnt/sda2/vax/simh/BIN$ ls
tape.tap  tape8_2_4_9:37:52.tap  vax


The only file that was modified is scp.c in the simh root directory.

I will now cut & paste the diff between my version of scp.c and the standard released version:

diff scp.c ../simhv373/scp.c
175d174
< #include <time.h>                /* FB */
240,241d238
< time_t t;  /* FB */
< struct tm stm;    /* FB */
1845c1842
< char gbuf[CBUFSIZE],tapefile[63],attdtapfil[63];
---
> char gbuf[CBUFSIZE];
1848d1844
< int code=5;
1858,1872c1854
< if (!strcmp(uptr->filename,"tape.tap")) {          /* autoattach tape?*/
<    sprintf(attdtapfil,"%s", uptr->filename);       /* yes, get filename */
<    time(&t);                                       /* gets epoch time */
<    localtime_r(&t,&stm);                           /* go broken time */
<    sprintf(tapefile,"tape%d_%d_%d_%d:%d:%d.tap",stm.tm_year-100\
<    ,stm.tm_mon+1,stm.tm_mday,stm.tm_hour,stm.tm_min,stm.tm_sec); /* new name */
<    scp_detach_unit (dptr, uptr);         /* normal detach */
<    code=rename(attdtapfil,tapefile);     /* rename tape.tap to new name */
<    if (code==0){                         /* rename ok? */
<       printf("Metatape file successfully renamed %s\n",tapefile);
<       scp_attach_unit (dptr, uptr, "tape.tap");
<       return(0);
<    }   
< }
< else return scp_detach_unit (dptr, uptr); /* normally detach if not tape.tap *
/
---
> return scp_detach_unit (dptr, uptr);                    /* detach */

Best regards,

Francois Boucher ing.



More information about the Simh mailing list