Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 86 → Rev 88

/kernel/trunk/fs/fat32.inc
2208,184 → 2208,6
ret
 
 
get_filesize:
;-----------------------------------------------------------
; input : eax = file name
; edx = path
; edi = if 0 - read rootdir else normal dir/file size
; output : eax = 0 - ok
; 3 - unknown FS
; 5 - file not found
; 10 - access denied
; ebx = file size
;-----------------------------------------------------------
cmp [fat_type],0
jnz get_filesize_fat_ok
xor ebx,ebx
mov eax,ERROR_UNKNOWN_FS
ret
 
get_filesize_fat_ok:
; call reserve_hd1
 
pushad
xor eax,eax
test edi,edi ; is read rootdir?
je get_filesize_dirsize ; yes
 
get_filesize_no_root:
mov ebx,edx
call get_cluster_of_a_path
jc get_filesize_not_found
 
mov ebx,PUSHAD_EAX ; file name
call analyze_directory
jc get_filesize_not_found
 
mov eax,[ebx+28] ; file size
test byte [ebx+11],0x10 ; is it directory?
jz get_filesize_set_size ; no
 
mov eax,[ebx+20-2] ; FAT entry
mov ax,[ebx+26]
and eax,[fatMASK]
 
get_filesize_dirsize:
call get_dir_size
cmp [hd_error],0
jne get_filesize_access_denied
 
get_filesize_set_size:
mov PUSHAD_EBX,eax
popad
mov [hd1_status],0
xor eax,eax
ret
 
get_filesize_not_found:
cmp [hd_error],0
jne get_filesize_access_denied
popad
mov [hd1_status],0
xor ebx,ebx
mov eax,ERROR_FILE_NOT_FOUND
ret
 
get_filesize_access_denied:
popad
mov [hd1_status],0
xor ebx,ebx
mov eax,ERROR_ACCESS_DENIED
ret
 
get_fileattr:
;-----------------------------------------------------------
; input : eax = file name
; edx = path
; output : eax = 0 - ok
; 3 - unknown FS
; 5 - file not found
; 10 - access denied
; ebx = file attribute
;-----------------------------------------------------------
cmp [fat_type],0
jnz get_fileattr_fat_ok
xor ebx,ebx
mov eax,ERROR_UNKNOWN_FS
ret
 
get_fileattr_fat_ok:
; call reserve_hd1
 
pushad
mov ebx,edx
call get_cluster_of_a_path
jc get_fileattr_not_found
 
mov ebx,PUSHAD_EAX ; file name
call analyze_directory
jc get_fileattr_not_found
 
movzx eax,byte [ebx+11] ; file attribute
mov PUSHAD_EBX,eax
popad
mov [hd1_status],0
xor eax,eax
ret
 
get_fileattr_not_found:
cmp [hd_error],0
jne get_fileattr_access_denied
popad
mov [hd1_status],0
xor ebx,ebx
mov eax,ERROR_FILE_NOT_FOUND
ret
 
get_fileattr_access_denied:
popad
mov [hd1_status],0
xor ebx,ebx
mov eax,ERROR_ACCESS_DENIED
ret
 
get_filedate:
;-----------------------------------------------------------
; input : eax = file name
; edx = path
; output : eax = 0 - ok
; 3 - unknown FS
; 5 - file not found
; 10 - access denied
; ebx = file date/time
; bits 31..25 = year-1980
; bits 24..21 = month
; bits 20..16 = day
; bits 15..11 = hour
; bits 10..5 = minute
; bits 4..0 = second/2
;-----------------------------------------------------------
cmp [fat_type],0
jnz get_filedate_fat_ok
xor ebx,ebx
mov eax,ERROR_UNKNOWN_FS
ret
 
get_filedate_fat_ok:
; call reserve_hd1
 
pushad
mov ebx,edx
call get_cluster_of_a_path
jc get_filedate_not_found
 
mov ebx,PUSHAD_EAX ; file name
call analyze_directory
jc get_filedate_not_found
 
mov eax,[ebx+22] ; file date/time
mov PUSHAD_EBX,eax
popad
mov [hd1_status],0
xor eax,eax
ret
 
get_filedate_not_found:
cmp [hd_error],0
jne get_filedate_access_denied
popad
mov [hd1_status],0
xor ebx,ebx
mov eax,ERROR_FILE_NOT_FOUND
ret
 
get_filedate_access_denied:
popad
mov [hd1_status],0
xor ebx,ebx
mov eax,ERROR_ACCESS_DENIED
ret
 
get_hd_info:
;-----------------------------------------------------------
; output : eax = 0 - ok
2953,7 → 2775,8
test byte [edi+11], 10h
jz .notfound
and dword [esp+12], 0
movzx eax, word [edi+26] ; cluster
mov eax, [edi+20-2]
mov ax, [edi+26] ; cluster
.fat32:
mov [esp+8], eax
mov dword [esp+4], fat_notroot_first