.title Mount / Dismount / Verify Logical Disks ; DECUS C Calling Format ; ; jsr r5,csv$ ;save r2,r3, and r4 ; ;r5 is parameter base ; ;c$pmtr(r5) is first argument ; ;c$pmtr+2(r5) is second argument ; ;... ; ;return args in r0 ; ... ; user code ; ... ; ; jmp cret$ ;restore r2-r5 and return ; rts pc ;does the same (cret$ follows csv$) ; ; csv$ and cret$ need be used only if arguments are used ; .include "os.mac" .mcall .close ; Mount / Dismount Errors ; ; 1 - Channel in use (17 used internally) ; 2 - Invalid logical disk unit number (must be 0-7) ; 3 - Logical Disk support not generated into system ; 4 - Logical Disk unit associated with file ; 5 - Invalid file specification ; 6 - Invalid logical unit numbering ; 7 - Unable to open specified file .if ne ts$sys ; tsx-plus specific ; Mount a Logical Disk ; ; int mlogcl(unit, rad50-file-spec, read-only flag); MDVCHNL = 17 ; channel .psect c$code mlogcl:: jsr r5,csv$ movb c$pmtr(r5),ldmunt ; load unit mov c$pmtr+2(r5),ldnam ; address of rad50 file spec clrb ldrwfg ; default to read/write tst c$pmtr+4(r5) ; check read-only beq 1$ incb ldrwfg ; set read-only 1$: mov #ldmnt,r0 br logicl .psect c$data ldmnt: .byte MDVCHNL,163 ; mount logical disk ldmunt: .byte 0 ; unit number ldrwfg: .byte 0 ; read only flag ldnam: .word 0 ; file-name-pointer ; Dismount the Logical Disk ; ; int dlogcl(unit); .psect c$code dlogcl:: jsr r5,csv$ movb c$pmtr(r5),lddunt ; set unit number mov #lddsmt,r0 ; dismount disk br logicl .psect c$data lddsmt: .byte 3,135 ; dismount logical disk lddunt: .byte 0,0 ; unit number ; Do Function and Report any Error .psect c$code errbyt = 52 ; system error byte logicl: emt 375 ; execute function bcs 1$ ; on error skip clr r0 ; good return rts pc 1$: clr r0 bisb @#errbyt,r0 inc r0 ; error return rts pc ; Verify the file is a logical device ; ; int vlogcl(unit); .psect c$code vlogcl:: jsr r5,csv$ mov #^rLD0,ldunit add c$pmtr(r5),ldunit mov #ldlook,r0 emt 375 ; lookup ldn: bcs 3$ mov #ldread,r0 emt 375 ; read home block bcs 3$ cmp #6,ldbuff+724 ; first directory segment bne 3$ mov #12.,r0 ; verify system mov #ldbuff+760,r1 mov #ldsyid,r2 1$: cmpb (r1)+,(r2)+ bne 3$ sob r0,1$ 2$: .close #MDVCHNL clr r0 rts pc 3$: .close #MDVCHNL mov #1,r0 rts pc .psect c$data ldlook: .byte MDVCHNL,1 ; .lookup .word ldunit .word 0 ldunit: .rad50 /LD0/ ; device .word 0,0,0 ldread: .byte MDVCHNL,10 ; .readw .word 1 ; read home block .word ldbuff ; buffer .word 256. .word 0 ldbuff: .blkw 256. .psect c$strn ldsyid: .ascii /DECRT11A / ; system id [12 characters] ; Determine the Home directory ; ; char **hlogcl(); ; ; Returns a pointer to a list of pointers. ; The data is the rad50 file specs leading to the ; default directory. .psect c$code hlogcl:: jsr r5,csv$ mov #dklook,r0 emt 375 ; lookup DK: bcs 8$ mov #dkstat,r0 emt 375 ; get DK: status bcs 8$ mov #dkdev,r3 ; make rad50 device name add dkunit,(r3) add (pc)+,(r3) .rad50 / 0/ clr r4 ; pointer counter 1$: mov r3,-(sp) ; save mov r3,r2 mov (r2),r3 ; check if device is a logical unit cmp #^rLD ,r3 beq 2$ sub #^rLD0,r3 cmp r3,#7 bhi 4$ ; no - physical device 2$: bic #^C7,r3 ; mask unit number mov r3,ldnmbr ; load number asl r3 mov r3,-(sp) ; x2 asl r3 asl r3 ; x8 add (sp)+,r3 ; x10 add #ldtabl,r3 ; table pointer mov r3,ldbufr ; load pointer mov #ldstat,r0 emt 375 ; get ld status tst r4 ; first entry ? bne 3$ ; no - skip tst (sp)+ ; dump default 3$: inc r4 br 1$ 4$: tst r4 bne 5$ ; no ld units inc r4 5$: mov #ldlist,r3 6$: mov (sp)+,(r3)+ ; copy sequence sob r4,6$ clr (r3)+ ; terminate list 7$: .close #MDVCHNL mov #ldlist,r0 rts pc 8$: .close #MDVCHNL clr r0 rts pc .psect c$data dklook: .byte MDVCHNL,1 ; .lookup .word 1$ .word 0 1$: .rad50 /DK / ; device .word 0,0,0 dkstat: .byte MDVCHNL,27 ; .cstat .word 1$ 1$: .blkw 4 ; .cstat status dkunit: .word 0 ; unit number dkdev: .rad50 /DK / ; device name .word 0,0,0 ldstat: .byte 4,135 ; ld status ldnmbr: .byte 0,0 ; unit number ldbufr: .word 0 ldtabl: .blkw 5 ; rad50 LDn: associations .blkw 5 .blkw 5 .blkw 5 .blkw 5 .blkw 5 .blkw 5 .blkw 5 ldlist: .blkw 9. ; list of pointers .endc .if ne rt$sys ; rt-11 specific ; Mount a Logical Disk ; ; int mlogcl(unit, rad50-file-spec, read-only flag); MDVCHNL = 17 ; channel .psect c$code mlogcl:: mov #3,r0 ; not in RT-11 br logicl ; Dismount the Logical Disk ; ; int dlogcl(unit); .psect c$code dlogcl:: clr r0 ; always br logicl ; Do Function and Report any Error .psect c$code errbyt = 52 ; system error byte logicl: rts pc ; Verify the file is a logical device ; ; int vlogcl(unit); .psect c$code vlogcl:: mov #1,r0 ; never !!! rts pc ; Determine the Home directory ; ; char **hlogcl(); ; ; Returns a pointer to a list of pointers. ; The data is the rad50 file specs leading to the ; default directory. .psect c$code hlogcl:: jsr r5,csv$ mov #dklook,r0 emt 375 ; lookup DK: bcs 1$ mov #dkstat,r0 emt 375 ; get DK: status bcs 1$ mov #dkdev,r3 ; make rad50 device name add dkunit,(r3) add (pc)+,(r3) .rad50 / 0/ .close #MDVCHNL mov #ldlist,r0 mov r3,(r0) rts pc 1$: .close #MDVCHNL clr r0 rts pc .psect c$data dklook: .byte MDVCHNL,1 ; .lookup .word 1$ .word 0 1$: .rad50 /DK / ; device .word 0,0,0 dkstat: .byte MDVCHNL,27 ; .cstat .word 1$ 1$: .blkw 4 ; .cstat status dkunit: .word 0 ; unit number dkdev: .rad50 /DK / ; device name .word 0,0,0 ldlist: .word dkdev ; list of pointers .word 0 .endc .end