]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/DOS/DIRCALL.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / DOS / DIRCALL.ASM
1 ; SCCSID = @(#)dircall.asm 1.1 85/04/10
2 ; SCCSID = @(#)dircall.asm 1.1 85/04/10
3 TITLE DIRCALL - Directory manipulation internal calls
4 NAME DIRCALL
5 ; Low level directory manipulation routines for making removing and
6 ; verifying local or NET directories
7 ;
8 ; DOS_MKDIR
9 ; DOS_CHDIR
10 ; DOS_RMDIR
11 ;
12 ; Modification history:
13 ;
14 ; Created: ARR 30 March 1983
15 ;
16
17 ;
18 ; get the appropriate segment definitions
19 ;
20 .xlist
21 include dosseg.asm
22
23 CODE SEGMENT BYTE PUBLIC 'CODE'
24 ASSUME SS:DOSGROUP,CS:DOSGROUP
25
26 .xcref
27 INCLUDE DOSSYM.INC
28 INCLUDE DEVSYM.INC
29 INCLUDE FASTOPEN.INC
30 INCLUDE FASTXXXX.INC
31 .cref
32 .list
33
34 Installed = TRUE
35
36 i_need THISSFT,DWORD
37 i_need THISCDS,DWORD
38 i_need NoSetDir,BYTE
39 i_need CURBUF, DWORD
40 i_need DIRSTART,WORD
41 i_need THISDPB,DWORD
42 i_need NAME1,BYTE
43 i_need LASTENT,WORD
44 i_need SATTRIB,BYTE
45 i_need ATTRIB,BYTE
46 i_need ALLOWED,BYTE
47 i_need FAILERR,BYTE
48 i_need RenBuf,BYTE
49 i_need FastOpenFlg,BYTE ; DOS 3.3
50 i_need FastOpenTable,BYTE ; DOS 3.3
51 i_need WFP_START,WORD ; DOS 3.3
52 i_need HIGH_SECTOR,WORD ; F.C. >32mb
53
54 BREAK <DOS_MkDir - Make a directory entry>
55
56 ; Inputs:
57 ; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
58 ; terminated)
59 ; [CURR_DIR_END] Points to end of Current dir part of string
60 ; ( = -1 if current dir not involved, else
61 ; Points to first char after last "/" of current dir part)
62 ; [THISCDS] Points to CDS being used
63 ; (Low word = -1 if NUL CDS (Net direct request))
64 ; Function:
65 ; Make a new directory
66 ; Returns:
67 ; Carry Clear
68 ; No error
69 ; Carry Set
70 ; AX is error code
71 ; error_path_not_found
72 ; Bad path (not in curr dir part if present)
73 ; error_bad_curr_dir
74 ; Bad path in current directory part of path
75 ; error_access_denied
76 ; Already exists, device name
77 ; DS preserved, Others destroyed
78
79 procedure DOS_MKDIR,NEAR
80 DOSAssume CS,<DS>,"DOS_MkDir"
81 ASSUME ES:NOTHING
82
83 Invoke TestNet
84 JNC local_mkdir
85 IF NOT Installed
86 transfer NET_MKDIR
87 ELSE
88 MOV AX,(multNET SHL 8) OR 3
89 INT 2FH
90 return
91 ENDIF
92
93 NODEACCERRJ:
94 MOV AX,error_access_denied
95 BadRet:
96 STC
97 LeaveCrit critDisk
98 return
99
100 PATHNFJ:
101 LeaveCrit critDisk
102 transfer SET_MKND_ERR ; Map the MakeNode error and return
103
104 LOCAL_MKDIR:
105 EnterCrit critDisk
106 ;
107 ; MakeNode requires an SFT to fiddle with. We Use a temp spot (RENBUF)
108 ;
109 MOV WORD PTR [THISSFT+2],SS
110 MOV WORD PTR [THISSFT],OFFSET DOSGroup:RenBuf
111 ;
112 ; NOTE: Need WORD PTR because MASM takes type of
113 ; TempSFT (byte) instead of type of sf_mft (word).
114 ;
115 MOV WORD PTR RenBuf.sf_mft,0 ; make sure SHARER won't complain.
116 MOV AL,attr_directory
117 invoke MAKENODE
118
119 JC PATHNFJ
120 CMP AX,3
121 JZ NODEACCERRJ ; Can't make a device into a directory
122 LES BP,[THISDPB] ; Makenode zaps this
123 LDS DI,[CURBUF]
124 ASSUME DS:NOTHING
125 SUB SI,DI
126 PUSH SI ; Pointer to dir_first
127 PUSH WORD PTR [DI.buf_sector+2] ;F.C. >32mb
128
129 PUSH WORD PTR [DI.buf_sector] ; Sector of new node
130 context DS
131 PUSH [DIRSTART] ; Parent for .. entry
132 XOR AX,AX
133 MOV [DIRSTART],AX ; Null directory
134 invoke NEWDIR
135 JC NODEEXISTSPOPDEL ; No room
136 invoke GETENT ; First entry
137 JC NODEEXISTSPOPDEL ; Screw up
138 LES DI,[CURBUF]
139
140 TEST ES:[DI.buf_flags],buf_dirty ;LB. if already dirty ;AN000;
141 JNZ yesdirty ;LB. don't increment dirty count ;AN000;
142 invoke INC_DIRTY_COUNT ;LB. ;AN000;
143 OR ES:[DI.buf_flags],buf_dirty
144 yesdirty:
145 ADD DI,BUFINSIZ ; Point at buffer
146 MOV AX,202EH ; ". "
147 MOV DX,[DIRSTART] ; Point at itself
148 invoke SETDOTENT
149 MOV AX,2E2EH ; ".."
150 POP DX ; Parent
151 invoke SETDOTENT
152 LES BP,[THISDPB]
153 MOV [ALLOWED],allowed_FAIL + allowed_RETRY
154 POP DX ; Entry sector
155 POP [HIGH_SECTOR] ;F.C. >32mb
156
157 XOR AL,AL ; Pre read
158 invoke GETBUFFR
159 JC NODEEXISTSP
160 MOV DX,[DIRSTART]
161 LDS DI,[CURBUF]
162 ASSUME DS:NOTHING
163 OR [DI.buf_flags],buf_isDIR
164 POP SI ; dir_first pointer
165 ADD SI,DI
166 MOV [SI],DX
167 XOR DX,DX
168 MOV [SI+2],DX ; Zero size
169 MOV [SI+4],DX
170 DIRUP:
171 TEST [DI.buf_flags],buf_dirty ;LB. if already dirty ;AN000;
172 JNZ yesdirty2 ;LB. don't increment dirty count ;AN000;
173 invoke INC_DIRTY_COUNT ;LB. ;AN000;
174 OR [DI.buf_flags],buf_dirty ; Dirty buffer
175 yesdirty2:
176 context DS
177 MOV AL,ES:[BP.dpb_drive]
178 invoke FLUSHBUF
179 MOV AX,error_access_denied
180 LeaveCrit critDisk
181 return
182
183 NODEEXISTSPOPDEL:
184 POP DX ; Parent
185 POP DX ; Entry sector
186 POP [HIGH_SECTOR] ; F.C. >32mb
187
188 LES BP,[THISDPB]
189 MOV [ALLOWED],allowed_FAIL + allowed_RETRY
190 XOR AL,AL ; Pre read
191 invoke GETBUFFR
192 JC NODEEXISTSP
193 LDS DI,[CURBUF]
194 ASSUME DS:NOTHING
195 OR [DI.buf_flags],buf_isDIR
196 POP SI ; dir_first pointer
197 ADD SI,DI
198 SUB SI,dir_first ;Point back to start of dir entry
199 MOV BYTE PTR [SI],0E5H ; Free the entry
200 CALL DIRUP ; Error doesn't matter since erroring anyway
201 NODEEXISTS:
202 JMP NODEACCERRJ
203
204 NODEEXISTSP:
205 POP SI ; Clean stack
206 JMP NODEEXISTS
207
208 EndProc DOS_MKDIR
209
210 BREAK <DOS_ChDir -- Verify a directory>
211
212 ; Inputs:
213 ; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
214 ; terminated)
215 ; [CURR_DIR_END] Points to end of Current dir part of string
216 ; ( = -1 if current dir not involved, else
217 ; Points to first char after last "/" of current dir part)
218 ; [THISCDS] Points to CDS being used May not be NUL
219 ; Function:
220 ; Validate the path for potential new current directory
221 ; Returns:
222 ; NOTE:
223 ; [SATTRIB] is modified by this call
224 ; Carry Clear
225 ; CX is cluster number of the DIR, LOCAL CDS ONLY
226 ; Caller must NOT set ID fields on a NET CDS.
227 ; Carry Set
228 ; AX is error code
229 ; error_path_not_found
230 ; Bad path
231 ; error_access_denied
232 ; device or file name
233 ; DS preserved, Others destroyed
234
235 procedure DOS_CHDIR,NEAR
236 DOSAssume CS,<DS>,"DOS_Chdir"
237 ASSUME ES:NOTHING
238
239 Invoke TestNet
240 JNC LOCAL_CHDIR
241 IF NOT Installed
242 transfer NET_CHDIR
243 ELSE
244 MOV AX,(multNET SHL 8) OR 5
245 INT 2FH
246 return
247 ENDIF
248
249 LOCAL_CHDIR:
250 EnterCrit critDisk
251 TEST ES:[DI.curdir_flags],curdir_splice ;PTM.
252 JZ nojoin ;PTM.
253 MOV ES:[DI.curdir_ID],0FFFFH ;PTM.
254 nojoin:
255 MOV [NoSetDir],FALSE
256 MOV [SATTRIB],attr_directory+attr_system+attr_hidden
257 ; Dir calls can find these
258 ; DOS 3.3 6/24/86 FastOpen
259
260 OR [FastOpenFlg],FastOpen_Set ; set fastopen flag
261 invoke GetPath
262 PUSHF ;AN000;
263 AND [FastOpenFlg],Fast_yes ; clear it all ;AC000;
264 POPF ;AN000;
265 ; DOS 3.3 6/24/86 FastOpen
266 MOV AX,error_path_not_found
267 JC ChDirDone
268 JNZ NOTDIRPATH ; Path not a DIR
269 MOV CX,[DIRSTART] ; Get cluster number
270 CLC
271 ChDirDone:
272 LeaveCrit critDisk
273 return
274
275 EndProc DOS_CHDIR
276
277 BREAK <DOS_RmDir -- Remove a directory>
278
279 ; Inputs:
280 ; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
281 ; terminated)
282 ; [CURR_DIR_END] Points to end of Current dir part of string
283 ; ( = -1 if current dir not involved, else
284 ; Points to first char after last "/" of current dir part)
285 ; [THISCDS] Points to CDS being used
286 ; (Low word = -1 if NUL CDS (Net direct request))
287 ; Function:
288 ; Remove a directory
289 ; NOTE: Attempt to remove current directory must be detected by caller
290 ; Returns:
291 ; NOTE:
292 ; [SATTRIB] is modified by this call
293 ; Carry Clear
294 ; No error
295 ; Carry Set
296 ; AX is error code
297 ; error_path_not_found
298 ; Bad path (not in curr dir part if present)
299 ; error_bad_curr_dir
300 ; Bad path in current directory part of path
301 ; error_access_denied
302 ; device or file name, root directory
303 ; Bad directory ('.' '..' messed up)
304 ; DS preserved, Others destroyed
305
306 procedure DOS_RMDIR,NEAR
307 DOSAssume CS,<DS>,"DOS_RmDir"
308 ASSUME ES:NOTHING
309
310 Invoke TestNet
311 JNC Local_RmDIR
312 IF NOT Installed
313 transfer NET_RMDIR
314 ELSE
315 MOV AX,(multNET SHL 8) OR 1
316 INT 2FH
317 return
318 ENDIF
319
320 LOCAL_RMDIR:
321 EnterCrit critDisk
322 MOV [NoSetDir],0
323 MOV [SATTRIB],attr_directory+attr_system+attr_hidden
324 ; Dir calls can find these
325 invoke GetPath
326 JC NOPATH ; Path not found
327 JNZ NOTDIRPATH ; Path not a DIR
328 MOV DI,[DIRSTART]
329 OR DI,DI ; Root ?
330 JNZ rmdir_get_buf ; No
331 JMP SHORT NOTDIRPATH
332
333 NOPATH:
334 MOV AX,error_path_not_found
335 JMP BadRet
336
337 NOTDIRPATHPOP:
338 POP AX ;F.C. >32mb
339 POP AX
340 NOTDIRPATHPOP2:
341 POP AX
342 NOTDIRPATH:
343 JMP NodeAccErrJ
344
345 rmdir_get_buf:
346 LDS DI,[CURBUF]
347 ASSUME DS:NOTHING
348 SUB BX,DI ; Compute true offset
349 PUSH BX ; Save entry pointer
350 PUSH WORD PTR [DI.buf_sector+2] ;F.C. >32mb
351 PUSH WORD PTR [DI.buf_sector] ; Save sector number
352 context DS
353 context ES
354 MOV DI,OFFSET DOSGROUP:NAME1
355 MOV AL,'?'
356 MOV CX,11
357 REP STOSB
358 XOR AL,AL
359 STOSB ; Nul terminate it
360 invoke STARTSRCH ; Set search
361 invoke GETENTRY ; Get start of directory
362 JC NOTDIRPATHPOP ; Screw up
363 MOV DS,WORD PTR [CURBUF+2]
364 ASSUME DS:NOTHING
365 MOV SI,BX
366 LODSW
367 CMP AX,(' ' SHL 8) OR '.' ; First entry '.'?
368 JNZ NOTDIRPATHPOP ; Nope
369 ADD SI,(SIZE dir_entry) - 2 ; Next entry
370 LODSW
371 CMP AX,('.' SHL 8) OR '.' ; Second entry '..'?
372 JNZ NOTDIRPATHPOP ; Nope
373 context DS
374 MOV [LASTENT],2 ; Skip . and ..
375 invoke GETENTRY ; Get next entry
376 JC NOTDIRPATHPOP ; Screw up
377 MOV [ATTRIB],attr_directory+attr_hidden+attr_system
378 invoke SRCH ; Do a search
379 JNC NOTDIRPATHPOP ; Found another entry!
380 CMP [FAILERR],0
381 JNZ NOTDIRPATHPOP ; Failure of search due to I 24 FAIL
382 LES BP,[THISDPB]
383 MOV BX,[DIRSTART]
384 ;; FastSeek 10/27/86
385 invoke Delete_FSeek ; delete the fastseek entry
386 ;; FastSeek 10/27/86
387 invoke RELEASE ; Release data in sub dir
388 JC NOTDIRPATHPOP ; Screw up
389 POP DX ; Sector # of entry
390 POP [HIGH_SECTOR] ; F.C. >32mb
391
392 MOV [ALLOWED],allowed_FAIL + allowed_RETRY
393 XOR AL,AL ; Pre read
394 invoke GETBUFFR ; Get sector back
395 JC NOTDIRPATHPOP2 ; Screw up
396 LDS DI,[CURBUF]
397 ASSUME DS:NOTHING
398 OR [DI.buf_flags],buf_isDIR
399 POP BX ; Pointer to start of entry
400 ADD BX,DI ; Corrected
401 MOV BYTE PTR [BX],0E5H ; Free the entry
402
403 ;DOS 3.3 FastOpen 6/16/86 F.C.
404 PUSH DS
405 context DS
406 invoke FastOpen_Delete ; call fastopen to delete an entry
407 POP DS
408 ;DOS 3.3 FastOpen 6/16/86 F.C.
409
410 JMP DIRUP ; In MKDIR, dirty buffer and flush
411
412 EndProc DOS_RMDIR
413
414 CODE ENDS
415 END