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

Edward Berry eaberry1 at pacbell.net
Mon Feb 4 13:41:21 EST 2008


That is useful!
I wonder if it would be possible to just copy the tape image file
without de-ttaching?
Say on sunday at 3AM the vax does backup
   backup/rewind . . .
   dismount/nounload . .
Then at 4AM a cron job on the host does:
   cp -p tape.tpe back${date}.tpe

or even:
   mv tape.tpe back${date}.tpe
   touch tape.tpe

The latter would have the advantage of starting with an empty tape
each time where the former would overwrite the previous tape and
if size of the images never decreases, all backups would be the
size of the largest.
The latter would only work if the tape image is reopened by filename
each time it is mounted; not if it is opened once when attached, and
referred to by file handle thereafter?
(easy enough to test, anyway)

(I'm using an older version of the simulator, and the auto-attach
seems to work only at boot time; if I dismount without /nounload
the next time I try to use the tape there is a repeating message
on the conslole requesting the operator to mount the tape; exactly
like a real vax. I don't always have access to the console and I
have vax.ini set to write out nvram and shut down cold upon exit
to the emulator so I can shutdown remotely if the linux has to
be rebooted.)

Ed

Boucher wrote:
> 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.
> _______________________________________________
> Simh mailing list
> Simh at trailing-edge.com
> http://mailman.trailing-edge.com/mailman/listinfo/simh
> 




More information about the Simh mailing list