Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6781 → Rev 6780

/kernel/trunk/fs/ntfs.inc
3192,18 → 3192,16
; out:
; [ebp+NTFS.fileDataStart] = allocated block starting cluster
; CF=1 -> disk full
push eax
mov ecx, [ebp+NTFS.BitmapBuffer]
add edi, ecx
add ecx, [ebp+NTFS.BitmapSize]
sub ecx, edi
ja @f
push eax
jnc @f
call bitmapBuffering
pop eax
shl ecx, 2
@@:
shr ecx, 2
push ecx
mov eax, [ebp+NTFS.fileDataSize]
shr eax, 5
jz .small
3256,56 → 3254,59
add esp, 8
jmp .start
 
.small: ; less than 32 clusters
mov eax, -1
repz scasd ; search for zero bits
test ecx, ecx
jnz @f
call bitmapBuffering
jmp .small
@@:
sub edi, 4
call bitmapBuffering
push ecx
.small: ; less than 32 clusters
pop ecx
or eax, -1
repz scasd
jecxz @b
push ecx
mov eax, [edi-4]
mov eax, [edi]
not eax
@@:
bsf ecx, eax ; first 0
jz .small
bsf ebx, eax ; first 0
jz .again
not eax
shr eax, cl
shl eax, cl
bsf edx, eax ; next 1
jz @f
sub edx, ecx
sub edx, ebx
cmp edx, [ebp+NTFS.fileDataSize]
jnc .got ; fits inside
bsf ecx, eax
bsf ebx, eax
not eax
shr eax, cl
shl eax, cl
jmp @b
 
@@: ; next dword
mov eax, [edi]
mov eax, [edi+4]
bsf edx, eax
jz .got ; empty
add edx, 32
sub edx, ecx
sub edx, ebx
cmp edx, [ebp+NTFS.fileDataSize]
jc .small
jnc .got ; share between dwords
.again:
add edi, 4
jmp .small
 
.got:
sub edi, 4
push ecx ; starting bit
push ebx ; starting bit
push edi ; starting dword
.done: ; mark space
pop edi ecx
mov ecx, [esp+4]
cmp ecx, 32
jc @f
xor ecx, ecx
add edi, 4
add dword [esp], 4
mov [esp+4], ecx
@@:
push ecx edi
or eax, -1
mov edi, [esp]
xor eax, eax
dec eax
shr eax, cl
shl eax, cl
neg ecx
3323,7 → 3324,8
push ecx
shr ecx, 5
add edi, 4
or eax, -1
xor eax, eax
dec eax
rep stosd
pop ecx
and ecx, 31
3360,6 → 3362,7
mov eax, edi
add eax, ebx
shr eax, 3
inc eax
cmp eax, [ebp+NTFS.BitmapSize]
jc @f
add eax, [ebp+NTFS.BitmapBuffer]
3444,18 → 3447,17
call fs_read64_app
test eax, eax
jnz .err
mov eax, [ebp+NTFS.BitmapSize]
add eax, 8000h
cmp [ebp+NTFS.BitmapTotalSize], eax
add [ebp+NTFS.BitmapSize], 8000h
mov eax, [ebp+NTFS.BitmapTotalSize]
cmp eax, [ebp+NTFS.BitmapSize]
jnc @f
mov eax, [ebp+NTFS.BitmapTotalSize]
mov [ebp+NTFS.BitmapSize], eax
@@:
mov [ebp+NTFS.BitmapSize], eax
pop ebx
mov ecx, [ebp+NTFS.BitmapBuffer]
add ecx, eax
add ecx, [ebp+NTFS.BitmapSize]
sub ecx, edi
jbe bitmapBuffering
jc bitmapBuffering
shr ecx, 2
ret