; FUNCTION LOGDSK(UNIT,FILBLK,SIZE,WRLOCK,AVAIL) ; INTEGER UNIT,FILBLK(4),SIZE,WRLOCK,AVAIL ; ; This subroutine gets information of a logical disk unit LDn: ; ; Input arguments: ; UNIT : contains the LD unit number of which info is wanted ; ; Output arguments: ; FILBLK : contains the physical device and file name in Radix50 ; or 4 zero words when the LD unit is not mounted ; SIZE : contains the size of the file in blocks ; WRLOCK : 0 if write enabled, -1 if write locked ; AVAIL : 0 if file available, -1 if not, +1 if handler not loaded ; ; Function value: ; 0 : normal return ; -1 : error reading LD translation tables ; -2 : no channel available .TITLE LOGDSK .PSECT USER$I .MCALL .CSTAT,.DSTAT,.LOOKUP,.SPFUN,.PURGE,.SERR,.HERR LOGDSK:: MOV #-2,FUNVAL ; initialize function value .SERR ; disable EMT error abortion MOV #15,CHAN ; init channel number STAT: .CSTAT #AREA,CHAN,#HANDLR ; get channel status BCS LOOK ; channel not open, use it DEC CHAN ; other channel number BGE STAT ; try channel BR RETURN ; no channel free, return LOOK: INC FUNVAL ; set function value to -1 .LOOKUP #AREA,CHAN,#DBLK ; open channel to LD handler BCS PURG ; branch if LOOKUP failed .SPFUN #AREA,CHAN,#372,#HANDLR,#-1 ; read translation tables BCS PURG ; branch if SPFUN failed CLR FUNVAL ; clear function value PURG: .PURGE CHAN ; close channel TST FUNVAL ; check function value BLT RETURN ; return if error occurred MOV 4(R5),R3 ; get address of FILBLK argument CLR (R3)+ ; clear FILBLK argument CLR (R3)+ ; CLR (R3)+ ; CLR (R3)+ ; CLR @6(R5) ; clear SIZE argument CLR @10(R5) ; clear WRLOCK argument CLR @12(R5) ; clear AVAIL argument MOV @2(R5),R1 ; get desired LD unit number BIC #177770,R1 ; only 1 octal digit ASL R1 ; 2*UNIT is index in HANDLR table MOV R1,R2 ; ASL R2 ; ASL R2 ; 8*UNIT is index in NAME table MOV HANDLR(R1),R0 ; get word from HANDLR table SWAB R0 ; swap bytes BIT #200,R0 ; test allocation bit BEQ RETURN ; not allocated, branch BIT #40,R0 ; test write lock bit BEQ FNAM ; write enabled, branch DEC @10(R5) ; set WRLOCK argument to -1 FNAM: MOV 4(R5),R3 ; get address of FILBLK argument MOV NAME(R2),(R3)+ ; copy name to FILBLK argument MOV NAME+2(R2),(R3)+ MOV NAME+4(R2),(R3)+ MOV NAME+6(R2),(R3)+ BIC #177770,R0 ; clear all but physical unit number ADD #36,R0 ; convert to Radix50 ADD R0,@4(R5) ; insert physical unit number in name MOV SIZE(R1),@6(R5) ; copy size to SIZE argument INC @12(R5) ; set AVAIL argument to +1 ADD #NAME,R2 ; point to filename .SERR ; disable EMT error abortion .DSTAT #AREA,R2 ; get device status BCS RETURN ; device unknown, branch TST AREA+4 ; handler loaded? BEQ RETURN ; no, branch DEC @12(R5) ; clear AVAIL argument .LOOKUP #AREA,CHAN,4(R5) ; check availability of file BCC 10$ ; branch if available DEC @12(R5) ; set AVAIL argument to -1 10$: .PURGE CHAN ; purge channel to file RETURN: .HERR ; enable EMT error abortion MOV FUNVAL,R0 ; return function value RTS PC ; return AREA: .BLKW 6 CHAN: .WORD FUNVAL: .WORD DBLK: .WORD ^RLD0,0,0,0 HANDLR: .BLKW 10 OFFSET: .BLKW 10 SIZE: .BLKW 10 NAME: .BLKW 40 .END