Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6420 → Rev 6419

/kernel/trunk/fs/ntfs.inc
1875,31 → 1875,6
jmp .forEXT
 
;----------------------------------------------------------------
ntfs_GetFileInfo:
cmp byte [esi], 0
jnz @f
movi eax, ERROR_UNSUPPORTED_FS
ret
@@:
call ntfs_lock
stdcall ntfs_find_lfn, [esp+4]
jnc .found
test eax, eax
jz ntfsFail
jmp ntfsNotFound
 
.found:
push esi edi
mov esi, eax
mov edi, [ebx+16]
xor eax, eax
call ntfs_direntry_to_bdfe
pop edi esi
call ntfs_unlock
xor eax, eax
ret
 
;----------------------------------------------------------------
ntfs_CreateFolder:
mov [ebp+NTFS.bFolder], 1
jmp @f
1922,8 → 1897,6
jc ntfsDenied
cmp [ebp+NTFS.bFolder], 1
jz .folder
test byte [eax+fileFlags], 1
jnz ntfsDenied
cmp [ebp+NTFS.fragmentCount], 1
jnz ntfsUnsupported ; record fragmented
; edit directory node
1940,19 → 1913,9
add eax, ecx
add eax, esi
@@:
mov edi, eax
mov eax, [ebx+12]
mov [edi+fileRealSize], eax
mov dword [edi+fileRealSize+4], 0
push ebx eax
call ntfsGetTime
mov [edi+fileModified], eax
mov [edi+fileModified+4], edx
mov [edi+recordModified], eax
mov [edi+recordModified+4], edx
mov [edi+fileAccessed], eax
mov [edi+fileAccessed+4], edx
pop edx ebx
mov edx, [ebx+12]
mov [eax+fileRealSize], edx
mov dword [eax+fileRealSize+4], 0
mov eax, [ebp+NTFS.LastRead]
mov [ebp+NTFS.nodeLastRead], eax
mov [ebp+NTFS.cur_attr], 0x80
1960,20 → 1923,11
mov [ebp+NTFS.cur_size], 0
call ntfs_read_attr
jc ntfsFail
mov esi, edi
mov edi, [ebp+NTFS.frs_buffer]
cmp word [edi+baseRecordReuse], 0
jnz ntfsUnsupported ; auxiliary record
mov al, [edi+attributeOffset]
add edi, eax
mov al, [edi+attributeOffset]
add edi, eax
mov ecx, 6
add esi, fileModified
add edi, 8
rep movsd
mov ecx, [ebp+NTFS.frs_buffer]
mov eax, edx
xor edx, edx
cmp word [ecx+baseRecordReuse], 0
jnz ntfsUnsupported ; auxiliary record
mov ecx, [ebp+NTFS.attr_offs]
cmp word [ecx+attributeFlags], 0
jnz ntfsUnsupported
2472,15 → 2426,6
rep stosd
cld
add edi, 4
call ntfsGetTime
mov [edi+fileCreated], eax
mov [edi+fileCreated+4], edx
mov [edi+fileModified], eax
mov [edi+fileModified+4], edx
mov [edi+recordModified], eax
mov [edi+recordModified+4], edx
mov [edi+fileAccessed], eax
mov [edi+fileAccessed+4], edx
pop ecx
pop esi
mov [edi+indexAllocatedSize], cx ; fill index with data
2695,12 → 2640,7
mov byte [edi+sizeWithHeader], 48h
mov byte [edi+sizeWithoutHeader], 30h
mov byte [edi+attributeOffset], 18h
mov cl, 8
add esi, fileCreated
add edi, 18h
rep movsd
add edi, 16
mov esi, [ebp+NTFS.indexPointer]
add edi, 48h
; $FileName
mov byte [edi+attributeType], 30h
mov byte [edi+attributeID], 1
3544,8 → 3484,8
jc ntfsNotFound
cmp [ebp+NTFS.cur_iRecord], 16
jc ntfsDenied
test dword [eax+fileFlags], 10000001h
jnz ntfsDenied
bt dword [eax+fileFlags], 28
jc ntfsDenied
cmp [ebp+NTFS.fragmentCount], 1
jnz ntfsUnsupported ; record fragmented
; edit directory node
3562,22 → 3502,12
add eax, ecx
add eax, esi
@@:
mov edi, eax
mov eax, [ebx+4]
mov ecx, [ebx+4]
mov edx, [ebx+8]
add eax, [ebx+12]
add ecx, [ebx+12]
adc edx, 0
mov [edi+fileRealSize], eax
mov [edi+fileRealSize+4], edx
push edx eax ebx
call ntfsGetTime
mov [edi+fileModified], eax
mov [edi+fileModified+4], edx
mov [edi+recordModified], eax
mov [edi+recordModified+4], edx
mov [edi+fileAccessed], eax
mov [edi+fileAccessed+4], edx
pop ebx ecx edx
mov [eax+fileRealSize], ecx
mov [eax+fileRealSize+4], edx
mov eax, [ebp+NTFS.LastRead]
mov [ebp+NTFS.nodeLastRead], eax
mov [ebp+NTFS.cur_attr], 0x80
3585,19 → 3515,10
mov [ebp+NTFS.cur_size], 0
call ntfs_read_attr
jc ntfsFail
mov esi, edi
mov edi, [ebp+NTFS.frs_buffer]
cmp word [edi+baseRecordReuse], 0
mov eax, ecx
mov ecx, [ebp+NTFS.frs_buffer]
cmp word [ecx+baseRecordReuse], 0
jnz ntfsUnsupported ; auxiliary record
mov al, [edi+attributeOffset]
add edi, eax
mov al, [edi+attributeOffset]
add edi, eax
mov eax, ecx
mov ecx, 6
add esi, fileModified
add edi, 8
rep movsd
mov ecx, [ebp+NTFS.attr_offs]
cmp word [ecx+attributeFlags], 0
jnz ntfsUnsupported
3724,8 → 3645,6
jc ntfsNotFound
cmp [ebp+NTFS.cur_iRecord], 16
jc ntfsDenied
test byte [eax+fileFlags], 1
jnz ntfsDenied
cmp [ebp+NTFS.fragmentCount], 1
jnz ntfsUnsupported ; record fragmented
mov ebx, [eax+directoryRecordReference]
3767,7 → 3686,7
jnz ntfsUnsupported ; auxiliary record
cmp word [esi+reuseCounter], bx
jnz .backToIndex ; broken index
test byte [esi+recordFlags], 1
cmp byte [esi+recordFlags], 0
jz .writeBitmapMFT ; record deleted
cmp byte [esi+hardLinkCounter], 3
jnc ntfsUnsupported
4042,8 → 3961,8
jc ntfsNotFound
cmp [ebp+NTFS.cur_iRecord], 16
jc ntfsDenied
test dword [eax+fileFlags], 10000001h
jnz ntfsDenied
bt dword [eax+fileFlags], 28
jc ntfsDenied
cmp [ebp+NTFS.fragmentCount], 1
jnz ntfsUnsupported ; record fragmented
; edit directory node
4060,20 → 3979,10
add eax, ecx
add eax, esi
@@:
mov edi, eax
mov eax, [ebx+4]
mov ecx, [ebx+4]
mov edx, [ebx+8]
mov [edi+fileRealSize], eax
mov [edi+fileRealSize+4], edx
push edx eax ebx
call ntfsGetTime
mov [edi+fileModified], eax
mov [edi+fileModified+4], edx
mov [edi+recordModified], eax
mov [edi+recordModified+4], edx
mov [edi+fileAccessed], eax
mov [edi+fileAccessed+4], edx
pop ebx ecx edx
mov [eax+fileRealSize], ecx
mov [eax+fileRealSize+4], edx
mov eax, [ebp+NTFS.LastRead]
mov [ebp+NTFS.nodeLastRead], eax
mov [ebp+NTFS.cur_attr], 0x80
4081,19 → 3990,10
mov [ebp+NTFS.cur_size], 0
call ntfs_read_attr
jc ntfsFail
mov esi, edi
mov edi, [ebp+NTFS.frs_buffer]
cmp word [edi+baseRecordReuse], 0
mov eax, ecx
mov ecx, [ebp+NTFS.frs_buffer]
cmp word [ecx+baseRecordReuse], 0
jnz ntfsUnsupported ; auxiliary record
mov al, [edi+attributeOffset]
add edi, eax
mov al, [edi+attributeOffset]
add edi, eax
mov eax, ecx
mov ecx, 6
add esi, fileModified
add edi, 8
rep movsd
mov ecx, [ebp+NTFS.attr_offs]
cmp word [ecx+attributeFlags], 0
jnz ntfsUnsupported
4149,94 → 4049,13
call ntfsSpaceClean
jmp ntfsDone
 
ntfsReadCMOS:
out 70h, al
in al, 71h
xor ah, ah
shl ax, 4
shr al, 4
aad
;----------------------------------------------------------------
ntfs_SetFileInfo:
movi eax, ERROR_UNSUPPORTED_FS
ret
 
ntfsGetTime:
mov al, 7
call ntfsReadCMOS
ror eax, 8
mov al, 8
call ntfsReadCMOS
ror eax, 8
mov al, 9
call ntfsReadCMOS
add eax, 2000
ror eax, 16
push eax
xor eax, eax
call ntfsReadCMOS
ror eax, 8
mov al, 2
call ntfsReadCMOS
ror eax, 8
mov al, 4
call ntfsReadCMOS
ror eax, 16
push eax
mov esi, esp
add esp, 8
ntfsCalculateTime:
; in: esi -> data block
; out: edx:eax = time
movzx eax, word [esi+6]
sub eax, 2001
jnc @f
xor eax, eax
@@:
mov edx, months
mov ebx, eax
inc eax
test eax, 3
jnz @f
add edx, 12
@@:
movzx eax, byte [esi+5]
dec eax
xor ecx, ecx
@@:
dec eax
js @f
add cl, [edx+eax]
adc ch, 0
jmp @b
@@:
mov eax, ebx
mov edx, 365
mul edx
shr ebx, 2
add eax, ebx
add eax, ecx
mov bl, [esi+4]
add eax, ebx
add eax, 400*365+100-4
mov dl, 24
mul edx
mov bl, [esi+2]
add eax, ebx
mov ecx, 60
mul ecx
mov bl, [esi+1]
add eax, ebx
mul ecx
mov bl, [esi]
add ebx, eax
mov eax, edx
mov ecx, 10000000
mul ecx
xchg eax, ebx
mul ecx
add edx, ebx
ret
 
;----------------------------------------------------------------
ntfs_SetFileInfo:
ntfs_GetFileInfo:
cmp byte [esi], 0
jnz @f
movi eax, ERROR_UNSUPPORTED_FS
4244,50 → 4063,21
@@:
call ntfs_lock
stdcall ntfs_find_lfn, [esp+4]
jnc @f
jnc .found
test eax, eax
jz ntfsFail
jmp ntfsNotFound
.found:
push esi edi
mov esi, eax
mov edi, [ebx+16]
xor eax, eax
call ntfs_direntry_to_bdfe
pop edi esi
call ntfs_unlock
xor eax, eax
ret
 
@@:
cmp [ebp+NTFS.fragmentCount], 1
jnz ntfsUnsupported ; record fragmented
mov esi, [ebp+NTFS.cur_index_buf]
cmp dword [esi], 'INDX'
jz @f
sub eax, esi
mov esi, [ebp+NTFS.indexRoot]
movzx edx, byte [esi+attributeOffset]
add eax, esi
add eax, edx
@@:
mov esi, [ebx+16]
mov edi, eax
mov eax, [esi]
and eax, 27h
and byte [edi+fileFlags], -28h
or [edi+fileFlags], al
add esi, 8
call ntfsCalculateTime
mov [edi+fileCreated], eax
mov [edi+fileCreated+4], edx
add esi, 8
call ntfsCalculateTime
mov [edi+fileAccessed], eax
mov [edi+fileAccessed+4], edx
add esi, 8
call ntfsCalculateTime
mov [edi+fileModified], eax
mov [edi+fileModified+4], edx
mov ebx, [ebp+NTFS.cur_index_buf]
cmp dword [ebx], 'INDX'
jz @f
mov ebx, [ebp+NTFS.frs_buffer]
@@:
mov edx, [ebp+NTFS.LastRead]
call writeRecord
jmp ntfsDone
 
ntfsUnsupported:
push ERROR_UNSUPPORTED_FS
jmp ntfsOut