     1                                  ;	SCCSID = @(#)close.asm	1.1 85/04/09
     2                                  ;TITLE	DOS_CLOSE/COMMIT - Internal SFT close and commit call for MSDOS
     3                                  ;NAME	DOS_CLOSE
     4                                  ; Internal Close and Commit calls to close a local or NET SFT.
     5                                  ;
     6                                  ;   DOS_CLOSE
     7                                  ;   DOS_COMMIT
     8                                  ;   FREE_SFT
     9                                  ;   SetSFTTimes
    10                                  ;
    11                                  ;   Revision history:
    12                                  ;
    13                                  ;	AN000  version 4.00  Jan. 1988
    14                                  ;	A005   PTM 3718 --- lost clusters when fastopen installed
    15                                  ;	A011   PTM 4766 --- C2 fastopen problem
    16                                  
    17                                  ;
    18                                  ; get the appropriate segment definitions
    19                                  ;
    20                                  [list -]
    20          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
    22                                  
    23                                  [list +]
    24                                  section DOSCODECODE
    25                                  [list -]
    25          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    25          ******************       warning: out: BPB.INC... [-w+user]
    25          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    25          ******************       warning: out: DEVSYM.INC... [-w+user]
    32                                  
    33                                  %iassign Installed TRUE
    34                                  
    35                                  	I_need	Attrib,BYTE
    36                                  	i_need	THISSFT,DWORD
    37                                  	i_need	CURBUF,DWORD
    38                                  	i_need	THISDRV,BYTE
    39                                  	i_need	ALLOWED,BYTE
    40                                  	i_need	EXTERR_LOCUS,BYTE
    41                                  	I_need	FailErr,BYTE
    42                                  	I_Need	PROC_ID,WORD
    43                                  	I_Need	USER_ID,WORD
    44                                  	i_need	JShare,DWORD
    45                                  	i_need	HIGH_SECTOR,WORD	 ;F.C. >32mb
    46                                  	i_need	OLD_FIRSTCLUS,WORD	  ;F.O. >32mb
    47                                  %if debug
    48                                  	I_need	BugLev,WORD
    49                                  	I_need	BugTyp,WORD
    50                                  %include "bugtyp.nas"
    51                                  %endif
    52                                  
    53                                   assume nocheck, ss:DOSGROUP
    54                                  
    55                                  Break <DOS_CLOSE -- CLOSE FILE from SFT>
    56                                  
    57                                  ; Inputs:
    58                                  ;	[THISSFT] set to the SFT for the file being used
    59                                  ; Function:
    60                                  ;	Close the indicated file via the SFT
    61                                  ; Returns:
    62                                  ;	sf_ref_count decremented otherwise
    63                                  ;	ES:DI point to SFT
    64                                  ;	Carry set if error
    65                                  ;	    AX has error code
    66                                  ; DS preserved, others destroyed
    67                                  
    68                                  	procedure   DOS_CLOSE,NEAR
    68          ******************       warning: proc DOS_CLOSE... [-w+user]
    69                                  	DOSAssume   CS,<DS>,"DOS_Close"
    70                                  	ASSUME	ES:NOTHING
    71                                  
    72 00000000 C43E[0000]              	LES	DI,[THISSFT]
    73                                  	Assert	ISSFT,<ES,DI>,<"DOS_CLOSE">
    74                                  	fmt	TypAccess,LevBUSY,<"$p: CLOSE SFT: $x:$x\n">,<ES,DI>
    75 00000004 268B5D05                	MOV	BX,[ES:DI + sf_flags]
    76                                  ;
    77                                  ; Network closes are handled entirely by the net code.
    78                                  ;
    79 00000008 F7C30080                	TEST	BX,sf_isnet
    80 0000000C 7406                    	JZ	LocalClose
    81                                  ;	invoke	OWN_SHARE		    ;IFS. IFS owns share ?		;AN000;
    82                                  ;	JZ	noshare 		    ;IFS. yes				;AN000;
    83                                  ;	EnterCrit   critDisk		    ;IFS.				;AN000;
    84                                  ;	CALL	SetSFTTimes		    ;IFS. set time for all SFT		;AN000;
    85                                  ;	LeaveCrit   critDisk		    ;IFS.				;AN000;
    86                                  noshare:
    87                                  multnet equ MultNET	; NASM port equate
    88 0000000E B80611CD2F              	CallInstall Net_Close,multnet,6
    89                                  ;	JC	nomore			    ;IFS. error 			;AN000;
    90                                  ;	invoke	OWN_SHARE		    ;IFS. IFS owns share ?		;AN000;
    91                                  ;	JZ	nomore			    ;IFS. yes				;AN000;
    92                                  ;	invoke	ShareEnd		    ;IFS. remove SFT entry from share	;AN000;
    93                                  nomore:
    94 00000013 C3                      	return
    95                                  
    96                                  ;
    97                                  ; All closes release the sharing information.
    98                                  ; No commit releases sharing information
    99                                  ;
   100                                  ; All closes decrement the ref count.
   101                                  ; No commit decrements the ref count.
   102                                  ;
   103                                  LocalClose:
   104 00000014 E8(0000)                	EnterCrit   critDisk
   105 00000017 E88C01                  	CALL	SetSFTTimes
   106                                  Free_SFT equ FREE_SFT	; NASM port label
   107 0000001A E80001                  	CALL	Free_SFT		; dec ref count or mark as busy
   108                                  
   109 0000001D F7C38000                	TEST	BX,devid_device        ;FS. device ?				;AN000;
   110 00000021 7511                    	JNZ	nofastsk	       ;FS. yes 				;AN000;
   111 00000023 268B4D0B                	MOV	CX,[ES:DI + sf_firclus]  ;FS. cx= first cluster			;AN000;
   112 00000027 09C9                    	OR	CX,CX		       ;FS. cx=0 ?				;AN000;
   113 00000029 7409                    	JZ	nofastsk	       ;FS. yes, dont do it			;AN000;
   114 0000002B 26C57507                	LDS	SI,[ES:DI + sf_devptr]   ;FS.					;AN000;
   115 0000002F 8A14                    	MOV	DL,[SI + dpb_drive]      ;FS. dl= drive				;AN000;
   116 00000031 E8(0000)                	invoke	FastSeek_Close	       ;FS. invoke fastseek			;AN000;
   117                                  nofastsk:
   118 00000034 161F                    	Context DS
   119 00000036 5053                    	SaveReg <AX,BX>
   120 00000038 E8(0000)                	invoke	ShareEnd
   121 0000003B 5B58                    	RestoreReg  <BX,AX>
   122                                  ;
   123                                  ; Commit enters here.  AX from commit MUST be <> 1, BX is flags word
   124                                  ;
   125                                  CloseEntry:
   126 0000003D 50                      	PUSH	AX
   127                                  ;
   128                                  ; File clean or device does not get stamped nor disk looked at.
   129                                  ;
   130 0000003E F7C3C000                	TEST	BX,devid_file_clean + devid_device
   131 00000042 7403                    	JZ	rdir
   132                                  Free_SFT_OK equ FREE_SFT_OK	; NASM port label
   133 00000044 E9C300                  	JMP	Free_SFT_OK		; either clean or device
   134                                  ;
   135                                  ; Retrieve the directory entry for the file
   136                                  ;
   137                                  rdir:
   138 00000047 E8E000                  	CALL	DirFromSFT
   139                                  ASSUME	DS:NOTHING
   140 0000004A B005                    	MOV	AL,error_access_denied
   141 0000004C 7303                    	JNC	clook
   142 0000004E E9BA00                  	JMP	CloseFinish		; pretend the close worked.
   143                                  clook:
   144                                  ;
   145                                  ; ES:DI points to entry
   146                                  ; DS:SI points to SFT
   147                                  ; ES:BX points to buffer header
   148                                  ;
   149 00000051 5756                    	SaveReg <DI,SI>
   150 00000053 8D7420                  	LEA	SI,[SI + sf_name]
   151                                  ;
   152                                  ; ES:DI point to directory entry
   153                                  ; DS:SI point to unpacked name
   154                                  ;
   155 00000056 E8(0000)                	invoke	XCHGP
   156                                  ;
   157                                  ; ES:DI point to unpacked name
   158                                  ; DS:SI point to directory entry
   159                                  ;
   160 00000059 E8(0000)                	invoke	MetaCompare
   161 0000005C E8(0000)                	invoke	XCHGP
   162 0000005F 5E5F                    	RestoreReg  <SI,DI>
   163 00000061 740C                    	JZ	CLOSE_GO		; Name OK
   164 00000063 89F7                    Bye:	MOV	DI,SI
   165 00000065 1E                      	PUSH	DS
   166 00000066 07                      	POP	ES			; ES:DI points to SFT
   167                                   assume es:nothing
   168 00000067 16                      	PUSH	SS
   169 00000068 1F                      	POP	DS
   170                                   assume ds:DOSGROUP
   171 00000069 F9                      	STC
   172 0000006A B002                    	MOV	AL,error_file_not_found
   173 0000006C E99C00                  	JMP	CloseFinish
   174                                  
   175                                  CLOSE_GO:
   176 0000006F F744020080              	TEST	word [SI + sf_mode],sf_isfcb	; FCB ?
   177 00000074 7412                    	JZ	nofcb			; no, set dir attr, sf_attr
   178 00000076 268A6D0B                	MOV	CH,[ES:DI + dir_attr]
   179 0000007A 8A4404                  	MOV	AL,[SI + sf_attr]
   180 0000007D 36A2[0000]              	MOV	[ss:Attrib],AL
   181 00000081 E8(0000)                	invoke	MatchAttributes
   182 00000084 75DD                    	JNZ	Bye			; attributes do not match
   183 00000086 EB07                    	JMP	SHORT setattr		;FT.
   184                                  nofcb:
   185 00000088 8A4404                  	MOV	AL,[SI + sf_attr] 	;FT.					;AN000;
   186 0000008B 2688450B                	MOV	[ES:DI + dir_attr],AL	;FT.					;AN000;
   187                                  setattr:
   188 0000008F 26804D0B20              	OR	BYTE PTR [ES:DI + dir_attr],attr_archive	;Set archive
   189 00000094 268B451A                	MOV	AX,[ES:DI + dir_first]	;AN011;F.O. save old first clusetr
   190 00000098 36A3[0000]              	MOV	[ss:OLD_FIRSTCLUS],AX	;AN011;F.O. save old first clusetr
   191                                  
   192 0000009C 8B440B                  	MOV	AX,[SI + sf_firclus]
   193 0000009F 2689451A                	MOV	[ES:DI + dir_first],AX	;Set firclus pointer
   194 000000A3 8B4411                  	MOV	AX,WORD PTR [SI + sf_size]
   195 000000A6 2689451C                	MOV	[ES:DI + dir_size_l],AX	;Set size
   196 000000AA 8B4413                  	MOV	AX,WORD PTR [SI + sf_size+2]
   197 000000AD 2689451E                	MOV	[ES:DI + dir_size_h],AX
   198 000000B1 8B440F                  	MOV	AX,[SI + sf_date]
   199 000000B4 26894518                	MOV	[ES:DI + dir_date],AX	;Set date
   200 000000B8 8B440D                  	MOV	AX,[SI + sf_time]
   201 000000BB 26894516                	MOV	[ES:DI + dir_time],AX	;Set time
   202                                  ;; File Tagging
   203                                  
   204                                  ;	MOV	AX,[SI.sf_codepage]	   ;AN000;
   205                                  ;	MOV	[ES:DI.dir_codepg],AX	   ;AN000;Set code page
   206                                  ;	MOV	AX,[SI.sf_extcluster]	   ;AN000;
   207                                  ;	MOV	[ES:DI.dir_extcluster],AX  ;AN000;   ;Set XA cluster
   208                                  ;	MOV	AL,[SI.sf_attr_hi]	   ;AN000;
   209                                  ;	MOV	[ES:DI.dir_attr2],AL	   ;AN000;   ;Set high attr
   210                                  
   211                                  ;; File Tagging
   212 000000BF 26F6470540              	TEST	byte [ES:BX + buf_flags],buf_dirty  ;LB. if already dirty		;AN000;
   213 000000C4 7508                    	JNZ	yesdirty		  ;LB.	  don't increment dirty count   ;AN000;
   214 000000C6 E8(0000)                	invoke	INC_DIRTY_COUNT 	  ;LB.					;AN000;
   215 000000C9 26804F0540              	OR	byte [ES:BX + buf_flags],buf_dirty ;Buffer dirty
   216                                  yesdirty:
   217 000000CE 1E56                    	SaveReg  <DS,SI>
   218 000000D0 8B4C0B                  	MOV	CX,[SI + sf_firclus]	; do this for Fastopen
   219 000000D3 36A0[0000]              	MOV	AL,[ss:THISDRV]
   220                                  ;;; 10/1/86  update fastopen cache
   221 000000D7 52                      	PUSH	DX
   222 000000D8 B400                    	MOV	AH,0			; dir entry update
   223 000000DA 88C2                    	MOV	DL,AL			; drive number A=0, B=1,,,
   224 000000DC 09C9                    	OR	CX,CX			  ;AN005; first cluster 0; may be truncated
   225 000000DE 750D                    	JNZ	do_update2		  ;AN005; no, do update
   226 000000E0 B403                    	MOV	AH,3			  ;AN005; do a delete cache entry
   227 000000E2 8B7C1B                  	MOV	DI,WORD PTR [SI + sf_dirsec]   ;AN005; cx:di = dir sector
   228 000000E5 8B4C1D                  	MOV	CX,WORD PTR [SI + sf_dirsec+2] ;AN005;
   229 000000E8 8A741F                  	MOV	DH,[SI + sf_dirpos]	     ;AN005; dh= dir pos
   230 000000EB EB0E                    	JMP	SHORT do_update 	;AN011;F.O.
   231                                  do_update2:				;AN011;F.O.
   232 000000ED 363B0E[0000]            	CMP	CX,[ss:OLD_FIRSTCLUS]	;AN011;F.O. same as old first clusetr?
   233 000000F2 7407                    	JZ	do_update		;AN011;F.O. yes
   234 000000F4 B402                    	MOV	AH,2			;AN011;F.O. delete the old entry
   235 000000F6 368B0E[0000]            	MOV	CX,[ss:OLD_FIRSTCLUS]	;AN011;F.O.
   236                                  do_update:				  ;AN005;
   237 000000FB 161F                    	Context DS
   238 000000FD E8(0000)                	invoke	FastOpen_Update 	; invoke fastopen
   239 00000100 5A                      	POP	DX
   240                                  
   241                                  ;;; 10/1/86  update fastopen cache
   242 00000101 E8(0000)                	invoke	FLUSHBUF		; flush all relevant buffers
   243 00000104 5F07                    	RestoreReg  <DI,ES>
   244 00000106 B005                    	MOV	AL,error_access_denied
   245 00000108 7201                    	JC	CloseFinish
   246                                  FREE_SFT_OK:
   247 0000010A F8                      	CLC				; signal no error.
   248                                  CloseFinish:
   249                                  ;
   250                                  ; Indicate to the device that the SFT is being closed.
   251                                  ;
   252                                  ;;;; 7/21/86
   253 0000010B 9C                      	PUSHF				; save flag from DirFromSFT
   254 0000010C E8(0000)                	invoke	Dev_Close_SFT
   255 0000010F 9D                      	POPF
   256                                  ;;;; 7/21/86
   257                                  ;
   258                                  ; See if the ref count indicates that we have busied the SFT.  If so, mark the
   259                                  ; SFT as being free.  Note that we do NOT need to be in critSFT as we are ONLY
   260                                  ; going to be moving from busy to free.
   261                                  ;
   262 00000110 59                      	POP	CX			; get old ref count
   263 00000111 9C                      	PUSHF
   264                                  	fmt	TypAccess,LevBUSY,<"$p: DOSFreeSFT: $x:$x from $x\n">,<ES,DI,AX>
   265 00000112 49                      	DEC	CX			; if cx != 1
   266 00000113 7503                    	JNZ	NoFree			; then do NOT free SFT
   267                                  	Assert	ISSFT,<ES,DI>,"DOS_FREE_SFT"
   268                                  sf_ref_Count equ sf_ref_count	; NASM port equate
   269 00000115 26890D                  	MOV	[ES:DI + sf_ref_Count],CX
   270                                  NoFree:
   271 00000118 E8(0000)                	LeaveCrit   critDisk
   272 0000011B 9D                      	POPF
   273 0000011C C3                      	return
   274                                  EndProc DOS_Close
   275                                  
   276                                  ;
   277                                  ; ES:DI -> SFT. Decs sft_ref_count.  If the count goes to 0, mark it as busy.
   278                                  ; Flags preserved.  Return old ref count in AX
   279                                  ;
   280                                  ; Note that busy is indicated by the SFT ref count being -1.
   281                                  ;
   282                                  Procedure   FREE_SFT,NEAR
   282          ******************       warning: proc FREE_SFT... [-w+user]
   283                                  	DOSAssume   CS,<DS>,"Free_SFT"
   284                                  	ASSUME	ES:NOTHING
   285                                  
   286 0000011D 9C                      	PUSHF		; Save carry state
   287 0000011E 268B05                  	MOV	AX,[ES:DI + sf_ref_count]
   288 00000121 48                      	DEC	AX
   289 00000122 7501                    	JNZ	SetCount
   290 00000124 48                      	DEC	AX
   291                                  SetCount:
   292 00000125 268705                  	XCHG	AX,[ES:DI + sf_ref_count]
   293 00000128 9D                      	POPF
   294 00000129 C3                      	return
   295                                  
   296                                  EndProc Free_SFT
   297                                  
   298                                  ;
   299                                  ;   DirFromSFT - locate a directory entry given an SFT.
   300                                  ;
   301                                  ;   Inputs:	ES:DI point to SFT
   302                                  ;		DS = DOSGroup
   303                                  ;   Outputs:
   304                                  ;		EXTERR_LOCUS = errLOC_Disk
   305                                  ;		CurBuf points to buffer
   306                                  ;		Carry Clear -> operation OK
   307                                  ;		    ES:DI point to entry
   308                                  ;		    ES:BX point to buffer
   309                                  ;		    DS:SI point to SFT
   310                                  ;		Carry SET   -> operation failed
   311                                  ;		    registers trashified
   312                                  ;   Registers modified: ALL
   313                                  
   314                                  Procedure   DirFromSFT,NEAR
   314          ******************       warning: proc DirFromSFT... [-w+user]
   315                                  	ASSUME	DS:DOSGroup,ES:NOTHING
   316                                  
   317 0000012A C606[0000]02            	MOV	byte [EXTERR_LOCUS],errLOC_Disk
   318 0000012F 0657                    	SaveReg <ES,DI>
   319 00000131 268B551D                	MOV	DX,WORD PTR [ES:DI + sf_dirsec+2]  ;F.C. >32mb
   320 00000135 8916[0000]              	MOV	[HIGH_SECTOR],DX		 ;F.C. >32mb
   321 00000139 268B551B                	MOV	DX,WORD PTR [ES:DI + sf_dirsec]
   322                                  
   323 0000013D FF36[0000]              	PUSH	word [HIGH_SECTOR]			 ;F.C. >32mb
   324 00000141 52                      	PUSH	DX
   325 00000142 E8(0000)                	invoke	FATREAD_SFT		; ES:BP points to DPB, [THISDRV] set
   326                                  					; [THISDPB] set
   327 00000145 5A                      	POP	DX
   328 00000146 8F06[0000]              	POP	word [HIGH_SECTOR]			 ;F.C. >32mb
   329 0000014A 7225                    	JC	PopDone
   330 0000014C 30C0                    	XOR	AL,AL			; Pre read
   331                                  allowed_FAIL equ Allowed_FAIL	; NASM port equate
   332                                  allowed_RETRY equ Allowed_RETRY	; NASM port equate
   333 0000014E C606[0000]18            	MOV	byte [ALLOWED],allowed_FAIL + allowed_RETRY
   334 00000153 E8(0000)                	invoke	GETBUFFR
   335 00000156 7219                    	JC	PopDone
   336 00000158 5E1F                    	RestoreReg  <SI,DS>		; Get back SFT pointer
   337                                  	ASSUME	DS:NOTHING
   338                                  Curbuf equ CURBUF	; NASM port label
   339 0000015A 36C43E[0000]            	LES	DI,[ss:Curbuf]
   340 0000015F 26804D0504              	OR	byte [ES:DI + buf_flags],buf_isDIR
   341 00000164 89FB                    	MOV	BX,DI			; ES:BX point to buffer header
   342 00000166 8D7D10                  	LEA	DI,[DI + BUFINSIZ]	; Point to buffer
   343 00000169 B020                    	MOV	AL,dir_entry_struc_size
   344                                  sf_DirPos equ sf_dirpos	; NASM port equate
   345 0000016B F6641F                  	MUL	byte [SI + sf_DirPos]
   346 0000016E 01C7                    	ADD	DI,AX			; Point at the entry
   347                                  
   348 00000170 C3                      	return				; carry is clear
   349                                  PopDone:
   350 00000171 5F07                    	RestoreReg  <DI,ES>
   351 00000173 C3                      	return
   352                                  EndProc DirFromSFT
   352          ******************       warning: ***** Possible stack size error in DirFromSFT ***** [-w+user]
   353                                  
   354                                  Break	<DOS_Commit - update directory entries>
   355                                  
   356                                  ; Inputs:
   357                                  ;	Same as DOS_CLOSE
   358                                  ; Function:
   359                                  ;	Commit the file
   360                                  ; Returns:
   361                                  ;	Same as DOS_CLOSE except ref_count field is not altered
   362                                  ; DS preserved, others destroyed
   363                                  
   364                                  	procedure   DOS_COMMIT,NEAR
   364          ******************       warning: proc DOS_COMMIT... [-w+user]
   365                                  	DOSAssume   CS,<DS>,"DOS_Commit"
   366                                  	ASSUME	ES:NOTHING
   367                                  
   368 00000174 C43E[0000]              	LES	DI,[THISSFT]
   369 00000178 268B5D05                	MOV	BX,[ES:DI + sf_flags]
   370 0000017C F7C3C000                	TEST	BX,devid_file_clean + devid_device	;Clears carry
   371 00000180 75F1                    	retnz
   372 00000182 F7C30080                	TEST	BX,sf_isnet
   373 00000186 7406                    	JZ	LOCAL_COMMIT
   374                                  %IFN Installed
   375                                  	transfer NET_COMMIT
   376                                  %ELSE
   377                                  multNET equ MultNET	; NASM port equate
   378 00000188 B80711                  	MOV	AX,(multNET << 8) | 7
   379 0000018B CD2F                    	INT	2FH
   380 0000018D C3                      	return
   381                                  %ENDIF
   382                                  
   383                                  ;
   384                                  ; Perform local commit operation by doing a close but not releaseing the SFT.
   385                                  ; There are three ways we can do this.	One is to enter a critical section to
   386                                  ; protect a potential free.  The second is to increment the ref count to mask
   387                                  ; the close decrementing.
   388                                  ;
   389                                  ; The proper way is to let the caller's of close decide if a decrement should
   390                                  ; be done.  We do this by providing another entry into close after the
   391                                  ; decrement and after the share information release.
   392                                  ;
   393                                  LOCAL_COMMIT:
   394 0000018E E8(0000)                	EnterCrit   critDisk
   395 00000191 E8(0000)                	EnterCrit   critDisk		;PTM.					;AN000;
   396 00000194 E80F00                  	call	SetSFTTimes
   397 00000197 B8FFFF                  	MOV	AX,-1
   398 0000019A E8A0FE                  	call	CloseEntry
   399 0000019D 9C                      	PUSHF				;PTM.					;AN000;
   400 0000019E E8(0000)                	invoke	DEV_OPEN_SFT		;PTM.  increment device count		;AN000;
   401 000001A1 9D                      	POPF				;PTM.					;AN000;
   402 000001A2 E8(0000)                	LeaveCrit CritDisk		;PTM.					;AN000;
   403 000001A5 C3                      	return
   404                                  
   405                                  EndProc DOS_COMMIT
   406                                  
   407                                  Break	<SetSFTTimes - signal a change in the times for an SFT>
   408                                  
   409                                  ;
   410                                  ;   SetSFTTimes - Examine the flags for a SFT and set the time appropriately.
   411                                  ;   Reflect these times in other SFT's for the same file.
   412                                  ;
   413                                  ;   Inputs:	ES:DI point to SFT
   414                                  ;		BX = sf_flags set apprpriately
   415                                  ;   Outputs:	Set sft times to current time iff File & dirty & !nodate
   416                                  ;   Registers modified: All except ES:DI, BX, AX
   417                                  ;
   418                                  
   419                                  Procedure   SetSFTTimes,NEAR
   419          ******************       warning: proc SetSFTTimes... [-w+user]
   420                                  	Assert	ISSFT,<ES,DI>,"SetSFTTimes"
   421                                  ;
   422                                  ; File clean or device does not get stamped nor disk looked at.
   423                                  ;
   424 000001A6 F7C3C000                	TEST	BX,devid_file_clean + devid_device
   425 000001AA 75F9                    	retnz				; clean or device => no timestamp
   426                                  ;
   427                                  ; file and dirty.  See if date is good
   428                                  ;
   429 000001AC F7C30040                	TEST	BX,sf_close_nodate
   430 000001B0 75F3                    	retnz				; nodate => no timestamp
   431 000001B2 5053                    	SaveReg <AX,BX>
   432 000001B4 E8(0000)                	invoke	DATE16			; Date/Time to AX/DX
   433 000001B7 2689450F                	MOV	[ES:DI + sf_date],AX
   434 000001BB 2689550D                	MOV	[ES:DI + sf_time],DX
   435 000001BF 31C0                    	XOR	AX,AX
   436                                  %if installed
   437 000001C1 FF1E[3800]              	call	far [JShare + 14 * 4]
   438                                  %else
   439                                  	call	ShSU
   440                                  %endif
   441 000001C5 5B58                    	RestoreReg  <BX,AX>
   442 000001C7 C3                      	return
   443                                  EndProc SetSFTTimes
   444                                  
   445                                      END
