.title getfilhdr Return file header record in indexf.sys file .sbttl History ; Author: R Eldridge ; 104 Computer Science ; Iowa State University ; Ames, IA 50011 ; (515) 294-5659 ; Created: Summer 1984 ; History: none. .page .sbttl Description ; Description: Return the file header record of the file id specified. ; Usage: status = get_file_header( area, device, buffer ) ; Input: area: storage area (see getfilhdr_area below) ; passed by reference ; ; io_chan: i/o channel ; if io_chan = 0 then open file ; ; file_id: file id ; if file_id = 0 then close file ; ; device: device name (string descriptor) ; passed by reference ; Output: status: integer ; return via r0 ; ; area: storage area (see getfilhdr_area below) ; passed by reference ; ; io_chan: resultant i/o channel assigned ; ; vbn_filehdr: vbn of start of filehdrs ; ; buffer: header record (string descriptor) ; passed by reference ; Registers: r6, r7: length and address of device string descriptor ; length and address of buffer string descriptor ; compute vbn of filehdr to read ; ; r7, r8: compute #blocks preceeding 1st filehdr ; ; r10: address of home block buffer ; ; r11: area(ap) .page .sbttl Data $HM2DEF $FIDDEF $RMSDEF $SSDEF .psect data,noexe,rd,wrt,long fab_indexf: $fab fnm=<[0,0]INDEXF.SYS>, - fac=, - mrs=512, - rtv=255, - shr=get rab_indexf: $rab fab=fab_indexf, - usz=512, - ubf=block block: .blkb 512 ; filehdr buffer $defini getfilhdr_area $def io_chan .blkw 1 ; i/o channel $def file_id .blkw 3 ; file id $def vbn_filehdr .blkl 1 ; vbn of start of filehdrs $defend .page .sbttl Main Procedure narg = 0 area = 4 device = 8 buffer = 12 .psect code,exe,rd,nowrt,long .entry get_file_header,^M ; check argument count cmpl #3,narg(ap) ; 3 or more arguments? bgeq 10$ ; yes movl #SS$_INSFARG,r0 ; not enough arguments ret ; return to caller ; initialize 10$: jsb INITIALIZE ; initialize blbc r0,99$ ; if error then return cmpl r0,#SS$_ENDOFFILE ; end of file? bneq 20$ ; no, find file id movl #SS$_NORMAL,r0 ; yes, return normal ret ; return to caller 20$: jsb READ ; find file id blbc r0,99$ ; if error then return ; return filehdr movq @buffer(ap),r6 ; string descriptor movc5 #512,block,#0,r6,(r7) ; move filehdr to buffer movl #SS$_NORMAL,r0 ; return normal 99$: ret ; return to caller .page .sbttl Procedure INITIALIZE INITIALIZE: movl area(ap),r11 ; area address ; if io_chan = 0 then open indexf.sys file tstw io_chan(r11) ; first time? beql 20$ ; yes, io_chan = 0 ; load i/o channel into fab movw io_chan(r11),fab_indexf+FAB$W_IFI ; if file_id = 0 then close file tstw file_id(r11) ; close file? beql 10$ ; yes, file_id = 0 movl #SS$_NORMAL,r0 ; no rsb ; disconnect rms and close file 10$: $disconnect - ; disconnect rms rab=rab_indexf blbc r0,99$ ; if error then return $close - ; close file fab=fab_indexf blbc r0,99$ ; if error then return movl #SS$_ENDOFFILE,r0 ; set end of file rsb ; use device name passed to set default device name 20$: movq @device(ap),r6 ; string descriptor moval (r7),fab_indexf+FAB$L_DNA ; default file name address movb r6,fab_indexf+FAB$B_DNS ; default file name size ; open file and connect rms $open - ; open file fab=fab_indexf blbc r0,99$ ; if error then return $connect - ; connect rms rab=rab_indexf blbc r0,99$ ; if error then return ; read the home block and compute m movl #2,rab_indexf+RAB$L_BKT ; skip boot block $read - ; read home block rab=rab_indexf blbc r0,99$ ; if error then return jsb CALCULATE ; calculate vbn of 1st filehdr ; save i/o channel movw fab_indexf+FAB$W_IFI,io_chan(r11) 99$: rsb .page .sbttl Procedure CALCULATE CALCULATE: ; compute m, the number of blocks preceeding the first file header ; m = 4 + int ((max_files + 4095) / 4096) movab block,r10 ; home block buffer movzwl HM2$W_CLUSTER(r10),r7 ; offset to 1st filehdr mull #4,r7 ; * 4 movl HM2$L_MAXFILES(r10),r8 ; max number of files addl #4095,r8 ; round up to next block divl #4096,r8 ; bitmap size in blocks addl3 r8,r7,vbn_filehdr(r11) ; vbn of 1st filehdr rsb .page .sbttl Procedure READ READ: ; if file_id > 0 then vbn = file_id + vbn_of_1st_filehdr tstw file_id(r11) ; + or - bgeq 10$ ; file_id is + ; if file_id < 0 then vbn = abs (file_id) movzwl file_id(r11),r6 ; file_id is - mnegl r6,r7 ; get abs value jmp 20$ ; calculate vbn of file id 10$: movzwl file_id(r11),r7 ; filedhr number addl vbn_filehdr(r11),r7 ; + vbn of 1st filehdr ; read filehdr 20$: movl r7,rab_indexf+RAB$L_BKT ; vbn of filehdr specified $read - ; read filehdr rab=rab_indexf rsb .end