     1                                  ;	SCCSID = @(#)delete.asm 1.3 85/10/18
     2                                  ;	SCCSID = @(#)delete.asm 1.3 85/10/18
     3                                  ;TITLE	DOS_DELETE - Internal DELETE call for MS-DOS
     4                                  ;NAME	DOS_DELETE
     5                                  ; Low level routine for deleting files
     6                                  ;
     7                                  ;   DOS_DELETE
     8                                  ;   REN_DEL_Check
     9                                  ;   FastOpen_Delete	       ; DOS 3.3
    10                                  ;   FastOpen_Update	       ; DOS 3.3
    11                                  ;   FastSeek_Open	       ; DOS 4.00
    12                                  ;   FSeek_dispatch	       ; DOS 4.00
    13                                  ;   FastSeek_Close	       ; DOS 4.00
    14                                  ;   FastSeek_Delete	       ; DOS 4.00
    15                                  ;   Delete_FSeek	       ; DOS 4.00
    16                                  ;   FastSeek_Lookup	       ; DOS 4.00
    17                                  ;   FastSeek_Insert	       ; DOS 4.00
    18                                  ;   FastSeek_Truncate	       ; DOS 4.00
    19                                  ;   FS_doit		       ; DOS 4.00
    20                                  ;
    21                                  ;   Revision history:
    22                                  ;
    23                                  ;   A000  version 4.00	Jan. 1988
    24                                  ;
    25                                  
    26                                  ;
    27                                  ; get the appropriate segment definitions
    28                                  ;
    29                                  [list -]
    29          ******************       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
    31                                  
    32                                  [list +]
    33                                  section DOSCODECODE
    34                                  [list -]
    34          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    34          ******************       warning: out: BPB.INC... [-w+user]
    34          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    34          ******************       warning: out: DEVSYM.INC... [-w+user]
    44                                  
    45                                  %iassign Installed TRUE
    46                                  
    47                                  	i_need	NoSetDir,BYTE
    48                                  	i_need	Creating,BYTE
    49                                  	i_need	DELALL,BYTE
    50                                  	i_need	THISDPB,DWORD
    51                                  	i_need	THISSFT,DWORD
    52                                  	i_need	THISCDS,DWORD
    53                                  	i_need	CURBUF,DWORD
    54                                  	i_need	ATTRIB,BYTE
    55                                  	i_need	SATTRIB,BYTE
    56                                  	i_need	WFP_START,WORD
    57                                  	i_need	FoundDel,BYTE
    58                                  	i_need	AUXSTACK,BYTE
    59                                  	i_need	VOLCHNG_FLAG,BYTE
    60                                  	i_need	JShare,DWORD
    61                                  	i_need	FastOpenTable,BYTE		  ; DOS 3.3
    62                                  	i_need	FastTable,BYTE			  ; DOS 4.00
    63                                  	i_need	FSeek_drive,BYTE		  ; DOS 4.00
    64                                  	i_need	FSeek_firclus,WORD		  ; DOS 4.00
    65                                  	i_need	FSeek_logclus,WORD		  ; DOS 4.00
    66                                  	i_need	FSeek_logsave,WORD		  ; DOS 4.00
    67                                  	i_need	FastSeekflg,BYTE		  ; DOS 4.00
    68                                  	i_need	Del_ExtCluster,WORD		  ; DOS 4.00
    69                                  	i_need	SAVE_BX,WORD			  ; DOS 4.00
    70                                  	i_need	DMAADD,DWORD
    71                                  	i_need	RENAMEDMA,BYTE
    72                                  
    73                                   assume nocheck, ss:DOSGROUP
    74                                  
    75                                  ; Inputs:
    76                                  ;	[WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
    77                                  ;		terminated)
    78                                  ;	[CURR_DIR_END] Points to end of Current dir part of string
    79                                  ;		( = -1 if current dir not involved, else
    80                                  ;		 Points to first char after last "/" of current dir part)
    81                                  ;	[THISCDS] Points to CDS being used
    82                                  ;		(Low word = -1 if NUL CDS (Net direct request))
    83                                  ;	[SATTRIB] Is attribute of search, determines what files can be found
    84                                  ; Function:
    85                                  ;	Delete the specified file(s)
    86                                  ; Outputs:
    87                                  ;	CARRY CLEAR
    88                                  ;		OK
    89                                  ;	CARRY SET
    90                                  ;	    AX is error code
    91                                  ;		error_file_not_found
    92                                  ;			Last element of path not found
    93                                  ;		error_path_not_found
    94                                  ;			Bad path (not in curr dir part if present)
    95                                  ;		error_bad_curr_dir
    96                                  ;			Bad path in current directory part of path
    97                                  ;		error_access_denied
    98                                  ;			Attempt to delete device or directory
    99                                  ;		***error_sharing_violation***
   100                                  ;			Deny both access required, generates an INT 24.
   101                                  ;			This error is NOT returned. The INT 24H is generated,
   102                                  ;			  and the file is ignored (not deleted). Delete will
   103                                  ;			  simply continue on looking for more files.
   104                                  ;			  Carry will NOT be set in this case.
   105                                  ; DS preserved, others destroyed
   106                                  
   107                                  fileFound   equ 01h
   108                                  fileDeleted equ 10h
   109                                  
   110                                  	procedure   DOS_DELETE,NEAR
   110          ******************       warning: proc DOS_DELETE... [-w+user]
   111                                  	DOSAssume   CS,<DS>,"DOS_Delete"
   112                                  	ASSUME	ES:NOTHING
   113                                  
   114 00000000 E8(0000)                	Invoke	TestNet
   115 00000003 7306                    	JNC	LOCAL_DELETE
   116                                  ;	invoke	OWN_SHARE2		       ;IFS. IFS owns share ?		;AN000;
   117                                  ;	JZ	ifsshare		       ;IFS. yes			;AN000;
   118                                  ;	PUSH	WORD PTR [DMAADD+2]	       ;IFS. save DMAADD		;AN000;
   119                                  ;	PUSH	WORD PTR [DMAADD]	       ;IFS.				;AN000;
   120                                  ;	CALL	IFS_SEARCH_FIRST	       ;IFS. do search first		;AN000;
   121                                  ;	JC	nofiles 		       ;IFS. file not existing		;AN000;
   122                                  delete_next_file:			       ;IFS.				;AN000;
   123                                  ;	CALL	IFS_REN_DEL_CHECK	       ;IFS. do REN_DEL_CHECK		;AN000;
   124                                  ;	JNC	share_okok		       ;IFS. share ok			;AN000;
   125                                  ;	MOV	AX,error_sharing_violation     ;IFS. share violation		;AN000;
   126                                  ;	JMP	SHORT nofiles		       ;IFS.				;AN000;
   127                                  share_okok:
   128                                  ;	MOV	AX,(multNET SHL 8) OR 19       ;IFS. delete it now		;AN000;
   129                                  ;;	INT	2FH			       ;IFS.				;AN000;
   130                                  ;	JC	nofiles 		       ;IFS. error			;AN000;
   131                                  ;	invoke	DOS_SEARCH_NEXT 	       ;IFS. get next entry		;AN000;
   132                                  ;	JNC	delete_next_file	       ;IFS.				;AN000;
   133                                  ;	CLC				       ;IFS. no more files		;AN000;
   134                                  nofiles:
   135                                  ;	POP	WORD PTR [DMAADD]	       ;IFS. retor DMAADD		;AN000;
   136                                  ;	POP	WORD PTR [DMAADD+2]	       ;IFS.				;AN000;
   137                                  ;	ret				       ;IFS. return
   138                                  ifsshare:
   139                                  
   140                                  
   141                                  %IFN Installed
   142                                  	transfer NET_DELETE
   143                                  %ELSE
   144                                  multNET equ MultNET	; NASM port equate
   145 00000005 B81311                  	MOV	AX,(multNET << 8) | 19
   146 00000008 CD2F                    	INT	2FH
   147 0000000A C3                      	return
   148                                  %ENDIF
   149                                  
   150                                  LOCAL_DELETE:
   151 0000000B C606[0000]00            	MOV	byte [FoundDel],00	; No files found and no files deleted
   152 00000010 E8(0000)                	EnterCrit   critDisk
   153                                  CREATING equ Creating	; NASM port label
   154 00000013 C706[0000]00E5          	MOV	WORD PTR [CREATING],0E500H  ; Assume not del *.*
   155 00000019 8B36[0000]              	MOV	SI,[WFP_START]
   156                                  SKPNUL:
   157 0000001D AC                      	LODSB
   158 0000001E 08C0                    	OR	AL,AL
   159 00000020 75FB                    	JNZ	SKPNUL			    ; go to end
   160 00000022 83EE04                  	SUB	SI,4			    ; Back over possible "*.*"
   161 00000025 813C2A2E                	CMP	WORD PTR [SI],("." << 8 | "*")
   162 00000029 7506                    	JNZ	TEST_QUEST
   163 0000002B 807C022A                	CMP	BYTE PTR [SI+2],"*"
   164 0000002F 741F                    	JZ	CHECK_ATTS
   165                                  TEST_QUEST:
   166 00000031 83EE09                  	SUB	SI,9		; Back over possible "????????.???"
   167 00000034 87FE                    	XCHG	DI,SI
   168 00000036 1607                    	context ES
   169 00000038 B83F3F                  	MOV	AX,"??"
   170 0000003B B90400                  	MOV	CX,4		; four sets of "??"
   171 0000003E F3AF                    	REPE	SCASW
   172 00000040 751C                    	JNZ	NOT_ALL
   173 00000042 87FE                    	XCHG	DI,SI
   174 00000044 AD                      	LODSW
   175 00000045 3D2E3F                  	CMP	AX,("?" << 8) | "."
   176 00000048 7514                    	JNZ	NOT_ALL
   177 0000004A AD                      	LODSW
   178 0000004B 3D3F3F                  	CMP	AX,"??"
   179 0000004E 750E                    	JNZ	NOT_ALL
   180                                  CHECK_ATTS:
   181 00000050 A0[0000]                	MOV	AL,BYTE PTR [SATTRIB]
   182 00000053 241F                    	AND	AL,attr_hidden+attr_system+attr_directory+attr_volume_id+attr_read_only
   183                                  					; Look only at hidden bits
   184 00000055 3C1F                    	CMP	AL,attr_hidden+attr_system+attr_directory+attr_volume_id+attr_read_only
   185                                  					; All must be set
   186 00000057 7505                    	JNZ	NOT_ALL
   187                                  
   188                                  ; NOTE WARNING DANGER-----
   189                                  ;    This DELALL stuff is not safe. It allows directories to be deleted.
   190                                  ;	It should ONLY be used by FORMAT in the ROOT directory.
   191                                  ;
   192                                  
   193 00000059 C606[0000]00            	MOV	byte [DELALL],0	     ; DEL *.* - flag deleting all
   194                                  NOT_ALL:
   195 0000005E C606[0000]01            	MOV	byte [NoSetDir],1
   196 00000063 E8(0000)                	invoke	GetPathNoSet
   197                                  	ASSUME	ES:NOTHING
   198 00000066 7313                    	JNC	Del_found
   199 00000068 750C                    	JNZ	bad_path
   200 0000006A 08C9                    	OR	CL,CL
   201 0000006C 7408                    	JZ	bad_path
   202                                  No_file:
   203 0000006E B80200                  	MOV	AX,error_file_not_found
   204                                  ErrorReturn:
   205 00000071 F9                      	STC
   206 00000072 E8(0000)                	LeaveCrit   critDisk
   207 00000075 C3                      	return
   208                                  
   209                                  bad_path:
   210 00000076 B80300                  	MOV	AX,error_path_not_found
   211 00000079 EBF6                    	JMP	ErrorReturn
   212                                  
   213                                  Del_found:
   214 0000007B 750C                    	JNZ	NOT_DIR 		; Check for dir specified
   215                                  DelAll equ DELALL	; NASM port label
   216 0000007D 803E[0000]00            	CMP	byte [DelAll],0		; DelAll = 0 allows delete of dir.
   217                                  Not_Dir equ NOT_DIR	; NASM port label
   218 00000082 7405                    	JZ	Not_Dir
   219                                  Del_access_err:
   220 00000084 B80500                  	MOV	AX,error_access_denied
   221 00000087 EBE8                    	JMP	ErrorReturn
   222                                  
   223                                  NOT_DIR:
   224 00000089 08E4                    	OR	AH,AH		; Check if device name
   225 0000008B 78F7                    	JS	Del_access_err	; Can't delete I/O devices
   226                                  ;
   227                                  ; Main delete loop.  CURBUF+2:BX points to a matching directory entry.
   228                                  ;
   229                                  DELFILE:
   230 0000008D 800E[0000]01            	OR	byte [FoundDel],fileFound	; file found, not deleted yet
   231                                  ;
   232                                  ; If we are deleting the Volume ID, then we set VOLUME_CHNG flag to make
   233                                  ; DOS issue a build BPB call the next time this drive is accessed.
   234                                  ;
   235 00000092 1E                      	PUSH	DS
   236 00000093 8A26[0000]              	MOV	AH,[DELALL]
   237 00000097 C53E[0000]              	LDS	DI,[CURBUF]
   238                                  ASSUME	DS:NOTHING
   239                                  ;; Extended Attributes
   240                                  ;	PUSH	AX			 ;FT. save cluster of XA		;AN000;
   241                                  ;	MOV	AX,[DS:BX.dir_ExtCluster];FT.					;AN000;
   242                                  ;	MOV	[Del_ExtCluster],AX	 ;FT.					;AN000;
   243                                  ;	POP	AX			 ;FT,					;AN000;
   244                                  
   245                                  ;; Extended Attributes
   246                                  Attrib equ ATTRIB	; NASM port label
   247 0000009B 36F606[0000]01          	TEST	byte [ss:Attrib],attr_read_only ; are we deleting RO files too?
   248 000000A1 7509                    	JNZ	DoDelete		; yes
   249 000000A3 F6470B01                	TEST	byte [BX + dir_attr],attr_read_only
   250 000000A7 7403                    	JZ	DoDelete		; not read only
   251 000000A9 1F                      	POP	DS
   252                                   assume ds:DOSGROUP
   253                                  DelNxt equ DELNXT	; NASM port label
   254 000000AA EB35                    	JMP	SHORT DelNxt		; Skip it (Note ES:BP not set)
   255                                  
   256                                  DoDelete:
   257 000000AC E88800                  	call	REN_DEL_Check		; Sets ES:BP = [THISDPB]
   258 000000AF 7303                    	JNC	DEL_SHARE_OK
   259 000000B1 1F                      	POP	DS
   260                                   assume ds:DOSGROUP
   261 000000B2 EB2D                    	JMP	SHORT DelNxt		; Skip it
   262                                  
   263                                  DEL_SHARE_OK:
   264                                  	Assert	ISBUF,<DS,DI>,"Del_Share_OK"
   265 000000B4 F6450540                	TEST	byte [DI + buf_flags],buf_dirty  ;LB. if already dirty 		;AN000;
   266 000000B8 7507                    	JNZ	yesdirty		  ;LB.	  don't increment dirty count   ;AN000;
   267 000000BA E8(0000)                	invoke	INC_DIRTY_COUNT 	  ;LB.					;AN000;
   268 000000BD 804D0540                	OR	byte [DI + buf_flags],buf_dirty
   269                                  yesdirty:
   270 000000C1 8827                    	MOV	[BX],AH 		; Put in E5H or 0
   271 000000C3 8B1C                    	MOV	BX,[SI] 		; Get firclus pointer
   272 000000C5 1F                      	POP	DS
   273                                  	DOSAssume   CS,<DS>,"Del_Share_OK"
   274 000000C6 800E[0000]10            	OR	byte [FoundDel],fileDeleted	; Deleted file
   275 000000CB 83FB02                  	CMP	BX,2
   276 000000CE 7211                    	JB	DELEXT			; File has invalid FIRCLUS (too small)
   277 000000D0 263B5E0D                	CMP	BX,[ES:BP + dpb_max_cluster]
   278 000000D4 770B                    	JA	DELEXT			; File has invalid FIRCLUS (too big)
   279                                  ;; FastSeek 10/27/86
   280 000000D6 E82D01                  	CALL	Delete_FSeek		; delete the fastseek entry
   281                                  ;; FastSeek 10/27/86
   282                                  
   283 000000D9 E8(0000)                	invoke	RELEASE 		; Free file data
   284 000000DC 7253                    	JC	No_fileJ
   285                                  ; DOS 3.3  FastOpen
   286                                  
   287 000000DE E8C300                  	CALL	FastOpen_Delete 	; delete the dir info in fastopen
   288                                  
   289                                  
   290                                  ; DOS 3.3  FastOpen
   291                                  ;; Extended Attributes
   292                                  DELEXT:
   293                                  
   294                                  ;	MOV	BX,[Del_ExtCluster]	;FT. delete XA cluster chain		;AN000;
   295                                  ;	CMP	BX,2			;FT.					;AN000;
   296                                  ;	JB	DELNXT			;FT. XA has invalid cluster (too small) ;AN000;
   297                                  ;	CMP	BX,[ES:BP.dpb_max_cluster];FT.					;AN000;
   298                                  ;	JA	DELNXT			;FT. XA has invalid cluster (too big)	;AN000;
   299                                  ;	invoke	RELEASE 		;FT. Free extended attrs cluster	;AN000;
   300                                  ;	JC	No_fileJ		;FT.					;AN000;
   301                                  
   302                                  ;; Extended Attributes
   303                                  DELNXT:
   304 000000E1 C42E[0000]              	LES	BP,[THISDPB]		; Possible to get here without this set
   305 000000E5 E8(0000)                	invoke	GETENTRY		; Registers need to be reset
   306 000000E8 7247                    	JC	No_fileJ
   307 000000EA E8(0000)                	invoke	NEXTENT
   308                                  %if DEBUG
   309                                  Flsh equ flsh	; NASM port label
   310                                  	JC	Flsh
   311                                  DelFile equ DELFILE	; NASM port label
   312                                  	JMP	DelFile
   313                                  flsh:
   314                                  %ELSE
   315 000000ED 739E                    	JNC	DELFILE
   316                                  %ENDIF
   317 000000EF C42E[0000]              	LES	BP,[THISDPB]		; NEXTENT sets ES=DOSGROUP
   318                                   assume es:DPB
   319 000000F3 268A4600                	MOV	AL,[ES:BP + dpb_drive]
   320 000000F7 E8(0000)                	invoke	FLUSHBUF
   321 000000FA 7235                    	JC	No_fileJ
   322                                  ;
   323                                  ; Now we need to test FoundDel for our flags.  The cases to consider are:
   324                                  ;
   325                                  ;   not found not deleted		file not found
   326                                  ;   not found	  deleted		*** impossible ***
   327                                  ;	found not deleted		access denied (read-only)
   328                                  ;	found	  deleted		no error
   329                                  ;
   330 000000FC F606[0000]10            	TEST	byte [FoundDel],fileDeleted	; did we delete a file?
   331 00000101 7427                    	JZ	DelError		; no, figure out what's wrong.
   332                                  ; We set VOLCHNG_FLAG to indicate that we have changed the volume label
   333                                  ; and to force the DOS to issue a media check.
   334 00000103 F606[0000]08            	TEST	byte [Attrib],attr_volume_id
   335 00000108 741C                    	jz	No_Set_Flag
   336 0000010A 50                      	PUSH	AX
   337 0000010B 06                      	PUSH	ES
   338 0000010C 57                      	PUSH	DI
   339 0000010D C43E[0000]              	LES	DI,[THISCDS]
   340                                  ASSUME	ES:NOTHING
   341 00000111 268A25                  	MOV	AH,BYTE PTR [ES:DI]	; Get drive
   342 00000114 80EC41                  	SUB	AH,'A'                  ; Convert to 0-based
   343 00000117 8826[0000]              	mov	byte ptr [VOLCHNG_FLAG],AH
   344 0000011B 30FF                    	XOR	BH,BH			;>32mb delte volume id from boot record ;AN000;
   345 0000011D E8(0000)                	invoke	Set_Media_ID		;>32mb set voulme id to boot record	;AN000;
   346 00000120 E8(0000)                	invoke	FATRead_CDS		; force media check
   347 00000123 5F                      	POP	DI
   348 00000124 07                      	POP	ES
   349                                   assume es:DPB
   350 00000125 58                      	POP	AX
   351                                  No_Set_Flag:
   352 00000126 E8(0000)                	LeaveCrit   critDisk		; carry is clear
   353 00000129 C3                      	return
   354                                  DelError:
   355 0000012A F606[0000]01            	TEST	byte [FoundDel],fileFound	; not deleted.	Did we find file?
   356                                  Del_access_errJ equ Del_Access_errJ	; NASM port label
   357 0000012F 7503                    	JNZ	Del_access_errJ 	; yes. Access denied
   358                                  No_fileJ:
   359 00000131 E93AFF                  	JMP	No_file 		; Nope
   360                                  Del_Access_errJ:
   361 00000134 E94DFF                  	JMP	Del_access_err
   362                                  
   363                                  EndProc DOS_DELETE
   364                                  
   365                                  Break	<REN_DEL_Check - check for access for rename and delete>
   366                                  
   367                                  ; Inputs:
   368                                  ;	[THISDPB] set
   369                                  ;	[CURBUF+2]:BX points to entry
   370                                  ;	[CURBUF+2]:SI points to firclus field of entry
   371                                  ;	[WFP_Start] points to name
   372                                  ; Function:
   373                                  ;	Check for Exclusive access on given file.
   374                                  ;	  Used by RENAME, SET_FILE_INFO, and DELETE.
   375                                  ; Outputs:
   376                                  ;	ES:BP = [THISDPB]
   377                                  ;	NOTE: The WFP string pointed to by [WFP_Start] Will be Modified.  The
   378                                  ;		last element will be loaded from the directory entry.  This is
   379                                  ;		so the name given to the sharer doesn't have any meta chars in
   380                                  ;		it.
   381                                  ;	Carry set if sharing violation, INT 24H generated
   382                                  ;	    NOTE THAT AX IS NOT error_sharing_violation.
   383                                  ;		This is because input AX is preserved.
   384                                  ;		Caller must set the error if needed.
   385                                  ;	Carry clear
   386                                  ;		OK
   387                                  ; AX,DS,BX,SI,DI preserved
   388                                  
   389                                  	procedure  REN_DEL_Check,NEAR
   389          ******************       warning: proc REN_DEL_Check... [-w+user]
   390                                  ASSUME	DS:NOTHING,ES:NOTHING
   391                                  
   392 00000137 1E                      	PUSH	DS
   393 00000138 57                      	PUSH	DI
   394 00000139 50                      	PUSH	AX
   395 0000013A 53                      	PUSH	BX
   396 0000013B 56                      	PUSH	SI		; Save CURBUF pointers
   397 0000013C 1607                    	context ES
   398                                  ASSUME	ES:DOSGROUP
   399 0000013E 368B3E[0000]            	MOV	DI,[ss:WFP_START]	; ES:DI -> WFP
   400 00000143 89DE                    	MOV	SI,BX
   401 00000145 368E1E[0200]            	MOV	DS,WORD PTR [ss:CURBUF+2]	; DS:SI -> entry (FCB style name)
   402                                   assume ds:nothing
   403 0000014A 89FB                    	MOV	BX,DI		; Set backup limit for skipback
   404 0000014C 83C302                  	ADD	BX,2		; Skip over d: to point to leading '\'
   405 0000014F E8(0000)                	invoke	StrLen		; CX is length of ES:DI including NUL
   406 00000152 49                      	DEC	CX		; Don't include nul in count
   407 00000153 01CF                    	ADD	DI,CX		; Point to NUL at end of string
   408 00000155 E8(0000)                	invoke	SkipBack	; Back up one element
   409 00000158 47                      	INC	DI		; Point to start of last element
   410 00000159 36893E[0000]            	MOV	[ss:SAVE_BX],DI	;IFS. save for DOS_RENAME			   ;AN000;
   411 0000015E E8(0000)                	invoke	PackName	; Transfer name from entry to ASCIZ tail.
   412 00000161 5E                      	POP	SI		; Get back entry pointers
   413 00000162 5B                      	POP	BX
   414 00000163 53                      	PUSH	BX
   415 00000164 56                      	PUSH	SI		; Back on stack
   416 00000165 161F                    	context DS
   417                                  ASSUME	DS:DOSGROUP
   418                                  ;
   419                                  ; Close the file if possible by us.
   420                                  ;
   421                                  %if installed
   422 00000167 FF1E[3400]              	Call	far [JShare + 13 * 4]
   423                                  %else
   424                                  	Call	ShCloseFile
   425                                  %endif
   426 0000016B 8C1E[0200]              	MOV	WORD PTR [THISSFT+2],DS
   427 0000016F C706[0000][C5FF]        	MOV	WORD PTR [THISSFT],OFFSET AUXSTACK - (sf_entry_struc_size) wrt DOSGROUP
   428                                  				; Scratch space
   429 00000175 30E4                    	XOR	AH,AH		; Indicate file to DOOPEN (high bit off)
   430 00000177 E8(0000)                	invoke	DOOPEN		; Fill in SFT for share check
   431 0000017A C43E[0000]              	LES	DI,[THISSFT]
   432 0000017E 26C745021000            	MOV	word [ES:DI + sf_mode],sharing_deny_both   ; requires exclusive access
   433 00000184 26C7050100              	MOV	word [ES:DI + sf_ref_count],1	; Pretend open
   434 00000189 E8(0000)                	invoke	ShareEnter
   435 0000018C 720C                    	jc	CheckDone
   436 0000018E C43E[0000]              	LES	DI,[THISSFT]
   437 00000192 26832500                	and	word [ES:DI + sf_ref_count],0	; Pretend closed and free
   438 00000196 E8(0000)                	invoke	SHAREEND		; Tell sharer we're done with THISSFT
   439 00000199 F8                      	CLC
   440                                  CheckDone:
   441 0000019A C42E[0000]              	LES	BP,[THISDPB]
   442 0000019E 5E                      	POP	SI
   443 0000019F 5B                      	POP	BX
   444 000001A0 58                      	POP	AX
   445 000001A1 5F                      	POP	DI
   446 000001A2 1F                      	POP	DS
   447                                   assume ds:nothing
   448 000001A3 C3                      	return
   449                                  
   450                                  EndProc REN_DEL_Check
   451                                  
   452                                  Break	<FastOpen_Delete - delete dir info in fastopen>
   453                                  
   454                                  ; Inputs:
   455                                  ;	None
   456                                  ; Function:
   457                                  ;	Call FastOpen to delete the dir info.
   458                                  ; Outputs:
   459                                  ;	None
   460                                  ;
   461                                  ;
   462                                  
   463                                  	procedure  FastOpen_Delete,NEAR
   463          ******************       warning: proc FastOpen_Delete... [-w+user]
   464                                  ASSUME	DS:NOTHING,ES:NOTHING
   465 000001A4 9C                      	PUSHF			; save flag
   466 000001A5 56                      	PUSH	SI		; save registers
   467 000001A6 53                      	PUSH	BX
   468 000001A7 50                      	PUSH	AX
   469                                  
   470                                  WFP_Start equ WFP_START	; NASM port label
   471 000001A8 368B36[0000]            	MOV	SI,[ss:WFP_Start]			       ; ds:si points to path name
   472 000001AD B003                    	MOV	AL,FONC_delete			       ; al = 3
   473                                  fastinvoke:
   474 000001AF BB[0200]                	MOV	BX,OFFSET FastTable + 2 wrt DOSGROUP
   475 000001B2 36FF1F                  	CALL	far [ss:BX]			       ; call fastopen
   476                                  
   477 000001B5 58                      	POP	AX		; restore registers
   478 000001B6 5B                      	POP	BX
   479 000001B7 5E                      	POP	SI
   480 000001B8 9D                      	POPF			; restore flag
   481 000001B9 C3                      	return
   482                                  EndProc FastOpen_Delete
   483                                  
   484                                  
   485                                  Break	<FastOpen_Update - update dir info in fastopen>
   486                                  
   487                                  ; Inputs:
   488                                  ;	DL     drive number (A=0,B=1,,,)
   489                                  ;	CX     first cluster #
   490                                  ;	AH     0 updates dir entry
   491                                  ;	       1 updates CLUSNUM  , BP = new CLUSNUM
   492                                  ;	ES:DI  directory entry
   493                                  ; Function:
   494                                  ;	Call FastOpen to update the dir info.
   495                                  ; Outputs:
   496                                  ;	None
   497                                  ;
   498                                  ;
   499                                  
   500                                  	procedure  FastOpen_Update,NEAR
   500          ******************       warning: proc FastOpen_Update... [-w+user]
   501                                  ASSUME	DS:NOTHING,ES:NOTHING
   502 000001BA 9C                      	PUSHF			; save flag
   503 000001BB 56                      	PUSH	SI
   504 000001BC 53                      	PUSH	BX		; save regs
   505 000001BD 50                      	PUSH	AX
   506                                  
   507 000001BE B004                    	MOV	AL,FONC_update			       ; al = 4
   508 000001C0 EBED                    	JMP	fastinvoke
   509                                  
   510                                  EndProc FastOpen_Update
   511                                  
   512                                  Break	<FastSeek_Open - create a file extent cache entry>
   513                                  
   514                                  ; Inputs:
   515                                  ;	DL     drive number (0=A,1=B,,,)
   516                                  ;	CX     first cluster #
   517                                  ; Function:
   518                                  ;	Create a file extent cache entry
   519                                  ; Outputs:
   520                                  ;	None
   521                                  ;
   522                                  ;
   523                                  
   524                                  	procedure  FastSeek_Open,NEAR						;AN000;
   524          ******************       warning: proc FastSeek_Open... [-w+user]
   525                                  ASSUME	DS:NOTHING,ES:NOTHING							;AN000;
   526                                  										;AN000;
   527 000001C2 36F606[0000]80          	TEST	byte [ss:FastSeekflg],Fast_yes	       ; Fastseek installed ?		;AN000;
   528 000001C8 7409                    	JZ	fs_no11 		       ; no				;AN000;
   529 000001CA 56                      	PUSH	SI			       ; save regs			;AN000;
   530 000001CB 50                      	PUSH	AX								;AN000;
   531 000001CC B00B                    	MOV	AL,FSEC_open		       ; al = 11			;AN000;
   532                                  fseek_disp:									;AN000;
   533 000001CE E80300                  	CALL	FSeek_dispatch		       ; call fastseek			;AN000;
   534 000001D1 58                      	POP	AX			       ; restore regs			;AN000;
   535 000001D2 5E                      	POP	SI								;AN000;
   536                                  fs_no11:									;AN000;
   537 000001D3 C3                      	return				       ; return 			;AN000;
   538                                  EndProc FastSeek_Open								;AN000;
   539                                  
   540                                  ; Inputs:
   541                                  ;	none
   542                                  ; Function:
   543                                  ;	Call Fastseek
   544                                  ; Outputs:
   545                                  ;	Output of Fastseek
   546                                  ;
   547                                  
   548                                  	procedure  FSeek_dispatch,NEAR
   548          ******************       warning: proc FSeek_dispatch... [-w+user]
   549                                  ASSUME	DS:NOTHING,ES:NOTHING							;AN000;
   550                                  										;AN000;
   551 000001D4 B402                    	MOV	AH,FastSeek_ID		      ; fastseek ID  = 1		;AN000;
   552                                   entry Fast_Dispatch			      ; future fastxxxx entry		;AN000;
   553 000001D6 50                      	PUSH	AX			      ; save ax 			;AN000;
   554 000001D7 88E0                    	MOV	AL,AH			      ; al=fastseek ID			;AN000;
   555 000001D9 30E4                    	XOR	AH,AH			      ; 				;AN000;
   556 000001DB 48                      	DEC	AX			      ; 				;AN000;
   557 000001DC D1E0                    	SHL	AX,1			      ; times 4 to get entry offset	;AN000;
   558 000001DE D1E0                    	SHL	AX,1								;AN000;
   559                                  										;AN000;
   560 000001E0 BE[0200]                	MOV	SI,OFFSET FastTable + 2 wrt DOSGROUP	; index to the		;AN000;
   561 000001E3 01C6                    	ADD	SI,AX					; fastxxxx entry	;AN000;
   562 000001E5 58                      	POP	AX					; restore ax		;AN000;
   563 000001E6 36FF1C                  	CALL	far [ss:SI]			; call fastseek 	;AN000;
   564 000001E9 C3                      	return
   565                                  EndProc FSeek_dispatch
   566                                  
   567                                  Break	<FastSeek_Close -  close a file extent entry>
   568                                  
   569                                  ; Inputs:
   570                                  ;	DL     drive number (0=A,1=B,,,)
   571                                  ;	CX     first cluster #
   572                                  ; Function:
   573                                  ;	Close a file extent entry
   574                                  ; Outputs:
   575                                  ;	None
   576                                  ;
   577                                  ;
   578                                  
   579                                  	procedure  FastSeek_Close,NEAR
   579          ******************       warning: proc FastSeek_Close... [-w+user]
   580                                  ASSUME	DS:NOTHING,ES:NOTHING							;AN000;
   581                                  
   582 000001EA 36F606[0000]80          	TEST	byte [ss:FastSeekflg],Fast_yes	       ; Fastseek installed ?		;AN000;
   583 000001F0 7429                    	JZ	fs_no2			       ; no				;AN000;
   584 000001F2 56                      	PUSH	SI			       ; save regs			;AN000;
   585 000001F3 50                      	PUSH	AX			       ;				;AN000;
   586 000001F4 B00C                    	MOV	AL,FSEC_close		       ; al = 12			;AN000;
   587 000001F6 EBD6                    	JMP	fseek_disp		       ; call fastseek			;AN000;
   588                                  EndProc FastSeek_Close								;AN000;
   589                                  
   590                                  Break	<FastSeek_Delete - delete a file extent  entry>
   591                                  
   592                                  ; Inputs:
   593                                  ;	DL     drive number (0=A,1=B,,,)
   594                                  ;	CX     first cluster #
   595                                  ; Function:
   596                                  ;	Delete a file extent entry
   597                                  ; Outputs:
   598                                  ;	None
   599                                  ;
   600                                  ;
   601                                  
   602                                  	procedure  FastSeek_Delete,NEAR
   602          ******************       warning: proc FastSeek_Delete... [-w+user]
   603                                  ASSUME	DS:NOTHING,ES:NOTHING							;AN000;
   604                                  										;AN000;
   605 000001F8 36F606[0000]80          	TEST	byte [ss:FastSeekflg],Fast_yes	       ; Fastseek installed ?		;AN000;
   606 000001FE 741B                    	JZ	fs_no2			       ; no				;AN000;
   607 00000200 56                      	PUSH	SI			       ; save regs			;AN000;
   608 00000201 50                      	PUSH	AX								;AN000;
   609 00000202 B00D                    	MOV	AL,FSEC_delete		       ; al=13				;AN000;
   610 00000204 EBC8                    	JMP	fseek_disp		       ; call fastseek			;AN000;
   611                                  EndProc FastSeek_Delete 							;AN000;
   612                                  										;AN000;
   613                                  ; Inputs:
   614                                  ;	FastSeekflg= 0 , not installed
   615                                  ;		     1 , installed
   616                                  ;	BX= first cluster number
   617                                  ;	ES:BP = addr of DPB
   618                                  ; Function:
   619                                  ;	Delete a file extent entry
   620                                  ; Outputs:
   621                                  ;	None
   622                                  ;
   623                                  
   624                                  	procedure  Delete_FSeek,NEAR						;AN000;
   624          ******************       warning: proc Delete_FSeek... [-w+user]
   625                                  ASSUME	DS:NOTHING,ES:NOTHING							;AN000;
   626 00000206 36F606[0000]80          	TEST	byte [ss:FastSeekflg],Fast_yes	       ; Fastseek installed ?		;AN000;
   627 0000020C 740D                    	JZ	fs_no2			       ; no				;AN000;
   628 0000020E 51                      	PUSH	CX			; save regs				;AN000;
   629 0000020F 52                      	PUSH	DX								;AN000;
   630 00000210 89D9                    	MOV	CX,BX			; first cluster #			;AN000;
   631 00000212 268A5600                	MOV	DL,[ES:BP + dpb_drive]	; drive #				;AN000;
   632 00000216 E8DFFF                  	CALL	FastSeek_Delete 	; call fastseek to delete an entry	;AN000;
   633 00000219 5A                      	POP	DX			; restore regs				;AN000;
   634 0000021A 59                      	POP	CX								;AN000;
   635                                  fs_no2: 									;AN000;
   636 0000021B C3                      	return				; exit					;AN000;
   637                                  EndProc Delete_FSeek								;AN000;
   638                                  
   639                                  Break	<FastSeek_Lookup - look up a cluster number>
   640                                  
   641                                  ; Inputs:
   642                                  ;	FSeek_drive : drive number (0=A,1=B,,,)
   643                                  ;	FSeek_firclus: first cluster #
   644                                  ;	FSeek_logclus: logical cluster #
   645                                  ; Function:
   646                                  ;	Look up a physical cluster #
   647                                  ; Outputs:
   648                                  ;	carry clear, DI = physical cluster #, FSeek_logsave=DI-1
   649                                  ;	carry set,
   650                                  ;		   partially found, DI=last physical cluster #
   651                                  ;		      FSeek_logsave=last logical cluster #
   652                                  
   653                                  	procedure  FastSeek_Lookup,NEAR 					;AN000;
   653          ******************       warning: proc FastSeek_Lookup... [-w+user]
   654                                  ASSUME	DS:NOTHING,ES:NOTHING							;AN000;
   655                                  
   656 0000021C 50                      	PUSH	AX			; save ax				;AN000;
   657 0000021D B00E                    	MOV	AL,FSEC_lookup		; al = 14				;AN000;
   658 0000021F 53                      	PUSH	BX			; save bx				;AN000;
   659 00000220 E82900                  	CALL	FS_doit 		; call fastseek 			;AN000;
   660 00000223 36891E[0000]            	MOV	[ss:FSeek_logsave],BX	; save returned BX			;AN000;
   661 00000228 5B                      	POP	BX			; restore bx				;AN000;
   662 00000229 58                      	POP	AX			; restore ax				;AN000;
   663 0000022A C3                      	return									;AN000;
   664                                  EndProc FastSeek_Lookup 							;AN000;
   665                                  										;AN000;
   666                                  
   667                                  Break	<FastSeek_Insert - insert a cluster number>
   668                                  
   669                                  ; Inputs:
   670                                  ;	FSeek_drive : drive number (0=A,1=B,,,)
   671                                  ;	FSeek_firclus: first cluster #
   672                                  ;	FSeek_logclus: logical cluster #
   673                                  ;	DI: physical cluster # to be inserted
   674                                  ; Function:
   675                                  ;	insert a physical cluster #
   676                                  ; Outputs:
   677                                  ;	none
   678                                  ;
   679                                  
   680                                  	procedure  FastSeek_Insert,NEAR
   680          ******************       warning: proc FastSeek_Insert... [-w+user]
   681                                  ASSUME	DS:NOTHING,ES:NOTHING
   682                                  
   683 0000022B 36F606[0000]02          	TEST	byte [ss:FastSeekflg],FS_insert 	; insert mode set ?		;AN000;
   684 00000231 7409                    	JZ	no_insert			; no				;AN000;
   685                                  										;AN000;
   686 00000233 50                      	PUSH	AX				; save regs			;AN000;
   687 00000234 53                      	PUSH	BX								;AN000;
   688 00000235 B00F                    	MOV	AL,FSEC_insert			; al = 15			;AN000;
   689                                  FSentry:									;AN000;
   690 00000237 E81200                  	CALL	FS_doit 			; call fastseek 		;AN000;
   691 0000023A 5B                      	POP	BX				; restore regs			;AN000;
   692 0000023B 58                      	POP	AX								;AN000;
   693                                  no_insert:
   694 0000023C C3                      	return
   695                                  EndProc FastSeek_insert
   696                                  
   697                                  Break	<FastSeek_Truncate - truncate cluster numbers>
   698                                  
   699                                  ; Inputs:
   700                                  ;	FSeek_drive : drive number (0=A,1=B,,,)
   701                                  ;	FSeek_firclus: first cluster #
   702                                  ;	FSeek_logclus: logical cluster #
   703                                  ; Function:
   704                                  ;	truncate physical cluster #s starting from FSeek_logclus
   705                                  ; Outputs:
   706                                  ;	none
   707                                  ;
   708                                  
   709                                  	procedure  FastSeek_Truncate,NEAR
   709          ******************       warning: proc FastSeek_Truncate... [-w+user]
   710                                  ASSUME	DS:NOTHING,ES:NOTHING
   711                                  										;AN000;
   712 0000023D 36F606[0000]80          	TEST	byte [ss:FastSeekflg],Fast_yes	       ; Fastseek installed ?		;AN000;
   713 00000243 7406                    	JZ	fs_no			       ; no				;AN000;
   714 00000245 50                      	PUSH	AX			       ; save regs			;AN000;
   715 00000246 53                      	PUSH	BX								;AN000;
   716 00000247 B010                    	MOV	AL,FSEC_truncate	       ; al = 16			;AN000;
   717 00000249 EBEC                    	JMP	FSentry 		       ; call fastseek			;AN000;
   718                                  fs_no:										;AN000;
   719 0000024B C3                      	return									;AN000;
   720                                  EndProc FastSeek_Truncate							;AN000;
   721                                  
   722                                  ; Inputs:
   723                                  ;	FSeek_drive : drive number (0=A,1=B,,,)
   724                                  ;	FSeek_firclus: first cluster #
   725                                  ;	FSeek_logclus: logical cluster #
   726                                  ; Function:
   727                                  ;	set up parameters and call fastseek
   728                                  ; Outputs:
   729                                  ;	outputs of fastseek
   730                                  ;
   731                                  	procedure  FS_doit,NEAR
   731          ******************       warning: proc FS_doit... [-w+user]
   732                                  ASSUME	DS:NOTHING,ES:NOTHING
   733                                  										;AN000;
   734 0000024C 51                      	PUSH	CX			; save regs				;AN000;
   735 0000024D 52                      	PUSH	DX								;AN000;
   736 0000024E 56                      	PUSH	SI								;AN000;
   737 0000024F 368A16[0000]            	MOV	DL,[ss:FSeek_drive]	; set drive #				;AN000;
   738 00000254 368B0E[0000]            	MOV	CX,[ss:FSeek_firclus]	; set 1st cluster #			;AN000;
   739 00000259 368B1E[0000]            	MOV	BX,[ss:FSeek_logclus]	; set logical cluster # 		;AN000;
   740                                  										;AN000;
   741 0000025E E873FF                  	CALL	FSeek_dispatch		; call fastseek 			;AN000;
   742                                  										;AN000;
   743                                  					; carry clear if found in DI		;AN000;
   744 00000261 5E                      	POP	SI			; otherwise, carry set			;AN000;
   745                                  										;AN000;
   746 00000262 5A                      	POP	DX			; restore regs				;AN000;
   747 00000263 59                      	POP	CX								;AN000;
   748 00000264 C3                      	return									;AN000;
   749                                  EndProc FS_doit 								;AN000;
   750                                  
   751                                  
   752                                  ; Inputs:
   753                                  ;	same as DOS_SEARCH_FIRST
   754                                  ; Function:
   755                                  ;	do a IFS search first
   756                                  ; Outputs:
   757                                  ;	same as DOS_SEARCH_FIRST
   758                                  ;
   759                                  	procedure  IFS_SEARCH_FIRST,NEAR					;AN000;
   759          ******************       warning: proc IFS_SEARCH_FIRST... [-w+user]
   760                                  	DOSAssume   CS,<DS>,"IFS_SEARCH_FIRST"                                  ;AN000;
   761                                  	ASSUME	ES:NOTHING							;AN000;
   762                                  
   763                                  ;	MOV	WORD PTR [DMAADD+2],DS	       ;IFS. replace with scratch area	;AN000;;AN000;
   764                                  ;	MOV	WORD PTR [DMAADD],OFFSET RENAMEDMA wrt DOSGROUP	;IFS.		;AN000;
   765                                  ;	invoke	SET_THISDPB		       ;IFS. THISDPB set		;AN000;
   766                                  ;	invoke	DOS_SEARCH_FIRST	       ;IFS. search first		;AN000;
   767                                  ;	return									;AN000;
   768                                  EndProc IFS_SEARCH_FIRST							;AN000;
   769                                  
   770                                  
   771                                  ; Inputs:
   772                                  ;	THISDPB set
   773                                  ;	WFP_Start points to name
   774                                  ; Function:
   775                                  ;	do a IFS REN_DEL_CHECK
   776                                  ; Outputs:
   777                                  ;	same as REN_DEL_CHECK
   778                                  ;
   779                                  	procedure  IFS_REN_DEL_CHECK,NEAR					;AN000;
   779          ******************       warning: proc IFS_REN_DEL_CHECK... [-w+user]
   780                                  	DOSAssume   CS,<DS>,"IFS_REN_DEL_CHECK"                                 ;AN000;
   781                                  	ASSUME	ES:NOTHING							;AN000;
   782                                  
   783                                  ;	MOV	AX,WORD PTR [DMAADD+2]	       ;IFS. set up			;AN000;;AN000;
   784                                  ;	MOV	WORD PTR [CURBUF+2],AX	       ;IFS. curbuf+2 : bx -> dir entry ;AN000;
   785                                  ;	MOV	BX,WORD PTR [DMAADD]	       ;IFS.				;AN000;
   786                                  ;	ADD	BX,21			       ;IFS.				;AN000;
   787                                  ;	MOV	SI,BX			       ;IFS. curbuf+2:si -> dir_first	;AN000;
   788                                  ;	ADD	SI,dir_first		       ;IFS.				;AN000;
   789                                  ;	EnterCrit   critDisk		       ;IFS. enter critical section	;AN000;
   790                                  ;	CALL	REN_DEL_Check		       ;IFS. share check		;AN000;
   791                                  ;	LeaveCrit   critDisk		       ;IFS. leave critical section	;AN000;
   792                                  ;	return									;AN000;
   793                                  EndProc IFS_REN_DEL_CHECK							;AN000;
   794                                  
   795                                      END
