Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/dskuse.fai
There are no other files named dskuse.fai in the archive.
	TITLE	DSKUSE - DISK USAGE INFORMATION

	SEARCH	MONSYM
	asuppress

SPECBT==CD%STF!CD%FAC!CD%PRM!CD%RTD
P==17
PDLEN==100

A=1
B=2
C=3
D=4

OPDEF CALL	[PUSHJ P,]
OPDEF RET	[POPJ P,]


OJFN:	0		;JFN OF OUTPUT FILE
SPJFN:	0		;for writing special output file
RJFN:	0		;JFN OF <ROOT-DIRECTORY>*.DIRECTORY.*
DNAME:	BLOCK	20	;ROOM FOR DIRECTORY NAME
ONAME:	BLOCK	40	;ROOM FOR USER NAME AND ... MORE
WTOT:	0		;TOTAL WORK ALLOCATION
PTOT:	0		;TOTAL PERM ALLOCATION
DTOT:	0		;TOTAL ACTUAL DISK SPACE ALLOCATED
CRLF:	BYTE (7)15,12
SEQNUM:	0		;sequence number for alpha sort
CUMDSK:	0
CUMDIR:	0


OPTR:0
RCDDIR:	0
WORKS:	0
DISKS:	0
DATES:	0
LISTFF:	0
PRVLNK:	0
LISTHD:	0
PERMS:	0
LINECT:	0
HEADER:	0
DIRINF:	BLOCK	50
SPACE:	ASCIZ	/                                            /  ;44 spaces
PDLIST:	BLOCK	PDLEN
RDBFLN==40
RDBUF:	block	rdbfln
FETCH1=12
FETCH2=13

RCDWLS:	BLOCK	RDBFLN+2
PINF:	377777,,0			;REPRESENTATION FOR ALLOCATION

;definitions of data structures
l.link==0
l.anum==1
l.disk==2
l.date==3
l.mode==4
l.text==5
START:	RESET
	MOVE	P,[IOWD PDLEN,PDLIST]
	HRROI	1,[ASCIZ/

DISK USAGE INFORMATION
/]
	PSOUT
GSTR:	HRROI	A,[ASCIZ/For what Structure: /]
	PSOUT
	HRROI	A,RDBUF
	MOVEI	B,RDBFLN*5-4
	HRROI	C,[ASCIZ/For what Structure: /]
	RDTTY
	ERJMP	GSTR
	MOVE	A,[POINT 7,RCDWLS]
	MOVE	B,[POINT 7,RDBUF]
CSTR:	ILDB	C,B
	CAIE	C,15
	CAIN	C,":"
	JRST	CSTRX
	CAIN	C,12
	JRST	CSTRX
	JUMPE	C,CSTRX
	CAIL	C,"A"+40
	CAILE	C,"Z"+40
	JRST	.+2
	SUBI	C," "
	IDPB	C,A
	DPB	C,B
	JRST	CSTR

CSTRX:	MOVEI	C,0
	DPB	C,B		;END STRING WITH NULL
	MOVE	C,RDBUF
	AND	C,[BYTE(7)177,177,177]
	SETZM	PSFLG#
	CAMN	C,[ASCIZ/PS/]
	SETOM	PSFLG
	HRROI	B,[ASCIZ/:<*>/]
	MOVEI	C,0
	SOUT		;tack on the :<*> to end of str name.
	IDPB	C,A

GPRM:	HRROI	A,[ASCIZ/Which reports
(sum of 1-alpha, 2-date, 4-amount, 10-losers): /]
	PSOUT
	HRROI	A,RDBUF
	MOVEI	B,RDBFLN*5-4
	HRROI	C,[ASCIZ/(sum of 1-alpha, 2-date, 4-amount, 10-losers): /]
	RDTTY
	ERJMP	GPRM
	MOVEI	C,10		;radix for input
	PUSHJ	P,GETNUM	;get a number from string
	MOVEM	B,PARMS#
	JUMPE	B,GPRM		;zero is no good
	TRNE	B,4		;wants amounts
	pushj	p,getlim	;get threshold

GOF:	HRROI	1,[ASCIZ/OUTPUT FILE NAME: /]
	PSOUT
	HRLZI	1,(GJ%FOU!GJ%MSG!GJ%CFM!GJ%FNS!GJ%SHT)
	MOVE	2,[.PRIIN,,.PRIOU]
	GTJFN
	JRST	[HRROI	1,[ASCIZ/CAN'T GET JFN  /]
		PSOUT
		JRST GOF]
	HRRZM	1,OJFN
	MOVE	2,[7B5!OF%WR]
	OPENF
	JRST	[HRROI	1,[ASCIZ/CAN'T OPENF OUTPUT FILE./]
		PSOUT
		JRST	START]

	SETZM	SPJFN
	SKIPN	PSFLG
	JRST	NOSJFN		;DON't Collect privileges except on PS
	HRLZI	1,(GJ%FOU!GJ%SHT)
	HRROI	2,[ASCIZ/PS:<OPERATOR>WL.LST/]
	GTJFN
	ERJMP	NOSJFN
	HRRZM	1,SPJFN
	MOVE	2,[7B5!OF%WR]
	OPENF
	ERJMP	[MOVE	A,SPJFN
		RLJFN
		SETZM	SPJFN
		JRST	.+1]
	JRST	NOSJFN
GETLIM:	hrroi	a,[PTFAL:asciz/Page threshold for amounts listing: /]
	PSOUT
	HRROI	A,RDBUF
	MOVEI	B,RDBFLN*5-4
	HRROI	C,PTFAL
	RDTTY
	ERJMP	GETLIM
	MOVEI	C,12		;radix 10 input
	PUSHJ	P,GETNUM	;read a number from rdbuf
	MOVEM	B,ATHRES#	;Store as the threshold
	RET

GETNUM:	PUSH	P,C		;save the input radix
	MOVE	A,[POINT 7,RDBUF]
	MOVEI	B,0
GETNM1:	ILDB	C,A		;GET THE FIRST BYTE OF ANSWER
	CAIGE	C,"0"
	JRST	GETNM2		;not a digit
	SUBI	C,"0"		;make it a number
	CAML	C,(P)		;is it a digit?
	JRST	GETNM2		;not a digit
	IMUL	B,(P)
	ADD	B,C
	JRST	GETNM1

GETNM2:	pop	p,c
	POPJ	P,
NOSJFN:	MOVSI	A,(RC%AWL)
	HRROI	B,RCDWLS
	RCDIR
	ERJMP	[HALTF]
	MOVEM	A,RCDFLG#
	MOVEM	C,RCDDIR#
	SETZM	WTOT
	SETZM	PTOT
	SETZM	DTOT
	SETZM	CUMDSK
	SETZM	CUMDIR
	HRRZI	1,100000
	MOVEM	1,LISTFF		;FIRST FREE ADDRESS FOR LIST
	HRRZI	1,LISTHD
	MOVEM	1,PRVLNK		;PREVIOUS LINK OUT WORD
	SETZM	SEQNUM		;INITIAL SEQUENCE NUMBER
LOOP:	HRROI	A,DNAME		;destination for dir name
	MOVE	B,RCDDIR	;dir number
	DIRST
	jfcl			;??
	MOVE	2,[ASCII/. . ./]
	MOVE	3,[ASCII/ . . /]
	MOVEM	2,ONAME
	MOVEM	3,ONAME+1
	MOVE	2,[ONAME,,ONAME+2]
	BLT	2,ONAME+10
	MOVE	1,[POINT 7,DNAME]
	MOVE	2,[POINT 7,ONAME]
PLP1:	ILDB	3,1			;BYTE
	JUMPE	3,PLP2
	IDPB	3,2
	JRST	PLP1

PLP2:	HRRZI	3," "
	IDPB	3,2
	IDPB	3,2
	MOVE	1,[POINT 7,ONAME+10,13]	;DEST. POINTER
	HRRZI	2,"["
	IDPB	2,1
	HRRZ	2,RCDDIR
	MOVE	3,[100005,,10]		;5 COLUMN, OCTAL, LEADING FILL
	NOUT
	JFCL
	HRRZI	2,"]"
	IDPB	2,1
	HRRZI	2," "
	IDPB	2,1
	IDPB	2,1
	MOVEM	1,OPTR
	MOVE	1,RCDDIR
	GTDAL
	MOVEM	3,PERMS
	CAME	3,PINF			;INFINITE?
	ADDM	3,PTOT
	MOVEM	1,WORKS
	CAME	1,PINF
	ADDM	1,WTOT
	ADDM	2,DTOT
	MOVEM	2,DISKS
	MOVE	1,OPTR
	MOVE	3,[100006,,12]
	NOUT
	JFCL
	MOVE	2,PERMS
	MOVE	3,[100007,,12]
	CAMN	2,PINF			;INFINITE?
	JRST	[HRROI 2,[ASCIZ/   +INF/]
		MOVEI 3,0
		SOUT
		JFCL
		JRST .+2]
	NOUT
	JFCL
	MOVE	2,WORKS
	MOVE	3,[100007,,12]
	CAMN	2,PINF			;INFINITE?
	JRST	[HRROI 2,[ASCIZ/   +INF/]
		MOVEI 3,0
		SOUT
		JFCL
		JRST .+2]
	NOUT
	JFCL
	HRRZI	2," "
	IDPB	2,1
	IDPB	2,1
	MOVEM	1,OPTR
	MOVE	1,RCDDIR
	HRRZI	2,DIRINF
	HRRZI	3,.NULIO
	GTDIR
	MOVE	1,OPTR
	MOVE	2,DIRINF+.CDLLD	;DATE OF LAST LOGIN
	MOVEM	2,DATES
	MOVE	3,DIRINF+.CDMOD		;GET MODE BITS
	TDNE	3,[CD%DIR!CD%RTD]	;SKIP UNLESS FILES ONLY.
	JRST	FONLY
	JUMPE	2,NEVER		;NEVER LOGGED IN
	HRLZI	3,(1B10)		;SUPPRESS SECONDS
	ODTIM
	JRST	DATOK

NEVER:	HRROI	2,[ASCIZ/NEVER          /]
	HRRZI	3,0
	SOUT
	JRST	DATOK

FONLY:	HRROI	2,[ASCIZ/FILES          /]
	HRLZI	3,377777
	MOVEM	3,DATES
	SETZ	3,
	SOUT
DATOK:	HRRZ	2,DIRINF+.CDPRV	;GET PRIVILIGE BITS
	JUMPE	2,DATOK1		;NONE
	MOVE	3,[NO%MAG!NO%LFL!10B17!10]  ;RADIX 8, 8 PLACES
	NOUT
	ERJMP	.+1
	JRST	DATOK2

DATOK1:	HRROI	2,[ASCIZ/        /]	;8 spaces
	MOVEI	3,0
	SOUT
DATOK2:	MOVE	2,DIRINF+.CDMOD		;ANY SPECIAL BITS?
	MOVEM	2,savmod#
	ANDI	2,SPECBT		;KEEP RELEVANT BITS
	JUMPE	2,DATOK3		;SKIP IF ZERO
	MOVE	3,[NO%MAG!NO%LFL!10B17!10]	;RADIX 8, 8 PLACES
	NOUT
	ERJMP	.+1
	JRST	DATOK4

DATOK3:	HRROI	2,[ASCIZ/        /]	;8 spaces
	MOVEI	3,0
	SOUT
DATOK4:	HRRZI	3,0
	IDPB	3,1
	MOVEM	1,OPTR
	MOVE	2,LISTFF	;GET FIRST FREE ADDRESS.
	MOVEM	2,@PRVLNK	;STORE IN PREVIOUS LINK OUT
	MOVEM	2,PRVLNK
	SETZM	L.LINK(2)	;ZERO NEW LINK OUT
	MOVE	3,DISKS
	MOVEM	3,L.DISK(2)	;STUFF DISK USAGE
	MOVE	3,DATES
	MOVEM	3,L.DATE(2)	;STUFF DATE
	AOS	3,SEQNUM
	MOVEM	3,L.ANUM(2)	;STORE SEQUENCE NUMBER OF ALPHA SORT
	MOVE	3,savmod
	movem	3,l.mode(2)	;mode word of user
	HRRZ	4,OPTR		;ADDRESS OF LAST WORD OF STRING
	SUBI	4,ONAME		;NUMBER OF WORDS IN STRING-1
	ADDI	4,L.TEXT+1(2)	;ENDING ADDRESS OF BLT+1
	HRLZI	3,ONAME		;SOURCE
	HRRI	3,L.TEXT(2)
	BLT	3,-1(4)		;MOVE STRING.
	MOVEM	4,LISTFF	;NEXT FREE ADDRESS FOR LIST
	MOVE	16,PRVLNK	;POINT TO NEWEST RECORD
	push	p,ojfn
	movei	a,.priou
	movem	a,ojfn
	PUSHJ	P,ODOIT
	pop	p,ojfn
	HRRZ	A,DIRINF+.CDPRV		;SPECIAL USER?
	JUMPE	A,NSPEC			;NO
	SKIPN	SPJFN			;JFN TO WRITE SPECIALS?
	JRST	NSPEC			;NO.
	PUSH	P,OJFN
	MOVE	A,SPJFN
	MOVEM	A,OJFN
	MOVE	16,PRVLNK
	PUSHJ	P,ODOIT
	POP	P,OJFN
NSPEC:
	MOVE	C,RCDDIR		;previous dir num
	hrroi	b,rcdwls	;points to wild card string
	MOVSI	A,(RC%AWL!RC%STP)
	RCDIR
	TLNN	A,(RC%NMD)
	TLNE	A,(RC%NOM!RC%AMB)
	JRST	DONE
	movem	c,rcddir
	JRST	LOOP
	
DONE:	SKIPN	A,SPJFN
	JRST	DONE1
	SETZM	SPJFN
	CLOSF
	ERJMP	.+1
DONE1:	MOVE	A,PARMS
	TRNN	A,1			;ALPHA SORT WANTED?
	JRST	DATREP			;NO.
	MOVEI	1,[ASCIZ/DISK USAGE - ALPHABETICALLY BY DIRECTORY NAME
/]
	MOVEM	1,HEADER
	SETZM	SPECFL
	PUSHJ	P,OUTLST		;OUTPUT CURRENT LIST
	PUSHJ	P,OUTTOT		;OUTPUT TOTALS
	MOVE	1,OJFN
	HRRZI	2,14
	BOUT
DATREP:	MOVE	A,PARMS
	TRNN	A,2			;DATE SORT WANTED?
	JRST	SIZREP			;NO
	PUSHJ	P,DATSOR
	HRRZI	1,[ASCIZ/DISK USAGE BY DATE OF LAST LOGIN
/]
	MOVEM	1,HEADER
	SETZM	SPECFL
	PUSHJ	P,OUTLST
	MOVE	1,OJFN
	HRRZI	2,14
	BOUT
SIZREP:	MOVE	A,PARMS
	TRNN	A,4			;SIZE REPORT WANTED?
	JRST	EXREP			;NOPE.
	HRRZI	1,[ASCIZ/DISK USAGE BY AMOUNT OF USAGE
/]
	MOVEM	1,HEADER
	SETOM	SPECFL
	PUSHJ	P,DSKSOR
	PUSHJ	P,OUTLST
	MOVE	1,OJFN
	HRRZI	2,14
	BOUT
EXREP:	MOVE	A,PARMS
	TRNE	A,10
	pushj	p,luzrep
	MOVE	1,OJFN
	CLOSF
	JFCL
	HALTF

LUZREP:	MOVEI	1,[ASCIZ/Losers, never logged, and files only
/]
	MOVEM	1,header
	pushj	p,datsor
	MOVE	16,LISTHD		;POINTER TO FIRST ITEM
LUZ1:	MOVE	1,OJFN
	HRRO	2,HEADER
	HRRZI	3,0
	SOUT
	MOVE	1,OJFN
	HRROI	2,[ASCIZ/
DIRECTORY NAME                            NUMBER     USED   PERM   WORK  LAST LOGIN          CAPS  CUM. USED

/]
	SETZB	3,LINECT
	SOUT
LUZ2:	PUSHJ	P,LUZTST		;IS THIS PRINTABLE?
	JRST	LUZ3			;NOPE
	PUSHJ	P,ODOIT
	SKIPN	16,(16)
	JRST	LUZ4
	AOS	1,LINECT
	CAIGE	1,66
	JRST	LUZ2
	MOVE	1,OJFN
	HRRZI	2,14
	BOUT
	JRST	LUZ1

LUZ3:	SKIPE	16,(16)
	JRST	LUZ2
LUZ4:	MOVE	1,OJFN
	MOVEI	2,14
	BOUT
	POPJ	P,

LUZTST:	MOVE	1,l.mode(16)
	Tdne	1,[cd%upd]	;update needed?
	JRST	CPOPJ1		;yes.  print luzer
	MOVE	1,l.date(16)
	JUMPE	1,CPOPJ1	;never
	CAMn	1,[377777,,777777]
	JRST	CPOPJ1
	popj	p,
OUTTOT:	HRROI	2,[ASCIZ/       /]	;7 SPACES
	MOVE	1,OJFN
	HRRZI	3,0
	SOUT
	HRROI	2,SPACE
	MOVE	1,OJFN
	HRRZI	3,0
	SOUT
	HRROI	2,[ASCIZ/--------------------
TOTALS:/]
	HRRZI	3,0
	MOVE	1,OJFN
	SOUT
	HRROI	2,SPACE
	MOVE	1,OJFN
	HRRZI	3,0
	SOUT
	MOVE	2,DTOT
	MOVE	3,[100006,,12]
	NOUT
	JFCL
	HRRZI	2,40
	BOUT
	MOVE	2,PTOT
	MOVE	3,[100006,,12]
	NOUT
	JFCL
	HRRZI	2,40
	BOUT
	MOVE	2,WTOT
	MOVE	3,[100006,,12]
	NOUT
	JFCL
	MOVE	1,OJFN
	HRROI	2,CRLF
	HRRZI	3,0
	SOUT
	POPJ	P,

OUTLST:	MOVE	16,LISTHD		;POINTER TO FIRST ITEM
	SETZM	CUMDSK		;CUMULATIVE DISK TOTAL
	SETZM	CUMDIR		;CUM. DIRECTORY COUNT
PAGELP:	MOVE	1,OJFN
	HRRO	2,HEADER
	HRRZI	3,0
	SOUT
	MOVE	1,OJFN
	HRROI	2,[ASCIZ/
DIRECTORY NAME                            NUMBER     USED   PERM   WORK  LAST LOGIN          CAPS  CUM. USED

/]
	HRRZI	3,0
	SOUT
	SETZM	LINECT
OLP:	SKIPN	SPECFL#		;SPECIAL THIS TIME?
	JRST	OLP0		;Normal listing
	PUSHJ	P,ODOSPC
	JRST	OLP1		;something was printed.  count it.
	SKIPN	16,(16)		;nothing was printed.  advance to next
	POPJ	P,		;no next
	JRST	OLP		;loop again

OLP0:	PUSHJ	P,ODOIT
OLP1:	SKIPN	16,(16)
	POPJ	P,
	AOS	1,LINECT
	CAIGE	1,66
	JRST	OLP
	MOVE	1,OJFN
	HRRZI	2,14
	BOUT
	JRST	PAGELP

ODOSPC:	MOVE	7,L.DISK(16)
	CAML	7,ATHRES		;above the threshold?
	JRST	ODOIT			;yes
	ADDM	7,CUMDSK		;not worth printing, but count it
	AOS	(P)			;signal nothing was printed.
	POPJ	P,

ODOIT:	MOVE	1,OJFN
	HRROI	2,L.TEXT(16)
	HRRZI	3,0
	SOUT
	MOVE	7,L.DISK(16)
	ADDB	7,CUMDSK
	HRRZI	2,40
	BOUT
	BOUT
	MOVE	2,7
	MOVE	3,[100006,,12]
	NOUT
	JFCL
	AOS	2,CUMDIR
	MOVE	3,[100010,,12]
	NOUT
	JFCL
	HRROI	2,CRLF
	SETZ	3,
	SOUT
	POPJ	P,

;SORT LIST ADDRESSED BY REGISTER 1.  RESULT TO REGISTER 1
SORT:	JUMPE	1,CPOPJ
	SKIPN	(1)
	POPJ	P,		;NO SECOND ELEMENT
	HRRZI	2,(1)		;ODD LIST HEAD
	MOVE	3,(1)		;EVEN LIST HEAD
	MOVE	4,2		;TAIL OF ODD LIST
	MOVE	5,3		;TAIL OF EVEN LIST
	MOVE	6,(2)		;ADDRESS OF SECOND ELEMENT
SORT1:	MOVE	6,(6)		;ADVANCE IN LIST
	MOVEM	6,(4)		;STORE ON ODD LIST
	MOVE	4,6		;ADVANCE ODD LIST
	JUMPE	6,SORT2		;JUMP IF DONE
	MOVE	6,(6)
	MOVEM	6,(5)		;STORE ON EVEN LIST
	MOVE	5,6		;ADVANCE EVEN LIST
	JUMPN	6,SORT1		;JUMP UNLESS DONE
SORT2:	PUSH	P,2		;SAVE ONE LIST
	MOVE	1,3		;GET OTHER LIST
	PUSHJ	P,SORT		;SORT ONE LIST
	EXCH	1,(P)		;SAVE SORTED LIST.  GET UNSORTED ONE
	PUSHJ	P,SORT		;SORT ANOTHER LIST
	POP	P,2		;SORTED LISTS IN 1 AND 2!
	MOVE	3,1		;NOW 2 AND 3
	HRRZI	4,1		;POINTER TO "TAIL"
MLP:	PUSHJ	P,SCOM
	EXCH	2,3		;MAKE 2 THE SMALLER ELEMENT
	MOVEM	2,(4)		;STORE LIST HEAD INTO TAIL OF COMPOSITE
	HRRZI	4,(2)		;ADVANCE LIST TAIL
	MOVE	2,(2)		;TAKE CDR OF "SMALL" LIST
	JUMPN	2,MLP		;CONTINUE MERGE
	MOVEM	3,(4)		;STORE ENTIRE OTHER LIST IN TAIL
	POPJ	P,

SCOM:	XCT	FETCH1		;14:=DATUM(2)
	XCT	FETCH2		;15:=DATUM(3)
	CAMGE	14,15
	JRST	CPOPJ1
	CAME	14,15
	POPJ	P,
	MOVE	14,L.ANUM(2)	;TIEBREAKER
	MOVE	15,L.ANUM(3)
	CAMGE	14,15
CPOPJ1:	AOS	(P)
CPOPJ:	POPJ	P,


DSKSOR:	MOVE	14,[MOVE 14,L.DISK(2)]
	MOVE	15,[MOVE 15,L.DISK(3)]
	JRST	SORCOM

DATSOR:	MOVE	14,[MOVE 14,L.DATE(2)]
	MOVE	15,[MOVE 15,L.DATE(3)]
SORCOM:	MOVEM	14,FETCH1
	MOVEM	15,FETCH2
	MOVE	1,LISTHD
	PUSHJ	P,SORT
	MOVEM	1,LISTHD
	POPJ	P,

ASUPPRESS
END START