Trailing-Edge
-
PDP-10 Archives
-
integ_tools_tops20_v7_30-apr-86_dumper
-
tools/comten1/tmountnew.com
There are 3 other files named tmountnew.com in the archive. Click here to see a list.
$ verify = F$VERIFY("NO")
$! TMOUNT.COM - A procedure to ALLOCATE and MOUNT a tape drive.
$! -- From the Research VAX. Modified: Jul-82/RT, 13-Aug-82/SLP
$! Last edit: 11-Jan-83/SLP
$! -- Now it's back on the RVAX again. 30-Mar-83/SLP.
$! 26-Jul-84/SLP. Add initialize_flag (intended for batch jobs).
$! 7-Aug-84/SLP. Better security for initialize_flag. First 4
$! letters must be INIT for it to be obeyed.
$!
$! Format: (HELP TMOUNT for more info)
$!
$! @TMOUNT [vol_label [format [write_status [density [initialize_flag]]]]]
$!
$! where the five parameters are optional. If you don't specify them,
$! you are prompted to provide them. (Also prompted if you give an
$! invalid parameter). All parameters, except vol_label and density,
$! can be abbreviated to a single letter.
$!
$ vol_label = P1
$! Volume label (reelid) - not validated, except to be sure you
$! give one, and that it is 1-6 characters long.
$!
$! You may include optional optional comments along with the
$! volume label. Add a "/" and the comment to the volume label.
$! If the comment includes spaces, enclose the entire parameter in
$! quotation marks.
$!
$ format = P2
$! The type of tape you have. ANSI, FOREIGN, or DEC-10_BACKUP
$! A, F, and D are valid abbreviations.
$! A = ANSI (standard VAX tape with ANSI labels)
$! F = FOREIGN (tape is mounted /FOREIGN)
$! D = DEC-10 BACKUP tape.
$!
$! A and F tapes are assigned a logical name of "TAPE".
$! D tapes are assigned a logical name of "DUMPER". For D tapes,
$! write_status is set to write locked and density is set to 800 BPI.
$!
$ write_status = P3
$! Is the tape to be mounted WRITE ENABLED?
$! Valid choices are YES and WRITE (Y or W) for write enable,
$! NO and NOWRITE (N) for write-lock.
$!
$ density = P4
$! BPI recording density. Valid choices are 800 and 1600.
$! Only required for write-enabled tapes.
$! 800 = 800 BPI
$! 1600 = 1600 BPI
$!
$ initialize_flag = P5
$! If the first four letters are INIT (in caps) then, skip the
$! "Does the tape need to be initialized?" prompt
$! and initialize the tape (if mounted ANSI and WRITE-ENABLED). This
$! provides a way for batch jobs to initialize a tape.
$!
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT -
"TMOUNT procedure - allocates a tape drive and mounts a tape on it."
$ WRITE SYS$OUTPUT " "
$!********************* Is a tape drive available? *********************
$ top:
$ IF F$LOGICAL("sys$mag1") .NES. "" THEN -
DEASSIGN sys$mag1
$ WRITE SYS$OUTPUT "$ ALLOCATE mt"
$ ON WARNING THEN GOTO nodrives
$ ALLOCATE mt sys$mag1
$ SET NOON !cancel trap
$ ON CONTROL_Y THEN GOTO abend
$ tape_drive = F$LOGICAL("sys$mag1")
$ DEASSIGN sys$mag1 ! Don't need this logical name anymore
$!
$!********************* Get volume label *******************************
$ get_vol_label:
$ IF vol_label .NES. "" THEN GOTO get_vol_label_1a
$ WRITE SYS$OUTPUT " "
$ get_vol_label_1:
$ INQUIRE/NOPUNCTUATION vol_label -
"What is the volume label (reel id) of the tape to mount? "
$ get_vol_label_1a:
$ ! Separate volume label and mount qualifiers.
$ i = F$LOCATE("/", vol_label)
$ mount_qualifiers = F$EXTRACT(i+1, F$LENGTH(vol_label)-i-1, vol_label)
$ vol_label = F$EXTRACT(0, i, vol_label)
$
$ IF vol_label .EQS. "" THEN GOTO get_vol_label_1
$ IF F$LENGTH(vol_label) .LE. 6 THEN GOTO get_vol_label_2
$ WRITE SYS$OUTPUT "%The volume label must not exceed 6 characters!"
$ GOTO get_vol_label_1
$ get_vol_label_2:
$ IF F$LOCATE(" ",vol_label) .EQ. F$LENGTH(vol_label) THEN GOTO get_format
$ WRITE SYS$OUTPUT -
"%The volume label must not contain an embedded space or tab!"
$ GOTO get_vol_label_1
$!
$!********************* Get tape format ********************************
$ get_format:
$ IF format .NES. "" THEN GOTO get_format_2
$ get_format_1:
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT -
"Are you mounting an ANSI (VAX), FOREIGN (unlabelled),"
$ INQUIRE format "or DEC-10 BACKUP format tape? (A, F, D) [A]"
$ IF format .EQS. "" THEN format = "A"
$ get_format_2:
$ IF F$LENGTH(format) .GT. 1 THEN format = F$EXTRACT(0,1,format)
$ IF (format .NES. "A") .AND. (format .NES. "F") .AND. -
(format .NES. "D") THEN -
GOTO get_format_1
$ IF format .NES. "D" THEN GOTO get_write_status
$ write_status = "LOCKED" ! We know the rest for
$ density = 800 ! for BACKUP tapes
$ init = "N"
$ GOTO mount
$!
$!********************* Get write status *******************************
$ get_write_status:
$ IF write_status .NES. "" THEN GOTO get_write_status_2
$ WRITE SYS$OUTPUT " "
$ get_write_status_1:
$ INQUIRE write_status -
"Do you want your tape WRITE ENABLED? (Y/W, N) [N]"
IF write_status .EQS. "" THEN write_status = "N"
$ get_write_status_2:
$ IF F$LENGTH(write_status) .GT. 1 THEN -
write_status = F$EXTRACT(0,1,write_status)
$ IF (write_status .NES. "Y") .AND. (write_status .NES. "N") .AND. -
(write_status .NES. "W") THEN -
GOTO get_write_status_1
$ IF write_status .EQS. "Y" THEN write_status = "ENABLED"
$ IF write_status .EQS. "W" THEN write_status = "ENABLED"
$ IF write_status .EQS. "N" THEN write_status = "LOCKED"
$!
$!********************* Get tape density *******************************
$ get_density:
$ IF density .NES. "" THEN GOTO get_density_2
$ IF write_status .EQS. "LOCKED" THEN GOTO get_density_exit
$ WRITE SYS$OUTPUT " "
$ get_density_1:
$ INQUIRE density "Your tape's BPI density (800, 1600) [1600]"
$ IF density .EQS. "" THEN density = 1600
$ get_density_2:
$ IF (density .NE. 800) .AND. (density .NE. 1600) THEN -
GOTO get_density_1
$ get_density_exit:
$!
$!********************* Initialize the tape? ***************************
$ initialize_check:
$ init = "N"
$ IF (write_status .EQS. "LOCKED") .OR. (format .NES. "A") THEN -
GOTO mount
$ IF F$LENGTH(initialize_flag) .GT. 4 THEN initialize_flag = F$EXTRACT(0,4,initialize_flag)
$ IF initialize_flag .NES. "INIT" THEN GOTO initialize_check0
$ init = "Y"
$ GOTO initialize
$ initialize_check0:
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT -
"Does this tape need to be initialized? (probably not!)"
$ WRITE SYS$OUTPUT -
"In general, you only need to initialize a tape if it's blank."
$ initialize_check1:
$ INQUIRE init "Initialize? (Y, N) [N]"
$ IF init .EQS. "" THEN init = "N"
$ IF F$LENGTH(init) .GT. 1 THEN init = F$EXTRACT(0,1,init)
$ IF init .EQS. "N" THEN GOTO mount
$ IF init .NES. "Y" THEN GOTO initialize_check1
$ WRITE SYS$OUTPUT -
"WARNING: Initialization will effectively ERASE your tape!"
$ initialize_check2:
$ INQUIRE init -
"Confirm: Do you REALLY want this tape initialized? (Y, N) [N]"
$ IF F$LENGTH(init) .GT. 1 THEN init = F$EXTRACT(0,1,init)
$ initialize_check3:
$ IF init .EQS. "" THEN init = "N"
$ IF init .EQS. "N" THEN GOTO mount
$ IF init .NES. "Y" THEN GOTO initialize_check2
$!
$! Easy way to initialize the tape is to mount it /FOREIGN (since MOUNT
$! automatically cancels the operator request when the tape is mounted,
$! REQUEST/REPLY requires operator response). Of course, this means the tape
$! is mounted when we don't want it to be, so we just DISMOUNT/NOUNLOAD.
$ initialize:
$ orig_format = format
$ format = "F"
$ WRITE SYS$OUTPUT "*************************************************"
$ WRITE SYS$OUTPUT "* Notice: your tape will be mounted twice. *"
$ WRITE SYS$OUTPUT "* Don't let this confuse (or alarm) you! *"
$ WRITE SYS$OUTPUT "* The first mount is to initialize your tape. *"
$ WRITE SYS$OUTPUT "* The second mount is to ready it for use. *"
$ WRITE SYS$OUTPUT "*************************************************"
$!
$!********************* Logical tape mount *****************************
$ mount:
$ command = "MOUNT"
$ IF density .NE. 0 THEN command = command + "/DENSITY=''density'"
$! IF write_status .EQS. "LOCKED" THEN command = command + "/NOWRITE"
$ IF format .NES. "A" THEN command = command + "/FOREIGN"
$ command = command + " ''tape_drive' ''vol_label' "
$ IF format .NES. "D" THEN command = command + "TAPE"
$ IF format .EQS. "D" THEN command = command + "DUMPER"
$ command = command + "/COMMENT=""WRITE-''write_status'"
$! IF density .NE. 0 THEN command = command + " at ''density' BPI"
$ IF F$LENGTH(mount_qualifiers) .GT. 0 THEN -
command = command + ". " + mount_qualifiers
$ command = command + """"
$! command = command + "for user ''F$GETJPI("","USERNAME")'"""
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "$ ", command
$ ON CONTROL_Y THEN GOTO abend
$ ON WARNING THEN GOTO oper_aborted
$! REQUEST/TO=TAPES "%Please insure ''tape_drive' in unloaded and off-line"
$ 'command'
$ SET NOON !Cancel traps
$ ON CONTROL_Y THEN GOTO mount_abort
$!
$!********************* Did operator mount the tape right? *************
$ check_write_status:
$!
$! By default, the tape has been mounted software write enabled
$! (/WRITE). After the mount, the software write status will
$! reflect the hardware write status (ie, whether there is a write
$! ring in the tape or not). So we compare the software write status
$! with the requested write_status to see if the tape was mounted
$! correctly (with reguard to write-enabled/locked status).
$!
$ IF F$GETDVI(tape_drive,"SWL") THEN GOTO write_lock_check
$!write_enable_check:
$ IF write_status .EQS. "ENABLED" THEN GOTO initialize_check4
$ GOTO incorrectly_mounted
$ write_lock_check:
$ IF write_status .EQS. "LOCKED" THEN GOTO initialize_check4
$ incorrectly_mounted:
$ command = "REQUEST/TO=TAPES "">>>>> Tape ''vol_label' on " + -
"''tape_drive' is supposed to be /WRITE-''write_status'!!"
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "$ ", command
$ 'command'
$ command = "DISMOUNT ''tape_drive'"
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "$ ", command
$ 'command'
$ GOTO mount
$!
$!********************* Need to dismount/initialize/remount? *********
$ initialize_check4:
$ IF init .EQS. "N" THEN GOTO complimentary_message
$ WRITE SYS$OUTPUT " "
$ command = "DISMOUNT/NOUNLOAD ''tape_drive'"
$ WRITE SYS$OUTPUT "$ ", command
$ 'command'
$ command = "INITIALIZE/DENSITY=''density' ''tape_drive' ''vol_label'"
$ WRITE SYS$OUTPUT "$ ", command
$ 'command'
$ format = orig_format
$ init = "N"
$ GOTO mount
$!
$!********************* Complimentary Message ************************
$ complimentary_message:
$ !
$ ! First double check the volume name (useful when ANSI mounted FOREIGN)
$ !
$ vol_name = F$GETDVI(tape_drive,"VOLNAM")
$ IF vol_name .EQS. "" THEN GOTO messages_2
$ IF vol_name .EQS. vol_label THEN GOTO messages_2
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "%WARNING - The ACTUAL volume label on this tape is '",-
vol_name, "'"
$ messages_2:
$ WRITE SYS$OUTPUT " "
$ GOTO format'format'
$ formatA:
$ WRITE SYS$OUTPUT -
"You may use the COPY command to transfer files between this VAX format"
$ GOTO end_msg
$ formatF:
$ WRITE SYS$OUTPUT -
"You may use the TAPECOPY utility to transfer files between this foreign-label"
$ end_msg:
$ WRITE SYS$OUTPUT "tape and your disk area."
GOTO end
$ formatD:
$ WRITE SYS$OUTPUT -
"You may use the DUMPER utility to transfer files on this DEC-10 BACKUP"
$ WRITE SYS$OUTPUT "tape to your disk area."
$ end:
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "When you finish using your tape,"
$ WRITE SYS$OUTPUT "please type the TDISMOUNT command to dismount it."
$ GOTO exit
$!
$!********************* Error Handling *******************************
$ nodrives:
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "%All tape drives are in use. Please try again later."
$ IF F$MODE() .EQS. "INTERACTIVE" THEN GOTO exit
$ WAIT 00:10
$ GOTO top
$ mount_abort:
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "%TMOUNT aborted after mounting your tape, dismounting it..."
$ WRITE SYS$OUTPUT "$ DISMOUNT ''tape_drive'"
$ DISMOUNT 'tape_drive'
$ GOTO abend
$ oper_aborted:
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "%Tape mount request could not be completed."
$ abend:
$ WRITE SYS$OUTPUT " "
$ WRITE SYS$OUTPUT "%TMOUNT aborted. Deallocating your tape drive..."
$ WRITE SYS$OUTPUT "$ DEALLOCATE ''tape_drive'"
$ DEALLOCATE 'tape_drive'
$!
$!********************* Exit *******************************************
$ exit:
$ WRITE SYS$OUTPUT " "
$ IF verify THEN SET VERIFY
$ EXIT