From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 25-SEP-1990 02:09:06.44
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Re: How do you know your INDEXF.SYS's status

Received:  by crdgw1.ge.com (5.57/GE 1.73)
	 id AA29982; Tue, 25 Sep 90 01:57:00 EDT
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Mon, 24 SEP 90 22:05:55 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA29034; Mon, 24 Sep 90 21:52:48 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 24 Sep 90 12:13:56 GMT
From: swrinde!cs.utexas.edu!execu!sequoia!uudell!bigtex!texsun!csccat!egsner!montagar!davidc@ucsd.edu  (David L. Cathey, SYSOP)
Organization: Public Access VAX/VMS BBS, Plano TX
Subject: Re: How do you know your INDEXF.SYS's status
Message-Id: <4862@montagar.lonestar.org>
References: <0093d1a5.709cce00.2172@SOL1.GPS.CALTECH.EDU>, <4846@montagar.lonestar.org>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


	Here is a program that will provide a count of total headers in
the INDEXF.SYS and the number of free headers that are left for SYS$DISK:.
Note that it will only provide information on SYS$DISK, I didn't take the
time to make a nifty user interface...  Also, it does not flush the cache,
and that can effect the number of free headers somewhat.

- 8< cut here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	.title	HEADERCNT
;++
;
;	HEADCNT	-- Count the number of free headers in the INDEXF.SYS
;
; Author:	David L. Cathey
; Date:		23-SEP-1990
; Copyright:	1990, Montagar Software Concepts
;
;	Note:  This software is intended as an example only.  No warranties
;	as to its usability are implied.  It's free and you get what you pay
;	for!  This software may be freely distributed as long as it is
;	accompanied by the copyright notice.
;--

	.library	/SYS$LIBRARY:LIB/
	$HM2DEF			; Home Block (ODS-2) Definitions
	;
	; Some home grown macros...  
	;
	.MACRO	_STKDEF	SYM,ALLOC,SIZ
	.IIF	NB,ALLOC,	ALLOC	SIZ
	.IIF	NB,SYM,	SYM = - .
	.ENDM	_STKDEF
	.MACRO	_STKEND
	STACK_K_LENGTH = - .
	.CROSS
	.RESTORE
	addl2	#STACK_K_LENGTH,sp
	.ENDM	_STKEND
	.MACRO	_STKINI
	.SAVE	LOCAL_BLOCK
	.NOCROSS
	.PSECT	_ABS_,ABS
	.ENDM	_STKINI
	.macro	_ILDEF
	$DEFINI	IL
	$DEF	IL_BUFLEN	.blkw	1
	$DEF	IL_CODE		.blkw	1
	$DEF	IL_ADDR		.blkl	1
	$DEF	IL_RETLEN	.blkl	1
	$EQU	IL_LENGTH	.
	$DEFEND	IL
	.macro	_ILDEF
	.endm	_ILDEF
	.endm	_ILDEF
	_ILDEF
	.macro	ITMLST_ITEM	code,buflen,bufadr,retlen=0
	movw	code,IL_CODE+<ITEM_NUMBER*IL_LENGTH>(r0)
	movw	buflen,IL_BUFLEN+<ITEM_NUMBER*IL_LENGTH>(r0)
	moval	bufadr,IL_ADDR+<ITEM_NUMBER*IL_LENGTH>(r0)
	.if	IDN <0> <retlen>
	.iff
	moval	retlen,IL_RETLEN+<ITEM_NUMBER*IL_LENGTH>(r0)
	.endc
	ITEM_NUMBER = ITEM_NUMBER + 1
	.endm	ITMLST_ITEM
	.macro	ITMLST_START	itmlst,count
	_ILDEF
	pushr	#^M<r2,r3,r4,r5>
	movc5	#0,(sp),#0,#<count*IL_LENGTH>,itmlst
	popr	#^M<r2,r3,r4,r5>
	movab	itmlst,r0
	ITEM_NUMBER = 0
	.endm	ITMLST_START

i_fab:		$FAB	dnm=<[000000]INDEXF.SYS>,fac=<bio,get>,fop=<bio>, -
			shr=<get,put,upd,upi>
i_rab:		$RAB	fab=i_fab

sys$disk:	.ascid	/SYS$DISK:/

;++
;	Entry point
;--
	.enable	local_block
	.entry	Main,0
_STKINI
_STKDEF	FP_ITMLST	.blkb	<3*IL_LENGTH>	; 3 element item list
_STKDEF	FP_DEVNAM	.blkb	16		; full device name
_STKDEF	FP_DEVNAMLEN	.blkl	1		; full device name length
_STKEND
	ITMLST_START	FP_ITMLST(fp),count=3
	ITMLST_ITEM	code=#DVI$_FULLDEVNAM, -
			buflen=#16, -
			bufadr=FP_DEVNAM(fp), -
			retlen=FP_DEVNAMLEN(fp)	; Get SYS$DISK device name
	$GETDVIW_S	devnam=sys$disk, -
			itmlst=FP_ITMLST(fp)
	blbc	r0,999$
	$FAB_STORE	fab=i_fab, -
			fna=FP_DEVNAM(fp), -	; Fill in FAB
			fns=FP_DEVNAMLEN(fp)
	$OPEN		fab=i_fab
	blbc	r0,999$				; Access INDEXF.SYS
	$CONNECT	rab=i_rab
	blbc	r0,999$
	calls	#0,Process_INDEXF		; Process the INDEXF.SYS
999$:
	ret
	.page
;++
;	Process the INDEXF...
;--
	.enable	local_block
	.entry	Process_INDEXF,^M<r6,r7,r8,r9,r10,r11>
_STKINI
_STKDEF	FP_DESC		.blkq	1		; Output descriptor
_STKDEF	FP_BUFFER	.blkb	132		; Output Buffer
_STKDEF	FP_HOMEBLK	.blkb	512		; HOME Block Buffer
_STKEND
	$RAB_STORE	rab=i_rab, -
			ubf=FP_HOMEBLK(fp), -
			usz=#512, -
			bkt=#2			; Get HOME block
	$READ 	rab=i_rab
	blbs	r0,5$
	brw	999$
5$:
	movab	FP_HOMEBLK(fp),r6		; Get address of HM in r6
	movzwl	HM2$W_IBMAPSIZE(r6),r7
	mull2	#512,r7				; Compute stack required for BM
	subl2	r7,sp				; Free up stack space
	movab	FP_HOMEBLK(fp),r11
	subl2	r7,r11				; Calculate stack buffer address
	movzwl	HM2$W_IBMAPVBN(r6),r10		; Get index bit map VBN
	$RAB_STORE	rab=i_rab, -
			ubf=(r11), -
			usz=r7, -		; Set up RAB for trasfer
			bkt=r10
	$READ	rab=i_rab			; Get bit map...
	blbc	r0,999$

	clrl	r8				; Clear r8 (bit number)
	clrl	r9				; # of free headers
10$:	ffc	r8,#32,(r11),r8			; Find a free header
	cmpl	r8,i_fab+FAB$L_ALQ		; Out of bounds of INDEXF ALQ?
	bgtr	20$				; Yes, done!
	incl	r9				; Increment # free headers
	incl	r8				; Skip this bit, now...
	brb	10$				; Find another
20$:
	movzwl	HM2$W_IBMAPVBN(r6),r8		; Get bit map VBN,
	movzwl	HM2$W_IBMAPSIZE(r6),r1		; and bit map size,
	subl3	r8,i_fab+FAB$L_ALQ,r11		; subtract # blocks in INDEXF to
	subl2	r1,r11				; first actual header from ALQ
	movab	FP_BUFFER(fp),FP_DESC+4(fp)
	movl	#132,FP_DESC(fp)
	$FAO_S	ctrstr=1000$, -
		outlen=FP_DESC(fp), -
		outbuf=FP_DESC(fp), -		; Format output buffer
		p1=r11, -
		p2=r9
	blbc	r0,999$

	pushaq	FP_DESC(fp)			; Output results...
	calls	#1,g^LIB$PUT_OUTPUT
999$:
	ret

1000$:	.ascid	/Number of headers: !SL, Number of free headers: !SL/

	.end	Main
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
David L. Cathey		                |INET: davidc@montagar.lonestar.org
"Can't have everything, where would you |UUCP: ...!letni!montagar!davidc
put it?"-Steven Wright "Everywhere!"-Me |Fone: (214)-618-2117

