Trailing-Edge
-
PDP-10 Archives
-
decuslib20-07
-
decus/20-0162/kill.mac
There are 6 other files named kill.mac in the archive. Click here to see a list.
;Program to selectively kill directories by a wildcard specification.
;Written by Joshua Brodsky 6/23/81 for UDC.
TITLE KILL - Kill directories
SEARCH MONSYM,MACSYM,JOSH
;Program version and edit history.
PRGVER==4 ;Version 4 (For TOPS release).
PRGCST==0 ;Written by non-DEC personnel.
PRGEDT==3 ;Edit version 3.
PRGMIN==1 ;Minor edit version.
%%LVER==:<PRGCST>B20+<PRGVER>B29+PRGMIN
%%RVER==:PRGEDT
;Major edit numbers:
;Version 1: Created 6/23/81 by Joshua Brodsky
;Version 2: Revised 11/25/81 by Joshua.
;Version 3: Added TEST feature; AC3 no longer clobbered by RESERR.
; Edit 12/23/81 by Joshua Brodsky.
;Version 3A:Fix return from RESERR to KILL11. 12/23/81 Joshua.
;Current version: 4(3). Last edit by JOSHUA.
;Entry vector.
ENVCT: JRST START
JRST BEGIN
%%LVER,,%%RVER
ENLEN==.-ENVCT
;MACRO definitions (some others in JOSH and MACSYM).
DEFINE PARSE <COMND
TXNE 1,CM%NOP
JRST REP>
DEFINE NOISE (WORD$),<MOVEI 2,[FLDDB.(.CMNOI,,<POINT 7,[ASCIZ/WORD$/]>)]
PARSE>
DEFINE CONFRM, <MOVEI 2,[FLDDB.(.CMCFM)]
PARSE>
;AC and symbol definitions.
P==17 ;Stack pointer for directories to keep
COUNT==16 ;Count of directories killed
STKCOU==15 ;Counter used in loop
ACJFN==14 ;JFN of file to record results
NUL==13 ;Null - must be 0
MESLIN==12 ;Line number to notify when done
CONAC==11 ;Confirm or not.
Q==10 ;Stack pointer to RESERVED directories
FORK==7 ;Fork handle, if pushing
STL==^D3500 ;Stack length
;Start address.
START: RESET
MOVEI 1,.FHSLF ;Test user's capabilities
RPCAP
TXNN 3,SC%OPR!SC%WHL
JRST [ERROUT (Wheel or Operator capability enabled is required)
JSR STOP
JRST .-1]
SCTRLH ;Set CTRL-H to ^H for COMND
MOVE P,[IOWD STL,STACK] ;Set up stack pointers:
MOVE Q,[IOWD 1000,NEWSTK] ;P-DIR's to keep. Q-reserve
PUSH Q,NUL ;Push NUL to Q for loop.
BEGIN: MOVEI 1,CMDBLK ;Initialize COMND line.
MOVEI 2,[FLDDB.(.CMINI)]
COMND
REPARS: MOVEI 1,CMDBLK ;Parse keyword
MOVEI 2,[FLDDB.(.CMKEY,,KEYW)]
PARSE
JRST @NUM(2) ;Goto command dispatch table.
CMDBLK: .CMDBK (REPARS,KILL>,BUFFER,ATOM,GETBLK)
GETBLK: BLOCK 17
ATOM: BLOCK 20
ATOM2: BLOCK 20
BUFFER: BLOCK 20
STRING: BLOCK 20
NEWSTK: BLOCK 1000
JFN: Z
GTDBLK: 20
BLOCK 20
NULBLK: BLOCK 20
NEWBUF: BLOCK 20
ARGH: ERROUT (Internal error, contact Joshua Brodsky)
HRROI 1,ERS
MOVE 2,[.FHSLF,,-1]
SETZ 3,
ERSTR
JFCL
JFCL
HRROI 1,ERS
ESOUT
JSR STOP
STACK: BLOCK STL
REP: HRROI 1,ERS
MOVE 2,[.FHSLF,,-1]
SETZ 3,
ERSTR
JFCL
JFCL
HRROI 1,ERS
ESOUT
JRST BEGIN
ERS: BLOCK 20
KEYW: NUM,,NUM ;COMND keyword table
[ASCIZ/BEGIN/],,0
[ASCIZ/CONFIRM/],,0
[ASCIZ/EXCEPT/],,0
[ASCIZ/EXIT/],,0
[ASCIZ/KEEP/],,0
[ASCIZ/KILL/],,0
[ASCIZ/LIST/],,0
[ASCIZ/NOTIFY/],,0
[ASCIZ/PUSH/],,0
[ASCIZ/TEST/],,0
NUM==.-KEYW-1
ADDR: .BEGIN ;Address lookup table.
.CONFM
EXCEPT
.EXIT
KEEP
.KILL
.LIST
NOTEY
.PUSH
.TEST
NUM2==.-ADDR
IFN NUM2-NUM,<PRINTX ?Tables of different lengths>
;The commands:
;KILL>EXIT (TO MONITOR)
.EXIT: NOISE (TO MONITOR)
CONFRM
JSR STOP
JRST BEGIN
;KILL>LIST (DELETED DIRECTORIES ON FILE) FILESPEC
.LIST: NOISE (DELETED DIRECTORIES ON FILE)
MOVEI 2,[FLDDB.(.CMOFI)]
PARSE
MOVE 4,2
CONFRM
MOVE 1,4
MOVE 2,[7B5+OF%WR]
OPENF
JRST REP
MOVE ACJFN,1
JRST BEGIN
;KILL>PUSH (COMMAND LEVEL AND KILL)
.PUSH: NOISE (COMMAND LEVEL AND KILL)
CONFRM
JUMPG FORK,SAFETY
MOVSI 1,(CR%CAP)
CFORK
JRST REP
MOVE FORK,1
MOVSI 1,(GJ%OLD+GJ%SHT)
HRROI 2,[ASCIZ/SYS:EXEC.EXE/]
GTJFN
JRST REP
HRLI 1,(FORK)
GET
JRST SAFETY
;KILL>TEST (KILLING MODE)
.TEST: NOISE (KILLING MODE)
CONFRM
SETOM TESTMD
TMSG <Now in test mode; will NOT kill any directories, but simulate
the killing.>
JRST BEGIN
;KILL>CONFIRM (MODE)
.CONFM: NOISE (MODE)
CONFRM
MOVEI CONAC,1
JRST BEGIN
;KILL>NOTIFY (LINE) OCTAL LINE NUMBER
NOTEY: NOISE (LINE)
MOVEI 2,[FLDDB.(.CMNUM,,10)]
PARSE
MOVE 4,2
CONFRM
MOVE MESLIN,4
JRST BEGIN
;KILL>EXCEPT (DIRECTORY) <DIR> (W OR W/O WILDCARDS)
EXCEPT: NOISE (DIRECTORY)
MOVEI 2,[FLDDB.(.CMDIR,,CM%DWC)]
PARSE ;Allow * in dir
MOVE 4,2
COPBYT: MOVE 1,[POINT 7,ATOM] ;Save direcotry name
MOVE 2,[POINT 7,NEWBUF] ;to find out if *
BYTLOP: ILDB 3,1
IDPB 3,2
JUMPN 3,BYTLOP
MOVX 1,<RC%AWL+RC%PAR>
HRROI 2,NEWBUF
RCDIR ;Have wildcards?
TXNE 1,RC%NOM+RC%AMB+RC%NMD
JRST ARGH ;Check for intern err
MOVE 5,1
MOVE 6,3
MOVEI 1,CMDBLK
CONFRM ;Confirm
CAME 4,6
JRST ARGH ;Confirm
MOVEI 1,.PRIOU
MOVE 2,6
DIRST ;OK first directory?
JRST REP
PUSH P,6
TMSG < [OK]
>
TXNN 5,RC%WLD ;Have wildcards?
JRST BEGIN ;No, done.
MOVE 3,6 ;Yes, loop.
RCLOOP: MOVE 1,[RC%AWL+RC%STP] ;Get next dir.
HRROI 2,NEWBUF
RCDIR
TXNE 1,RC%NMD
JRST BEGIN ;No more? Done.
MOVEI 1,.PRIOU
MOVE 2,3
DIRST
JRST REP
PUSH P,3 ;OK that dir.
TMSG < [OK]
>
JRST RCLOOP
;KILL>KILL (SPECIFICATION IS)
.KILL: NOISE (SPECIFICATION IS)
MOVEI 2,[FLDDB.(.CMDIR,,CM%DWC)]
PARSE
JUMPE 2,[ERROUT (No directories match this specification.)
JRST BEGIN]
MOVE 6,2
MOVE 3,[POINT 7,ATOM]
MOVE 4,[POINT 7,ATOM2] ;Copy spec.
KLOOP: ILDB 5,3
IDPB 5,4
JUMPN 5,KLOOP
CONFRM ;Confirm
MOVE 1,[RC%AWL+RC%PAR]
HRROI 2,ATOM2
RCDIR
TXNE 1,RC%NOM+RC%AMB
JRST ARGH
TXNN 1,RC%WLD ;Does it have wildcards?
JRST [ERROUT (Directory did not contain wildcards.)
JRST BEGIN]
CAME 3,6
JRST ARGH
MOVE 3,[POINT 7,ATOM2] ;Yes, copy to WILD spec.
MOVE 4,[POINT 7,WILD]
KLOOP2: ILDB 5,3
IDPB 5,4
JUMPN 5,KLOOP2
JRST BEGIN ;Done.
;KILL>KEEP (DIRECTORIES IN FILE) FILESPEC
KEEP: NOISE (DIRECTORIES IN FILE)
MOVEI 2,[FLDDB.(.CMIFI)]
PARSE
MOVE 5,2
CONFRM
MOVE 1,5
MOVE 2,[7B5+OF%RD]
OPENF
JRST REP
READFL: MOVE 1,5 ;Input dir from file
HRROI 2,STRING
MOVEI 3,^D100
MOVEI 4,^D62
SIN
ERJMP BEGIN
IDPB NUL,2
MOVX 1,<RC%PAR+RC%AWL>
HRROI 2,STRING
SETZ 3,
RCDIR
TXNE 1,RC%NOM+RC%AMB ;Bad directory?
JRST [ERROUT (Illigal directory in file - )
HRROI 1,STRING
PSOUT
JRST BEGIN]
TXNE 1,RC%WLD ;Wildcards?
JRST RWILD
PUSH P,3 ;No, push
RCONT: MOVE 1,5
BIN ;Input CR,
ERJMP BEGIN
BIN ;LF.
ERJMP BEGIN ;If EOF, done.
JRST READFL ;Get next spec.
RWILD: PUSH P,3
MOVE 1,[RC%AWL+RC%STP] ;Here on wildcards.
HRROI 2,STRING ;Save first spec.
RCDIR ;Get next spec.
TXNE 1,RC%NMD
JRST RCONT ;Any more in group?
JRST RWILD ;Yes, loop.
;KILL>BEGIN (KILLING)
.BEGIN: NOISE (KILLING)
CONFRM
SAFETY: HRROI 1,WILD ;if global kill, safety check.
HRROI 2,[ASCIZ/PS:<*>/]
STCMP
JUMPN 1,SAFE
MOVE 1,STACK
JUMPE 1,[ERROUT (Stack for directories to keep is empty!)
JRST BEGIN]
JUMPE ACJFN,[ERROUT (No output file specified)
JRST BEGIN]
SAFE: TMSG <[CONFIRM WITH CTRL-Y]>
PBIN
CAIN 1,""
JRST CONFIR
TMSG < NOT CONFIRMED!>
JRST BEGIN
CONFIR: TMSG <
NOTE: You are about to destroy many, many directories. All files in
these directories will be eternally lost. You may abort with CTRL-C at
any time.
>
MOVE 1,TESTMD
JUMPE 1,TESMD1
TMSG <In test mode. Will NOT actually kill
>
TESMD1: MOVEI 1,-1
DOBE
MOVEI 2,5
MOVEI 3,^D10
LOOP: MOVEI 1,.PRIOU ;Count down
NOUT
JRST REP
TMSG <...>
MOVEI 1,^D1000
DISMS
SOJG 2,LOOP
MOVEI 1,7
PBOUT ;Ring bell, print header.
TMSG <
Killing started at >
MOVEI 1,.PRIOU
MOVNI 2,1
MOVNI 3,1
ODTIM
PRICR
JUMPE FORK,KILL1
MOVE 1,FORK
SETZ 2,
SFRKV
KILL1: MOVE 1,[RC%PAR+RC%AWL] ;KILL1 initializes killing
HRROI 2,WILD
RCDIR
TXNE 1,RC%NOM+RC%AMB
JRST ARGH
KILL2: MOVE 4,STACK(STKCOU) ;KILL2 finds a directory
JUMPE 4,KILL3 ;not reserved in the p stack
CAMN 3,4
JRST NEXT
AOJG STKCOU,KILL2
KILL3: JUMPE CONAC,KILL5 ;KILL3 confirms the directory
MOVEI 1,.PRIOU ;if confirmations are wanted
MOVE 2,3
DIRST
JRST REP
TMSG < [Confirm]>
PBIN
CAIE 1,^D13
JSR STOP
PBIN
KILL5: HRROI 1,KILL4 ;KILL5 lists the directory
MOVE 2,3
DIRST
JRST REP
JUMPE ACJFN,KILL7
MOVE 1,ACJFN
MOVE 2,3
DIRST
JRST REP
KILL7: MOVE 1,3 ;Does directory have subdirectory
MOVEI 2,GTDBLK ;quota?
HRROI 3,NULBLK
GTDIR
ERJMP ARGH
MOVE 3,1
MOVE 2,GTDBLK+.CDSDQ
JUMPG 2,RESERV ;Yes, be safe and reserve it.
MOVE 1,[RC%AWL+RC%STP] ;KILL7 kills the directory
HRROI 2,WILD
RCDIR
MOVE 4,1
HRROI 1,KILL4
MOVE 2,[CD%DEL]
JSR KILDIR ;[3] Kill the direcotory
JRST RESERR ;[3] (Or simulate it)
ADDI COUNT,1
KILL10: MOVE 1,ACJFN
JUMPE 1,[MOVE 1,4
JRST NEXT1]
MOVEI 2,^D13
BOUT
MOVEI 2,^D10
BOUT
MOVE 1,4
JRST NEXT1
NEXT: MOVE 1,[RC%AWL+RC%STP] ;NEXT gets the next directory
HRROI 2,WILD ;to try
RCDIR
NEXT1: TXNE 1,RC%NOM+RC%AMB
JRST ARGH
TXNE 1,RC%NMD
JRST ENDKIL
SETZ STKCOU,
JRST KILL2 ;Loop...
RESERR: TMSG <
%Warning: Cannot kill directory >
HRROI 1,KILL4
PSOUT
TMSG <, skipping because:
>
HRROI 1,ERS
MOVE 2,[.FHSLF,,-1]
EXCH NUL,3 ;Save AC3 in handy AC while setting to zero. [3]
ERSTR
JFCL
JFCL
HRROI 1,ERS
ESOUT
MOVEI 1,""
PBOUT
MOVE 3,NUL ;Repair the damage. [3]
SETZ NUL,
JRST KILL10 ;Resume...
RESER1: TMSG <
%Warning: Cannot kill directory >
HRROI 1,KILL4
PSOUT
TMSG <, skipping because:
>
HRROI 1,ERS
MOVE 2,[.FHSLF,,-1]
EXCH NUL,3 ;Save AC3 in handy AC while setting to zero. [3]
ERSTR
JFCL
JFCL
HRROI 1,ERS
ESOUT
MOVEI 1,""
PBOUT
MOVE 3,NUL ;Repair the damage. [3]
SETZ NUL,
JRST KILL11
KILL4: BLOCK 20
WILD: ASCIZ/PS:<*>/
BLOCK 5
RESERV: MOVE 1,[RC%PAR] ;RESERV reserves directories
HRROI 2,KILL4 ;to kill with inferior
RCDIR ;directories, until they are
TXNE 1,RC%NOM+RC%AMB ;killed first.
JRST ARGH
PUSH Q,3
MOVE 1,ACJFN
JUMPE 1,NEXT
MOVEI 2,"*"
BOUT
MOVEI 2,^D13
BOUT
MOVEI 2,^D10
BOUT
JRST NEXT
ENDKIL: POP Q,2 ;ENDKIL kills directories
JUMPE 2,KILL6 ;that have been reserved.
HRROI 1,KILL4
DIRST
JRST REP
HRROI 1,KILL4
MOVE 2,[CD%DEL]
JSR KILDIR ;[3] Kill the directory
JRST RESER1 ;[3] (Or simulate it)
KILL11: AOJA COUNT,ENDKIL
KILL6: MOVE 1,ACJFN
JUMPE 1,.+3
CLOSF
JRST REP
TMSG <
Killing completed at > ;kill6 completes the job
MOVEI 1,.PRIOU
MOVNI 2,1
MOVNI 3,1
ODTIM
PRICR
MOVEI 1,.PRIOU
MOVE 2,COUNT
MOVEI 3,^D10
NOUT
JRST REP
TMSG < directories killed.>
JUMPE MESLIN,ENDPRG
MOVEI 1,400000(MESLIN)
HRROI 2,[ASCIZ/[Killing complete]/]
TTMSG
ENDPRG: JSR STOP
JRST ENDPRG
STOP: Z ;stop is in place of haltf,
JUMPG FORK,STOP1 ;to avoid killing a fork.
STOP2: HALTF
JRST @STOP
JRST @STOP
STOP1: MOVE 1,FORK
WFORK
JRST STOP2
;All this here is [3].
TESTMD: Z
KILDIR: Z
MOVEM 1,TEMP1
MOVE 1,TESTMD
JUMPE 1,ACTKIL
MOVE 1,KILDIR
ADDI 1,1
MOVEM 1,KILDIR
MOVE 1,TEMP1
JRST @KILDIR
ACTKIL: MOVE 1,TEMP1
CRDIR
ERJMP @KILDIR
MOVEM 1,TEMP1
MOVE 1,KILDIR
ADDI 1,1
MOVEM 1,KILDIR
MOVE 1,TEMP1
JRST @KILDIR
TEMP1: Z
END <ENLEN,,ENVCT>