.MCALL .MODULE .MODULE CKFS,VERSION=08,COMMENT= ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .ENABL GBL,LC .SBTTL Macro definitions .MCALL .DSTATUS, .FETCH, .SETTOP .MCALL FDBDF$, FERDF$, DEFIN$ FDBDF$ ;Define FDB offsets FERDF$ ;Define file service error codes DEFIN$ ;Definitions for IND files .PSECT $CKFS .SBTTL $CKIFS/$CKOFS - Check input/output file specification ;+ ;$CKIFS ;Check input file specification ; ;$CKOFS ;Check output file specification ; ; Input: R1 -> Address of FDB ; R2 -> Address of 4 word RAD50 file specification ; ; Output: R1 -> Address of FDB ; R2 -> Address of 4 word RAD50 file specification ; C-bit set if error ; ;R0 is destroyed ;- .ENABL LSB $CKIFS::CALL $FDINZ ;Initialize FDB BCS 35$ ;Branch out if error BIT #,R0 ;Is the device write-only? BNE 5$ ;Yes CMPB F$STAT(R1),#DEV.TT ;Is device the console terminal? BEQ 25$ ; if so, don't require filename. CALL ISFLST ;Is device file structured? BNE 15$ ;If so, check for filename BR 5$ ;Error if not $CKOFS::CALL $FDINZ ;Initialize the FDB BCS 35$ ;Branch out if error BIT #,R0 ;Is the device read-only? BEQ 10$ ;No 5$: MOV #,F$ERR(R1) ;Set code for invalid device or unit BR 30$ ;Set the C-bit for error and return 10$: CALL ISFLST ;Is device file structured? BEQ 25$ ;If so, don't worry about filenames 15$: TST F$FNAM(R1) ;Is the file name specified? BNE 25$ ;Yes 20$: MOV #,F$ERR(R1) ;Set error code for bad file name 25$: TST (PC)+ ;Clear c bit to indicate success 30$: SEC ;Set C-bit for error 35$: RETURN ; What kind of device are we going to allow IND to work with? ; Do a Bit-test and return. The caller can then do BEQ or BNE. ISFLST::BIT #,F$STAT(R1) ; File structured device? RETURN .DSABL LSB .SBTTL $FDINZ - Initialize FDB ;+ ;$FDINZ ;This routine checks the validity of the device/file and initializes the FDB. ; ; Input: R1 -> Address of FDB ; R2 -> Address of 4 word RAD50 file specification ; ; Output: R0 = Device status word ; R1 -> Address of FDB ; R2 -> Address of 4 word RAD50 file specification ; ; C-bit is set if error has occured otherwise it is cleared. ;- .ENABL LSB $FDINZ: SAVE TSTB F$FLGS(R1) ;Is the file already open? BEQ 1$ ;No MOV #,F$ERR(R1) ;Store error condition in FDB BR 6$ ;Branch to error clean up 1$: .DSTATUS #DVINFO,R2 ;Get device information BCS 7$ ;Error MOV @R0,-(SP) ;Save status for return to caller CMPB #4,@R0 ;Console terminal BEQ 2$ ;Branch out if yes MOV @R0,-(SP) ; get DSTAT word BIC #^C,@SP ; interesting bits CMP (SP)+,# ; pseudohandler? BEQ 7$ ; don't allow those TST 4(R0) ;Is the device resident? BNE 2$ ;Yes, initialize MOV PRGEND,R0 ;Get address of next available space ADD DVINFO+2,R0 ;Add in the handler size .SETTOP CMP R0,PRGEND ;Check for room BLOS 6$ ;Branch with error if no room .FETCH PRGEND,R2 ;Fetch the handler MOV R0,PRGEND ;Update the end of program plus handlers 2$: MOV #F$SIZE-1,-(SP) ;Number of bytes to zero MOV R1,R3 ;Copy FDB address INC R3 ;Step past channel number 3$: CLRB (R3)+ ;Zero the entry DEC @SP ; ... BNE 3$ ; ... TST (SP)+ ;Clean up the stack MOV #-1,F$BLKN(R1) ;Initialize block number in FDB MOV R1,R3 ;Copy FDB address ADD #F$DNAM,R3 ;Point to descriptor in FDB MOV (R2)+,(R3)+ ;Copy device name to FDB MOV DVINFO,F$STAT(R1) ;Save device status in FDB CALL ISFLST ;Is it file structured? BEQ 5$ ;Branch if not. 4$: MOV (R2)+,(R3)+ ;Copy file name to FDB MOV (R2)+,(R3)+ ; ... MOV (R2)+,(R3)+ ;Copy file type to FDB 5$: RESTOR RETURN ;+ ;Error processing routine for this module. ;- 6$: MOV #,F$ERR(R1) ;No space for handler BR 8$ ;Join common error exit code 7$: MOV #,F$ERR(R1) ;Set invalid device or unit error code 8$: MOV R1,R3 ;Point to FDB area ADD #,R3 ;Point to descriptor in FDB MOV (R2)+,(R3)+ ;Move the device name in SEC ;Set c-bit for error BR 4$ ;Move in rest of filespec .DSABL LSB .END