Type ASSEMBLE
Source Lines : 844
Fixes Applied : 2
Most Recent Version : Tuesday, December 12, 1978
Last Fix ID : [HRC015DS]
Module
DMSFNS
Function
TO CLOSE ONE OR MORE INPUT OR OUTPUT DISK FILE(S).
Attributes
NUCLEUS RESIDENT, REENTRANT
Operation
DMSFNSA CHECKS THE CALLER'S PARAMETER LIST FOR '*' IN FILENAME OR FILETYPE, OR A NONALPHABETIC CHARACTER FOR THE MODE; IF ANY OF THESE CONDITIONS ARE MET, A FLAG IS SET TO CHECK FOR ADDITIONAL ENTRIES IN THE ACTIVE FILE TABLE. AFTER THIS PRELIMINARY CHECK, DMSFNSA CALLS DMSLAD TO FIND AN AFT BLOCK THAT MATCHES THE CALLER'S PARAMETER LIST. IF NONE IS FOUND, AN ERROR 6 IS GIVEN AS SHOWN IN THE EXIT CONDITIONS. IF A MATCH IS FOUND, A CHECK IS MADE TO DETERMINE WHETHER THE FILE IS AN ACTIVE WRITE, AN ACTIVE READ, OR NEITHER. IF NEITHER, IT WAS PLACED THERE BY POINT, BUT WAS NOT READ OR WRITTEN SUBSEQUENTLY. ACTION IS TAKEN IN THESE THREE CASES AS DESCRIBED IN THE FOLLOWING PARAGRAPHS. ACTIVE READ FILE IF THE FILE FOUND BY DMSLAD IS AN ACTIVE READ FILE, DMSFNSA TAKES THE FOLLOWING STEPS TO CLOSE THE FILE: 1. RELEASE TO FREE STORAGE THE 800-BYTE BUFFER USED FOR THE DATA BLOCK (VIA A CALL TO FRET). 2. ALSO RELEASE EITHER THE 200- OR 800-BYTE BUFFER CURRENTLY IN USE FOR THE CHAIN LINK. 3. IF THE FILE HAS A MODE NUMBER OF 3 (FOR EXAMPLE, A3), IT IS NOW ERASED UNLESS THE SUBSET INITIAL- IZATION FLAG IS ON. THIS IS DONE BY CALLING DMSFREE TO OBTAIN FREE STORAGE FOR A SUITABLE CALL TO DMSERS, THEN CALLING DMSERS TO ELIMINATE THE FILE AND THEN GIVING BACK THE FREE STORAGE VIA DMSFRET. CARE IS TAKEN TO PRESERVE INFORMATION TO AVOID RE-ENTERABILITY PROBLEMS BETWEEN DMSFNSA AND DMSERS. 4. NEXT, DMSLAFFT IS CALLED TO RELEASE THIS SLOT IN THE ACTIVE FILE TABLE. 5. FINALLY, IF EITHER THE FILENAME, FILETYPE, OR FILEMODE INDICATED THAT ADDITIONAL FILES SHOULD BE CHECKED. DMSFNSA RETURNS TO THE PORTION OF CODE WHICH CALLS DMSLAD, TO CHECK FOR ANY MORE AFT BLOCKS THAT MAY MATCH THE CALLER'S P-LIST. 6. FINALLY, WHEN ALL APPROPRIATE FILE(S) HAVE BEEN CLOSED, DMSFNSA GIVES A NORMAL RETURN AS INDICATED UNDER EXIT CONDITIONS. FILE ACTIVE FROM A POINT CALL FOR THIS CASE (ACTIVE BUT NEITHER A READ NOR A WRITE), DMSLAFFT IS CALLED, ETC., AS SHOWN ABOVE IN STEPS 4, 5, AND 6 FOR THE "ACTIVE READ FILE" CASE. ACTIVE WRITE FILE IF THE FILE FOUND BY DMSLAD IS AN ACTIVE WRITE FILE, DMSFNSA TAKES THE FOLLOWING STEPS TO CLOSE THE FILE: 1. CHECKS THE POINTER (AFTPFST) IN THE AFT BLOCK TO THE FST ENTRY (IF ANY) IN THE FST HYPERBLOCKS. IF NONZERO, PROCEED TO STEP 2. IF ZERO (AS IS THE CASE FOR A NEW FILE NEVER BEFORE CLOSED), THE SPECIAL FSTLKW ENTRY TO OBTAIN AN EMPTY 40-BYTE FST ENTRY IS CALLED, AND THE AFTPFST POINTER IS SET TO THE ADDRESS PROVIDED BY DMSLFSW. 2. MOVES THE 40-BYTE ENTRY FROM THE AFTFST SLOT IN THE AFT BLOCK TO ITS LOCATION WITHIN THE FST HYPERBLOCKS, SETS THE MODE-LETTER AND CLEARS THE FLAG-BYTE. 3. UNLESS THE FIRST FIVE LETTERS OF THE FILETYPE=SYSUT OR CMSUT, THE TIME OF DAY AND YEAR ARE COMPUTED IN THE SAME MANNER AS GETCLK, AND THE DATE-TIME STORED IN FSTD IN THE FST ENTRY, AND THE YEAR IN FSTYR. (IF THE FILETYPE INDICATES A UTILITY FILE IS BEING FINIS'ED, THIS STEP IS UNNECESSARY AND IS THEREFORE OMITTED.) 4. NEXT THE CURRENT DATA BLOCK POINTED TO BY AFTDBA IS WRITTEN ON DISK. 5. THEN THE FREE STORAGE BLOCK THAT WAS USED FOR THE DATA BLOCK IS RETURNED TO FREE STORAGE VIA DMSFRET. 6. IF THE FIRST CHAIN LINK IS NOT RESIDENT, THE CURRENT CHAIN LINK (UNLESS NULL) IS WRITTEN ON DISK, AND THE FIRST CHAIN LINK BROUGHT INTO CORE. 7. THE LINKAGE PORTION OF THE FIRST CHAIN LINK (AFTCLB) IS MOVED FROM THE AFT BLOCK TO THE FIRST CHAIN LINK, AND THE FIRST CHAIN LINK WRITTEN ON DISK. 8. THEN THE FREE STORAGE BLOCK USED FOR THE CHAIN LINK (EITHER 200 OR 800 BYTES IN LENGTH) IS RETURNED TO FREE STORAGE VIA DMSFRET. 9. THE WRITE POINTER IS COMPUTED AS THE NUMBER OF ITEMS PLUS ONE AND STORED IN THE FST ENTRY. 10. THE NUMBER OF ACTIVE WRITE FILES FOR THIS ACTIVE DISK TABLE (ADTNACW) IS DECREMENTED BY ONE. 11. IF THE NUMBER OF ACTIVE WRITE FILES (ADTNACW) IS NOW=0, THEN DMSAUDUD IS CALLED TO UPDATE THE FILE DIRECTORY FOR THIS ACTIVE DISK TABLE. 12. DMSLAFFT IS THEN CALLED TO RELEASE THIS SLOT IN THE ACTIVE FILE TABLE. 13. THEN IF EITHER THE FILENAME, FILETYPE, OR FILEMODE INDICATED THAT ADDITIONAL FILES SHOULD BE CHECKED, DMSFNSA RETURNS TO THE PORTION OF CODE THAT CALLS DMSLAD, TO CHECK FOR ANY MORE AFT BLOCKS THAT MAY MATCH THE CALLER'S P-LIST. 14. FINALLY, WHEN ALL APPROPRIATE FILE(S) HAVE BEEN CLOSED, DMSFNSA GIVES A NORMAL RETURN AS INDICATED UNDER EXIT CONDITIONS.
Calls to Other Routines
DMSLAFFT, DMSLAD, DMSERS, DMSFREE, DMSFRET, DMSLFSW, DMSDIOR, DMSAUD, DMSDIOW