Rev 115 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 115 | Rev 131 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; FAT32.INC ;; |
3 | ;; FAT32.INC ;; |
4 | ;; ;; |
4 | ;; ;; |
5 | ;; FAT16/32 functions for MenuetOS ;; |
5 | ;; FAT16/32 functions for KolibriOS ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;; |
7 | ;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;; See file COPYING for details ;; |
9 | ;; See file COPYING for details ;; |
- | 10 | ;; 17.08.2006 LFN write/append to file - diamond ;; |
|
10 | ;; 23.06.2006 LFN start application - diamond ;; |
11 | ;; 23.06.2006 LFN start application - diamond ;; |
11 | ;; 15.06.2006 LFN get/set file/folder info - diamond ;; |
12 | ;; 15.06.2006 LFN get/set file/folder info - diamond ;; |
12 | ;; 27.05.2006 LFN create/rewrite file - diamond ;; |
13 | ;; 27.05.2006 LFN create/rewrite file - diamond ;; |
13 | ;; 04.05.2006 LFN read folder - diamond ;; |
14 | ;; 04.05.2006 LFN read folder - diamond ;; |
14 | ;; 29.04.2006 Elimination of hangup after the ;; |
15 | ;; 29.04.2006 Elimination of hangup after the ;; |
Line 102... | Line 103... | ||
102 | dir_entry: times 32 db 0 |
103 | dir_entry: times 32 db 0 |
Line 103... | Line 104... | ||
103 | 104 | ||
Line 104... | Line 105... | ||
104 | startpath: times 255 db 0 |
105 | startpath: times 255 db 0 |
105 | - | ||
106 | fat16_root db 0 ; flag for fat16 rootdir |
106 | |
Line 107... | Line 107... | ||
107 | f_del db 0 ; 1=overwrite fat entry |
107 | fat16_root db 0 ; flag for fat16 rootdir |
Line 108... | Line 108... | ||
108 | fat_change db 0 ; 1=fat has changed |
108 | fat_change db 0 ; 1=fat has changed |
Line 223... | Line 223... | ||
223 | 223 | ||
224 | sfc_in_cache: |
224 | sfc_in_cache: |
225 | cmp [fat_type],16 |
225 | cmp [fat_type],16 |
Line 226... | Line -... | ||
226 | jne sfc_test32 |
- | |
227 | - | ||
228 | cmp [f_del],1 ; overwrite previous value? |
- | |
229 | je sfc_set16 ; yes |
- | |
230 | cmp word [ebx+esi],0 ; is cluster free? |
- | |
231 | je sfc_set16 ; yes |
- | |
232 | mov dword [8*0x100000],0xffffff |
- | |
233 | mov edx,[ebx+esi] ; get old value |
- | |
234 | jmp sfc_nonzero |
226 | jne sfc_test32 |
235 | 227 | ||
236 | sfc_set16: |
228 | sfc_set16: |
Line 237... | Line 229... | ||
237 | xchg [ebx+esi],dx ; save new value and get old value |
229 | xchg [ebx+esi],dx ; save new value and get old value |
238 | jmp sfc_write |
230 | jmp sfc_write |
239 | - | ||
240 | sfc_test32: |
- | |
241 | mov eax,[fatMASK] |
- | |
242 | cmp [f_del],1 ; overwrite previous value? |
- | |
243 | je sfc_set32 ; yes |
- | |
244 | test eax,[ebx+esi] ; is cluster free? |
- | |
245 | je sfc_set32 ; yes |
- | |
Line 246... | Line 231... | ||
246 | mov dword [8*0x100000],0xffffff |
231 | |
247 | mov edx,[ebx+esi] ; get old value |
232 | sfc_test32: |
248 | jmp sfc_nonzero |
233 | mov eax,[fatMASK] |
249 | 234 | ||
Line 552... | Line 537... | ||
552 | jne adw_not_found |
537 | jne adw_not_found |
Line 553... | Line 538... | ||
553 | 538 | ||
554 | push eax ; save new cluster |
539 | push eax ; save new cluster |
555 | mov edx,eax |
540 | mov edx,eax |
556 | mov eax,[cluster_tmp] ; change last cluster to point new cluster |
- | |
557 | mov [f_del],1 |
541 | mov eax,[cluster_tmp] ; change last cluster to point new cluster |
558 | call set_FAT |
542 | call set_FAT |
559 | cmp [hd_error],0 |
543 | cmp [hd_error],0 |
Line 560... | Line -... | ||
560 | jne adw_not_found_1 |
- | |
561 | - | ||
562 | mov [f_del],0 |
544 | jne adw_not_found_1 |
563 | 545 | ||
564 | mov ecx,-1 ; remove 1 cluster from free disk space |
546 | mov ecx,-1 ; remove 1 cluster from free disk space |
565 | call add_disk_free_space |
547 | call add_disk_free_space |
Line 881... | Line 863... | ||
881 | make_dir_already_exist: |
863 | make_dir_already_exist: |
882 | cmp [hd_error],0 |
864 | cmp [hd_error],0 |
883 | jne make_dir_error_1 |
865 | jne make_dir_error_1 |
884 | mov eax,[cluster] ; directory cluster |
866 | mov eax,[cluster] ; directory cluster |
885 | xor edx,edx ; free |
867 | xor edx,edx ; free |
886 | mov [f_del],1 |
- | |
887 | call set_FAT |
868 | call set_FAT |
888 | cmp [hd_error],0 |
869 | cmp [hd_error],0 |
889 | jne make_dir_error_1 |
870 | jne make_dir_error_1 |
Line 890... | Line -... | ||
890 | - | ||
891 | mov [f_del],0 |
- | |
892 | 871 | ||
893 | popad |
872 | popad |
894 | call update_disk ; write all of cache and fat to hd |
873 | call update_disk ; write all of cache and fat to hd |
895 | make_dir_error_2: |
874 | make_dir_error_2: |
896 | mov [hd1_status],0 |
875 | mov [hd1_status],0 |
Line 1236... | Line 1215... | ||
1236 | cmp [hd_error],0 |
1215 | cmp [hd_error],0 |
1237 | jne append_access_1 |
1216 | jne append_access_1 |
Line 1238... | Line 1217... | ||
1238 | 1217 | ||
1239 | mov edx,eax |
1218 | mov edx,eax |
1240 | mov eax,[cluster] |
- | |
1241 | mov [f_del],1 |
1219 | mov eax,[cluster] |
1242 | call set_FAT ; update previous cluster |
1220 | call set_FAT ; update previous cluster |
1243 | cmp [hd_error],0 |
1221 | cmp [hd_error],0 |
Line 1244... | Line -... | ||
1244 | jne append_access_1 |
- | |
1245 | 1222 | jne append_access_1 |
|
1246 | mov [f_del],0 |
1223 | |
Line 1247... | Line 1224... | ||
1247 | pop eax |
1224 | pop eax |
1248 | jmp append_remove_free |
1225 | jmp append_remove_free |
Line 1360... | Line 1337... | ||
1360 | 1337 | ||
Line 1361... | Line 1338... | ||
1361 | jmp truncate_new_cluster |
1338 | jmp truncate_new_cluster |
1362 | 1339 | ||
1363 | truncate_pos_found: |
- | |
1364 | mov edx,[fatEND] ; new end for cluster chain |
1340 | truncate_pos_found: |
1365 | mov [f_del],1 |
1341 | mov edx,[fatEND] ; new end for cluster chain |
1366 | call set_FAT |
1342 | call set_FAT |
Line 1367... | Line -... | ||
1367 | cmp [hd_error],0 |
- | |
1368 | jne append_access |
1343 | cmp [hd_error],0 |
Line 1369... | Line 1344... | ||
1369 | 1344 | jne append_access |
|
1370 | mov [f_del],0 |
1345 | |
1371 | mov eax,edx ; clear rest of chain |
1346 | mov eax,edx ; clear rest of chain |
Line 1873... | Line 1848... | ||
1873 | ;----------------------------------------------------- |
1848 | ;----------------------------------------------------- |
1874 | ; input : eax = first cluster |
1849 | ; input : eax = first cluster |
1875 | ;----------------------------------------------------- |
1850 | ;----------------------------------------------------- |
1876 | push eax ecx edx |
1851 | push eax ecx edx |
1877 | xor ecx,ecx ; cluster count |
1852 | xor ecx,ecx ; cluster count |
1878 | mov [f_del],1 ; delete on |
- | |
Line 1879... | Line 1853... | ||
1879 | 1853 | ||
1880 | clean_new_chain: |
1854 | clean_new_chain: |
1881 | cmp eax,[LAST_CLUSTER] ; end of file |
1855 | cmp eax,[LAST_CLUSTER] ; end of file |
1882 | ja delete_OK |
1856 | ja delete_OK |
Line 1895... | Line 1869... | ||
1895 | jmp clean_new_chain |
1869 | jmp clean_new_chain |
Line 1896... | Line 1870... | ||
1896 | 1870 | ||
1897 | delete_OK: |
1871 | delete_OK: |
1898 | call add_disk_free_space ; add clusters to free disk space |
1872 | call add_disk_free_space ; add clusters to free disk space |
1899 | access_denied_01: |
- | |
1900 | mov [f_del],0 |
1873 | access_denied_01: |
1901 | pop edx ecx eax |
1874 | pop edx ecx eax |
Line 1902... | Line 1875... | ||
1902 | ret |
1875 | ret |
Line 3286... | Line 3259... | ||
3286 | call set_FAT |
3259 | call set_FAT |
3287 | mov edx, eax |
3260 | mov edx, eax |
3288 | mov eax, [esp+4] |
3261 | mov eax, [esp+4] |
3289 | mov eax, [eax] |
3262 | mov eax, [eax] |
3290 | push edx |
3263 | push edx |
3291 | mov [f_del], 1 |
- | |
3292 | call set_FAT |
3264 | call set_FAT |
3293 | pop edx |
3265 | pop edx |
3294 | cmp [hd_error], 0 |
3266 | cmp [hd_error], 0 |
3295 | jz @f |
3267 | jz @f |
3296 | pop edx |
3268 | pop edx |
Line 3448... | Line 3420... | ||
3448 | mov ax, [edi+26] |
3420 | mov ax, [edi+26] |
3449 | mov word [edi+20], cx |
3421 | mov word [edi+20], cx |
3450 | mov word [edi+26], cx |
3422 | mov word [edi+26], cx |
3451 | test eax, eax |
3423 | test eax, eax |
3452 | jz .done1 |
3424 | jz .done1 |
3453 | mov [f_del], 1 |
- | |
3454 | @@: |
3425 | @@: |
3455 | cmp eax, [fatRESERVED] |
3426 | cmp eax, [fatRESERVED] |
3456 | jae .done1 |
3427 | jae .done1 |
3457 | push edx |
3428 | push edx |
3458 | xor edx, edx |
3429 | xor edx, edx |
Line 3734... | Line 3705... | ||
3734 | ; allocate new cluster |
3705 | ; allocate new cluster |
3735 | pop eax |
3706 | pop eax |
3736 | mov ecx, eax |
3707 | mov ecx, eax |
3737 | call get_free_FAT |
3708 | call get_free_FAT |
3738 | jc .diskfull |
3709 | jc .diskfull |
3739 | mov [f_del], 1 |
- | |
3740 | push edx |
3710 | push edx |
3741 | mov edx, [fatEND] |
3711 | mov edx, [fatEND] |
3742 | call set_FAT |
3712 | call set_FAT |
3743 | xchg eax, ecx |
3713 | xchg eax, ecx |
3744 | mov edx, ecx |
3714 | mov edx, ecx |
Line 3781... | Line 3751... | ||
3781 | add esp, 32 |
3751 | add esp, 32 |
3782 | call update_disk |
3752 | call update_disk |
3783 | popad |
3753 | popad |
3784 | ret |
3754 | ret |
Line -... | Line 3755... | ||
- | 3755 | ||
- | 3756 | ;---------------------------------------------------------------- |
|
- | 3757 | ; |
|
- | 3758 | ; fs_HdWrite - LFN variant for writing to floppy |
|
- | 3759 | ; |
|
- | 3760 | ; esi points to filename |
|
- | 3761 | ; ebx pointer to 64-bit number = first wanted byte, 0+ |
|
- | 3762 | ; may be ebx=0 - start from first byte |
|
- | 3763 | ; ecx number of bytes to write, 0+ |
|
- | 3764 | ; edx mem location to data |
|
- | 3765 | ; |
|
- | 3766 | ; ret ebx = bytes written (maybe 0) |
|
- | 3767 | ; eax = 0 ok write or other = errormsg |
|
- | 3768 | ; |
|
- | 3769 | ;-------------------------------------------------------------- |
|
- | 3770 | fs_HdWrite.access_denied: |
|
- | 3771 | push ERROR_ACCESS_DENIED |
|
- | 3772 | fs_HdWrite.ret0: |
|
- | 3773 | pop eax |
|
- | 3774 | xor ebx, ebx |
|
- | 3775 | ret |
|
- | 3776 | ||
- | 3777 | fs_HdWrite.ret11: |
|
- | 3778 | push 11 |
|
- | 3779 | jmp fs_HdWrite.ret0 |
|
- | 3780 | ||
- | 3781 | fs_HdWrite: |
|
- | 3782 | cmp [fat_type], 0 |
|
- | 3783 | jnz @f |
|
- | 3784 | push ERROR_UNKNOWN_FS |
|
- | 3785 | jmp .ret0 |
|
- | 3786 | @@: |
|
- | 3787 | cmp byte [esi], 0 |
|
- | 3788 | jz .access_denied |
|
- | 3789 | pushad |
|
- | 3790 | call hd_find_lfn |
|
- | 3791 | pushfd |
|
- | 3792 | cmp [hd_error], 0 |
|
- | 3793 | jz @f |
|
- | 3794 | popfd |
|
- | 3795 | popad |
|
- | 3796 | push 11 |
|
- | 3797 | jmp .ret0 |
|
- | 3798 | @@: |
|
- | 3799 | popfd |
|
- | 3800 | jnc .found |
|
- | 3801 | popad |
|
- | 3802 | push ERROR_FILE_NOT_FOUND |
|
- | 3803 | jmp .ret0 |
|
- | 3804 | .found: |
|
- | 3805 | ; FAT does not support files larger than 4GB |
|
- | 3806 | test ebx, ebx |
|
- | 3807 | jz .l1 |
|
- | 3808 | cmp dword [ebx+4], 0 |
|
- | 3809 | jz @f |
|
- | 3810 | .eof: |
|
- | 3811 | popad |
|
- | 3812 | push ERROR_END_OF_FILE |
|
- | 3813 | jmp .ret0 |
|
- | 3814 | @@: |
|
- | 3815 | mov ebx, [ebx] |
|
- | 3816 | .l1: |
|
- | 3817 | ; now edi points to direntry, ebx=start byte to write, |
|
- | 3818 | ; ecx=number of bytes to write, edx=data pointer |
|
- | 3819 | ||
- | 3820 | ; extend file if needed |
|
- | 3821 | add ecx, ebx |
|
- | 3822 | jc .eof ; FAT does not support files larger than 4GB |
|
- | 3823 | push eax ; save directory sector |
|
- | 3824 | push 0 ; return value=0 |
|
- | 3825 | ||
- | 3826 | call get_time_for_file |
|
- | 3827 | mov [edi+22], ax ; last write time |
|
- | 3828 | call get_date_for_file |
|
- | 3829 | mov [edi+24], ax ; last write date |
|
- | 3830 | mov [edi+18], ax ; last access date |
|
- | 3831 | ||
- | 3832 | push dword [edi+28] ; save current file size |
|
- | 3833 | cmp ecx, [edi+28] |
|
- | 3834 | jbe .length_ok |
|
- | 3835 | cmp ecx, ebx |
|
- | 3836 | jz .length_ok |
|
- | 3837 | call hd_extend_file |
|
- | 3838 | jnc .length_ok |
|
- | 3839 | mov [esp+4], eax |
|
- | 3840 | ; hd_extend_file can return three error codes: FAT table error, device error or disk full. |
|
- | 3841 | ; First two cases are fatal errors, in third case we may write some data |
|
- | 3842 | cmp al, ERROR_DISK_FULL |
|
- | 3843 | jz .disk_full |
|
- | 3844 | pop eax |
|
- | 3845 | pop eax |
|
- | 3846 | mov [esp+4+28], eax |
|
- | 3847 | pop eax |
|
- | 3848 | popad |
|
- | 3849 | xor ebx, ebx |
|
- | 3850 | ret |
|
- | 3851 | .disk_full: |
|
- | 3852 | ; correct number of bytes to write |
|
- | 3853 | mov ecx, [edi+28] |
|
- | 3854 | cmp ecx, ebx |
|
- | 3855 | ja .length_ok |
|
- | 3856 | .ret: |
|
- | 3857 | call update_disk |
|
- | 3858 | cmp [hd_error], 0 |
|
- | 3859 | jz @f |
|
- | 3860 | mov byte [esp+4], 11 |
|
- | 3861 | @@: |
|
- | 3862 | pop eax |
|
- | 3863 | pop eax |
|
- | 3864 | mov [esp+4+28], eax ; eax=return value |
|
- | 3865 | pop eax |
|
- | 3866 | sub edx, [esp+20] |
|
- | 3867 | mov [esp+16], edx ; ebx=number of written bytes |
|
- | 3868 | popad |
|
- | 3869 | ret |
|
- | 3870 | .length_ok: |
|
- | 3871 | mov esi, [edi+28] |
|
- | 3872 | mov eax, [edi+20-2] |
|
- | 3873 | mov ax, [edi+26] |
|
- | 3874 | mov edi, eax ; edi=current cluster |
|
- | 3875 | xor ebp, ebp ; ebp=current sector in cluster |
|
- | 3876 | ; save directory |
|
- | 3877 | mov eax, [esp+8] |
|
- | 3878 | push ebx |
|
- | 3879 | mov ebx, buffer |
|
- | 3880 | call hd_write |
|
- | 3881 | pop ebx |
|
- | 3882 | cmp [hd_error], 0 |
|
- | 3883 | jz @f |
|
- | 3884 | .device_err: |
|
- | 3885 | mov byte [esp+4], 11 |
|
- | 3886 | jmp .ret |
|
- | 3887 | @@: |
|
- | 3888 | ||
- | 3889 | ; now ebx=start pos, ecx=end pos, both lie inside file |
|
- | 3890 | sub ecx, ebx |
|
- | 3891 | jz .ret |
|
- | 3892 | .write_loop: |
|
- | 3893 | ; get length of data in current sector |
|
- | 3894 | push ecx |
|
- | 3895 | sub ebx, 0x200 |
|
- | 3896 | jb .hasdata |
|
- | 3897 | neg ebx |
|
- | 3898 | xor ecx, ecx |
|
- | 3899 | jmp @f |
|
- | 3900 | .hasdata: |
|
- | 3901 | neg ebx |
|
- | 3902 | cmp ecx, ebx |
|
- | 3903 | jbe @f |
|
- | 3904 | mov ecx, ebx |
|
- | 3905 | @@: |
|
- | 3906 | ; get current sector number |
|
- | 3907 | mov eax, edi |
|
- | 3908 | dec eax |
|
- | 3909 | dec eax |
|
- | 3910 | imul eax, [SECTORS_PER_CLUSTER] |
|
- | 3911 | add eax, [DATA_START] |
|
- | 3912 | add eax, ebp |
|
- | 3913 | ; load sector if needed |
|
- | 3914 | cmp dword [esp+4], 0 ; we don't need to read uninitialized data |
|
- | 3915 | jz .noread |
|
- | 3916 | cmp ecx, 0x200 ; we don't need to read sector if it is fully rewritten |
|
- | 3917 | jz .noread |
|
- | 3918 | cmp ecx, esi ; (same for the last sector) |
|
- | 3919 | jz .noread |
|
- | 3920 | push ebx |
|
- | 3921 | mov ebx, buffer |
|
- | 3922 | call hd_read |
|
- | 3923 | pop ebx |
|
- | 3924 | cmp [hd_error], 0 |
|
- | 3925 | jz @f |
|
- | 3926 | .device_err2: |
|
- | 3927 | pop ecx |
|
- | 3928 | jmp .device_err |
|
- | 3929 | @@: |
|
- | 3930 | .noread: |
|
- | 3931 | ; zero uninitialized data if file was extended (because hd_extend_file does not this) |
|
- | 3932 | push eax ecx edi |
|
- | 3933 | xor eax, eax |
|
- | 3934 | mov ecx, 0x200 |
|
- | 3935 | sub ecx, [esp+4+12] |
|
- | 3936 | jbe @f |
|
- | 3937 | mov edi, buffer |
|
- | 3938 | add edi, [esp+4+12] |
|
- | 3939 | rep stosb |
|
- | 3940 | @@: |
|
- | 3941 | ; zero uninitialized data in the last sector |
|
- | 3942 | mov ecx, 0x200 |
|
- | 3943 | sub ecx, esi |
|
- | 3944 | jbe @f |
|
- | 3945 | mov edi, buffer |
|
- | 3946 | add edi, esi |
|
- | 3947 | rep stosb |
|
- | 3948 | @@: |
|
- | 3949 | pop edi ecx eax |
|
- | 3950 | ; copy new data |
|
- | 3951 | push eax |
|
- | 3952 | mov eax, edx |
|
- | 3953 | neg ebx |
|
- | 3954 | jecxz @f |
|
- | 3955 | add ebx, buffer+0x200 |
|
- | 3956 | call memmove |
|
- | 3957 | xor ebx, ebx |
|
- | 3958 | @@: |
|
- | 3959 | pop eax |
|
- | 3960 | ; save sector |
|
- | 3961 | push ebx |
|
- | 3962 | mov ebx, buffer |
|
- | 3963 | call hd_write |
|
- | 3964 | pop ebx |
|
- | 3965 | cmp [hd_error], 0 |
|
- | 3966 | jnz .device_err2 |
|
- | 3967 | add edx, ecx |
|
- | 3968 | sub [esp], ecx |
|
- | 3969 | pop ecx |
|
- | 3970 | jz .ret |
|
- | 3971 | ; next sector |
|
- | 3972 | inc ebp |
|
- | 3973 | cmp ebp, [SECTORS_PER_CLUSTER] |
|
- | 3974 | jb @f |
|
- | 3975 | xor ebp, ebp |
|
- | 3976 | mov eax, edi |
|
- | 3977 | call get_FAT |
|
- | 3978 | mov edi, eax |
|
- | 3979 | cmp [hd_error], 0 |
|
- | 3980 | jnz .device_err |
|
- | 3981 | @@: |
|
- | 3982 | sub esi, 0x200 |
|
- | 3983 | jae @f |
|
- | 3984 | xor esi, esi |
|
- | 3985 | @@: |
|
- | 3986 | sub dword [esp], 0x200 |
|
- | 3987 | jae @f |
|
- | 3988 | and dword [esp], 0 |
|
- | 3989 | @@: jmp .write_loop |
|
- | 3990 | ||
- | 3991 | hd_extend_file.zero_size: |
|
- | 3992 | xor eax, eax |
|
- | 3993 | jmp hd_extend_file.start_extend |
|
- | 3994 | ||
- | 3995 | ; extends file on hd to given size (new data area is undefined) |
|
- | 3996 | ; in: edi->direntry, ecx=new size |
|
- | 3997 | ; out: CF=0 => OK, eax destroyed |
|
- | 3998 | ; CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL or 11) |
|
- | 3999 | hd_extend_file: |
|
- | 4000 | push ebp |
|
- | 4001 | mov ebp, [SECTORS_PER_CLUSTER] |
|
- | 4002 | imul ebp, [BYTES_PER_SECTOR] |
|
- | 4003 | push ecx |
|
- | 4004 | ; find the last cluster of file |
|
- | 4005 | mov eax, [edi+20-2] |
|
- | 4006 | mov ax, [edi+26] |
|
- | 4007 | mov ecx, [edi+28] |
|
- | 4008 | jecxz .zero_size |
|
- | 4009 | .last_loop: |
|
- | 4010 | sub ecx, ebp |
|
- | 4011 | jbe .last_found |
|
- | 4012 | call get_FAT |
|
- | 4013 | cmp [hd_error], 0 |
|
- | 4014 | jz @f |
|
- | 4015 | .device_err: |
|
- | 4016 | pop ecx |
|
- | 4017 | .device_err2: |
|
- | 4018 | pop ebp |
|
- | 4019 | push 11 |
|
- | 4020 | .ret_err: |
|
- | 4021 | pop eax |
|
- | 4022 | stc |
|
- | 4023 | ret |
|
- | 4024 | @@: |
|
- | 4025 | cmp eax, 2 |
|
- | 4026 | jb .fat_err |
|
- | 4027 | cmp eax, [fatRESERVED] |
|
- | 4028 | jb .last_loop |
|
- | 4029 | .fat_err: |
|
- | 4030 | pop ecx ebp |
|
- | 4031 | push ERROR_FAT_TABLE |
|
- | 4032 | jmp .ret_err |
|
- | 4033 | .last_found: |
|
- | 4034 | push eax |
|
- | 4035 | call get_FAT |
|
- | 4036 | cmp [hd_error], 0 |
|
- | 4037 | jz @f |
|
- | 4038 | pop eax |
|
- | 4039 | jmp .device_err |
|
- | 4040 | @@: |
|
- | 4041 | cmp eax, [fatRESERVED] |
|
- | 4042 | pop eax |
|
- | 4043 | jb .fat_err |
|
- | 4044 | ; set length to full number of clusters |
|
- | 4045 | sub [edi+28], ecx |
|
- | 4046 | .start_extend: |
|
- | 4047 | pop ecx |
|
- | 4048 | ; now do extend |
|
- | 4049 | push edx |
|
- | 4050 | mov edx, 2 ; start scan from cluster 2 |
|
- | 4051 | .extend_loop: |
|
- | 4052 | cmp [edi+28], ecx |
|
- | 4053 | jae .extend_done |
|
- | 4054 | ; add new cluster |
|
- | 4055 | push eax |
|
- | 4056 | mov eax, edx |
|
- | 4057 | call get_free_FAT |
|
- | 4058 | jc .disk_full |
|
- | 4059 | mov edx, [fatEND] |
|
- | 4060 | call set_FAT |
|
- | 4061 | mov edx, eax |
|
- | 4062 | pop eax |
|
- | 4063 | test eax, eax |
|
- | 4064 | jz .first_cluster |
|
- | 4065 | push edx |
|
- | 4066 | call set_FAT |
|
- | 4067 | pop edx |
|
- | 4068 | jmp @f |
|
- | 4069 | .first_cluster: |
|
- | 4070 | ror edx, 16 |
|
- | 4071 | mov [edi+20], dx |
|
- | 4072 | ror edx, 16 |
|
- | 4073 | mov [edi+26], dx |
|
- | 4074 | @@: |
|
- | 4075 | mov eax, edx |
|
- | 4076 | cmp [hd_error], 0 |
|
- | 4077 | jnz .device_err3 |
|
- | 4078 | add [edi+28], ebp |
|
- | 4079 | jmp .extend_loop |
|
- | 4080 | .extend_done: |
|
- | 4081 | mov [edi+28], ecx |
|
- | 4082 | pop edx ebp |
|
- | 4083 | clc |
|
- | 4084 | ret |
|
- | 4085 | .device_err3: |
|
- | 4086 | pop edx |
|
- | 4087 | jmp .device_err2 |
|
- | 4088 | .disk_full: |
|
- | 4089 | pop eax edx ebp |
|
- | 4090 | push ERROR_DISK_FULL |
|
- | 4091 | pop eax |
|
- | 4092 | cmp [hd_error], 0 |
|
- | 4093 | jz @f |
|
- | 4094 | mov al, 11 |
|
- | 4095 | @@: stc |
|
- | 4096 | ret |
|
3785 | 4097 | ||
3786 | fs_HdGetFileInfo: |
4098 | fs_HdGetFileInfo: |
3787 | cmp [fat_type], 0 |
4099 | cmp [fat_type], 0 |
3788 | jnz @f |
4100 | jnz @f |
3789 | mov eax, ERROR_UNKNOWN_FS |
4101 | mov eax, ERROR_UNKNOWN_FS |