.TITLE BROOM -- Disk Blanking Program. .IDENT /V01.X/ ; EDIT # 0006 12 Apr 1981 18:05:56 DB0:[300,341]BROOM.MAC;10 ; PREVIOUS EDIT 12 Apr 1981 17:59:34 DB0:[300,341]BROOM.MAC;7 .ENABL LC .SBTTL Documentation Notes. ; Module Name: BROOM.MAC ; ; Programmer: Eric A. Johnson ; ; Date: 25-Jun-80 ; ; Version: 1.0 ; ; Residence: DB0:[377,23] ; ; For: System Security ; ; Core Requirements: 7K ; ; ; Type/Language: MACRO-11 ; ; Indirect Command File: DB0:[377,23]BROOM.CMD ; ; Abstract: This program allocates a file on each disk ; the size of which is equal to the number of free blocks ; on the volume, then writes a blank buffer to each block. ; This effectively erases the free space on the disk so that ; deleted files are truely deleted. ; ; BRM> dev:,dev:,... ; ; where dev is a mounted Files-11 device only. It is strongly ; recommended that BROOM is only used on queisent devices as ; the program allocates every available block on the device ; to the temporary file. ; ; Modified by Ray Van Tassle 12 Apr 1981 ; so that it is non-priv & will run on any system .SBTTL Local Macro Definitions. .MCALL QIOW$,DIR$,EXST$S,FDAT$R,OPNT$D,CLOSE$,NBOF$L,WAIT$ .MCALL FSRSZ$,FDBDF$,FDRC$A,FDBK$A,FDOP$A,NMBLK$,WRITE$ .MCALL GCMLB$,GCML$ .MCALL CSI$,CSI$SW,CSI$SV,CSI$ND,CSI$1,CSI$2 .MACRO PUSH,LIST .IRP .I., .IF IDN,<.I.>,<*> CLR -(SP) .IFF MOV .I.,-(SP) .ENDC .ENDR .ENDM .MACRO POP,LIST .IRP .I., .IF IDN,<.I.>,<*> TST (SP)+ .IFF MOV (SP)+,.I. .ENDC .ENDR .ENDM .MACRO PRINT,.BUFF.,.LEN.,.CCW. MOV .BUFF.,-(SP) MOV .LEN.,-(SP) .IF B .CCW. CLR -(SP) .IFF MOV .CCW.,-(SP) .ENDC CALL $OUT .ENDM .SBTTL Working storage and Symbol defs. LUN = 1 ; LUN for TI messeges. FILUN = 2 ; LUN for file. EX.ENA=200 EX.AC1=001 EX.AC2=002 $WRT: QIOW$ IO.WLB,LUN,1,100,,,<0,0,0> FNPTR: .WORD AJAX+F.FNB+N.DVNM,AJAX+F.FNB+N.UNIT IOSTAT: .BLKW 2 ; I/O STATUS BLOCK OUTBUF: .BLKB 80. ; Messege output buffer. PATBUF: .BLKB 512. ; File output buffer. .SBTTL Get command line block CMDBLK: GCMLB$ 0,BRM,,LUN,,80. ;Define working storage for GCML. .SBTTL CSI block and table definitions. CSI$ .EVEN CSIBLK: .BLKB C.SIZE ;CSI working storage. .SBTTL Messeges. OPNMSG: .ASCIZ "BROOM -- Error opening file on %2A%B:" FCSMSG: .ASCIZ "BROOM -- FCS Error %D." WRTMSG: .ASCIZ "BROOM -- Error encountered during WRITE$." WTEMSG: .ASCIZ "BROOM -- Error encountered on write completion." ERCMSG: .ASCII "BROOM -- Error processing command line." ERCMSL=.-ERCMSG .SBTTL FDB for cleanup file. .EVEN FSRSZ$ 1 ; Allocate FSR buffer. AJAX: FDBDF$ ; Allocate 1 FDB. FDRC$A FD.RWM ; Block I/O. FDBK$A PATBUF,512.,,,IOSTAT ; Init block access. FDOP$A FILUN,CSIBLK+C.DSDS,FILNAM,FO.WRT!FA.TMP ; Define file open section. FILNAM: NMBLK$ CLEANER,TMP,,NL,0 ; Default Nameblock. .PAGE .sbttl Start of code, get command line. BROOM:: GCML$ #CMDBLK ;Get the command line. BCS CMDERR ;Go look at the error. CSI$1 #CSIBLK,CMDBLK+G.CMLD+2,CMDBLK+G.CMLD ;Init CSI block. BCS CMDERR ;Branch if error. TST CSIBLK+C.CMLD ;Anything to look at? BEQ BROOM ;Nope - try again. PRSDEV: CSI$2 #CSIBLK,OUTPUT ;Decode next command. BCS CMDERR ;Branch if error. BITB #,CSIBLK+C.STAT ;Test for name or directory. BNE CMDERR ;Error if specified. BITB #CS.DVF,CSIBLK+C.STAT ;Was a device specified? BEQ CMDERR ; NO, ERROR JMP OKDEV CMDERR: CMPB #GE.EOF,CMDBLK+G.ERR ;End of file from GCML? BEQ EXOUT ;Leave quietly if so. PRINT #ERCMSG,#ERCMSL,#40 ;Else error in command. BR BROOM ;Go try it again. ; All roads lead here. EXTERR: EXST$S #EX$ERR ;Exit with error status. EXOUT: EXST$S #EX$SUC ;Exit gracefully. OKDEV: ; Define file attributes and attempt to open him. FDAT$R #AJAX,#R.FIX,#FD.BLK ;Fill in the FDB. OPNT$D #AJAX ;Open the big guy marked for delete. BCS OPNERR ;Go complain if problem. ; Now extend the file to include all free blocks on device. MOV #100000,R1 ; A very large extend ; GET AS LARGE A CONTIGUOUS CHUNK AS WE CAN MOV #,R2 ; If NG, get as big as we can 20$: CALL .EXTND ;Gobble it up. BCC 20$ ; This is the beginning of the write loop. WRITLP: WRITE$ #AJAX,,,,#5 ;Attempt to write a block. BCS WRTERR ;Complain if problem. WAIT$ #AJAX,#5 ;Wait for I/O completion. BCC WRITLP ;If I/O was successful, go do another. ; Wait error response. MOV #OUTBUF,R0 ;R0->Output buffer. MOV #WTEMSG,R1 ;R1->Format String. CALL $EDMSG ;Make it pretty. PRINT #OUTBUF,R1,#40 ;Output the messege. BR PUTFCS ;Go tell'em what kind it was. ; Write error response. WRTERR: CMPB #IE.DFU,AJAX+F.ERR ;End of file encountered? BEQ CLSOUT ;Yup -- That's what we're looking for. MOV #OUTBUF,R0 ;R0->Output buffer. MOV #WRTMSG,R1 ;R1->Format String. CALL $EDMSG ;Make it pretty. PRINT #OUTBUF,R1,#40 ;Output the messege. ; Common code to write FCS error messege. PUTFCS: MOV #-1,-(SP) ;Ready the stack. MOVB AJAX+F.ERR,(SP) ;Push the FCS error. MOV #OUTBUF,R0 ;R0->Output buffer. MOV #FCSMSG,R1 ;R1->Format String. MOV SP,R2 ;R2->Argument block. CALL $EDMSG ;Make it pretty. TST (SP)+ ;Clean the stack. PRINT #OUTBUF,R1,#40 ;Output the messege. ; Close the file cause we're done with him. He'll go away on his own. CLSOUT: CLOSE$ #AJAX ;Now close him. BITB #CS.MOR,CSIBLK+C.STAT ;Is there anymore in the cmd line? BEQ 10$ ;No, branch aid... JMP PRSDEV ;Else look at the command string. 10$: JMP BROOM ;Go get another command. ; We come here to complain if we couldn't open the file. OPNERR: MOV #OUTBUF,R0 ;R0->Output buffer. MOV #OPNMSG,R1 ;R1->Format String. MOV #FNPTR,R2 ;R2->Argument block. CALL $EDMSG ;Make it pretty. PRINT #OUTBUF,R1,#40 ;Output the messege. MOV #-1,-(SP) ;Push the base on the stack. MOVB AJAX+F.ERR,(SP) ;Add the FCS error. MOV #OUTBUF,R0 ;R0->Output buffer. MOV #FCSMSG,R1 ;R1->Format String. MOV SP,R2 ;R2->Argument block. CALL $EDMSG ;Make it pretty. TST (SP)+ ;Clean the stack. PRINT #OUTBUF,R1,#40 ;Output the messege. JMP EXTERR ;Die a bad death. .sbttl $OUT -- Output line to TI: ; This subroutine will output a string to the terminal ; that is currently assigned to TI: $OUT: MOV 4(SP),$WRT+Q.IOPL+2 ; Set buffer length BEQ 10$ ; EQ - then skip I/O MOV 2(SP),$WRT+Q.IOPL+4 ; Set CCW word MOV 6(SP),$WRT+Q.IOPL ; Set buffer address DIR$ #$WRT ; Perform I/O 10$: MOV (SP),6(SP) ; Restore return address ADD #6,SP ; Clean up stack RETURN ; Return to whom called us .END BROOM