summaryrefslogtreecommitdiff
path: root/v4.0/src/DOS/CREATE.ASM
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--v4.0/src/DOS/CREATE.ASM380
1 files changed, 380 insertions, 0 deletions
diff --git a/v4.0/src/DOS/CREATE.ASM b/v4.0/src/DOS/CREATE.ASM
new file mode 100644
index 0000000..6983e29
--- /dev/null
+++ b/v4.0/src/DOS/CREATE.ASM
@@ -0,0 +1,380 @@
1; SCCSID = @(#)create.asm 1.6 85/08/19
2TITLE DOS_CREATE/DOS_CREATE_NEW - Internal CREATE calls for MS-DOS
3NAME DOS_CREATE
4; Internal Create and Create new to create a local or NET file and SFT.
5;
6; DOS_CREATE
7; DOS_CREATE_NEW
8; SET_MKND_ERR
9; SET_Media_ID
10; SET_EXT_Mode
11;
12; Revision history:
13;
14; A000 version 4.00 Jan. 1988
15; A001 D490 -- Change IOCTL subfunctios from 63h,43h to 66h, 46h
16
17;
18; get the appropriate segment definitions
19;
20.xlist
21include dosseg.asm
22
23CODE SEGMENT BYTE PUBLIC 'CODE'
24 ASSUME SS:DOSGROUP,CS:DOSGROUP
25
26.xcref
27INCLUDE DOSSYM.INC
28INCLUDE DEVSYM.INC
29include version.inc
30.cref
31.list
32
33Installed = TRUE
34
35 i_need NoSetDir,BYTE
36 i_need THISSFT,DWORD
37 i_need THISCDS,DWORD
38 I_need EXTERR,WORD
39 I_Need ExtErr_locus,BYTE
40 I_need JShare,DWORD
41 I_need VOLCHNG_FLAG,BYTE
42 I_need SATTRIB,BYTE
43 I_need CALLVIDM,DWORD
44 I_need OpenBuf,128
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;
51
52; Inputs:
53; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
54; terminated)
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
64; Function:
65; Try to create the specified file truncating an old one that exists
66; Outputs:
67; sf_ref_count is NOT altered
68; CARRY CLEAR
69; THISSFT filled in.
70; sf_mode = unchanged for FCB, sharing_compat + open_for_both
71; CARRY SET
72; AX is error code
73; error_path_not_found
74; Bad path (not in curr dir part if present)
75; error_bad_curr_dir
76; Bad path in current directory part of path
77; error_access_denied
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
82; generates an INT 24
83; DS preserved, others destroyed
84
85 procedure DOS_Create,NEAR
86 DOSAssume CS,<DS>,"DOS_Create"
87 ASSUME ES:NOTHING
88
89 XOR AH,AH ; Truncate is OK
90Create_inter:
91 TEST AL,NOT (attr_all + attr_ignore + attr_volume_id)
92 ; Mask out any meaningless bits
93 JNZ AttErr
94 TEST AL,attr_volume_id
95 JZ NoReset
96 OR [DOS34_FLAG],DBCS_VOLID ;AN000;FOR dbcs volid
97 MOV AL,attr_volume_id
98NoReset:
99 OR AL,attr_archive ; File changed
100 TEST AL,attr_directory + attr_device
101 JZ ATT_OK
102AttErr:
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.
107ATT_OK:
108 LES DI,[THISSFT]
109 PUSH ES
110 LES SI,[THISCDS]
111 CMP SI,-1
112 JNZ TEST_RE_NET
113 POP ES
114
115;Extended open hooks
116 TEST [EXTOPEN_ON],ext_open_on ;AN000;EO. from extnded open
117 JZ NOEXTOP ;AN000;EO. no, do normal
118IFS_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
121 INT 2FH ;AN000;EO.
122 POP BX ;AN000;EO. trash bx
123 MOV [EXTOPEN_ON],0 ;AN000;EO.
124 return ;AN000;EO.
125NOEXTOP: ;AN000;
126;Extended open hooks
127
128IF NOT Installed
129 transfer NET_SEQ_CREATE
130ELSE
131 PUSH AX
132 MOV AX,(multNET SHL 8) OR 24
133 INT 2FH
134 POP BX ; BX is trashed anyway
135 return
136ENDIF
137
138TEST_RE_NET:
139 TEST ES:[SI.curdir_flags],curdir_isnet
140 POP ES
141 JZ LOCAL_CREATE
142
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.
146dochk:
147 ; invoke IFS_SHARE_CHECK ;AN000;IFS. check share
148 ; JC nomore ;AN000;IFS. share violation
149
150;Extended open hooks
151 TEST [EXTOPEN_ON],ext_open_on ;AN000;EO. from extnded open
152 JNZ IFS_extopen ;AN000;EO. yes, issue extended open
153;Extended open hooks
154
155IF NOT Installed
156 transfer NET_CREATE
157ELSE
158 PUSH AX
159 MOV AX,(multNET SHL 8) OR 23
160 INT 2FH
161 POP BX ; BX is trashed anyway
162nomore:
163 return
164ENDIF
165
166LOCAL_CREATE:
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
170setdone:
171 EnterCrit critDisk
172 invoke MakeNode
173 JNC Create_ok
174 mov [VOLCHNG_FLAG],-1 ; indicate no change in volume label
175 LeaveCrit critDisk
176
177 entry SET_MKND_ERR
178 DOSAssume CS,<DS>,"Set_MkNd_Err"
179 ASSUME ES:NOTHING
180; Looks up MakeNode errors and converts them. AL is MakeNode
181; error, SI is GetPath bad spot return if path_not_found error.
182
183 MOV BX,OFFSET DOSGROUP:CRTERRTAB
184 XLAT
185CreatBadRet:
186 STC
187 return
188
189TABLE SEGMENT
190Public CREAT001S,CREAT001E
191CREAT001S label byte
192CRTERRTAB LABEL BYTE ; Lookup table for MakeNode returns
193 DB ? ; none
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
201CREAT001E label byte
202TABLE ENDS
203
204;
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.
208;
209Create_ok:
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.
212
213;;; FASTOPEN 8/29/86
214 invoke FastOpen_Delete
215;;; FASTOPEN 8/29/86
216 mov al,[SATTRIB]
217 test al,attr_volume_id
218 jz NoVolLabel
219 LES DI,[THISCDS]
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
225
226 EnterCrit CritDisk
227 invoke FatRead_CDS ; force a media check
228 LeaveCrit CritDisk
229NoVolLabel:
230 MOV ax,2
231 LES DI,ThisSFT
232if installed
233 call JShare + 14 * 4
234else
235 Call ShSU
236endif
237 LeaveCrit critDisk
238 transfer SET_SFT_MODE
239
240EndProc DOS_Create
241
242; Inputs:
243; [WFP_START] Points to WFP string ("d:/" must be first 3 chars, NUL
244; terminated)
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
254; Function:
255; Try to create the specified file truncating an old one that exists
256; Outputs:
257; sf_ref_count is NOT altered
258; CARRY CLEAR
259; THISSFT filled in.
260; sf_mode = sharing_compat + open_for_both for Non-FCB SFT
261; CARRY SET
262; AX is error code
263; error_path_not_found
264; Bad path (not in curr dir part if present)
265; error_bad_curr_dir
266; Bad path in current directory part of path
267; error_access_denied
268; Create a second volume id or create a dir
269; error_file_exists
270; Already a file by this name
271; DS preserved, others destroyed
272
273 procedure DOS_Create_New,NEAR
274 DOSAssume CS,<DS>,"DOS_Create_New"
275 ASSUME ES:NOTHING
276
277 MOV AH,1 ; Truncate is NOT OK
278 JMP Create_inter
279
280EndProc DOS_Create_New
281
282
283; Inputs:
284; NAME1= Volume ID
285; BH= 0, delete volume id
286; 1, set new volume id
287; DS= DOSGROUP
288; Function:
289; Set Volume ID to DOS 4.00 Boot record.
290; Outputs:
291; CARRY CLEAR
292; volume id set
293; CARRY SET
294; AX is error code
295
296 procedure Set_Media_ID,NEAR ;AN000;
297 DOSAssume CS,<DS>,"DOS_Create_New" ;AN000;
298 ASSUME ES:NOTHING ;AN000;
299
300 PUSH AX ;AN000;;>32mb
301 PUSH ES ;AN000;;>32mb
302 PUSH DI ;AN000;;>32mb
303
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
309
310 PUSH BX ;AN000;;>32mb
311 PUSH DX ;AN000;;>32mb
312 XOR BH,BH ;AN000;;>32mb
313
314 invoke $IOCTL ;AN000;;>32mb
315 POP DX ;AN000;;>32mb
316 POP BX ;AN000;;>32mb
317 JC geterr ;AN000;;>32mb
318
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
323Noname: ;AN000;
324 MOV SI,OFFSET DOSGROUP:NO_NAME_ID ;AN000;>32mb
325doset: ;AN000;
326 MOV DI,DX ;AN000;;>32mb
327 ADD DI,MEDIA_LABEL ;AN000;;>32mb
328 PUSH CS ;AN000;;>32mb move new volume id to packet
329 POP DS ;AN000;;>32mb
330 PUSH CS ;AN000;;>32mb
331 POP ES ;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
338geterr: ;AN000;
339 PUSH CS ;AN000;>32mb
340 POP DS ;AN000;>32mb ds= dosgroup
341
342 POP DI ;AN000;;>32mb
343 POP ES ;AN000;;>32mb
344 POP AX ;AN000;;>32mb
345 return ;AN000;>32mb
346
347EndProc Set_Media_ID ;AN000;
348
349
350; Inputs:
351; [EXTOPEN_ON]= flag for extende open
352; SAVE_BX= mode specified in Extended Open
353; Function:
354; Set mode in ThisSFT
355; Outputs:
356; carry set,mode is set if from Extended Open
357; carry clear, mode not set yet
358
359IF NOT IBMCOPYRIGHT
360 public Set_EXT_mode
361ENDIF
362
363 procedure Set_EXT_mode,NEAR ;AN000;
364 ASSUME ES:NOTHING,DS:NOTHING ;AN000;
365
366 TEST [EXTOPEN_ON],ext_open_on ;AN000;EO. from extnded open
367 JZ NOTEX ;AN000;EO. no, do normal
368 PUSH AX ;AN000;EO.
369 MOV AX,[SAVE_BX] ;AN000;EO.
370 OR ES:[DI.sf_mode],AX ;AN000;EO.
371 POP AX ;AN000;EO.
372 STC ;AN000;EO.
373NOTEX: ;AN000;
374 return ;AN000;EO.
375
376EndProc Set_EXT_mode ;AN000;
377
378CODE ENDS
379 END
380 \ No newline at end of file