1 ; SCCSID = @(#)create.asm 1.6 85/08/19
2 TITLE DOS_CREATE
/DOS_CREATE_NEW
- Internal CREATE calls for
MS-DOS
4 ; Internal Create and Create new to create a local or NET file and SFT.
14 ; A000 version 4.00 Jan. 1988
15 ; A001 D490 -- Change IOCTL subfunctios from 63h,43h to 66h, 46h
18 ; get the appropriate segment definitions
23 CODE SEGMENT BYTE PUBLIC 'CODE'
24 ASSUME
SS:DOSGROUP
,CS:DOSGROUP
39 I_Need ExtErr_locus
,BYTE
41 I_need VOLCHNG_FLAG
,BYTE
45 I_need EXTOPEN_ON
,BYTE ;AN000; extended open
46 I_need NAME1
,BYTE ;AN000;
47 I_need NO_NAME_ID
,BYTE ;AN000;
48 I_need Packet_Temp
,WORD ;AN000;
49 I_need DOS34_FLAG
,WORD ;AN000;
50 I_need SAVE_BX
,WORD ;AN000;
53 ; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
55 ; [CURR_DIR_END] Points to end of Current dir part of string
56 ; ( = -1 if current dir not involved, else
57 ; Points to first char after last "/" of current dir part)
58 ; [THISCDS] Points to CDS being used
59 ; (Low word = -1 if NUL CDS (Net direct request))
60 ; [THISSFT] Points to SFT to fill in if file created
61 ; (sf_mode field set so that FCB may be detected)
62 ; [SATTRIB] Is attribute of search, determines what files can be found
63 ; AX is Attribute to create
65 ; Try to create the specified file truncating an old one that exists
67 ; sf_ref_count is NOT altered
70 ; sf_mode = unchanged for FCB, sharing_compat + open_for_both
73 ; error_path_not_found
74 ; Bad path (not in curr dir part if present)
76 ; Bad path in current directory part of path
78 ; Attempt to re-create read only file , or
79 ; create a second volume id or create a dir
80 ; error_sharing_violation
81 ; The sharing mode was correct but not allowed
83 ; DS preserved, others destroyed
85 procedure DOS_Create
,NEAR
86 DOSAssume
CS,<DS>,"DOS_Create"
89 XOR AH,AH ; Truncate is OK
91 TEST AL,NOT (attr_all
+ attr_ignore
+ attr_volume_id
)
92 ; Mask out any meaningless bits
94 TEST AL,attr_volume_id
96 OR [DOS34_FLAG
],DBCS_VOLID
;AN000;FOR dbcs volid
99 OR AL,attr_archive
; File changed
100 TEST AL,attr_directory
+ attr_device
103 MOV AX,5 ; Attribute problem
104 MOV Exterr_Locus
,errLOC_Unk
105 JMP SHORT SET_MKND_ERR
; Gotta use MKDIR to make dirs, NEVER allow
106 ; attr_device to be set.
116 TEST [EXTOPEN_ON
],ext_open_on
;AN000;EO. from extnded open
117 JZ NOEXTOP
;AN000;EO. no, do normal
118 IFS_extopen: ;AN000;EO.
119 PUSH AX ;AN000;EO. pass create attr
120 MOV AX,(multNET
SHL 8) OR 46 ;AN000;EO. issue extended open verb
122 POP BX ;AN000;EO. trash bx
123 MOV [EXTOPEN_ON
],0 ;AN000;EO.
129 transfer NET_SEQ_CREATE
132 MOV AX,(multNET
SHL 8) OR 24
134 POP BX ; BX is trashed anyway
139 TEST ES:[SI.curdir_flags
],curdir_isnet
143 CALL Set_EXT_mode
;AN000;EO.
144 JC SHORT dochk
;AN000;EO.
145 OR ES:[DI.sf_mode
],sharing_compat
+ open_for_both
;IFS.
147 ; invoke IFS_SHARE_CHECK ;AN000;IFS. check share
148 ; JC nomore ;AN000;IFS. share violation
151 TEST [EXTOPEN_ON
],ext_open_on
;AN000;EO. from extnded open
152 JNZ IFS_extopen
;AN000;EO. yes, issue extended open
159 MOV AX,(multNET
SHL 8) OR 23
161 POP BX ; BX is trashed anyway
167 CALL Set_EXT_mode
;AN000;EO. set mode if from extended open
168 JC setdone
;AN000;EO.
169 OR ES:[DI].sf_mode
,sharing_compat
+open_for_both
174 mov [VOLCHNG_FLAG
],-1 ; indicate no change in volume label
178 DOSAssume
CS,<DS>,"Set_MkNd_Err"
180 ; Looks up MakeNode errors and converts them. AL is MakeNode
181 ; error, SI is GetPath bad spot return if path_not_found error.
183 MOV BX,OFFSET DOSGROUP
:CRTERRTAB
190 Public CREAT001S
,CREAT001E
192 CRTERRTAB
LABEL BYTE ; Lookup table for MakeNode returns
194 DB error_access_denied
; MakeNode error 1
195 DB error_cannot_make
; MakeNode error 2
196 DB error_file_exists
; MakeNode error 3
197 DB error_path_not_found
; MakeNode error 4
198 DB error_access_denied
; MakeNode error 5
199 DB error_sharing_violation
; MakeNode error 6
200 DB error_file_not_found
; MakeNode error 7
205 ; We have just created a new file. This results in the truncation of old
206 ; files. We must inform the sharer to slash all the open SFT's for this
207 ; file to the current size.
210 ; If we created a volume id on the diskette, set the VOLCHNG_FLAG to logical
211 ; drive number to force a Build BPB after Media Check.
214 invoke FastOpen_Delete
217 test al,attr_volume_id
220 mov ah,byte ptr ES:[DI] ; get drive letter
221 sub ah,'A' ; convert to drive letter
222 mov [VOLCHNG_FLAG
],ah ;Set flag to indicate volid change
223 MOV BH,1 ;AN000;>32mb set volume id to boot record
224 CALL Set_Media_ID
;AN000;>32mb
227 invoke FatRead_CDS
; force a media check
238 transfer SET_SFT_MODE
243 ; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
245 ; [CURR_DIR_END] Points to end of Current dir part of string
246 ; ( = -1 if current dir not involved, else
247 ; Points to first char after last "/" of current dir part)
248 ; [THISCDS] Points to CDS being used
249 ; (Low word = -1 if NUL CDS (Net direct request))
250 ; [THISSFT] Points to SFT to fill in if file created
251 ; (sf_mode field set so that FCB may be detected)
252 ; [SATTRIB] Is attribute of search, determines what files can be found
253 ; AX is Attribute to create
255 ; Try to create the specified file truncating an old one that exists
257 ; sf_ref_count is NOT altered
260 ; sf_mode = sharing_compat + open_for_both for Non-FCB SFT
263 ; error_path_not_found
264 ; Bad path (not in curr dir part if present)
266 ; Bad path in current directory part of path
267 ; error_access_denied
268 ; Create a second volume id or create a dir
270 ; Already a file by this name
271 ; DS preserved, others destroyed
273 procedure DOS_Create_New
,NEAR
274 DOSAssume
CS,<DS>,"DOS_Create_New"
277 MOV AH,1 ; Truncate is NOT OK
280 EndProc DOS_Create_New
285 ; BH= 0, delete volume id
286 ; 1, set new volume id
289 ; Set Volume ID to DOS 4.00 Boot record.
296 procedure Set_Media_ID
,NEAR ;AN000;
297 DOSAssume
CS,<DS>,"DOS_Create_New" ;AN000;
298 ASSUME
ES:NOTHING
;AN000;
300 PUSH AX ;AN000;;>32mb
301 PUSH ES ;AN000;;>32mb
302 PUSH DI ;AN000;;>32mb
304 INC AH ;AN000;;>32mb bl=drive #
305 MOV BL,AH ;AN000;;>32mb bl=drive # (A=1,B=2,,,)
306 MOV AL,0DH ;AN000;;>32mb generic IOCTL
307 MOV CX,0866H ;AN001;;>32mb get media id
308 MOV DX,OFFSET DOSGROUP
:PACKET_TEMP
;AN000;>32mb
310 PUSH BX ;AN000;;>32mb
311 PUSH DX ;AN000;;>32mb
312 XOR BH,BH ;AN000;;>32mb
314 invoke $IOCTL
;AN000;;>32mb
317 JC geterr
;AN000;;>32mb
319 OR BH,BH ;AN000;;>32mb delete volume id
320 JZ NoName
;AN000;>32mb yes
321 MOV SI,OFFSET DOSGROUP
:NAME1
;AN000;>32mb
322 JMP SHORT doset
;AN000;>32mb yes
324 MOV SI,OFFSET DOSGROUP
:NO_NAME_ID
;AN000;>32mb
326 MOV DI,DX ;AN000;;>32mb
327 ADD DI,MEDIA_LABEL
;AN000;;>32mb
328 PUSH CS ;AN000;;>32mb move new volume id to packet
330 PUSH CS ;AN000;;>32mb
332 MOV CX,11 ;AN000;;>32mb
333 REP MOVSB ;AN000;;>32mb
334 MOV CX,0846H ;AN001;;>32mb
335 MOV AL,0DH ;AN000;;>32mb
336 XOR BH,BH ;AN000;;>32mb
337 invoke $IOCTL
;AN000;;>32mb set volume id
340 POP DS ;AN000;>32mb ds= dosgroup
347 EndProc Set_Media_ID
;AN000;
351 ; [EXTOPEN_ON]= flag for extende open
352 ; SAVE_BX= mode specified in Extended Open
354 ; Set mode in ThisSFT
356 ; carry set,mode is set if from Extended Open
357 ; carry clear, mode not set yet
363 procedure Set_EXT_mode
,NEAR ;AN000;
364 ASSUME
ES:NOTHING
,DS:NOTHING
;AN000;
366 TEST [EXTOPEN_ON
],ext_open_on
;AN000;EO. from extnded open
367 JZ NOTEX
;AN000;EO. no, do normal
369 MOV AX,[SAVE_BX
] ;AN000;EO.
370 OR ES:[DI.sf_mode
],AX ;AN000;EO.
376 EndProc Set_EXT_mode
;AN000;