Rev 2130 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2130 | Rev 2434 | ||
---|---|---|---|
Line 42... | Line 42... | ||
42 | ;; 20.5.2002 Hd status check - VT ;; |
42 | ;; 20.5.2002 Hd status check - VT ;; |
43 | ;; 29.6.2002 Improved fat32 verification - VT ;; |
43 | ;; 29.6.2002 Improved fat32 verification - VT ;; |
44 | ;; ;; |
44 | ;; ;; |
45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 46... | Line 46... | ||
46 | 46 | ||
Line 47... | Line 47... | ||
47 | $Revision: 2130 $ |
47 | $Revision: 2434 $ |
Line 48... | Line 48... | ||
48 | 48 | ||
Line 92... | Line 92... | ||
92 | fat_in_cache dd -1 |
92 | fat_in_cache dd -1 |
93 | endg |
93 | endg |
Line 94... | Line 94... | ||
94 | 94 | ||
95 | uglobal |
95 | uglobal |
- | 96 | align 4 |
|
96 | align 4 |
97 | fat_cache: |
97 | fat_cache: times 512 db 0 |
98 | times 512 db 0 |
- | 99 | Sector512: ; label for dev_hdcd.inc |
|
98 | Sector512: ; label for dev_hdcd.inc |
100 | buffer: |
- | 101 | times 512 db 0 |
|
99 | buffer: times 512 db 0 |
102 | fsinfo_buffer: |
100 | fsinfo_buffer: times 512 db 0 |
103 | times 512 db 0 |
Line 101... | Line 104... | ||
101 | endg |
104 | endg |
102 | 105 | ||
103 | uglobal |
106 | uglobal |
104 | fat16_root db 0 ; flag for fat16 rootdir |
107 | fat16_root db 0 ; flag for fat16 rootdir |
Line 105... | Line 108... | ||
105 | fat_change db 0 ; 1=fat has changed |
108 | fat_change db 0 ; 1=fat has changed |
Line 106... | Line 109... | ||
106 | endg |
109 | endg |
107 | 110 | ||
108 | reserve_hd1: |
111 | reserve_hd1: |
109 | 112 | ||
110 | cli |
113 | cli |
111 | cmp [hd1_status],0 |
114 | cmp [hd1_status], 0 |
112 | je reserve_ok1 |
115 | je reserve_ok1 |
Line 113... | Line 116... | ||
113 | 116 | ||
Line 114... | Line 117... | ||
114 | sti |
117 | sti |
115 | call change_task |
118 | call change_task |
116 | jmp reserve_hd1 |
119 | jmp reserve_hd1 |
117 | 120 | ||
118 | reserve_ok1: |
121 | reserve_ok1: |
119 | 122 | ||
120 | push eax |
123 | push eax |
121 | mov eax,[CURRENT_TASK] |
124 | mov eax, [CURRENT_TASK] |
122 | shl eax,5 |
125 | shl eax, 5 |
Line 123... | Line 126... | ||
123 | mov eax,[eax+CURRENT_TASK+TASKDATA.pid] |
126 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
124 | mov [hd1_status],eax |
127 | mov [hd1_status], eax |
125 | pop eax |
128 | pop eax |
Line 134... | Line 137... | ||
134 | reserve_hd_channel: |
137 | reserve_hd_channel: |
135 | ; BIOS disk accesses are protected with common mutex hd1_status |
138 | ; BIOS disk accesses are protected with common mutex hd1_status |
136 | ; This must be modified when hd1_status will not be valid! |
139 | ; This must be modified when hd1_status will not be valid! |
137 | cmp [hdpos], 0x80 |
140 | cmp [hdpos], 0x80 |
138 | jae .ret |
141 | jae .ret |
139 | cmp [hdbase], 0x1F0 |
142 | cmp [hdbase], 0x1F0 |
140 | jne .IDE_Channel_2 |
143 | jne .IDE_Channel_2 |
141 | .IDE_Channel_1: |
144 | .IDE_Channel_1: |
142 | cli |
145 | cli |
143 | cmp [IDE_Channel_1],0 |
146 | cmp [IDE_Channel_1], 0 |
144 | je .reserve_ok_1 |
147 | je .reserve_ok_1 |
145 | sti |
148 | sti |
146 | call change_task |
149 | call change_task |
147 | jmp .IDE_Channel_1 |
150 | jmp .IDE_Channel_1 |
148 | .IDE_Channel_2: |
151 | .IDE_Channel_2: |
149 | cli |
152 | cli |
150 | cmp [IDE_Channel_2],0 |
153 | cmp [IDE_Channel_2], 0 |
151 | je .reserve_ok_2 |
154 | je .reserve_ok_2 |
152 | sti |
155 | sti |
153 | call change_task |
156 | call change_task |
154 | jmp .IDE_Channel_2 |
157 | jmp .IDE_Channel_2 |
155 | .reserve_ok_1: |
158 | .reserve_ok_1: |
156 | mov [IDE_Channel_1], 1 |
159 | mov [IDE_Channel_1], 1 |
157 | push eax |
160 | push eax |
158 | mov al, 1 |
161 | mov al, 1 |
159 | jmp @f |
162 | jmp @f |
Line 167... | Line 170... | ||
167 | cmp al, [hd_in_cache] |
170 | cmp al, [hd_in_cache] |
168 | jz @f |
171 | jz @f |
169 | mov [hd_in_cache], al |
172 | mov [hd_in_cache], al |
170 | call clear_hd_cache |
173 | call clear_hd_cache |
171 | @@: |
174 | @@: |
172 | pop eax |
175 | pop eax |
173 | sti |
176 | sti |
174 | .ret: |
177 | .ret: |
175 | ret |
178 | ret |
Line 176... | Line 179... | ||
176 | 179 | ||
177 | free_hd_channel: |
180 | free_hd_channel: |
178 | ; see comment at reserve_hd_channel |
181 | ; see comment at reserve_hd_channel |
179 | cmp [hdpos], 0x80 |
182 | cmp [hdpos], 0x80 |
180 | jae .ret |
183 | jae .ret |
181 | cmp [hdbase], 0x1F0 |
184 | cmp [hdbase], 0x1F0 |
182 | jne .IDE_Channel_2 |
185 | jne .IDE_Channel_2 |
183 | .IDE_Channel_1: |
186 | .IDE_Channel_1: |
184 | mov [IDE_Channel_1],0 |
187 | mov [IDE_Channel_1], 0 |
185 | .ret: |
188 | .ret: |
186 | ret |
189 | ret |
187 | .IDE_Channel_2: |
190 | .IDE_Channel_2: |
188 | mov [IDE_Channel_2],0 |
191 | mov [IDE_Channel_2], 0 |
189 | ret |
192 | ret |
190 | ;******************************************** |
193 | ;******************************************** |
Line 191... | Line 194... | ||
191 | problem_partition db 0 ; used for partitions search |
194 | problem_partition db 0 ; used for partitions search |
Line 196... | Line 199... | ||
196 | ;-------------------------------- |
199 | ;-------------------------------- |
197 | ; input : EAX = cluster |
200 | ; input : EAX = cluster |
198 | ; EDX = value to save |
201 | ; EDX = value to save |
199 | ; output : EDX = old value |
202 | ; output : EDX = old value |
200 | ;-------------------------------- |
203 | ;-------------------------------- |
201 | push eax ebx esi |
204 | push eax ebx esi |
Line 202... | Line 205... | ||
202 | 205 | ||
203 | cmp eax,2 |
206 | cmp eax, 2 |
204 | jb sfc_error |
207 | jb sfc_error |
205 | cmp eax,[LAST_CLUSTER] |
208 | cmp eax, [LAST_CLUSTER] |
206 | ja sfc_error |
209 | ja sfc_error |
207 | cmp [fs_type],16 |
210 | cmp [fs_type], 16 |
208 | je sfc_1 |
211 | je sfc_1 |
209 | add eax,eax |
212 | add eax, eax |
210 | sfc_1: |
213 | sfc_1: |
211 | add eax,eax |
214 | add eax, eax |
212 | mov esi,511 |
215 | mov esi, 511 |
213 | and esi,eax ; esi = position in fat sector |
216 | and esi, eax ; esi = position in fat sector |
214 | shr eax,9 ; eax = fat sector |
217 | shr eax, 9 ; eax = fat sector |
215 | add eax,[FAT_START] |
218 | add eax, [FAT_START] |
216 | mov ebx,fat_cache |
219 | mov ebx, fat_cache |
217 | 220 | ||
218 | cmp eax,[fat_in_cache] ; is fat sector already in memory? |
221 | cmp eax, [fat_in_cache]; is fat sector already in memory? |
219 | je sfc_in_cache ; yes |
222 | je sfc_in_cache ; yes |
220 | 223 | ||
221 | cmp [fat_change],0 ; is fat changed? |
224 | cmp [fat_change], 0 ; is fat changed? |
222 | je sfc_no_change ; no |
225 | je sfc_no_change ; no |
223 | call write_fat_sector ; yes. write it into disk |
226 | call write_fat_sector; yes. write it into disk |
224 | cmp [hd_error],0 |
227 | cmp [hd_error], 0 |
Line 225... | Line 228... | ||
225 | jne sfc_error |
228 | jne sfc_error |
226 | 229 | ||
227 | sfc_no_change: |
230 | sfc_no_change: |
228 | mov [fat_in_cache],eax ; save fat sector |
231 | mov [fat_in_cache], eax; save fat sector |
229 | call hd_read |
232 | call hd_read |
Line 230... | Line 233... | ||
230 | cmp [hd_error],0 |
233 | cmp [hd_error], 0 |
231 | jne sfc_error |
234 | jne sfc_error |
232 | 235 | ||
Line 233... | Line 236... | ||
233 | 236 | ||
234 | sfc_in_cache: |
237 | sfc_in_cache: |
235 | cmp [fs_type],16 |
238 | cmp [fs_type], 16 |
Line 236... | Line 239... | ||
236 | jne sfc_test32 |
239 | jne sfc_test32 |
237 | 240 | ||
Line 238... | Line 241... | ||
238 | sfc_set16: |
241 | sfc_set16: |
239 | xchg [ebx+esi],dx ; save new value and get old value |
242 | xchg [ebx+esi], dx ; save new value and get old value |
240 | jmp sfc_write |
243 | jmp sfc_write |
241 | 244 | ||
242 | sfc_test32: |
245 | sfc_test32: |
243 | mov eax,[fatMASK] |
246 | mov eax, [fatMASK] |
244 | 247 | ||
Line 245... | Line 248... | ||
245 | sfc_set32: |
248 | sfc_set32: |
246 | and edx,eax |
249 | and edx, eax |
Line 247... | Line 250... | ||
247 | xor eax,-1 ; mask for high bits |
250 | xor eax, -1 ; mask for high bits |
248 | and eax,[ebx+esi] ; get high 4 bits |
251 | and eax, [ebx+esi] ; get high 4 bits |
Line 249... | Line 252... | ||
249 | or eax,edx |
252 | or eax, edx |
250 | mov edx,[ebx+esi] ; get old value |
253 | mov edx, [ebx+esi] ; get old value |
251 | mov [ebx+esi],eax ; save new value |
254 | mov [ebx+esi], eax ; save new value |
Line 252... | Line 255... | ||
252 | 255 | ||
253 | sfc_write: |
256 | sfc_write: |
254 | mov [fat_change],1 ; fat has changed |
257 | mov [fat_change], 1 ; fat has changed |
255 | 258 | ||
256 | sfc_nonzero: |
259 | sfc_nonzero: |
257 | and edx,[fatMASK] |
260 | and edx, [fatMASK] |
Line 258... | Line 261... | ||
258 | 261 | ||
259 | sfc_error: |
262 | sfc_error: |
260 | pop esi ebx eax |
263 | pop esi ebx eax |
261 | ret |
264 | ret |
262 | 265 | ||
263 | 266 | ||
264 | get_FAT: |
267 | get_FAT: |
265 | ;-------------------------------- |
268 | ;-------------------------------- |
266 | ; input : EAX = cluster |
269 | ; input : EAX = cluster |
267 | ; output : EAX = next cluster |
270 | ; output : EAX = next cluster |
268 | ;-------------------------------- |
271 | ;-------------------------------- |
269 | push ebx esi |
272 | push ebx esi |
270 | 273 | ||
271 | cmp [fs_type],16 |
274 | cmp [fs_type], 16 |
272 | je gfc_1 |
275 | je gfc_1 |
273 | add eax,eax |
276 | add eax, eax |
274 | gfc_1: |
277 | gfc_1: |
275 | add eax,eax |
278 | add eax, eax |
276 | mov esi,511 |
279 | mov esi, 511 |
Line 277... | Line 280... | ||
277 | and esi,eax ; esi = position in fat sector |
280 | and esi, eax ; esi = position in fat sector |
278 | shr eax,9 ; eax = fat sector |
281 | shr eax, 9 ; eax = fat sector |
279 | add eax,[FAT_START] |
282 | add eax, [FAT_START] |
280 | mov ebx,fat_cache |
283 | mov ebx, fat_cache |
281 | 284 | ||
Line 282... | Line 285... | ||
282 | cmp eax,[fat_in_cache] ; is fat sector already in memory? |
285 | cmp eax, [fat_in_cache]; is fat sector already in memory? |
283 | je gfc_in_cache |
286 | je gfc_in_cache |
284 | 287 | ||
285 | cmp [fat_change],0 ; is fat changed? |
288 | cmp [fat_change], 0 ; is fat changed? |
286 | je gfc_no_change ; no |
289 | je gfc_no_change ; no |
287 | call write_fat_sector ; yes. write it into disk |
290 | call write_fat_sector; yes. write it into disk |
Line 288... | Line 291... | ||
288 | cmp [hd_error],0 |
291 | cmp [hd_error], 0 |
289 | jne hd_error_01 |
292 | jne hd_error_01 |
290 | 293 | ||
291 | gfc_no_change: |
294 | gfc_no_change: |
292 | mov [fat_in_cache],eax |
295 | mov [fat_in_cache], eax |
293 | call hd_read |
296 | call hd_read |
294 | cmp [hd_error],0 |
297 | cmp [hd_error], 0 |
295 | jne hd_error_01 |
298 | jne hd_error_01 |
296 | 299 | ||
297 | gfc_in_cache: |
300 | gfc_in_cache: |
298 | mov eax,[ebx+esi] |
301 | mov eax, [ebx+esi] |
299 | and eax,[fatMASK] |
302 | and eax, [fatMASK] |
Line 300... | Line 303... | ||
300 | hd_error_01: |
303 | hd_error_01: |
301 | pop esi ebx |
304 | pop esi ebx |
302 | ret |
305 | ret |
303 | 306 | ||
304 | 307 | ||
Line 305... | Line 308... | ||
305 | get_free_FAT: |
308 | get_free_FAT: |
306 | ;----------------------------------------------------------- |
309 | ;----------------------------------------------------------- |
307 | ; output : if CARRY=0 EAX = # first cluster found free |
310 | ; output : if CARRY=0 EAX = # first cluster found free |
308 | ; if CARRY=1 disk full |
311 | ; if CARRY=1 disk full |
309 | ; Note : for more speed need to use fat_cache directly |
312 | ; Note : for more speed need to use fat_cache directly |
310 | ;----------------------------------------------------------- |
313 | ;----------------------------------------------------------- |
311 | push ecx |
314 | push ecx |
312 | mov ecx,[LAST_CLUSTER] ; counter for full disk |
315 | mov ecx, [LAST_CLUSTER]; counter for full disk |
313 | sub ecx,2 |
316 | sub ecx, 2 |
314 | mov eax,[fatStartScan] |
317 | mov eax, [fatStartScan] |
315 | cmp eax,2 |
318 | cmp eax, 2 |
316 | jb gff_reset |
319 | jb gff_reset |
Line 317... | Line 320... | ||
317 | 320 | ||
318 | gff_test: |
321 | gff_test: |
319 | cmp eax,[LAST_CLUSTER] ; if above last cluster start at cluster 2 |
322 | cmp eax, [LAST_CLUSTER]; if above last cluster start at cluster 2 |
320 | jbe gff_in_range |
323 | jbe gff_in_range |
321 | gff_reset: |
324 | gff_reset: |
322 | mov eax,2 |
325 | mov eax, 2 |
Line 323... | Line 326... | ||
323 | 326 | ||
324 | gff_in_range: |
327 | gff_in_range: |
325 | push eax |
328 | push eax |
326 | call get_FAT ; get cluster state |
329 | call get_FAT ; get cluster state |
327 | cmp [hd_error],0 |
330 | cmp [hd_error], 0 |
328 | jne gff_not_found_1 |
331 | jne gff_not_found_1 |
Line 329... | Line 332... | ||
329 | 332 | ||
330 | test eax,eax ; is it free? |
333 | test eax, eax ; is it free? |
331 | pop eax |
334 | pop eax |
332 | je gff_found ; yes |
335 | je gff_found ; yes |
333 | inc eax ; next cluster |
336 | inc eax ; next cluster |
Line 334... | Line 337... | ||
334 | dec ecx ; is all checked? |
337 | dec ecx ; is all checked? |
335 | jns gff_test ; no |
338 | jns gff_test ; no |
336 | 339 | ||
337 | gff_not_found_1: |
340 | gff_not_found_1: |
338 | add esp,4 |
341 | add esp, 4 |
339 | gff_not_found: |
342 | gff_not_found: |
Line 340... | Line 343... | ||
340 | pop ecx ; yes. disk is full |
343 | pop ecx ; yes. disk is full |
341 | stc |
344 | stc |
342 | ret |
345 | ret |
343 | 346 | ||
344 | gff_found: |
347 | gff_found: |
345 | lea ecx,[eax+1] |
348 | lea ecx, [eax+1] |
346 | mov [fatStartScan],ecx |
349 | mov [fatStartScan], ecx |
347 | pop ecx |
350 | pop ecx |
Line 348... | Line 351... | ||
348 | clc |
351 | clc |
349 | ret |
352 | ret |
350 | 353 | ||
Line 351... | Line 354... | ||
351 | 354 | ||
352 | write_fat_sector: |
355 | write_fat_sector: |
353 | ;----------------------------------------------------------- |
356 | ;----------------------------------------------------------- |
Line 386... | Line 389... | ||
386 | ; ECX,EDX,ESI,EDI not changed |
389 | ; ECX,EDX,ESI,EDI not changed |
387 | ; IF CARRY=1 filename not found |
390 | ; IF CARRY=1 filename not found |
388 | ; Note : if cluster=0 it's changed to read rootdir |
391 | ; Note : if cluster=0 it's changed to read rootdir |
389 | ; save 2 previous directory sectors in longname_sec |
392 | ; save 2 previous directory sectors in longname_sec |
390 | ;----------------------------------------------------------- |
393 | ;----------------------------------------------------------- |
391 | push ecx edx esi edi ebx ; ebx = [esp+0] |
394 | push ecx edx esi edi ebx; ebx = [esp+0] |
392 | mov [longname_sec1],0 |
395 | mov [longname_sec1], 0 |
393 | mov [longname_sec2],0 |
396 | mov [longname_sec2], 0 |
Line 394... | Line 397... | ||
394 | 397 | ||
395 | adr_new_cluster: |
398 | adr_new_cluster: |
396 | mov [cluster_tmp],eax |
399 | mov [cluster_tmp], eax |
397 | mov [fat16_root],0 |
400 | mov [fat16_root], 0 |
398 | cmp eax,[LAST_CLUSTER] |
401 | cmp eax, [LAST_CLUSTER] |
399 | ja adr_not_found ; too big cluster number, something is wrong |
402 | ja adr_not_found ; too big cluster number, something is wrong |
400 | cmp eax,2 |
403 | cmp eax, 2 |
401 | jnb adr_data_cluster |
404 | jnb adr_data_cluster |
402 | 405 | ||
403 | mov eax,[ROOT_CLUSTER] ; if cluster < 2 then read rootdir |
406 | mov eax, [ROOT_CLUSTER]; if cluster < 2 then read rootdir |
404 | cmp [fs_type],16 |
407 | cmp [fs_type], 16 |
405 | jne adr_data_cluster |
408 | jne adr_data_cluster |
406 | mov eax,[ROOT_START] |
409 | mov eax, [ROOT_START] |
407 | mov edx,[ROOT_SECTORS] |
410 | mov edx, [ROOT_SECTORS] |
408 | mov [fat16_root],1 ; flag for fat16 rootdir |
411 | mov [fat16_root], 1 ; flag for fat16 rootdir |
Line 409... | Line 412... | ||
409 | jmp adr_new_sector |
412 | jmp adr_new_sector |
410 | 413 | ||
411 | adr_data_cluster: |
414 | adr_data_cluster: |
412 | sub eax,2 |
415 | sub eax, 2 |
413 | mov edx,[SECTORS_PER_CLUSTER] |
416 | mov edx, [SECTORS_PER_CLUSTER] |
Line 414... | Line 417... | ||
414 | imul eax,edx |
417 | imul eax, edx |
415 | add eax,[DATA_START] |
418 | add eax, [DATA_START] |
416 | 419 | ||
417 | adr_new_sector: |
420 | adr_new_sector: |
418 | mov ebx,buffer |
421 | mov ebx, buffer |
Line 419... | Line 422... | ||
419 | call hd_read |
422 | call hd_read |
Line 420... | Line 423... | ||
420 | cmp [hd_error],0 |
423 | cmp [hd_error], 0 |
421 | jne adr_not_found |
424 | jne adr_not_found |
422 | 425 | ||
423 | mov ecx,512/32 ; count of dir entrys per sector = 16 |
426 | mov ecx, 512/32 ; count of dir entrys per sector = 16 |
424 | 427 | ||
425 | adr_analyze: |
428 | adr_analyze: |
426 | mov edi,[ebx+11] ; file attribute |
429 | mov edi, [ebx+11] ; file attribute |
427 | and edi,0xf |
430 | and edi, 0xf |
428 | cmp edi,0xf |
431 | cmp edi, 0xf |
429 | je adr_long_filename |
432 | je adr_long_filename |
430 | test edi,0x8 ; skip over volume label |
433 | test edi, 0x8 ; skip over volume label |
431 | jne adr_long_filename ; Note: label can be same name as file/dir |
434 | jne adr_long_filename; Note: label can be same name as file/dir |
432 | 435 | ||
433 | mov esi,[esp+0] ; filename need to be uppercase |
436 | mov esi, [esp+0] ; filename need to be uppercase |
434 | mov edi,ebx |
437 | mov edi, ebx |
435 | push ecx |
438 | push ecx |
Line 436... | Line 439... | ||
436 | mov ecx,11 |
439 | mov ecx, 11 |
437 | cld |
440 | cld |
438 | rep cmpsb ; compare 8+3 filename |
441 | rep cmpsb ; compare 8+3 filename |
439 | pop ecx |
442 | pop ecx |
440 | je adr_found |
443 | je adr_found |
441 | 444 | ||
442 | adr_long_filename: |
445 | adr_long_filename: |
443 | add ebx,32 ; position of next dir entry |
446 | add ebx, 32 ; position of next dir entry |
444 | dec ecx |
447 | dec ecx |
445 | jnz adr_analyze |
448 | jnz adr_analyze |
446 | 449 | ||
447 | mov ecx,[longname_sec1] ; save 2 previous directory sectors |
450 | mov ecx, [longname_sec1]; save 2 previous directory sectors |
448 | mov [longname_sec1],eax ; for delete long filename |
451 | mov [longname_sec1], eax; for delete long filename |
Line 449... | Line 452... | ||
449 | mov [longname_sec2],ecx |
452 | mov [longname_sec2], ecx |
450 | inc eax ; next sector |
453 | inc eax ; next sector |
451 | dec edx |
454 | dec edx |
452 | jne adr_new_sector |
455 | jne adr_new_sector |
453 | cmp [fat16_root],1 ; end of fat16 rootdir |
456 | cmp [fat16_root], 1 ; end of fat16 rootdir |
454 | je adr_not_found |
457 | je adr_not_found |
455 | 458 | ||
456 | adr_next_cluster: |
459 | adr_next_cluster: |
457 | mov eax,[cluster_tmp] |
460 | mov eax, [cluster_tmp] |
458 | call get_FAT ; get next cluster |
461 | call get_FAT ; get next cluster |
Line 459... | Line 462... | ||
459 | cmp [hd_error],0 |
462 | cmp [hd_error], 0 |
460 | jne adr_not_found |
463 | jne adr_not_found |
461 | 464 | ||
462 | cmp eax,2 ; incorrect fat chain? |
465 | cmp eax, 2 ; incorrect fat chain? |
Line 463... | Line 466... | ||
463 | jb adr_not_found ; yes |
466 | jb adr_not_found ; yes |
464 | cmp eax,[fatRESERVED] ; is it end of directory? |
467 | cmp eax, [fatRESERVED]; is it end of directory? |
465 | jb adr_new_cluster ; no. analyse it |
468 | jb adr_new_cluster ; no. analyse it |
466 | 469 | ||
Line 467... | Line 470... | ||
467 | adr_not_found: |
470 | adr_not_found: |
468 | pop edi edi esi edx ecx ; first edi will remove ebx |
471 | pop edi edi esi edx ecx; first edi will remove ebx |
469 | stc ; file not found |
472 | stc ; file not found |
Line 483... | Line 486... | ||
483 | ; ESI = # blocks to skip over |
486 | ; ESI = # blocks to skip over |
484 | ; output : if CARRY=0 ok EBX/EDX/ESI updated |
487 | ; output : if CARRY=0 ok EBX/EDX/ESI updated |
485 | ; if CARRY=1 cluster out of range |
488 | ; if CARRY=1 cluster out of range |
486 | ; Note : if cluster=0 it's changed to read rootdir |
489 | ; Note : if cluster=0 it's changed to read rootdir |
487 | ;----------------------------------------------------------- |
490 | ;----------------------------------------------------------- |
488 | push eax ecx |
491 | push eax ecx |
- | 492 | ||
- | 493 | mov [fat16_root], 0 |
|
- | 494 | cmp eax, [LAST_CLUSTER] |
|
- | 495 | ja gdc_error ; too big cluster number, something is wrong |
|
- | 496 | cmp eax, 2 |
|
- | 497 | jnb gdc_cluster |
|
Line 489... | Line -... | ||
489 | - | ||
490 | mov [fat16_root],0 |
- | |
491 | cmp eax,[LAST_CLUSTER] |
- | |
492 | ja gdc_error ; too big cluster number, something is wrong |
- | |
493 | cmp eax,2 |
- | |
494 | jnb gdc_cluster |
- | |
495 | 498 | ||
496 | mov eax,[ROOT_CLUSTER] ; if cluster < 2 then read rootdir |
499 | mov eax, [ROOT_CLUSTER]; if cluster < 2 then read rootdir |
497 | cmp [fs_type],16 |
500 | cmp [fs_type], 16 |
498 | jne gdc_cluster |
501 | jne gdc_cluster |
499 | mov eax,[ROOT_START] |
502 | mov eax, [ROOT_START] |
500 | mov ecx,[ROOT_SECTORS] ; Note: not cluster size |
503 | mov ecx, [ROOT_SECTORS]; Note: not cluster size |
501 | mov [fat16_root],1 ; flag for fat16 rootdir |
504 | mov [fat16_root], 1 ; flag for fat16 rootdir |
Line 502... | Line 505... | ||
502 | jmp gdc_read |
505 | jmp gdc_read |
503 | 506 | ||
504 | gdc_cluster: |
507 | gdc_cluster: |
505 | sub eax,2 |
508 | sub eax, 2 |
506 | mov ecx,[SECTORS_PER_CLUSTER] |
509 | mov ecx, [SECTORS_PER_CLUSTER] |
Line 507... | Line 510... | ||
507 | imul eax,ecx |
510 | imul eax, ecx |
508 | add eax,[DATA_START] |
511 | add eax, [DATA_START] |
509 | 512 | ||
510 | gdc_read: |
513 | gdc_read: |
511 | test esi,esi ; first wanted block |
514 | test esi, esi ; first wanted block |
Line 512... | Line 515... | ||
512 | je gdcl1 ; yes, skip count is 0 |
515 | je gdcl1 ; yes, skip count is 0 |
513 | dec esi |
516 | dec esi |
514 | jmp gdcl2 |
517 | jmp gdcl2 |
515 | 518 | ||
Line 516... | Line 519... | ||
516 | gdcl1: |
519 | gdcl1: |
517 | call hd_read |
520 | call hd_read |
Line 518... | Line 521... | ||
518 | cmp [hd_error],0 |
521 | cmp [hd_error], 0 |
519 | jne gdc_error |
522 | jne gdc_error |
520 | 523 | ||
Line 521... | Line 524... | ||
521 | add ebx,512 ; update pointer |
524 | add ebx, 512 ; update pointer |
522 | dec edx |
525 | dec edx |
523 | 526 | ||
Line 524... | Line 527... | ||
524 | gdcl2: |
527 | gdcl2: |
525 | test edx,edx ; is all read? |
528 | test edx, edx ; is all read? |
526 | je out_of_read |
529 | je out_of_read |
527 | 530 | ||
Line 528... | Line 531... | ||
528 | inc eax ; next sector |
531 | inc eax ; next sector |
529 | dec ecx |
532 | dec ecx |
530 | jnz gdc_read |
533 | jnz gdc_read |
531 | 534 | ||
Line 532... | Line 535... | ||
532 | out_of_read: |
535 | out_of_read: |
533 | pop ecx eax |
536 | pop ecx eax |
534 | clc |
537 | clc |
Line 548... | Line 551... | ||
548 | ; '.' = space char |
551 | ; '.' = space char |
549 | ; '0' = char(0) (ASCII=0) !!! ) |
552 | ; '0' = char(0) (ASCII=0) !!! ) |
550 | ; output : if (CARRY=1) -> ERROR in the PATH |
553 | ; output : if (CARRY=1) -> ERROR in the PATH |
551 | ; if (CARRY=0) -> EAX=cluster |
554 | ; if (CARRY=0) -> EAX=cluster |
552 | ;--------------------------------------------------------- |
555 | ;--------------------------------------------------------- |
553 | push ebx edx |
556 | push ebx edx |
Line 554... | Line 557... | ||
554 | 557 | ||
555 | mov eax,[ROOT_CLUSTER] |
558 | mov eax, [ROOT_CLUSTER] |
Line 556... | Line 559... | ||
556 | mov edx,ebx |
559 | mov edx, ebx |
557 | 560 | ||
558 | search_end_of_path: |
561 | search_end_of_path: |
Line 559... | Line 562... | ||
559 | cmp byte [edx],0 |
562 | cmp byte [edx], 0 |
560 | je found_end_of_path |
563 | je found_end_of_path |
561 | 564 | ||
562 | inc edx ; '/' |
565 | inc edx; '/' |
563 | mov ebx,edx |
566 | mov ebx, edx |
564 | call analyze_directory |
567 | call analyze_directory |
565 | jc directory_not_found |
568 | jc directory_not_found |
566 | 569 | ||
567 | mov eax,[ebx+20-2] ; read the HIGH 16bit cluster field |
570 | mov eax, [ebx+20-2] ; read the HIGH 16bit cluster field |
568 | mov ax,[ebx+26] ; read the LOW 16bit cluster field |
571 | mov ax, [ebx+26] ; read the LOW 16bit cluster field |
Line 569... | Line 572... | ||
569 | and eax,[fatMASK] |
572 | and eax, [fatMASK] |
570 | add edx,11 ; 8+3 (name+extension) |
573 | add edx, 11 ; 8+3 (name+extension) |
571 | jmp search_end_of_path |
574 | jmp search_end_of_path |
572 | 575 | ||
Line 573... | Line 576... | ||
573 | found_end_of_path: |
576 | found_end_of_path: |
574 | pop edx ebx |
577 | pop edx ebx |
575 | clc ; no errors |
578 | clc ; no errors |
576 | ret |
579 | ret |
Line 577... | Line 580... | ||
577 | 580 | ||
578 | directory_not_found: |
581 | directory_not_found: |
579 | pop edx ebx |
582 | pop edx ebx |
580 | stc ; errors occour |
583 | stc ; errors occour |
581 | ret |
584 | ret |
582 | 585 | ||
583 | 586 | ||
584 | bcd2bin: |
587 | bcd2bin: |
585 | ;---------------------------------- |
588 | ;---------------------------------- |
586 | ; input : AL=BCD number (eg. 0x11) |
589 | ; input : AL=BCD number (eg. 0x11) |
587 | ; output : AH=0 |
590 | ; output : AH=0 |
Line 588... | Line 591... | ||
588 | ; AL=decimal number (eg. 11) |
591 | ; AL=decimal number (eg. 11) |
589 | ;---------------------------------- |
592 | ;---------------------------------- |
590 | xor ah,ah |
593 | xor ah, ah |
591 | shl ax,4 |
594 | shl ax, 4 |
592 | shr al,4 |
595 | shr al, 4 |
593 | aad |
596 | aad |
594 | ret |
597 | ret |
595 | 598 | ||
596 | 599 | ||
597 | get_date_for_file: |
600 | get_date_for_file: |
598 | ;----------------------------------------------------- |
601 | ;----------------------------------------------------- |
599 | ; Get date from CMOS and pack day,month,year in AX |
602 | ; Get date from CMOS and pack day,month,year in AX |
600 | ; DATE bits 0..4 : day of month 0..31 |
603 | ; DATE bits 0..4 : day of month 0..31 |
601 | ; 5..8 : month of year 1..12 |
604 | ; 5..8 : month of year 1..12 |
602 | ; 9..15 : count of years from 1980 |
605 | ; 9..15 : count of years from 1980 |
603 | ;----------------------------------------------------- |
606 | ;----------------------------------------------------- |
604 | mov al,0x7 ;day |
607 | mov al, 0x7 ;day |
605 | out 0x70,al |
608 | out 0x70, al |
606 | in al,0x71 |
609 | in al, 0x71 |
607 | call bcd2bin |
610 | call bcd2bin |
608 | ror eax,5 |
611 | ror eax, 5 |
609 | 612 | ||
610 | mov al,0x8 ;month |
613 | mov al, 0x8 ;month |
611 | out 0x70,al |
614 | out 0x70, al |
612 | in al,0x71 |
615 | in al, 0x71 |
613 | call bcd2bin |
616 | call bcd2bin |
614 | ror eax,4 |
617 | ror eax, 4 |
Line 615... | Line 618... | ||
615 | 618 | ||
616 | mov al,0x9 ;year |
619 | mov al, 0x9 ;year |
617 | out 0x70,al |
620 | out 0x70, al |
618 | in al,0x71 |
621 | in al, 0x71 |
619 | call bcd2bin |
622 | call bcd2bin |
620 | add ax,20 ;because CMOS return only the two last |
623 | add ax, 20 ;because CMOS return only the two last |
621 | ;digit (eg. 2000 -> 00 , 2001 -> 01) and we |
624 | ;digit (eg. 2000 -> 00 , 2001 -> 01) and we |
622 | rol eax,9 ;need the difference with 1980 (eg. 2001-1980) |
625 | rol eax, 9 ;need the difference with 1980 (eg. 2001-1980) |
623 | ret |
626 | ret |
624 | 627 | ||
625 | 628 | ||
626 | get_time_for_file: |
629 | get_time_for_file: |
627 | ;----------------------------------------------------- |
630 | ;----------------------------------------------------- |
628 | ; Get time from CMOS and pack hour,minute,second in AX |
631 | ; Get time from CMOS and pack hour,minute,second in AX |
629 | ; TIME bits 0..4 : second (the low bit is lost) |
632 | ; TIME bits 0..4 : second (the low bit is lost) |
630 | ; 5..10 : minute 0..59 |
633 | ; 5..10 : minute 0..59 |
631 | ; 11..15 : hour 0..23 |
634 | ; 11..15 : hour 0..23 |
632 | ;----------------------------------------------------- |
635 | ;----------------------------------------------------- |
633 | mov al,0x0 ;second |
636 | mov al, 0x0 ;second |
634 | out 0x70,al |
637 | out 0x70, al |
635 | in al,0x71 |
638 | in al, 0x71 |
636 | call bcd2bin |
639 | call bcd2bin |
637 | ror eax,6 |
640 | ror eax, 6 |
638 | 641 | ||
639 | mov al,0x2 ;minute |
642 | mov al, 0x2 ;minute |
Line 640... | Line 643... | ||
640 | out 0x70,al |
643 | out 0x70, al |
641 | in al,0x71 |
644 | in al, 0x71 |
642 | call bcd2bin |
645 | call bcd2bin |
643 | ror eax,6 |
646 | ror eax, 6 |
644 | 647 | ||
645 | mov al,0x4 ;hour |
648 | mov al, 0x4 ;hour |
646 | out 0x70,al |
649 | out 0x70, al |
647 | in al,0x71 |
650 | in al, 0x71 |
648 | call bcd2bin |
651 | call bcd2bin |
649 | rol eax,11 |
652 | rol eax, 11 |
650 | ret |
653 | ret |
651 | 654 | ||
Line 652... | Line 655... | ||
652 | 655 | ||
653 | set_current_time_for_entry: |
656 | set_current_time_for_entry: |
654 | ;----------------------------------------------------- |
657 | ;----------------------------------------------------- |
655 | ; Set current time/date for file entry |
658 | ; Set current time/date for file entry |
656 | ; input : ebx = file entry pointer |
659 | ; input : ebx = file entry pointer |
657 | ;----------------------------------------------------- |
660 | ;----------------------------------------------------- |
658 | push eax |
661 | push eax |
659 | call get_time_for_file ; update files date/time |
662 | call get_time_for_file; update files date/time |
660 | mov [ebx+22],ax |
663 | mov [ebx+22], ax |
661 | call get_date_for_file |
664 | call get_date_for_file |
662 | mov [ebx+24],ax |
665 | mov [ebx+24], ax |
663 | pop eax |
666 | pop eax |
664 | ret |
667 | ret |
665 | 668 | ||
666 | 669 | ||
667 | 670 | ||
668 | add_disk_free_space: |
671 | add_disk_free_space: |
669 | ;----------------------------------------------------- |
672 | ;----------------------------------------------------- |
670 | ; input : ecx = cluster count |
673 | ; input : ecx = cluster count |
671 | ; Note : negative = remove clusters from free space |
674 | ; Note : negative = remove clusters from free space |
672 | ; positive = add clusters to free space |
675 | ; positive = add clusters to free space |
673 | ;----------------------------------------------------- |
676 | ;----------------------------------------------------- |
674 | test ecx,ecx ; no change |
677 | test ecx, ecx ; no change |
675 | je add_dfs_no |
678 | je add_dfs_no |
676 | cmp [fs_type],32 ; free disk space only used by fat32 |
679 | cmp [fs_type], 32 ; free disk space only used by fat32 |
677 | jne add_dfs_no |
680 | jne add_dfs_no |
678 | 681 | ||
Line 679... | Line 682... | ||
679 | push eax ebx |
682 | push eax ebx |
680 | mov eax,[ADR_FSINFO] |
683 | mov eax, [ADR_FSINFO] |
Line 681... | Line 684... | ||
681 | mov ebx,fsinfo_buffer |
684 | mov ebx, fsinfo_buffer |
682 | call hd_read |
685 | call hd_read |
Line 683... | Line 686... | ||
683 | cmp [hd_error],0 |
686 | cmp [hd_error], 0 |
684 | jne add_not_fs |
687 | jne add_not_fs |
685 | 688 | ||
Line 722... | Line 725... | ||
722 | ;-------------------------------------------------------------------------- |
725 | ;-------------------------------------------------------------------------- |
723 | cmp [fs_type], 16 |
726 | cmp [fs_type], 16 |
724 | jz fat_ok_for_reading |
727 | jz fat_ok_for_reading |
725 | cmp [fs_type], 32 |
728 | cmp [fs_type], 32 |
726 | jz fat_ok_for_reading |
729 | jz fat_ok_for_reading |
727 | xor ebx,ebx |
730 | xor ebx, ebx |
728 | mov eax,ERROR_UNKNOWN_FS |
731 | mov eax, ERROR_UNKNOWN_FS |
729 | mov [hd1_status], ebx |
732 | mov [hd1_status], ebx |
730 | ret |
733 | ret |
Line 731... | Line 734... | ||
731 | 734 | ||
732 | fat_ok_for_reading: |
735 | fat_ok_for_reading: |
Line 733... | Line 736... | ||
733 | ; call reserve_hd1 |
736 | ; call reserve_hd1 |
- | 737 | ||
- | 738 | pushad |
|
- | 739 | ||
- | 740 | mov ebx, edx |
|
- | 741 | call get_cluster_of_a_path |
|
- | 742 | jc file_to_read_not_found |
|
- | 743 | ||
- | 744 | test edi, edi ; read rootdir |
|
- | 745 | jne no_read_root |
|
- | 746 | ||
- | 747 | xor eax, eax |
|
- | 748 | call get_dir_size ; return rootdir size |
|
Line 734... | Line -... | ||
734 | - | ||
735 | pushad |
- | |
736 | - | ||
737 | mov ebx,edx |
- | |
738 | call get_cluster_of_a_path |
- | |
739 | jc file_to_read_not_found |
- | |
740 | - | ||
741 | test edi,edi ; read rootdir |
- | |
742 | jne no_read_root |
- | |
743 | - | ||
744 | xor eax,eax |
- | |
745 | call get_dir_size ; return rootdir size |
- | |
746 | cmp [hd_error],0 |
749 | cmp [hd_error], 0 |
747 | jne file_access_denied |
750 | jne file_access_denied |
748 | 751 | ||
Line 749... | Line 752... | ||
749 | mov [file_size],eax |
752 | mov [file_size], eax |
750 | mov eax,[ROOT_CLUSTER] |
753 | mov eax, [ROOT_CLUSTER] |
751 | jmp file_read_start |
754 | jmp file_read_start |
752 | 755 | ||
753 | no_read_root: |
756 | no_read_root: |
754 | mov ebx,PUSHAD_EAX ; file name |
757 | mov ebx, PUSHAD_EAX ; file name |
755 | call analyze_directory |
758 | call analyze_directory |
756 | jc file_to_read_not_found |
759 | jc file_to_read_not_found |
757 | 760 | ||
758 | mov eax,[ebx+28] ; file size |
761 | mov eax, [ebx+28] ; file size |
759 | test byte [ebx+11],0x10 ; is it directory? |
762 | test byte [ebx+11], 0x10; is it directory? |
760 | jz read_set_size ; no |
763 | jz read_set_size ; no |
761 | 764 | ||
762 | mov eax,[ebx+20-2] ; FAT entry |
765 | mov eax, [ebx+20-2] ; FAT entry |
763 | mov ax,[ebx+26] |
766 | mov ax, [ebx+26] |
Line 764... | Line 767... | ||
764 | and eax,[fatMASK] |
767 | and eax, [fatMASK] |
765 | call get_dir_size |
768 | call get_dir_size |
Line 766... | Line 769... | ||
766 | cmp [hd_error],0 |
769 | cmp [hd_error], 0 |
767 | jne file_access_denied |
770 | jne file_access_denied |
768 | 771 | ||
Line 769... | Line 772... | ||
769 | read_set_size: |
772 | read_set_size: |
770 | mov [file_size],eax |
773 | mov [file_size], eax |
771 | 774 | ||
772 | mov eax,[ebx+20-2] ; FAT entry |
775 | mov eax, [ebx+20-2] ; FAT entry |
Line 773... | Line 776... | ||
773 | mov ax,[ebx+26] |
776 | mov ax, [ebx+26] |
774 | and eax,[fatMASK] |
777 | and eax, [fatMASK] |
775 | 778 | ||
- | 779 | file_read_start: |
|
- | 780 | mov ebx, PUSHAD_ECX ; pointer to buffer |
|
- | 781 | mov edx, PUSHAD_EBX ; file blocks to read |
|
- | 782 | mov esi, PUSHAD_ESI ; first 512 block to read |
|
- | 783 | ||
- | 784 | file_read_new_cluster: |
|
- | 785 | call get_data_cluster |
|
Line -... | Line 786... | ||
- | 786 | jc file_read_eof ; end of file or cluster out of range |
|
- | 787 | ||
776 | file_read_start: |
788 | test edx, edx ; is all read? |
777 | mov ebx,PUSHAD_ECX ; pointer to buffer |
789 | je file_read_OK ; yes |
Line 778... | Line -... | ||
778 | mov edx,PUSHAD_EBX ; file blocks to read |
- | |
779 | mov esi,PUSHAD_ESI ; first 512 block to read |
- | |
780 | - | ||
781 | file_read_new_cluster: |
- | |
782 | call get_data_cluster |
- | |
783 | jc file_read_eof ; end of file or cluster out of range |
- | |
784 | - | ||
785 | test edx,edx ; is all read? |
- | |
786 | je file_read_OK ; yes |
- | |
787 | 790 | ||
788 | call get_FAT ; get next cluster |
791 | call get_FAT ; get next cluster |
789 | cmp [hd_error],0 |
792 | cmp [hd_error], 0 |
790 | jne file_access_denied |
793 | jne file_access_denied |
791 | 794 | ||
Line 792... | Line 795... | ||
792 | cmp eax,[fatRESERVED] ; end of file |
795 | cmp eax, [fatRESERVED]; end of file |
793 | jnb file_read_eof |
796 | jnb file_read_eof |
794 | cmp eax,2 ; incorrect fat chain |
797 | cmp eax, 2 ; incorrect fat chain |
795 | jnb file_read_new_cluster |
798 | jnb file_read_new_cluster |
796 | 799 | ||
797 | popad |
800 | popad |
798 | mov [hd1_status],0 |
801 | mov [hd1_status], 0 |
799 | mov ebx,[file_size] |
802 | mov ebx, [file_size] |
Line 800... | Line 803... | ||
800 | mov eax,ERROR_FAT_TABLE |
803 | mov eax, ERROR_FAT_TABLE |
801 | ret |
804 | ret |
802 | 805 | ||
803 | file_read_eof: |
806 | file_read_eof: |
804 | cmp [hd_error],0 |
807 | cmp [hd_error], 0 |
805 | jne file_access_denied |
808 | jne file_access_denied |
Line 806... | Line 809... | ||
806 | popad |
809 | popad |
807 | mov [hd1_status],0 |
810 | mov [hd1_status], 0 |
808 | mov ebx,[file_size] |
811 | mov ebx, [file_size] |
809 | mov eax,ERROR_END_OF_FILE |
812 | mov eax, ERROR_END_OF_FILE |
810 | ret |
813 | ret |
811 | 814 | ||
812 | file_read_OK: |
815 | file_read_OK: |
813 | popad |
816 | popad |
Line 814... | Line 817... | ||
814 | mov [hd1_status],0 |
817 | mov [hd1_status], 0 |
815 | mov ebx,[file_size] |
818 | mov ebx, [file_size] |
816 | xor eax,eax |
819 | xor eax, eax |
817 | ret |
820 | ret |
818 | 821 | ||
819 | file_to_read_not_found: |
822 | file_to_read_not_found: |
Line 820... | Line 823... | ||
820 | cmp [hd_error],0 |
823 | cmp [hd_error], 0 |
821 | jne file_access_denied |
824 | jne file_access_denied |
822 | popad |
825 | popad |
823 | mov [hd1_status],0 |
826 | mov [hd1_status], 0 |
824 | xor ebx,ebx |
827 | xor ebx, ebx |
825 | mov eax,ERROR_FILE_NOT_FOUND |
828 | mov eax, ERROR_FILE_NOT_FOUND |
826 | ret |
829 | ret |
827 | 830 | ||
828 | file_access_denied: |
831 | file_access_denied: |
829 | popad |
832 | popad |
830 | mov [hd1_status],0 |
833 | mov [hd1_status], 0 |
831 | xor ebx,ebx |
834 | xor ebx, ebx |
832 | mov eax,ERROR_ACCESS_DENIED |
835 | mov eax, ERROR_ACCESS_DENIED |
833 | ret |
836 | ret |
834 | 837 | ||
Line 835... | Line 838... | ||
835 | get_dir_size: |
838 | get_dir_size: |
836 | ;----------------------------------------------------- |
839 | ;----------------------------------------------------- |
837 | ; input : eax = first cluster (0=rootdir) |
840 | ; input : eax = first cluster (0=rootdir) |
838 | ; output : eax = directory size in bytes |
841 | ; output : eax = directory size in bytes |
839 | ;----------------------------------------------------- |
842 | ;----------------------------------------------------- |
840 | push edx |
843 | push edx |
841 | xor edx,edx ; count of directory clusters |
844 | xor edx, edx ; count of directory clusters |
842 | test eax,eax |
845 | test eax, eax |
Line 843... | Line 846... | ||
843 | jnz dir_size_next |
846 | jnz dir_size_next |
844 | 847 | ||
Line 845... | Line 848... | ||
845 | mov eax,[ROOT_SECTORS] |
848 | mov eax, [ROOT_SECTORS] |
846 | shl eax,9 ; fat16 rootdir size in bytes |
849 | shl eax, 9 ; fat16 rootdir size in bytes |
847 | cmp [fs_type],16 |
850 | cmp [fs_type], 16 |
Line 848... | Line 851... | ||
848 | je dir_size_ret |
851 | je dir_size_ret |
849 | mov eax,[ROOT_CLUSTER] |
852 | mov eax, [ROOT_CLUSTER] |
850 | 853 | ||
Line 851... | Line 854... | ||
851 | dir_size_next: |
854 | dir_size_next: |
852 | cmp eax,2 ; incorrect fat chain |
855 | cmp eax, 2 ; incorrect fat chain |
853 | jb dir_size_end |
856 | jb dir_size_end |
854 | cmp eax,[fatRESERVED] ; end of directory |
857 | cmp eax, [fatRESERVED]; end of directory |
855 | ja dir_size_end |
858 | ja dir_size_end |
856 | call get_FAT ; get next cluster |
859 | call get_FAT ; get next cluster |
Line 857... | Line 860... | ||
857 | cmp [hd_error],0 |
860 | cmp [hd_error], 0 |
858 | jne dir_size_ret |
861 | jne dir_size_ret |
859 | 862 | ||
860 | inc edx |
863 | inc edx |
861 | jmp dir_size_next |
864 | jmp dir_size_next |
862 | 865 | ||
863 | dir_size_end: |
866 | dir_size_end: |
864 | imul eax,[SECTORS_PER_CLUSTER],512 ; cluster size in bytes |
867 | imul eax, [SECTORS_PER_CLUSTER], 512; cluster size in bytes |
865 | imul eax,edx |
868 | imul eax, edx |
866 | 869 | ||
867 | dir_size_ret: |
870 | dir_size_ret: |
868 | pop edx |
871 | pop edx |
869 | ret |
872 | ret |
870 | 873 | ||
871 | 874 | ||
872 | clear_cluster_chain: |
875 | clear_cluster_chain: |
Line 873... | Line 876... | ||
873 | ;----------------------------------------------------- |
876 | ;----------------------------------------------------- |
874 | ; input : eax = first cluster |
877 | ; input : eax = first cluster |
875 | ;----------------------------------------------------- |
878 | ;----------------------------------------------------- |
876 | push eax ecx edx |
879 | push eax ecx edx |
877 | xor ecx,ecx ; cluster count |
880 | xor ecx, ecx ; cluster count |
Line 878... | Line 881... | ||
878 | 881 | ||
879 | clean_new_chain: |
882 | clean_new_chain: |
880 | cmp eax,[LAST_CLUSTER] ; end of file |
883 | cmp eax, [LAST_CLUSTER]; end of file |
Line 911... | Line 914... | ||
911 | ;----------------------------------------------------------- |
914 | ;----------------------------------------------------------- |
912 | cmp [fs_type], 16 |
915 | cmp [fs_type], 16 |
913 | jz info_fat_ok |
916 | jz info_fat_ok |
914 | cmp [fs_type], 32 |
917 | cmp [fs_type], 32 |
915 | jz info_fat_ok |
918 | jz info_fat_ok |
916 | xor edx,edx |
919 | xor edx, edx |
917 | xor ebx,ebx |
920 | xor ebx, ebx |
918 | xor ecx,ecx |
921 | xor ecx, ecx |
919 | mov eax,ERROR_UNKNOWN_FS |
922 | mov eax, ERROR_UNKNOWN_FS |
920 | ret |
923 | ret |
Line 921... | Line 924... | ||
921 | 924 | ||
922 | info_fat_ok: |
925 | info_fat_ok: |
Line 923... | Line 926... | ||
923 | ; call reserve_hd1 |
926 | ; call reserve_hd1 |
924 | 927 | ||
925 | xor ecx,ecx ; count of free clusters |
928 | xor ecx, ecx ; count of free clusters |
Line 926... | Line 929... | ||
926 | mov eax,2 |
929 | mov eax, 2 |
927 | mov ebx,[LAST_CLUSTER] |
930 | mov ebx, [LAST_CLUSTER] |
928 | 931 | ||
929 | info_cluster: |
932 | info_cluster: |
930 | push eax |
933 | push eax |
931 | call get_FAT ; get cluster info |
934 | call get_FAT ; get cluster info |
932 | cmp [hd_error],0 |
935 | cmp [hd_error], 0 |
933 | jne info_access_denied |
936 | jne info_access_denied |
934 | 937 | ||
Line 935... | Line 938... | ||
935 | test eax,eax ; is it free? |
938 | test eax, eax ; is it free? |
936 | jnz info_used ; no |
939 | jnz info_used ; no |
937 | inc ecx |
940 | inc ecx |
938 | 941 | ||
939 | info_used: |
942 | info_used: |
940 | pop eax |
943 | pop eax |
941 | inc eax |
944 | inc eax |
942 | cmp eax,ebx ; is above last cluster? |
945 | cmp eax, ebx ; is above last cluster? |
943 | jbe info_cluster ; no. test next cluster |
946 | jbe info_cluster ; no. test next cluster |
944 | 947 | ||
945 | dec ebx ; cluster count |
948 | dec ebx ; cluster count |
Line 946... | Line 949... | ||
946 | imul edx,[SECTORS_PER_CLUSTER],512 ; cluster size in bytes |
949 | imul edx, [SECTORS_PER_CLUSTER], 512; cluster size in bytes |
947 | mov [hd1_status],0 |
950 | mov [hd1_status], 0 |
948 | xor eax,eax |
951 | xor eax, eax |
949 | ret |
952 | ret |
950 | 953 | ||
951 | info_access_denied: |
954 | info_access_denied: |
952 | add esp,4 |
955 | add esp, 4 |
Line 953... | Line 956... | ||
953 | xor edx,edx |
956 | xor edx, edx |
954 | xor ebx,ebx |
957 | xor ebx, ebx |
955 | xor ecx,ecx |
958 | xor ecx, ecx |
956 | mov eax,ERROR_ACCESS_DENIED |
959 | mov eax, ERROR_ACCESS_DENIED |
957 | ret |
960 | ret |
958 | 961 | ||
Line 959... | Line 962... | ||
959 | update_disk: |
962 | update_disk: |
960 | ;----------------------------------------------------------- |
963 | ;----------------------------------------------------------- |
961 | ; write changed fat and cache to disk |
964 | ; write changed fat and cache to disk |
Line 962... | Line 965... | ||
962 | ;----------------------------------------------------------- |
965 | ;----------------------------------------------------------- |
Line 963... | Line 966... | ||
963 | cmp [fat_change],0 ; is fat changed? |
966 | cmp [fat_change], 0 ; is fat changed? |
964 | je upd_no_change |
967 | je upd_no_change |
965 | 968 | ||
Line 966... | Line 969... | ||
966 | call write_fat_sector |
969 | call write_fat_sector |
967 | cmp [hd_error],0 |
970 | cmp [hd_error], 0 |
968 | jne update_disk_acces_denied |
971 | jne update_disk_acces_denied |
Line 1054... | Line 1057... | ||
1054 | jz ext2_HdRead |
1057 | jz ext2_HdRead |
1055 | or ebx, -1 |
1058 | or ebx, -1 |
1056 | mov eax, ERROR_UNKNOWN_FS |
1059 | mov eax, ERROR_UNKNOWN_FS |
1057 | ret |
1060 | ret |
1058 | @@: |
1061 | @@: |
1059 | push edi |
1062 | push edi |
1060 | cmp byte [esi], 0 |
1063 | cmp byte [esi], 0 |
1061 | jnz @f |
1064 | jnz @f |
1062 | .noaccess: |
1065 | .noaccess: |
1063 | pop edi |
1066 | pop edi |
1064 | .noaccess_2: |
1067 | .noaccess_2: |
1065 | or ebx, -1 |
1068 | or ebx, -1 |
1066 | mov eax, ERROR_ACCESS_DENIED |
1069 | mov eax, ERROR_ACCESS_DENIED |
1067 | ret |
1070 | ret |
Line 1068... | Line 1071... | ||
1068 | 1071 | ||
1069 | @@: |
1072 | @@: |
1070 | call hd_find_lfn |
1073 | call hd_find_lfn |
1071 | jnc .found |
1074 | jnc .found |
1072 | pop edi |
1075 | pop edi |
1073 | cmp [hd_error],0 |
1076 | cmp [hd_error], 0 |
1074 | jne .noaccess_2 |
1077 | jne .noaccess_2 |
1075 | or ebx, -1 |
1078 | or ebx, -1 |
1076 | mov eax, ERROR_FILE_NOT_FOUND |
1079 | mov eax, ERROR_FILE_NOT_FOUND |
Line 1077... | Line 1080... | ||
1077 | ret |
1080 | ret |
1078 | 1081 | ||
1079 | .found: |
1082 | .found: |
1080 | test byte [edi+11], 0x10 ; do not allow read directories |
1083 | test byte [edi+11], 0x10; do not allow read directories |
1081 | jnz .noaccess |
1084 | jnz .noaccess |
1082 | test ebx, ebx |
1085 | test ebx, ebx |
1083 | jz .l1 |
1086 | jz .l1 |
1084 | cmp dword [ebx+4], 0 |
1087 | cmp dword [ebx+4], 0 |
1085 | jz @f |
1088 | jz @f |
1086 | xor ebx, ebx |
1089 | xor ebx, ebx |
1087 | .reteof: |
1090 | .reteof: |
1088 | mov eax, 6 |
1091 | mov eax, 6 |
1089 | pop edi |
1092 | pop edi |
1090 | ret |
1093 | ret |
1091 | @@: |
1094 | @@: |
1092 | mov ebx, [ebx] |
1095 | mov ebx, [ebx] |
1093 | .l1: |
1096 | .l1: |
1094 | push ecx edx |
1097 | push ecx edx |
1095 | push 0 |
1098 | push 0 |
Line 1099... | Line 1102... | ||
1099 | cmp eax, ecx |
1102 | cmp eax, ecx |
1100 | jae @f |
1103 | jae @f |
1101 | mov ecx, eax |
1104 | mov ecx, eax |
1102 | mov byte [esp], 6 |
1105 | mov byte [esp], 6 |
1103 | @@: |
1106 | @@: |
1104 | mov eax, [edi+20-2] |
1107 | mov eax, [edi+20-2] |
1105 | mov ax, [edi+26] |
1108 | mov ax, [edi+26] |
1106 | ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data |
1109 | ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data |
1107 | .new_cluster: |
1110 | .new_cluster: |
1108 | jecxz .new_sector |
1111 | jecxz .new_sector |
1109 | test eax, eax |
1112 | test eax, eax |
1110 | jz .eof |
1113 | jz .eof |
1111 | cmp eax, [fatRESERVED] |
1114 | cmp eax, [fatRESERVED] |
1112 | jae .eof |
1115 | jae .eof |
1113 | mov [cluster_tmp], eax |
1116 | mov [cluster_tmp], eax |
1114 | dec eax |
1117 | dec eax |
1115 | dec eax |
1118 | dec eax |
1116 | mov edi, [SECTORS_PER_CLUSTER] |
1119 | mov edi, [SECTORS_PER_CLUSTER] |
1117 | imul eax, edi |
1120 | imul eax, edi |
1118 | add eax, [DATA_START] |
1121 | add eax, [DATA_START] |
1119 | .new_sector: |
1122 | .new_sector: |
1120 | test ecx, ecx |
1123 | test ecx, ecx |
1121 | jz .done |
1124 | jz .done |
1122 | sub ebx, 512 |
1125 | sub ebx, 512 |
1123 | jae .skip |
1126 | jae .skip |
1124 | add ebx, 512 |
1127 | add ebx, 512 |
1125 | jnz .force_buf |
1128 | jnz .force_buf |
1126 | cmp ecx, 512 |
1129 | cmp ecx, 512 |
1127 | jb .force_buf |
1130 | jb .force_buf |
1128 | ; we may read directly to given buffer |
1131 | ; we may read directly to given buffer |
1129 | push ebx |
1132 | push ebx |
1130 | mov ebx, edx |
1133 | mov ebx, edx |
1131 | call hd_read |
1134 | call hd_read |
1132 | pop ebx |
1135 | pop ebx |
1133 | cmp [hd_error],0 |
1136 | cmp [hd_error], 0 |
1134 | jne .noaccess_1 |
1137 | jne .noaccess_1 |
1135 | add edx, 512 |
1138 | add edx, 512 |
1136 | sub ecx, 512 |
1139 | sub ecx, 512 |
1137 | jmp .skip |
1140 | jmp .skip |
1138 | .force_buf: |
1141 | .force_buf: |
1139 | ; we must read sector to temporary buffer and then copy it to destination |
1142 | ; we must read sector to temporary buffer and then copy it to destination |
1140 | push eax ebx |
1143 | push eax ebx |
1141 | mov ebx, buffer |
1144 | mov ebx, buffer |
1142 | call hd_read |
1145 | call hd_read |
1143 | mov eax, ebx |
1146 | mov eax, ebx |
1144 | pop ebx |
1147 | pop ebx |
1145 | cmp [hd_error],0 |
1148 | cmp [hd_error], 0 |
1146 | jne .noaccess_3 |
1149 | jne .noaccess_3 |
1147 | add eax, ebx |
1150 | add eax, ebx |
1148 | push ecx |
1151 | push ecx |
1149 | add ecx, ebx |
1152 | add ecx, ebx |
1150 | cmp ecx, 512 |
1153 | cmp ecx, 512 |
1151 | jbe @f |
1154 | jbe @f |
1152 | mov ecx, 512 |
1155 | mov ecx, 512 |
1153 | @@: |
1156 | @@: |
1154 | sub ecx, ebx |
1157 | sub ecx, ebx |
1155 | mov ebx, edx |
1158 | mov ebx, edx |
1156 | call memmove |
1159 | call memmove |
1157 | add edx, ecx |
1160 | add edx, ecx |
1158 | sub [esp], ecx |
1161 | sub [esp], ecx |
1159 | pop ecx |
1162 | pop ecx |
1160 | pop eax |
1163 | pop eax |
1161 | xor ebx, ebx |
1164 | xor ebx, ebx |
1162 | .skip: |
1165 | .skip: |
1163 | inc eax |
1166 | inc eax |
1164 | dec edi |
1167 | dec edi |
1165 | jnz .new_sector |
1168 | jnz .new_sector |
1166 | mov eax, [cluster_tmp] |
1169 | mov eax, [cluster_tmp] |
1167 | call get_FAT |
1170 | call get_FAT |
1168 | cmp [hd_error],0 |
1171 | cmp [hd_error], 0 |
1169 | jne .noaccess_1 |
1172 | jne .noaccess_1 |
Line 1170... | Line 1173... | ||
1170 | 1173 | ||
1171 | jmp .new_cluster |
1174 | jmp .new_cluster |
1172 | .noaccess_3: |
1175 | .noaccess_3: |
1173 | pop eax |
1176 | pop eax |
1174 | .noaccess_1: |
1177 | .noaccess_1: |
1175 | pop eax |
1178 | pop eax |
Line 1244... | Line 1247... | ||
1244 | ; init header |
1247 | ; init header |
1245 | push eax ecx |
1248 | push eax ecx |
1246 | mov edi, edx |
1249 | mov edi, edx |
1247 | mov ecx, 32/4 |
1250 | mov ecx, 32/4 |
1248 | xor eax, eax |
1251 | xor eax, eax |
1249 | rep stosd |
1252 | rep stosd |
1250 | pop ecx eax |
1253 | pop ecx eax |
1251 | mov byte [edx], 1 ; version |
1254 | mov byte [edx], 1 ; version |
1252 | mov esi, edi ; esi points to BDFE |
1255 | mov esi, edi ; esi points to BDFE |
1253 | .new_cluster: |
1256 | .new_cluster: |
1254 | mov [cluster_tmp], eax |
1257 | mov [cluster_tmp], eax |
Line 1523... | Line 1526... | ||
1523 | ; zero new cluster |
1526 | ; zero new cluster |
1524 | mov ecx, 512/4 |
1527 | mov ecx, 512/4 |
1525 | mov edi, buffer |
1528 | mov edi, buffer |
1526 | push edi |
1529 | push edi |
1527 | xor eax, eax |
1530 | xor eax, eax |
1528 | rep stosd |
1531 | rep stosd |
1529 | pop edi |
1532 | pop edi |
1530 | pop ecx |
1533 | pop ecx |
1531 | mov eax, [esp+4] |
1534 | mov eax, [esp+4] |
1532 | mov [eax], edx |
1535 | mov [eax], edx |
1533 | and dword [eax+4], 0 |
1536 | and dword [eax+4], 0 |
Line 1589... | Line 1592... | ||
1589 | fs_HdRewrite: |
1592 | fs_HdRewrite: |
1590 | xor eax, eax |
1593 | xor eax, eax |
1591 | .common: |
1594 | .common: |
1592 | cmp [fs_type], 1 |
1595 | cmp [fs_type], 1 |
1593 | jz ntfs_HdRewrite |
1596 | jz ntfs_HdRewrite |
1594 | cmp [fs_type], 2 |
1597 | cmp [fs_type], 2 |
1595 | jz ext2_HdRewrite |
1598 | jz ext2_HdRewrite |
1596 | cmp [fs_type], 16 |
1599 | cmp [fs_type], 16 |
1597 | jz @f |
1600 | jz @f |
1598 | cmp [fs_type], 32 |
1601 | cmp [fs_type], 32 |
1599 | jnz fshrfs |
1602 | jnz fshrfs |
1600 | @@: |
1603 | @@: |
Line 1763... | Line 1766... | ||
1763 | .test_short_name_entry: |
1766 | .test_short_name_entry: |
1764 | cmp byte [edi+11], 0xF |
1767 | cmp byte [edi+11], 0xF |
1765 | jz .test_short_name_cont |
1768 | jz .test_short_name_cont |
1766 | mov ecx, 11 |
1769 | mov ecx, 11 |
1767 | push esi edi |
1770 | push esi edi |
1768 | repz cmpsb |
1771 | repz cmpsb |
1769 | pop edi esi |
1772 | pop edi esi |
1770 | jz .short_name_found |
1773 | jz .short_name_found |
1771 | .test_short_name_cont: |
1774 | .test_short_name_cont: |
1772 | lea eax, [esp+12+12+8] |
1775 | lea eax, [esp+12+12+8] |
1773 | call dword [eax-8] |
1776 | call dword [eax-8] |
Line 1788... | Line 1791... | ||
1788 | ; now find space in directory |
1791 | ; now find space in directory |
1789 | ; we need to save LFN <=> LFN is not equal to short name <=> generated name contains '~' |
1792 | ; we need to save LFN <=> LFN is not equal to short name <=> generated name contains '~' |
1790 | mov al, '~' |
1793 | mov al, '~' |
1791 | push ecx edi |
1794 | push ecx edi |
1792 | mov ecx, 8 |
1795 | mov ecx, 8 |
1793 | repnz scasb |
1796 | repnz scasb |
1794 | push 1 |
1797 | push 1 |
1795 | pop eax ; 1 entry |
1798 | pop eax ; 1 entry |
1796 | jnz .notilde |
1799 | jnz .notilde |
1797 | ; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total |
1800 | ; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total |
1798 | xor eax, eax |
1801 | xor eax, eax |
Line 1919... | Line 1922... | ||
1919 | ; lea eax, [esp+8+12+8] |
1922 | ; lea eax, [esp+8+12+8] |
1920 | ; call dword [eax+16] ; end write |
1923 | ; call dword [eax+16] ; end write |
1921 | .nolfn: |
1924 | .nolfn: |
1922 | xchg esi, [esp] |
1925 | xchg esi, [esp] |
1923 | mov ecx, 11 |
1926 | mov ecx, 11 |
1924 | rep movsb |
1927 | rep movsb |
1925 | mov word [edi], 20h ; attributes |
1928 | mov word [edi], 20h ; attributes |
1926 | sub edi, 11 |
1929 | sub edi, 11 |
1927 | pop esi ecx |
1930 | pop esi ecx |
1928 | add esp, 12 |
1931 | add esp, 12 |
1929 | mov byte [edi+13], 0 ; tenths of a second at file creation time |
1932 | mov byte [edi+13], 0 ; tenths of a second at file creation time |
Line 1994... | Line 1997... | ||
1994 | .writeshort: |
1997 | .writeshort: |
1995 | mov ecx, [esp+8] |
1998 | mov ecx, [esp+8] |
1996 | push ecx |
1999 | push ecx |
1997 | mov edi, buffer |
2000 | mov edi, buffer |
1998 | mov ebx, edi |
2001 | mov ebx, edi |
1999 | rep movsb |
2002 | rep movsb |
2000 | .writedircont: |
2003 | .writedircont: |
2001 | mov ecx, buffer+0x200 |
2004 | mov ecx, buffer+0x200 |
2002 | sub ecx, edi |
2005 | sub ecx, edi |
2003 | push eax |
2006 | push eax |
2004 | xor eax, eax |
2007 | xor eax, eax |
2005 | rep stosb |
2008 | rep stosb |
2006 | pop eax |
2009 | pop eax |
2007 | pop ecx |
2010 | pop ecx |
2008 | .writecommon: |
2011 | .writecommon: |
2009 | call hd_write |
2012 | call hd_write |
2010 | cmp [hd_error], 0 |
2013 | cmp [hd_error], 0 |
Line 2073... | Line 2076... | ||
2073 | cmp ecx, [esp+12] |
2076 | cmp ecx, [esp+12] |
2074 | jnz .writedircont |
2077 | jnz .writedircont |
2075 | dec dword [esp+16] |
2078 | dec dword [esp+16] |
2076 | push esi |
2079 | push esi |
2077 | mov ecx, 32/4 |
2080 | mov ecx, 32/4 |
2078 | rep movsd |
2081 | rep movsd |
2079 | pop esi |
2082 | pop esi |
2080 | mov dword [edi-32], '. ' |
2083 | mov dword [edi-32], '. ' |
2081 | mov dword [edi-32+4], ' ' |
2084 | mov dword [edi-32+4], ' ' |
2082 | mov dword [edi-32+8], ' ' |
2085 | mov dword [edi-32+8], ' ' |
2083 | mov byte [edi-32+11], 10h |
2086 | mov byte [edi-32+11], 10h |
2084 | push esi |
2087 | push esi |
2085 | mov ecx, 32/4 |
2088 | mov ecx, 32/4 |
2086 | rep movsd |
2089 | rep movsd |
2087 | pop esi |
2090 | pop esi |
2088 | mov dword [edi-32], '.. ' |
2091 | mov dword [edi-32], '.. ' |
2089 | mov dword [edi-32+4], ' ' |
2092 | mov dword [edi-32+4], ' ' |
2090 | mov dword [edi-32+8], ' ' |
2093 | mov dword [edi-32+8], ' ' |
2091 | mov byte [edi-32+11], 10h |
2094 | mov byte [edi-32+11], 10h |
Line 2125... | Line 2128... | ||
2125 | jmp fs_HdWrite.ret0 |
2128 | jmp fs_HdWrite.ret0 |
Line 2126... | Line 2129... | ||
2126 | 2129 | ||
2127 | fs_HdWrite: |
2130 | fs_HdWrite: |
2128 | cmp [fs_type], 1 |
2131 | cmp [fs_type], 1 |
2129 | jz ntfs_HdWrite |
2132 | jz ntfs_HdWrite |
2130 | cmp [fs_type], 2 |
2133 | cmp [fs_type], 2 |
2131 | jz ext2_HdWrite |
2134 | jz ext2_HdWrite |
2132 | cmp [fs_type], 16 |
2135 | cmp [fs_type], 16 |
2133 | jz @f |
2136 | jz @f |
2134 | cmp [fs_type], 32 |
2137 | cmp [fs_type], 32 |
2135 | jz @f |
2138 | jz @f |
Line 2293... | Line 2296... | ||
2293 | mov ecx, 0x200 |
2296 | mov ecx, 0x200 |
2294 | sub ecx, [esp+4+12] |
2297 | sub ecx, [esp+4+12] |
2295 | jbe @f |
2298 | jbe @f |
2296 | mov edi, buffer |
2299 | mov edi, buffer |
2297 | add edi, [esp+4+12] |
2300 | add edi, [esp+4+12] |
2298 | rep stosb |
2301 | rep stosb |
2299 | @@: |
2302 | @@: |
2300 | ; zero uninitialized data in the last sector |
2303 | ; zero uninitialized data in the last sector |
2301 | mov ecx, 0x200 |
2304 | mov ecx, 0x200 |
2302 | sub ecx, esi |
2305 | sub ecx, esi |
2303 | jbe @f |
2306 | jbe @f |
2304 | mov edi, buffer |
2307 | mov edi, buffer |
2305 | add edi, esi |
2308 | add edi, esi |
2306 | rep stosb |
2309 | rep stosb |
2307 | @@: |
2310 | @@: |
2308 | pop edi ecx |
2311 | pop edi ecx |
2309 | ; copy new data |
2312 | ; copy new data |
2310 | mov eax, edx |
2313 | mov eax, edx |
2311 | neg ebx |
2314 | neg ebx |
Line 2343... | Line 2346... | ||
2343 | xor esi, esi |
2346 | xor esi, esi |
2344 | @@: |
2347 | @@: |
2345 | sub dword [esp], 0x200 |
2348 | sub dword [esp], 0x200 |
2346 | jae @f |
2349 | jae @f |
2347 | and dword [esp], 0 |
2350 | and dword [esp], 0 |
- | 2351 | @@: |
|
2348 | @@: jmp .write_loop |
2352 | jmp .write_loop |
Line 2349... | Line 2353... | ||
2349 | 2353 | ||
2350 | hd_extend_file.zero_size: |
2354 | hd_extend_file.zero_size: |
2351 | xor eax, eax |
2355 | xor eax, eax |
Line 2452... | Line 2456... | ||
2452 | push ERROR_DISK_FULL |
2456 | push ERROR_DISK_FULL |
2453 | pop eax |
2457 | pop eax |
2454 | cmp [hd_error], 0 |
2458 | cmp [hd_error], 0 |
2455 | jz @f |
2459 | jz @f |
2456 | mov al, 11 |
2460 | mov al, 11 |
- | 2461 | @@: |
|
2457 | @@: stc |
2462 | stc |
2458 | ret |
2463 | ret |
Line 2459... | Line 2464... | ||
2459 | 2464 | ||
2460 | ;---------------------------------------------------------------- |
2465 | ;---------------------------------------------------------------- |
2461 | ; |
2466 | ; |
Line 2470... | Line 2475... | ||
2470 | ; |
2475 | ; |
2471 | ;-------------------------------------------------------------- |
2476 | ;-------------------------------------------------------------- |
2472 | fs_HdSetFileEnd: |
2477 | fs_HdSetFileEnd: |
2473 | cmp [fs_type], 1 |
2478 | cmp [fs_type], 1 |
2474 | jz ntfs_HdSetFileEnd |
2479 | jz ntfs_HdSetFileEnd |
2475 | cmp [fs_type], 2 |
2480 | cmp [fs_type], 2 |
2476 | jz ext2_HdSetFileEnd |
2481 | jz ext2_HdSetFileEnd |
2477 | cmp [fs_type], 16 |
2482 | cmp [fs_type], 16 |
2478 | jz @f |
2483 | jz @f |
2479 | cmp [fs_type], 32 |
2484 | cmp [fs_type], 32 |
2480 | jz @f |
2485 | jz @f |
2481 | push ERROR_UNKNOWN_FS |
2486 | push ERROR_UNKNOWN_FS |
Line 2587... | Line 2592... | ||
2587 | mov edi, buffer+0x200 |
2592 | mov edi, buffer+0x200 |
2588 | add edi, [esp+8] |
2593 | add edi, [esp+8] |
2589 | push eax |
2594 | push eax |
2590 | xor eax, eax |
2595 | xor eax, eax |
2591 | mov [esp+12], eax |
2596 | mov [esp+12], eax |
2592 | rep stosb |
2597 | rep stosb |
2593 | pop eax |
2598 | pop eax |
2594 | pop edi |
2599 | pop edi |
2595 | call hd_write |
2600 | call hd_write |
2596 | cmp [hd_error], 0 |
2601 | cmp [hd_error], 0 |
2597 | jz .next_cluster |
2602 | jz .next_cluster |
Line 2687... | Line 2692... | ||
2687 | lea edi, [buffer+eax] |
2692 | lea edi, [buffer+eax] |
2688 | push ecx |
2693 | push ecx |
2689 | mov ecx, 0x200 |
2694 | mov ecx, 0x200 |
2690 | sub ecx, eax |
2695 | sub ecx, eax |
2691 | xor eax, eax |
2696 | xor eax, eax |
2692 | rep stosb |
2697 | rep stosb |
2693 | pop eax |
2698 | pop eax |
2694 | call hd_write |
2699 | call hd_write |
2695 | pop ebx |
2700 | pop ebx |
2696 | .truncate_done: |
2701 | .truncate_done: |
2697 | pop ecx eax edi |
2702 | pop ecx eax edi |
Line 2704... | Line 2709... | ||
2704 | ret |
2709 | ret |
Line 2705... | Line 2710... | ||
2705 | 2710 | ||
2706 | fs_HdGetFileInfo: |
2711 | fs_HdGetFileInfo: |
2707 | cmp [fs_type], 1 |
2712 | cmp [fs_type], 1 |
2708 | jz ntfs_HdGetFileInfo |
2713 | jz ntfs_HdGetFileInfo |
2709 | cmp [fs_type], 2 |
2714 | cmp [fs_type], 2 |
2710 | jz ext2_HdGetFileInfo |
2715 | jz ext2_HdGetFileInfo |
2711 | cmp [fs_type], 16 |
2716 | cmp [fs_type], 16 |
2712 | jz @f |
2717 | jz @f |
2713 | cmp [fs_type], 32 |
2718 | cmp [fs_type], 32 |
2714 | jz @f |
2719 | jz @f |