Rev 74 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 74 | Rev 75 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | ;; FAT16/32 functions for MenuetOS ;; |
5 | ;; FAT16/32 functions for MenuetOS ;; |
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 | ;; 04.05.2006 LFN read folder - diamond ;; |
|
10 | ;; 29.04.2006 Elimination of hangup after the ;; |
11 | ;; 29.04.2006 Elimination of hangup after the ;; |
11 | ;; expiration hd_wait_timeout - Mario79 ;; |
12 | ;; expiration hd_wait_timeout - Mario79 ;; |
12 | ;; 23.04.2006 LFN read - diamond ;; |
13 | ;; 23.04.2006 LFN read file - diamond ;; |
13 | ;; 28.01.2006 find all Fat16/32 partition in all input point ;; |
14 | ;; 28.01.2006 find all Fat16/32 partition in all input point ;; |
14 | ;; to MBR, see file part_set.inc - Mario79 ;; |
15 | ;; to MBR, see file part_set.inc - Mario79 ;; |
15 | ;; 15.01.2005 get file size/attr/date, file_append - ATV ;; |
16 | ;; 15.01.2005 get file size/attr/date, file_append - ATV ;; |
16 | ;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;; |
17 | ;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;; |
17 | ;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;; |
18 | ;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;; |
Line 2934... | Line 2935... | ||
2934 | ; out: CF=1 - file not found |
2935 | ; out: CF=1 - file not found |
2935 | ; else CF=0 and edi->direntry |
2936 | ; else CF=0 and edi->direntry |
2936 | pusha |
2937 | pusha |
2937 | sub esp, 262*2 ; allocate space for LFN |
2938 | sub esp, 262*2 ; allocate space for LFN |
2938 | mov ebp, esp |
2939 | mov ebp, esp |
- | 2940 | push 0 ; for fat_get_name: read ASCII name |
|
2939 | mov eax, [ROOT_CLUSTER] ; start from root |
2941 | mov eax, [ROOT_CLUSTER] ; start from root |
2940 | .mainloop: |
2942 | .mainloop: |
2941 | .new_cluster: |
2943 | .new_cluster: |
2942 | mov [cluster_tmp], eax |
2944 | mov [cluster_tmp], eax |
2943 | mov [fat16_root], 0 |
2945 | mov [fat16_root], 0 |
Line 2988... | Line 2990... | ||
2988 | cmp eax, 2 |
2990 | cmp eax, 2 |
2989 | jb .notfound |
2991 | jb .notfound |
2990 | cmp eax, [fatRESERVED] |
2992 | cmp eax, [fatRESERVED] |
2991 | jb .new_cluster |
2993 | jb .new_cluster |
2992 | .notfound: |
2994 | .notfound: |
2993 | add esp, 262*2 |
2995 | add esp, 262*2+4 |
2994 | popa |
2996 | popa |
2995 | stc |
2997 | stc |
2996 | ret |
2998 | ret |
2997 | .found: |
2999 | .found: |
2998 | pop eax |
3000 | pop eax |
Line 3034... | Line 3036... | ||
3034 | jz .notfound |
3036 | jz .notfound |
3035 | mov eax, [edi+20-2] |
3037 | mov eax, [edi+20-2] |
3036 | mov ax, [edi+26] |
3038 | mov ax, [edi+26] |
3037 | jmp .mainloop |
3039 | jmp .mainloop |
3038 | .done: |
3040 | .done: |
3039 | add esp, 262*2+4 ; CF=0 |
3041 | add esp, 262*2+4+4 ; CF=0 |
3040 | push edi |
3042 | push edi |
3041 | popad |
3043 | popad |
3042 | ret |
3044 | ret |
Line 3043... | Line 3045... | ||
3043 | 3045 | ||
Line 3195... | Line 3197... | ||
3195 | xor eax, eax |
3197 | xor eax, eax |
3196 | ret |
3198 | ret |
3197 | .eof: |
3199 | .eof: |
3198 | pop ebx edx ecx ebx |
3200 | pop ebx edx ecx ebx |
3199 | jmp .reteof |
3201 | jmp .reteof |
- | 3202 | ||
- | 3203 | ;---------------------------------------------------------------- |
|
- | 3204 | ; |
|
- | 3205 | ; fs_HdReadFolder - LFN variant for reading hard disk folder |
|
- | 3206 | ; |
|
- | 3207 | ; esi points to filename |
|
- | 3208 | ; ebx pointer to 32-bit number = first wanted block, 0+ |
|
- | 3209 | ; ecx number of blocks to read, 0+ |
|
- | 3210 | ; edx mem location to return data |
|
- | 3211 | ; |
|
- | 3212 | ; ret ebx = size or 0xffffffff folder not found |
|
- | 3213 | ; eax = 0 ok read or other = errormsg |
|
- | 3214 | ; |
|
- | 3215 | ;-------------------------------------------------------------- |
|
- | 3216 | fs_HdReadFolder: |
|
- | 3217 | mov ebx, [ebx] |
|
- | 3218 | mov eax, [ROOT_CLUSTER] |
|
- | 3219 | push edi |
|
- | 3220 | cmp byte [esi], 0 |
|
- | 3221 | jz .doit |
|
- | 3222 | call hd_find_lfn |
|
- | 3223 | jnc .found |
|
- | 3224 | pop edi |
|
- | 3225 | or ebx, -1 |
|
- | 3226 | mov eax, ERROR_FILE_NOT_FOUND |
|
- | 3227 | ret |
|
- | 3228 | .found: |
|
- | 3229 | test byte [edi+11], 0x10 ; do not allow read files |
|
- | 3230 | jnz .found_dir |
|
- | 3231 | pop edi |
|
- | 3232 | or ebx, -1 |
|
- | 3233 | mov eax, ERROR_ACCESS_DENIED |
|
- | 3234 | ret |
|
- | 3235 | .found_dir: |
|
- | 3236 | mov eax, [edi+20-2] |
|
- | 3237 | mov ax, [edi+26] ; eax=cluster |
|
- | 3238 | .doit: |
|
- | 3239 | push esi ecx |
|
- | 3240 | push ebp |
|
- | 3241 | sub esp, 262*2 ; reserve space for LFN |
|
- | 3242 | mov ebp, esp |
|
- | 3243 | push 1 ; for fat_get_name: read UNICODE name |
|
- | 3244 | ; init header |
|
- | 3245 | push eax ecx |
|
- | 3246 | mov edi, edx |
|
- | 3247 | mov ecx, 32/4 |
|
- | 3248 | xor eax, eax |
|
- | 3249 | rep stosd |
|
- | 3250 | pop ecx eax |
|
- | 3251 | mov byte [edx], 1 ; version |
|
- | 3252 | mov esi, edi ; esi points to BDFE |
|
- | 3253 | .new_cluster: |
|
- | 3254 | mov [cluster_tmp], eax |
|
- | 3255 | test eax, eax |
|
- | 3256 | jnz @f |
|
- | 3257 | cmp [fat_type], 32 |
|
- | 3258 | jz .notfound |
|
- | 3259 | mov eax, [ROOT_START] |
|
- | 3260 | push [ROOT_SECTORS] |
|
- | 3261 | push ebx |
|
- | 3262 | jmp .new_sector |
|
- | 3263 | @@: |
|
- | 3264 | dec eax |
|
- | 3265 | dec eax |
|
- | 3266 | imul eax, [SECTORS_PER_CLUSTER] |
|
- | 3267 | push [SECTORS_PER_CLUSTER] |
|
- | 3268 | add eax, [DATA_START] |
|
- | 3269 | push ebx |
|
- | 3270 | .new_sector: |
|
- | 3271 | mov ebx, buffer |
|
- | 3272 | mov edi, ebx |
|
- | 3273 | call hd_read |
|
- | 3274 | cmp [hd_error], 0 |
|
- | 3275 | jnz .notfound2 |
|
- | 3276 | add ebx, 512 |
|
- | 3277 | push eax |
|
- | 3278 | .l1: |
|
- | 3279 | call fat_get_name |
|
- | 3280 | jc .l2 |
|
- | 3281 | cmp byte [edi+11], 0xF |
|
- | 3282 | jnz .do_bdfe |
|
- | 3283 | add edi, 0x20 |
|
- | 3284 | cmp edi, ebx |
|
- | 3285 | jb .do_bdfe |
|
- | 3286 | pop eax |
|
- | 3287 | inc eax |
|
- | 3288 | dec dword [esp+4] |
|
- | 3289 | jnz @f |
|
- | 3290 | mov eax, [cluster_tmp] |
|
- | 3291 | test eax, eax |
|
- | 3292 | jz .done |
|
- | 3293 | call get_FAT |
|
- | 3294 | cmp [hd_error], 0 |
|
- | 3295 | jnz .notfound2 |
|
- | 3296 | cmp eax, 2 |
|
- | 3297 | jb .done |
|
- | 3298 | cmp eax, [fatRESERVED] |
|
- | 3299 | jae .done |
|
- | 3300 | push eax |
|
- | 3301 | mov eax, [SECTORS_PER_CLUSTER] |
|
- | 3302 | mov [esp+8], eax |
|
- | 3303 | pop eax |
|
- | 3304 | mov [cluster_tmp], eax |
|
- | 3305 | dec eax |
|
- | 3306 | dec eax |
|
- | 3307 | imul eax, [SECTORS_PER_CLUSTER] |
|
- | 3308 | add eax, [DATA_START] |
|
- | 3309 | @@: |
|
- | 3310 | mov ebx, buffer |
|
- | 3311 | mov edi, ebx |
|
- | 3312 | call hd_read |
|
- | 3313 | cmp [hd_error], 0 |
|
- | 3314 | jnz .notfound2 |
|
- | 3315 | add ebx, 512 |
|
- | 3316 | push eax |
|
- | 3317 | .do_bdfe: |
|
- | 3318 | inc dword [edx+8] ; new file found |
|
- | 3319 | dec dword [esp+4] |
|
- | 3320 | jns .l2 |
|
- | 3321 | dec ecx |
|
- | 3322 | js .l2 |
|
- | 3323 | inc dword [edx+4] ; new file block copied |
|
- | 3324 | call fat_entry_to_bdfe |
|
- | 3325 | .l2: |
|
- | 3326 | add edi, 0x20 |
|
- | 3327 | cmp edi, ebx |
|
- | 3328 | jb .l1 |
|
- | 3329 | pop eax |
|
- | 3330 | inc eax |
|
- | 3331 | dec dword [esp+4] |
|
- | 3332 | jnz .new_sector |
|
- | 3333 | mov eax, [cluster_tmp] |
|
- | 3334 | test eax, eax |
|
- | 3335 | jz .done |
|
- | 3336 | call get_FAT |
|
- | 3337 | cmp [hd_error], 0 |
|
- | 3338 | jnz .notfound2 |
|
- | 3339 | cmp eax, 2 |
|
- | 3340 | jb .done |
|
- | 3341 | cmp eax, [fatRESERVED] |
|
- | 3342 | jae .done |
|
- | 3343 | push eax |
|
- | 3344 | mov eax, [SECTORS_PER_CLUSTER] |
|
- | 3345 | mov [esp+8], eax |
|
- | 3346 | pop eax |
|
- | 3347 | pop ebx |
|
- | 3348 | add esp, 4 |
|
- | 3349 | jmp .new_cluster |
|
- | 3350 | .notfound2: |
|
- | 3351 | add esp, 8 |
|
- | 3352 | .notfound: |
|
- | 3353 | add esp, 262*2+4 |
|
- | 3354 | pop ebp ecx esi edi |
|
- | 3355 | mov eax, ERROR_FILE_NOT_FOUND |
|
- | 3356 | or ebx, -1 |
|
- | 3357 | ret |
|
- | 3358 | .done: |
|
- | 3359 | add esp, 262*2+4+8 |
|
- | 3360 | pop ebp |
|
- | 3361 | mov ebx, [edx+8] |
|
- | 3362 | xor eax, eax |
|
- | 3363 | dec ecx |
|
- | 3364 | js @f |
|
- | 3365 | mov al, ERROR_END_OF_FILE |
|
- | 3366 | @@: |
|
- | 3367 | pop ecx esi edi |
|
- | 3368 | ret |
|
- | 3369 | ||
3200 | ; \end{diamond}>>>> |
3370 | ; \end{diamond}>>>> |