; ;DISKUSG.MAR Program to produce a USAGE_DIR:DISKUSAGE.LIS, disk usage file. ; It reads from the file USAGE_DIR:USAGE.DAT, which was ; produced from $ ANALYZE/DISK_STRUCTUR/USAGE command. ; It creates the file USAGE_DIR:DISKUSAGE.LIS. ; This program is driven by the command procedure DISKUSG.COM ; ; ; Written by : Scott Stuart ; Education Services ; Digital Equipment Corporation ; July 20, 1983 ; ; ; ; USG SYMBOLS USED ; ; USG$L_ALLOCATED number of blocks allocated to the file, ; including the file header ; USG$W_DIR_LEN length of directory string in USG$T_FILESPEC ; USG$T_FILESPEC fill spec in the form [dir]fn.ty;ver ; lost files will have a null dir entry [] ; USG$W_SPEC_LEN length of USG$T_FILESPEC ; USG$T_FILE_LEN maximum length of file record ; ; ; ; ; ; ; ; ; SYMBOL DEFINITION ; ; NULL = 0 ZERO = 0 ONE = 1 TWO = 2 TEN = 10 TWELVE = 12 FORTY = 40 SIXTY = 60 SEVENTY = 80 EIGHTY = 80 ; DEVICE_OFFSET = 16 ;output position for USAGE_DISK TIME_OFFSET = 38 ;output position for date/time HEADER_LENGTH = 62 ;output length for HEADER record OUT_LENGTH = 50 ;output length beyond dir for SFD & UFD SFD_OFFSET = 45 UFD_INDENT = 30 UFD_OFFSET = 40 TOT_LENGTH = 60 ;output length for GRAND TOTAL TOT_OFFSET = 43 SORT_KEY_LEN = 80 ;room for all subdirectories ; ; ; ; ; ; ; ; ; REGISTERS USED ; ; REGISTER USE ; -------- --- ; R11 grand total blocks allocated ; R10 UFD total blocks allocated ; R9 UFD length ; R8 SFD total blocks allocated ; R7 base address of USG$K_FILE record ; R6 base address of FILE_SPEC ; R5 temporary stroage for macro PRINT_BLANK ; ; ; ; ; ; ; ; .MACRO CHECK_STATUS code=r0, ?go blbs code, go pushl code calls #1, g^lib$stop go: .endm check_status ; ; ; ; ; ; .MACRO PRINT_BLANK NUM_BLANKS=1,?BLABEL ; ; Macro to print NUM_BLANKS blank lines. ; R6 is used to keep count of the number of ; line printed. The size of the output buffer ; is set to 0 and then the approriate number ; of $PUT's are executed. ; ; ; MOVL #NUM_BLANKS,R5 ;set up a counter MOVW #ZERO,USAGE_OUT_RAB+RAB$W_RSZ ;set up the buffer length as 0 BLABEL: $PUT RAB=USAGE_OUT_RAB ;output a blank line SOBGTR R5,BLABEL ;decrement the counter .ENDM PRINT_BLANK ; ; ; ; ; ; .MACRO LONG_ASCII SRC,DEST ; ; ; Macro to convert a long word integer to ; an ascii string. The longword string is in ; location SRC and the ASCII string is put in DEST. ; Location LONG_BUFFER is used to hold the longword value ; before it is translated. Location STRING_DESCRIPTOR is used to ; hold the string descriptor for NUMERIC_STRING. The string will ; be moved to location DEST after the conversion. ; The RTL routine OTS$CVT_L_TI is called to do the ; conversion. ; ; MOVL SRC,LONG_BUFFER ;move the input to the buffer ; PUSHAL STRING_DESCRIPTOR PUSHAL LONG_BUFFER ;set up the arguments on the stack ; CALLS #2,G^OTS$CVT_L_TI ;call the RTL routine CHECK_STATUS ; MOVC3 #10,NUMERIC_STRING,- DEST ;move the converted string to ;the output buffer ; .ENDM LONG_ASCII ; ; ; ; ; ; ; ; ; ; ; ; .TITLE DISKUSG ; .PSECT DATA,LONG ; ; ; ; ; define the symbols for the usage file ; $USGDEF ; ; ; ; OLD_UFD: .ASCII / TOTAL / .BLKB 60 ; OLD_UFD_LENGTH: .BLKL ; ; KEY_BUFFER: ;put sort keys here .BLKB SORT_KEY_LEN ; IN_BUF: .BLKL 80 ;set aside a 320 byte buffer ; IN_SIZE = 160 ;set up the buffer size ; ; HEADER: .ASCII /DISK USAGE FOR / ; ; DEVICE_LOGNAME: .ASCII /USAGE_DISK/ ; DEVICE_LOGNAME_DESC: .LONG 10 .ADDRESS- DEVICE_LOGNAME ; DEVICE_EQUIVNAME: .ASCII / / ; DEVICE_EQUIVNAME_DESC: .LONG 40 .ADDRESS- DEVICE_EQUIVNAME ; EQUIVNAME_LEN: .BLKW ; TIME: .BLKB 40 ; TIME_DESC: .LONG 40 .ADDRESS- TIME ; ; OUT_BUF: .ASCII / GRAND TOTAL ...................... / ;set up an 80 byte output buffer ; ; ; ASCII_A: .ASCII /A/ ;use for checking for numeric directories ; ; OLD_SFD: .BLKB 80 ;leave room for all subdirectories ; OLD_SFD_LENGTH: .BLKW ; END_BRACKET: .ASCII /]/ ; PERIOD: .ASCII /./ ; SPACE: .ASCII / / ; ; ; ; set up a key and filespec for the sort routine ; The input file will be sorted before ; it is processed. ; SORT_KEY: .WORD 1 ;number of keys .WORD 1 ;character data type .WORD 0 ;ascending sort .WORD 0 ;key position .WORD SORT_KEY_LEN ;key size ; ; ; ; Character string descriptor parameter for SOR$RELEASE_REC ; IN_RECORD_DESC: .LONG 0 .ADDRESS- IN_BUF-SORT_KEY_LEN ; ; Character string descriptor parameter for SOR$RETURN_REC ; OUT_RECORD_DESC: .LONG USG$K_FILE_LEN .ADDRESS- IN_BUF ; MAX_RECORD_SIZE: .LONG USG$K_FILE_LEN ; ; STRING_DESCRIPTOR: .LONG 10 ;number of digits in output string .ADDRESS- NUMERIC_STRING ; NUMERIC_STRING: .BLKB 10 ;leave room for a 10 digit number ; ; ; LONG_BUFFER: .BLKL ; ; ; ; ; ; ; ; ; ; ; ; FAB's and RAB's ; .ALIGN LONG ; ; ; FAB and RAB for USAGESRT.DAT ; This is the file created by sorting the file produced by ; ANALYZE/DISK_STRUCTURE/USAGE. ; It is the input file ; USAGE_IN_FAB: $FAB FNM= ; ; USAGE_IN_RAB: $RAB FAB=USAGE_IN_FAB,- UBF=IN_BUF,- USZ=160 ; ; ; FAB and RAB for DISKUSAGE.LIS ; This is the output file created by the program. ; ; USAGE_OUT_FAB: $FAB FNM=,- FAC=,- ORG=SEQ,- RAT=,- RFM=VAR,- MRS=80,- FOP= ; ; USAGE_OUT_RAB: $RAB FAB=USAGE_OUT_FAB,- RBF=OUT_BUF,- RSZ=TOT_LENGTH,- RAC=SEQ ; ; ; ; ; ; ; ; ; ; ; Begin Main Program ; .PSECT MAIN ; ; DISKUSG: .WORD 0 ; ; ; ; ; ; Initialization ; CLRL R11 ;used for grand total blocks allocated CLRL R10 ;used for UFD total blocks allocated CLRL R9 ;used for UFD length CLRL R8 ;used for SFD total blocks allocatedof blocks allocated CLRL R7 ;used for base address of IN_BUF CLRL R6 ;used for base address of FILE_SPEC ; ; ; $CREATE FAB=USAGE_OUT_FAB ;create and connect DISKUSGAGE.l CHECK_STATUS ; $CONNECT- RAB=USAGE_OUT_RAB CHECK_STATUS ; ; $OPEN FAB=USAGE_IN_FAB ;open and connect USAGESRT.DAT CHECK_STATUS ; $CONNECT- RAB=USAGE_IN_RAB CHECK_STATUS ; ; MOVAL IN_BUF,R7 ;R7 will have base address of buffer MOVAL USG$T_FILESPEC(R7),R6 ;R6 will have base address of USG$T_FILE_SPEC; ; ; $GET RAB=USAGE_IN_RAB ;get USG$K_IDENT record CHECK_STATUS ; ; WRITE_HEADER: ; ; write the first record with the device used for ; the report and the time the report was generated ; ; PRINT_BLANK TWO ; $TRNLOG_S - ;translate the logical name USAGE_DISK LOGNAM=DEVICE_LOGNAME_DESC, - RSLLEN=EQUIVNAME_LEN, - RSLBUF=DEVICE_EQUIVNAME_DESC ; MOVC3 EQUIVNAME_LEN,- ;move the equivalence name to output buffer DEVICE_EQUIVNAME,- HEADER+DEVICE_OFFSET ; ; $ASCTIM_S - ;translate the system time TIMBUF=TIME_DESC ; MOVC3 #17,TIME,- ;move time to HEADER record HEADER+TIME_OFFSET ; ; ; Now get the RAB output buffer to ; point to the header buffer. ; ; MOVW #HEADER_LENGTH,- ;set up the output length USAGE_OUT_RAB+RAB$W_RSZ ; MOVAL HEADER,- ;output buffer = HEADER USAGE_OUT_RAB+RAB$L_RBF ; $PUT RAB=USAGE_OUT_RAB ;write the HEADER record ; PRINT_BLANK TWO ; ; ; ; ; ; ; ; i) Read records from the file USAGE_DIR:USAGE.DAT ; ii) Set up the sort field as the directory field without ; the trailing ] ; iii) Send a record at a time to SORT ; iv) Call SORT ; v) Retrurn a record ; vi) Process each record ; vii) Produce the output file USAGE_DIR:DISKUSAGE.LIS ; ; PUSHAL MAX_RECORD_SIZE ;max record size PUSHAL SORT_KEY ;address of key CALLS #2,G^SOR$INIT_SORT ;set up the keys for the sort CHECK_STATUS ; ; GET_RECORD: $GET RAB=USAGE_IN_RAB ;get USG$K_FILE record CMPL #RMS$_EOF,R0 BEQL SORT ; CMPB USG$B_TYPE(R7),- ;check record type #USG$K_FILE BNEQ GET_RECORD ; ; SUBW2 #1,USG$W_DIR_LEN(R7) ;ignore the trailing ] ; MOVC5 USG$W_DIR_LEN(R7),(R6),- ;put the key at the begining of the record SPACE,#SORT_KEY_LEN,- IN_BUF-SORT_KEY_LEN ; ADDW2 #1,USG$W_DIR_LEN(R7) ;include the trailing ] for processing ; ADDW3 USAGE_IN_RAB+RAB$W_RSZ,- ;length of record buffer #SORT_KEY_LEN,- IN_RECORD_DESC ; PUSHAL IN_RECORD_DESC CALLS #1,G^SOR$RELEASE_REC ;send the record to SORT CHECK_STATUS ; BRB GET_RECORD ;get the next record ; ; SORT: CALLS #0,G^SOR$SORT_MERGE ;SORT the records CHECK_STATUS ; ; ; Return first record and set up OLD_UFD and ; OLD_SFD. Also accumulate totals ; RETURN_FIRST_RECORD: PUSHAL USAGE_IN_RAB+RAB$W_RSZ PUSHAL OUT_RECORD_DESC CALLS #2,G^SOR$RETURN_REC ;get first USG$K_FILE record CHECK_STATUS ; CMPW #TWO,USG$W_DIR_LEN(R7) ;check for null directory BEQL RETURN_FIRST_RECORD ;skip it if its null ; CMPC3 #ONE,USG$T_FILESPEC+ONE(R7),- ASCII_A ;search for a non-alphabetic character as the first ;character of the directory name ;N bit is set if FILESPEC