git-svn-id: svn://kolibrios.org@6781 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2016-12-04 10:56:24 +00:00
parent 9a564b1fbf
commit d3eb673c05

View File

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