.SETT FILE ;	COPY PACKS USING DSC AND BAD
.SETT CREATED ;		24-MAY-78	STAN ROSE
.;
.ENABLE SUBSTITUTION
.ENABLE GLOBAL
.;
.SETS DSKTYP <SYDISK>
.;
@[1,2]SYSID
.;
.OPEN TI:COMMENT.FIL
.ENABLE DATA
*********************************************************************
*
* THIS BATCH FILE COPIES DISK PACKS USING DSC 
* IT WILL FIRST RUN "BAD" ON THE PACK TO CREATE THE BAD BLOCK FILE
*
* MAKE SURE THE "FROM" DISK IS WRITE-PROTECTED AND THE "TO" DISK IS NOT
*
*	RUN ON THE '$SYSID' MACHINE AT '<DATE>' '<TIME>'
*
*********************************************************************
;
.DISABLE DATA
.;
	.ENABLE QUIET
;
.SETF IBAD
.IFINS BAD .SETT IBAD
.IFNINS PSE INS $PSE
.IFNINS INI INS $INI
.IFF IBAD INS $BAD/INC=4000.
.SETF IDSC
.IFINS ...DSC .SETT IDSC
.IFF IDSC INS $DSC
.DISABLE QUIET
.MORE:
.ENABLE QUIET
	SET /UIC=[1,6]
	PIP ERROR.SAV/PU:15/NM
	PIP ERROR.SAV/RE/NV/NM=ERROR.SYS
	PIP ERROR.OLD;*/RE/NV/NM=ERROR.TMP;*
	PIP ERROR.OLD/PU:10/NM
	SET /UIC=[1,7]
.DISABLE QUIET
.ASK QU ARE THE PACKS READY
.IFF QU .GOTO MORE
.REASK:
.ASKN [0:17] DUNIT WHAT IS THE UNIT NUMBER OF THE "FROM" DRIVE
.SETN OK 0
.GOSUB ONLIN
.IF OK EQ 0 .GOTO REASK
.SETN DRIVEF DUNIT
.TOASK:
.ASKN [0:17] DUNIT WHAT IS THE UNIT NUMBER OF THE "TO" DRIVE
.SETN OK 1
.GOSUB ONLIN
.IF OK EQ 0 .GOTO TOASK
.SETN DRIVET DUNIT
.IF DRIVEF NE DRIVET .GOTO NOTSAM
.ENABLE DATA
*
****************************************************************
*
*	DRIVES MUST BE DIFFERENT
*
****************************************************************
.DISABLE DATA
.RETRY:
	DMO 'DSKTYP''DRIVEF':/DEV/LOCK=V
	DMO 'DSKTYP''DRIVET':/DEV/LOCK=V
	DEA 'DSKTYP''DRIVEF':
	DEA 'DSKTYP''DRIVET':
	SET /PUB='DSKTYP''DRIVET':
	SET /PUB='DSKTYP''DRIVEF':
.GOTO REASK
.NOTSAM:
.IF DRIVEF <> <SYUNIT> .GOTO FNOTSY
.ENABLE DATA
*
****************************************************************
*
*	'DSKTYP''<SYUNIT>' IS THE SYSTEM DISK, IF YOU WISH TO COPY IT
*	YOU MUST EITHER BOOT FROM A DIFFERENT DRIVE OR RUN THE STAND-ALONE DSC
*
****************************************************************
*
.DISABLE DATA
.GOTO RETRY
.FNOTSY:
.IF DRIVET <> <SYUNIT> .GOTO ONWARD
.ENABLE DATA
*
****************************************************************
*
*	YOU CANNOT COPY ONTO 'DSKTYP''<SYUNIT>', IT IS THE SYSTEM DISK
*
****************************************************************
*
.DISABLE DATA
.GOTO RETRY
.ONWARD:
.ASK QU DID YOU ANSWER CORRECTLY
.IFF QU .GOTO REASK
.ASK FORMAT DO YOU NEED TO FORMAT 'DSKTYP''DRIVET':
.SETT BADIT
.IFF FORMAT .ASK BADIT DO YOU NEED TO BAD 'DSKTYP''DRIVET':
.IFF FORMAT .GOTO DONFMT
.SETS DR "DR"
.SETS DM "DM"
;		__________________________ START FORMATTING 'DSKTYP''DRIVET'
.SETS FUNC "FORMAT"
	TIM
.IF DSKTYP = DR   FMT 'DSKTYP''DRIVET':/VE/WLT=123456
.IF DSKTYP = DM   FMT 'DSKTYP''DRIVET':/VE/WLT=123456
.IF DSKTYP <> DR .AND .IF  DSKTYP <> DM  FMT 'DSKTYP''DRIVET':/VE
	.IF <EXSTAT> NE 1 .GOTO XFAIL
.;
.DONFMT:
	.IFF BADIT .GOTO DONBAD
;		__________________________ START BADDING 'DSKTYP''DRIVET'
	TIM
	BAD 'DSKTYP''DRIVET':/LI
.IF <EXSTAT> EQ 1 .GOTO BAD3
	.SETS FUNC "BAD"
.XFAIL:
;***********************************************************************
;	'FUNC' FAILURE	'FUNC' FAILURE	'FUNC' FAILURE
;
;	RETRY ON ANOTHER DISK DRIVE, ELSE REMOVE PACK FROM SERVICE
;***********************************************************************
	.GOTO RETRY

.BAD3:
	TIM
;
.ENABLE QUIET
	ERF
	.WAIT ERRLOG
	PIP ERROR.OLD/RE/NV/NM=ERROR.TMP
	RUN ERRLOG
.DISABLE QUIET
	INI 'DSKTYP''DRIVET':BADDED/BAD=[AUTO]
.;
.DONBAD:
;
;		_______________ COPY 'DSKTYP''DRIVEF' TO 'DSKTYP''DRIVET'
TIM
DSC 'DSKTYP''DRIVET':='DSKTYP''DRIVEF':
.SETN DSCSTA <EXSTAT>
TIM
.IF DSCSTA EQ 1 .GOTO CHKERR
.IF DSCSTA EQ 0 .GOTO WARN
;************************************************************
;************************************************************
;	FATAL DSC FAILURE
;
;	SHOW TO SHIFT SUPERVISOR AND PUT FRONT COPY OF
;		CONSOLE SHEET ASIDE FOR DPG
;
;************************************************************
;************************************************************
	INI 'DSKTYP''DRIVET':BADDED/INF=5
.GOTO CHKER1
.WARN:
;************************************************************
;	WARNING		WARNING		WARNING
;
;	COPY MAY NOT HAVE SUCCEEDED, CHECK THE ERROR
;		MESSAGES FROM DSC ABOVE AND CHECK
;		WITH SHIFT SUPERVISOR
;
;************************************************************
.;		PICK UP ERROR LOG COUNT FROM COPY VIA ERRCHK EXIT STATUS
.CHKERR:
RUN [2,1]ERRCHK
.SETN NUMERR <EXSTAT>
.IF NUMERR EQ 0 .GOTO NXT
.CHKER1:
;		___________________PLEASE WAIT FOR ERROR SUMMARY
	SET /UIC=[1,6]
	PSE =
	RUN [2,1]ERRSUM
	.IF <EXSTAT> EQ 1	SYE TI:=/SU
	SET /UIC=[1,7]
.NXT:
	DMO 'DSKTYP''DRIVET':/DEV/LOCK=V
	DMO 'DSKTYP''DRIVEF':/DEV/LOCK=V
DEA 'DSKTYP''DRIVEF':
DEA 'DSKTYP''DRIVET':
;
.ASK QU IS THERE MORE TO COPY
.IFT QU .GOTO MORE
ERF
.IFF IBAD REM ...BAD
.IFF IDSC REM ...DSC
.WAIT ERRLOG
RUN ERRLOG
.GOTO END
.;	SUBROUTINE TO BRING ONLINE AND MOUNT DISK DSKTYP DUNIT
.;
.ONLIN:
	SET /NOPUB='DSKTYP''DUNIT':
.IF <EXSTAT> EQ 1 .GOTO 4
	DMO 'DSKTYP''DUNIT':/DEV/LOCK=V
.IF <EXSTAT> EQ 1 .GOTO ONLIN
.4:
	CON OFFLINE 'DSKTYP''DUNIT':
	CON ONLINE 'DSKTYP''DUNIT':
	MOU 'DSKTYP''DUNIT':/OVR/VI
.IF <EXSTAT> NE 1 .GOTO 6
	DMO 'DSKTYP''DUNIT':/LOCK=V/DEV
.ASK Q DOES THE PACK ON 'DSKTYP''DUNIT' HAVE THE EXPECTED LABEL
.IFF Q .GOTO 5
.7:
	.SETN OK 0
	ALL 'DSKTYP''DUNIT':
	MOU 'DSKTYP''DUNIT':/FOR
	.IF <EXSTAT> EQ 1 .GOTO GOOD
.6:
;****************************************************
;	MOUNT FAILURE FOR 'DSKTYP''DUNIT':
;		TRY ANOTHER DRIVE
;****************************************************
	.IF OK EQ 0 .GOTO 5
;***		IF 'DSKTYP''DUNIT': IS A BRAND NEW PACK
;***		THEN A "HOME BLOCK READ ERROR" IS OKAY AT THIS POINT
;
.ASK Q IS 'DSKTYP''DUNIT': A BRAND NEW PACK ?
.IFT Q .GOTO 7
.5:
	DEA 'DSKTYP''DUNIT':
	SET /PUB='DSKTYP''DUNIT':
	.SETN OK 0
	.RETURN
.GOOD:	.SETN OK 1
	.RETURN
.END:	/
