summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/CHKDSK/CHKDSK2.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/CHKDSK/CHKDSK2.ASM')
-rw-r--r--v4.0/src/CMD/CHKDSK/CHKDSK2.ASM449
1 files changed, 449 insertions, 0 deletions
diff --git a/v4.0/src/CMD/CHKDSK/CHKDSK2.ASM b/v4.0/src/CMD/CHKDSK/CHKDSK2.ASM
new file mode 100644
index 0000000..45838da
--- /dev/null
+++ b/v4.0/src/CMD/CHKDSK/CHKDSK2.ASM
@@ -0,0 +1,449 @@
1TITLE CHKDSK - MS-DOS Disk consistancy checker
2page ,132 ;
3
4 .xlist
5 include chkseg.inc
6 INCLUDE CHKCHNG.INC
7 INCLUDE DOSSYM.INC
8 INCLUDE CHKEQU.INC
9 INCLUDE CHKMACRO.INC
10 include pathmac.inc
11 .list
12
13SUBTTL Initialized Data
14PAGE
15CONST SEGMENT PUBLIC PARA 'DATA'
16 EXTRN BADVER:byte,BADDRV_ARG:word,INVPATH_ARG:word
17 EXTRN FILE_ARG:word
18 EXTRN BADCD_ARG:word,BADSUBDIR:byte
19 EXTRN BADDRVM:byte
20 EXTRN BADIDBYT:byte
21 EXTRN OPNERR_ARG:word,NOEXT_ARG:word,EXTENT_ARG:word
22 EXTRN IDMES_ARG:WORD
23 EXTRN FILE_ARG1:WORD,FILE_ARG2:WORD
24 EXTRN badrw_num:word,BADRW_STR:WORD,BLOCK_NUM:WORD
25 EXTRN BADSW_ARG:WORD,DSKSPC:WORD
26 EXTRN HIDMES:WORD,DIRMES:WORD,FILEMES:WORD,ORPHMES2:WORD
27 EXTRN ORPHMES3:WORD,BADSPC:WORD,FRESPC:WORD
28 EXTRN TOTMEM:WORD,FREMEM:WORD,REPORT_ARG:WORD,CRLF_ARG:WORD
29 EXTRN RARG1:dWORD,RARG3:dWORD,ORPHCNT:dWORD ;an049;bgb
30 EXTRN SubstErr:BYTE
31 extrn tot_bytes_lo:word, tot_bytes_hi:word
32
33 extrn SWITCHAR:byte,TCHAR:byte,HECODE:byte,CONBUF:byte
34 extrn DOTMES:byte,NOISY:byte,HAVFIX:byte
35 extrn DOFIX:byte,DIRBUF:near,PARSTR:byte
36 extrn NUL:byte,ERRSUB:word,ALLFILE:byte
37 extrn ORPHFCB:byte,ORPHEXT:byte,HIDCNT:dword
38 extrn HIDSIZ:word,FILCNT:dword,FILSIZ:word,DIRCNT:dword ;an049;bgb
39 extrn DIRSIZ:word,CROSSCNT:dword,BADSIZ:word ;an049;bgb
40 extrn ORPHSIZ:word ;an049;bgb
41 extrn LCLUS:word ;an049;bgb
42 extrn USERDIR:byte,FRAGMENT:byte
43 extrn ALLDRV:byte,FIXMFLG:byte,DIRCHAR:byte
44 extrn EOFVAL:word ;an050;bgb
45 extrn Idmes2:Byte,Idmes1:Byte,idmes3:byte ;an017;bgb
46CONST ENDS
47
48SUBTTL Un-initialized Data
49PAGE
50DATA SEGMENT PUBLIC PARA 'DATA'
51 extrn THISDPB:dword,DOTSNOGOOD:byte,NUL_ARG:byte
52 extrn NAMBUF:byte,SRFCBPT:word
53 extrn ISCROSS:byte,MCLUS:word,CSIZE:byte,SSIZE:word
54 extrn DSIZE:word,ARG1:word,ARG_BUF:byte,ERRCNT:byte
55 extrn USERDEV:byte,HARDCH:dword,CONTCH:dword
56 extrn mem_size:word ;an055;bgb
57 extrn psp_segment:word ;an030;bgb
58 extrn write_fault:byte ;an045;bgb
59DATA ENDS
60
61CODE SEGMENT PUBLIC PARA 'CODE'
62ASSUME CS:DG,DS:DG,ES:DG,SS:DG
63 EXTRN INT_23:NEAR
64 EXTRN PROMPTYN:NEAR,GET_CURRDIRERR:NEAR,GET_CURRDIR:NEAR
65 EXTRN FINDCHAIN:NEAR,CHECKERR:NEAR
66 EXTRN Write_Disk:Near, multiply_32_bits:near
67
68 PUBLIC PRINTF_CRLF,DOCRLF,SUBERRP,FCB_TO_ASCZ,EPRINT
69 PUBLIC DOINT26,DOTCOMBMES,REPORT
70 public ramcarv
71
72
73;EPRINT:
74; CALL CHECKERR
75; JNZ RET14
76; cmp byte ptr [nul_arg],0
77; jnz hav_eprint_arg
78; mov [file_arg2],offset dg:nul
79;hav_eprint_arg:
80; mov [file_arg1],dx
81; ;mov dx,offset dg:file_arg
82; mov dx,file_arg ;Get offset of message ;AC000;
83; call printf_crlf
84; mov byte ptr [nul_arg],0
85;RET14: ret
86
87
88EPrint:
89 call CheckErr ;See if we should display msg
90 pathlabl chkdsk2
91; $IF Z ;Yes if Z set ;AC000;
92 JNZ $$IF1
93 push dx ;Save message ;AC000;
94 Message File_Arg ;Put out file in question ;AC000;
95 pop dx ;Get back message ;AC000;
96 call Printf_CRLF ;Print it
97 cmp byte ptr [nul_arg],0 ;Is there a second message?
98; $IF NZ ;Yes if not nul ;AC000;
99 JZ $$IF2
100 mov dx,File_Arg2 ;Display it ;AN000;
101 call Printf_CRLF ; ;AN000;
102; $ENDIF ; ;AC000;
103$$IF2:
104 mov byte ptr [nul_arg],0 ;Re-init this field
105; $ENDIF
106$$IF1:
107 ret ;
108
109DOTCOMBMES:
110 CMP [NOISY],0
111 JZ SUBERRP
112 mov [file_arg2],dx
113 CALL get_currdirERR
114 ;MOV DX,OFFSET DG:CENTRY ;Centry got split into 3 msg's
115 ;inc byte ptr [nul_arg] ;
116 CALL EPRINT
117 RET
118
119SUBERRP:
120 MOV AL,1 ;found a subdir error
121 XCHG AL,BYTE PTR [ERRSUB] ;set error flag and get old flag
122 CMP AL,0 ;were any errors found before?
123; $if z ;no errors found yet
124 JNZ $$IF5
125 ;JNZ RET32
126 MOV SI,OFFSET DG:NUL ;display error msgs
127 CALL get_currdirERR
128 MOV DX,OFFSET DG:BADSUBdir
129 CALL EPRINT
130; $endif
131$$IF5:
132RET32: RET
133
134;****************************************************************************
135; called by: get_thisel2
136; inputs: DS:SI - pointer to file name
137;****************************************************************************
138FCB_TO_ASCZ: ;Convert DS:SI to ASCIZ ES:DI
139 PUSH CX
140;move filename from ds:si to es:di
141 MOV CX,8 ; Pack the name
142 REP MOVSB ; Move all of it
143main_kill_tail:
144; delete trailing spaces in name
145 CMP BYTE PTR ES:[DI-1]," " ;was the last char in name a space?
146 JNZ find_check_dot
147 DEC DI ; Back up over trailing space
148 INC CX
149 CMP CX,8
150 JB main_kill_tail
151find_check_dot:
152; ???
153 CMP WORD PTR [SI],(" " SHL 8) OR " "
154 JNZ got_ext ; Some chars in extension
155 CMP BYTE PTR [SI+2]," "
156 JZ find_done ; No extension
157got_ext:
158; move period for extension
159 MOV AL,"."
160 STOSB
161; move 3 byte extension
162 MOV CX,3
163 REP MOVSB
164ext_kill_tail:
165;delete trailing blanks
166 CMP BYTE PTR ES:[DI-1]," " ;
167 JNZ find_done ;
168 DEC DI ; Back up over trailing space
169 JMP ext_kill_tail ;
170find_done: ;
171; put hex zero at the end
172 XOR AL,AL ;
173 STOSB ; NUL terminate
174 POP CX
175 RET
176
177
178DOINT26:
179; PUSH CX ;reg saves are handled in write_disk ;ac048;bgb;an045;bgb
180; PUSH DX ;reg saves are handled in write_disk ;ac048;bgb;an045;bgb
181; PUSH BX ;reg saves are handled in write_disk ;ac048;bgb;an045;bgb
182 call Write_Disk ; ;an045;bgb;AC000;
183; POP BX ;reg saves are handled in write_disk ;ac048;bgb;an045;bgb
184; POP DX ;reg saves are handled in write_disk ;ac048;bgb;an045;bgb
185; POP CX ;reg saves are handled in write_disk ;ac048;bgb;an045;bgb
186; JNC RET23 ;ac048;bgb;an045;bgb
187 ;MOV SI,OFFSET DG:WRITING ;ac048;bgb;an045;bgb
188 ;CALL DSKERR ;ac048;bgb;an045;bgb
189; $IF C ;ac048;bgb;an045;bgb
190 JNC $$IF7
191 mov dx,offset dg:write_fault ;ac048;bgb;an045;bgb
192 invoke printf_crlf ;ac048;bgb;an045;bgb
193; $ENDIF ;ac048;bgb;an045;bgb
194$$IF7:
195; ;ac048;bgb;ac048;bgb;an045;bgb
196;Need to handle 'Fail' option of critical error here. ;ac048;bgb;an045;bgb
197; ;ac048;bgb;an045;bgb
198 ;ac048;bgb;an045;bgb
199; JZ DOINT26 ;ac048;bgb;an045;bgb
200RET23: RET ;ac048;bgb;an045;bgb
201
202
203
204;**************************************
205; Prints all reporting data
206;**************************************
207
208REPORT:
209;total disk space
210 mov bx,offset dg:dskspc
211 mov dx,tot_bytes_hi ;total bytes in disk ;AN006;bgb
212 mov ax,tot_bytes_lo ;total bytes in disk ;AN006;bgb
213 xor si,si ;no file count
214 xor di,di ;no file count
215 call Report_Mes_2 ; ;AN006;bgb
216;hidden files
217 mov ax,hidsiz ;get cluster count ;an049;bgb
218 or ax,ax ;are there any hidden files?
219; $IF NZ ;yes ;AC000;
220 JZ $$IF9
221 mov si,word ptr hidcnt ;si=low file count ;an049;bgb
222 mov di,word ptr hidcnt+2 ;di=hi file count ;an049;bgb
223 mov bx,offset dg:hidmes ;bx=msg ;
224 call report_mes_1 ;
225; $ENDIF ; ;AC000;
226$$IF9:
227;space in subdirectories
228 mov ax,dirsiz ;get cluster count
229 or ax,ax ;Are there any directories? ;an049;bgb
230; $IF NZ ;yes ;AC000;
231 JZ $$IF11
232 mov si,word ptr dircnt ;si=low file count ;an049;bgb
233 mov di,word ptr dircnt+2 ;di=hi file count ;an049;bgb
234 mov bx,offset dg:dirmes ;bx=msg
235 call report_mes_1 ;an049;bgb
236; $ENDIF ; ;AC000;
237$$IF11:
238;user files
239 mov ax,filsiz ;get cluster count
240 or ax,ax ;Are there any user files? ;an049;bgb
241; $IF NZ ;yes ;AC000;
242 JZ $$IF13
243 mov si,word ptr filcnt ;si=lo file count ;an049;bgb
244 mov di,word ptr filcnt+2 ;di=hi file count ;an049;bgb
245 mov bx,offset dg:filemes ;bx=msg
246 call report_mes_1
247; $ENDIF ; ;AC000;
248$$IF13:
249;chains of lost clusters
250 mov ax,orphsiz ;get cluster count
251 or ax,ax ;Are there any lost clusters? ;an049;bgb
252; $IF NZ ;yes ;AC000;
253 JZ $$IF15
254 mov si,word ptr orphcnt ;si=lo file count
255 mov di,word ptr orphcnt+2 ;di=hi file count
256 cmp dofix,0 ;/F entered?
257; $IF Z ;no ;AC000;
258 JNZ $$IF16
259 mov bx,offset dg:orphmes3 ;bytes would be recovered
260; $else
261 JMP SHORT $$EN16
262$$IF16:
263 mov bx,offset dg:orphmes2 ;bytes were recovered
264; $ENDIF ; ;AC000;
265$$EN16:
266 call report_mes_1
267; $ENDIF ; ;AC000;
268$$IF15:
269;clusters of bad spots
270 mov ax,badsiz ;get cluster count
271 or ax,ax ;Are there any bad spots on disk?
272; $IF NZ ;if low word > zero, then yes ;AC000;
273 JZ $$IF20
274 xor si,si ;no files to count
275 xor di,di ;no files to count
276 mov bx,offset dg:badspc ;Issue report
277 call report_mes_1
278; $ENDIF ; ;AC000;
279$$IF20:
280;bytes on disk left - free space
281 mov ax,[dsize] ;get total disk clusters
282 sub ax,[dirsiz] ; - dirs
283 sub ax,[filsiz] ; - files
284 sub ax,[hidsiz] ; - hidden files
285 sub ax,[badsiz] ; - bad spots
286 sub ax,[orphsiz] ; - lost clusters recovered
287 sub ax,[lclus] ; - lost clusters not recovered
288 xor si,si
289 xor di,di
290 mov bx,offset dg:frespc
291 call report_mes_1 ;Free space is whats left
292 call docrlf ; ;AN000;
293;size of each allocation unit
294 xor dx,dx ;Figure out cluster size ;AN000;
295 xor ah,ah ; ;AN000;
296 mov cx,SSize ;Bytes/sector * ;AN000;
297 mov al,CSize ; Sectors/cluster ;AN000;
298 mul cx ; = Bytes/Cluster in AX ;AN000;
299 mov bx,offset dg:idmes2 ;Allocation size message ;AN000;
300 xor si,si
301 xor di,di
302 call Report_Mes_2 ; ;AN000;
303;total clusters
304 mov ax,Mclus ;Allocation units available ;AN000;
305 dec ax ;MCLUS is # clusters+1
306 xor dx,dx ; ;AN000;
307 mov bx,offset dg:idmes1 ; ;AN000;
308 xor si,si
309 xor di,di
310 call Report_Mes_2 ; ;AN000;
311;;;;;;;;call docrlf ; ;an017;bgb
312;avail clusters ;an017;bgb
313public avail_clus
314avail_clus:
315 mov ax,[dsize] ;total clusters on disk ;an017;bgb
316 sub ax,[dirsiz] ; - clusters in subdirs ;an017;bgb
317 sub ax,[filsiz] ; - user files ;an017;bgb
318 sub ax,[hidsiz] ; - hidden files ;an017;bgb
319 sub ax,[badsiz] ; - bad spots ;an017;bgb
320 sub ax,[orphsiz] ; - lost clusters recovered ;an017;bgb
321 sub ax,[lclus] ; - lost clusters not recovered ;an017;bgb
322 mov bx,offset dg:idmes3 ; ;an017;bgb
323 xor dx,dx ; ;AN017;bgb
324 xor si,si
325 xor di,di
326 call Report_Mes_2 ;dont convert to bytes! ;an017;bgb
327 call docrlf ;an017;bgb
328
329
330;dcl Jan 8, 87 Compensate for RAM Carving - Start
331
332ramcarv:
333 push es ;AN000;
334 xor bx,bx ;AN000;
335 mov ah,0c1h ; return Ext'd Bios Data Seg Address ;AN000;
336 int 15h ;AN000;
337; $IF NC ; ram carving exists if no carry ;AC000; ;AN000;
338 JC $$IF22
339 xor ax,ax ; zero out ax
340 mov al,byte ptr es:[0] ; pointer to # of 1k blocks of RAM Carve;AN000;
341 mov dx,64 ; convert 1k blocks to paras ;AN000;
342 mul dx ;AN000;
343 mov bx,ax ; save value in BX ;AN000;
344; $ENDIF ; ;AC000; ;AN000;
345$$IF22:
346 pop es ;AN000;
347
348;dcl Jan 8, 87 Compensate for RAM Carving - End
349
350 mov ax,[mem_size] ;Find out about memory
351 add ax,bx ; dcl Jan 8, 87 Compensate for RAM Carving
352 mov dx,16 ;Mul to convert kbytes to bytes
353 mul dx
354 mov bx,offset dg:totmem
355 call report_mes_2
356 mov ax,[mem_size]
357;;;;;;; mov dx,psp_segment ;an030;bgb
358 sub ax,psp_segment ;an030;bgb
359 mov dx,16
360 mul dx
361 mov bx,offset dg:fremem
362 call report_mes_2
363 ret
364
365;*************************************************************
366;
367; Print the message specified by the control string.
368;
369; REPORT_MES_1
370; On entry:
371; BX contains the address of the control string.
372; AX contains a cluster count for the %ld argument in the control string.
373; CX contains a word count for the %d argument in the control string
374; or is meaningless.
375;
376; REPORT_MES_2
377; On entry:
378; BX contains the address of the control string.
379; AX,DX contain a long integer.
380; CX contains a word count for the %d argument in the control string
381; or is meaningless.
382;
383;*************************************************************
384
385;*****************************************************************************
386; REPORT_MES_1 - Print the report messages. Display the file count and
387; translate the number of clusters into the number of bytes.
388;
389; WARNING!! NOTE!! -->
390;
391; called by - PROCEDURE NAME
392;
393; inputs: AX - cluster count (1-ffff)
394; BX - offset of control string
395; CX -
396; DX - high word of cluster count is zero'd out here.
397; SP -
398; BP -
399; SI - low word of file count
400; DI - hi word of file count
401; DS - segment of control string
402; ES -
403;
404; output: DISPLAY OF DATA TO SCREEN
405;
406; Regs abused - ALL
407;
408;logic: 1. zero out hi word of cluster count, and multiply by sectors per
409; cluster. This gives number of sectors, which is a double word.
410;
411; 2. multiply by bytes per sector to give number of bytes.
412;
413; 3. place values in diplay fields, and call the msg. retriever.
414;
415;*****************************************************************************
416report_mes_1:
417 push bx ;save it
418 xor dx,dx ;zero out hi word for multiply
419 mov cl,csize ;get sectors per cluster
420 xor ch,ch ;zero out hi byte of word
421 mul cx ;Convert cluster count to sector count ax/dx
422
423 mov bx,dx ;bx:ax is number to be mult;bgb
424 mov cx,ssize ;cx is number to mult with ;bgb
425 call multiply_32_bits ;bgb
426 mov dx,bx ;move hi value to dx
427 pop bx ;retore pointer;bgb
428
429report_mes_2:
430 mov word ptr rarg1,ax ;Lo word of bytes in ax
431 mov word ptr rarg1+2,dx ;Hi word of bytes in dx
432 mov word ptr rarg3,si ;lo word of file count in si
433 mov word ptr rarg3+2,di ;hi word of file count in di
434 mov report_arg,bx ;Store the offset of the ctrl string
435 mov dx,bx ;dx has ptr to msg for disp_interface ;AC000;
436 call printf_crlf ;print msg, then carraige return
437 ret
438
439PRINTF_CRLF:
440 call display_interface ; ;AC000;
441DOCRLF: mov dx,offset dg:crlf_arg
442 call Display_Interface ;Replace old printf call with SysDispMsg;AN000;
443 ret ; ;AN000;
444
445
446 pathlabl chkdsk2
447CODE ENDS
448 END
449 \ No newline at end of file