1 TITLE CHKDSK
- MS-DOS Disk consistancy checker
13 SUBTTL Initialized
Data
15 CONST
SEGMENT PUBLIC PARA
'DATA'
16 EXTRN BADVER
:byte,BADDRV_ARG
:word,INVPATH_ARG
:word
18 EXTRN BADCD_ARG
:word,BADSUBDIR
:byte
21 EXTRN OPNERR_ARG
:word,NOEXT_ARG
:word,EXTENT_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
31 extrn tot_bytes_lo
:word, tot_bytes_hi
:word
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
48 SUBTTL Un
-initialized
Data
50 DATA 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
61 CODE SEGMENT PUBLIC PARA
'CODE'
62 ASSUME
CS:DG
,DS:DG
,ES:DG
,SS:DG
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
68 PUBLIC PRINTF_CRLF
,DOCRLF
,SUBERRP
,FCB_TO_ASCZ
,EPRINT
69 PUBLIC DOINT26
,DOTCOMBMES
,REPORT
76 ; cmp byte ptr [nul_arg],0
78 ; mov [file_arg2],offset dg:nul
81 ; ;mov dx,offset dg:file_arg
82 ; mov dx,file_arg ;Get offset of message ;AC000;
84 ; mov byte ptr [nul_arg],0
89 call CheckErr
;See if we should display msg
91 ; $IF Z ;Yes if Z set ;AC000;
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;
100 mov dx,File_Arg2
;Display it ;AN000;
101 call Printf_CRLF
; ;AN000;
104 mov byte ptr [nul_arg
],0 ;Re-init this field
114 ;MOV DX,OFFSET DG:CENTRY ;Centry got split into 3 msg's
115 ;inc byte ptr [nul_arg] ;
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
126 MOV SI,OFFSET DG
:NUL
;display error msgs
128 MOV DX,OFFSET DG
:BADSUBdir
134 ;****************************************************************************
135 ; called by: get_thisel2
136 ; inputs: DS:SI - pointer to file name
137 ;****************************************************************************
138 FCB_TO_ASCZ: ;Convert DS:SI to ASCIZ ES:DI
140 ;move filename from ds:si to es:di
141 MOV CX,8 ; Pack the name
142 REP MOVSB ; Move all of it
144 ; delete trailing spaces in name
145 CMP BYTE PTR ES:[DI-1]," " ;was the last char in name a space?
147 DEC DI ; Back up over trailing space
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
158 ; move period for extension
161 ; move 3 byte extension
165 ;delete trailing blanks
166 CMP BYTE PTR ES:[DI-1]," " ;
168 DEC DI ; Back up over trailing space
171 ; put hex zero at the end
173 STOSB ; NUL terminate
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
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
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
199 ; JZ DOINT26 ;ac048;bgb;an045;bgb
200 RET23: RET ;ac048;bgb;an045;bgb
204 ;**************************************
205 ; Prints all reporting data
206 ;**************************************
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
217 mov ax,hidsiz
;get cluster count ;an049;bgb
218 or ax,ax ;are there any hidden files?
219 ; $IF NZ ;yes ;AC000;
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 ;
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;
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
239 mov ax,filsiz
;get cluster count
240 or ax,ax ;Are there any user files? ;an049;bgb
241 ; $IF NZ ;yes ;AC000;
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
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;
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?
259 mov bx,offset dg
:orphmes3
;bytes would be recovered
263 mov bx,offset dg
:orphmes2
;bytes were recovered
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;
274 xor si,si ;no files to count
275 xor di,di ;no files to count
276 mov bx,offset dg
:badspc
;Issue report
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
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;
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;
302 call Report_Mes_2
; ;AN000;
304 mov ax,Mclus
;Allocation units available ;AN000;
305 dec ax ;MCLUS is # clusters+1
307 mov bx,offset dg
:idmes1
; ;AN000;
310 call Report_Mes_2
; ;AN000;
311 ;;;;;;;;call docrlf ; ;an017;bgb
312 ;avail clusters ;an017;bgb
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
326 call Report_Mes_2
;dont convert to bytes! ;an017;bgb
327 call docrlf
;an017;bgb
330 ;dcl Jan 8, 87 Compensate for RAM Carving - Start
335 mov ah,0c1h ; return Ext'd Bios Data Seg Address ;AN000;
337 ; $IF NC ; ram carving exists if no carry ;AC000; ;AN000;
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;
343 mov bx,ax ; save value in BX ;AN000;
344 ; $ENDIF ; ;AC000; ;AN000;
348 ;dcl Jan 8, 87 Compensate for RAM Carving - End
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
354 mov bx,offset dg
:totmem
357 ;;;;;;; mov dx,psp_segment ;an030;bgb
358 sub ax,psp_segment
;an030;bgb
361 mov bx,offset dg
:fremem
365 ;*************************************************************
367 ; Print the message specified by the control string.
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
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
383 ;*************************************************************
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.
389 ; WARNING!! NOTE!! -->
391 ; called by - PROCEDURE NAME
393 ; inputs: AX - cluster count (1-ffff)
394 ; BX - offset of control string
396 ; DX - high word of cluster count is zero'd out here.
399 ; SI - low word of file count
400 ; DI - hi word of file count
401 ; DS - segment of control string
404 ; output: DISPLAY OF DATA TO SCREEN
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.
411 ; 2. multiply by bytes per sector to give number of bytes.
413 ; 3. place values in diplay fields, and call the msg. retriever.
415 ;*****************************************************************************
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
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
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
440 call display_interface
; ;AC000;
441 DOCRLF: mov dx,offset dg
:crlf_arg
442 call Display_Interface
;Replace old printf call with SysDispMsg;AN000;