forked from KolibriOS/kolibrios
ext fs fixing
git-svn-id: svn://kolibrios.org@6856 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b08e3b7796
commit
d248870812
@ -1196,23 +1196,12 @@ extfsExtendFile:
|
|||||||
pop eax
|
pop eax
|
||||||
jmp .errFree
|
jmp .errFree
|
||||||
|
|
||||||
freeIndirectBlock:
|
freeBlockList:
|
||||||
; in: edi -> indirect block number, edx = starting block
|
; in: edi -> list of blocks, edx = amount of blocks
|
||||||
; out: edi = edi+4, eax=-1 -> done, eax=0 -> end
|
; out: ebx=0 -> end of list
|
||||||
pushd ecx 0 edi edx
|
|
||||||
mov eax, [edi]
|
|
||||||
test eax, eax
|
|
||||||
jz .ret
|
|
||||||
mov ebx, [ebp+EXTFS.mainBlockBuffer]
|
|
||||||
call extfsReadBlock
|
|
||||||
jc .ret
|
|
||||||
lea edi, [ebx+edx*4]
|
|
||||||
neg edx
|
|
||||||
add edx, [ebp+EXTFS.dwordsPerBlock]
|
|
||||||
.freeExtent:
|
|
||||||
mov ebx, [edi]
|
mov ebx, [edi]
|
||||||
test ebx, ebx
|
test ebx, ebx
|
||||||
jz .end
|
jz .ret
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
@@:
|
@@:
|
||||||
@ -1228,9 +1217,28 @@ freeIndirectBlock:
|
|||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call extfsExtentFree
|
call extfsExtentFree
|
||||||
test edx, edx
|
test edx, edx
|
||||||
jnz .freeExtent
|
jnz freeBlockList
|
||||||
dec dword[esp+8]
|
.ret:
|
||||||
.end:
|
ret
|
||||||
|
|
||||||
|
freeIndirectBlock:
|
||||||
|
; in: edi -> indirect block number, edx = starting block
|
||||||
|
; out: edi = edi+4, eax=0 -> end
|
||||||
|
pushd ecx 0 edi edx
|
||||||
|
mov eax, [edi]
|
||||||
|
test eax, eax
|
||||||
|
jz .ret
|
||||||
|
mov ebx, [ebp+EXTFS.mainBlockBuffer]
|
||||||
|
call extfsReadBlock
|
||||||
|
jc .ret
|
||||||
|
lea edi, [ebx+edx*4]
|
||||||
|
neg edx
|
||||||
|
add edx, [ebp+EXTFS.dwordsPerBlock]
|
||||||
|
call freeBlockList
|
||||||
|
test ebx, ebx
|
||||||
|
jz @f
|
||||||
|
inc dword[esp+8]
|
||||||
|
@@:
|
||||||
pop edx edi
|
pop edx edi
|
||||||
mov eax, [edi]
|
mov eax, [edi]
|
||||||
test edx, edx
|
test edx, edx
|
||||||
@ -1339,16 +1347,9 @@ extfsTruncateFile:
|
|||||||
lea edi, [esi+INODE.blockNumbers+edx*4]
|
lea edi, [esi+INODE.blockNumbers+edx*4]
|
||||||
neg edx
|
neg edx
|
||||||
add edx, 12
|
add edx, 12
|
||||||
xor ecx, ecx
|
call freeBlockList
|
||||||
inc ecx
|
test ebx, ebx
|
||||||
@@:
|
|
||||||
mov eax, [edi]
|
|
||||||
test eax, eax
|
|
||||||
jz .ret
|
jz .ret
|
||||||
call extfsExtentFree
|
|
||||||
stosd
|
|
||||||
dec edx
|
|
||||||
jnz @b
|
|
||||||
.indirectBlocks:
|
.indirectBlocks:
|
||||||
lea edi, [esi+INODE.addressBlock]
|
lea edi, [esi+INODE.addressBlock]
|
||||||
call freeIndirectBlock
|
call freeIndirectBlock
|
||||||
@ -1412,9 +1413,7 @@ linkInode:
|
|||||||
; dl = file type
|
; dl = file type
|
||||||
push esi edi ebx ecx eax edx
|
push esi edi ebx ecx eax edx
|
||||||
call strlen
|
call strlen
|
||||||
add ecx, 8 ; directory entry size
|
|
||||||
push esi ebx ecx
|
push esi ebx ecx
|
||||||
xor ecx, ecx
|
|
||||||
lea esi, [ebp+EXTFS.inodeBuffer]
|
lea esi, [ebp+EXTFS.inodeBuffer]
|
||||||
mov ebx, esi
|
mov ebx, esi
|
||||||
call readInode
|
call readInode
|
||||||
@ -1435,6 +1434,7 @@ linkInode:
|
|||||||
call extfsReadBlock
|
call extfsReadBlock
|
||||||
jc .error_block_read
|
jc .error_block_read
|
||||||
mov ecx, [esp+12]
|
mov ecx, [esp+12]
|
||||||
|
add ecx, 8 ; directory entry size
|
||||||
mov edi, [ebp+EXTFS.tempBlockBuffer]
|
mov edi, [ebp+EXTFS.tempBlockBuffer]
|
||||||
mov edx, edi
|
mov edx, edi
|
||||||
add edx, [ebp+EXTFS.bytesPerBlock]
|
add edx, [ebp+EXTFS.bytesPerBlock]
|
||||||
@ -1464,27 +1464,24 @@ linkInode:
|
|||||||
add edi, eax
|
add edi, eax
|
||||||
cmp edi, edx
|
cmp edi, edx
|
||||||
jb .searchSpace
|
jb .searchSpace
|
||||||
pop ecx ecx eax
|
pop ecx
|
||||||
|
@@:
|
||||||
|
pop ecx eax
|
||||||
inc ecx
|
inc ecx
|
||||||
jmp .searchBlock
|
jmp .searchBlock
|
||||||
|
|
||||||
.zeroLength:
|
.zeroLength:
|
||||||
mov [edi+DIRENTRY.entryLength], cx
|
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
sub eax, edi
|
sub eax, edi
|
||||||
|
mov [edi+DIRENTRY.entryLength], ax
|
||||||
cmp eax, ecx
|
cmp eax, ecx
|
||||||
jge .found
|
jge .found
|
||||||
mov [edi+DIRENTRY.inodeNumber], 0
|
mov [edi+DIRENTRY.inodeNumber], 0
|
||||||
mov [edi+DIRENTRY.entryLength], ax
|
|
||||||
; this block wasn't linking to the next one, so write it, and use the next block
|
|
||||||
pop eax
|
pop eax
|
||||||
mov ebx, [ebp+EXTFS.tempBlockBuffer]
|
mov ebx, [ebp+EXTFS.tempBlockBuffer]
|
||||||
call extfsWriteBlock
|
call extfsWriteBlock
|
||||||
pop ecx
|
jmp @b
|
||||||
inc ecx
|
|
||||||
cmp ecx, [esp]
|
|
||||||
push ecx
|
|
||||||
jnz @f
|
|
||||||
.alloc_block:
|
.alloc_block:
|
||||||
mov eax, [esi+INODE.fileSize]
|
mov eax, [esi+INODE.fileSize]
|
||||||
add eax, [ebp+EXTFS.bytesPerBlock]
|
add eax, [ebp+EXTFS.bytesPerBlock]
|
||||||
@ -1497,7 +1494,6 @@ linkInode:
|
|||||||
call writeInode
|
call writeInode
|
||||||
jc .error_get_inode_block
|
jc .error_get_inode_block
|
||||||
mov ecx, [esp]
|
mov ecx, [esp]
|
||||||
@@:
|
|
||||||
call extfsGetExtent
|
call extfsGetExtent
|
||||||
jc .error_get_inode_block
|
jc .error_get_inode_block
|
||||||
push eax
|
push eax
|
||||||
@ -1506,15 +1502,17 @@ linkInode:
|
|||||||
mov [edi+DIRENTRY.entryLength], ax
|
mov [edi+DIRENTRY.entryLength], ax
|
||||||
.found:
|
.found:
|
||||||
pop edx ecx ecx ecx ebx esi
|
pop edx ecx ecx ecx ebx esi
|
||||||
push ebx
|
|
||||||
mov [edi+DIRENTRY.inodeNumber], ebx
|
mov [edi+DIRENTRY.inodeNumber], ebx
|
||||||
sub ecx, 8
|
|
||||||
mov word [edi+DIRENTRY.nameLength], cx
|
mov word [edi+DIRENTRY.nameLength], cx
|
||||||
cmp [ebp+EXTFS.superblock.dynamicVersionFlag], 0
|
sub eax, 8
|
||||||
je .name
|
cmp ecx, eax
|
||||||
mov eax, [esp+4]
|
adc ecx, 0
|
||||||
|
test [ebp+EXTFS.superblock.incompatibleFlags], 2
|
||||||
|
jz @f
|
||||||
|
mov eax, [esp]
|
||||||
mov [edi+DIRENTRY.fileType], al
|
mov [edi+DIRENTRY.fileType], al
|
||||||
.name:
|
@@:
|
||||||
|
push ebx
|
||||||
add edi, 8
|
add edi, 8
|
||||||
rep movsb
|
rep movsb
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
@ -1660,12 +1658,12 @@ findInode:
|
|||||||
@@: ; doesn't match
|
@@: ; doesn't match
|
||||||
pop esi
|
pop esi
|
||||||
.next_rec:
|
.next_rec:
|
||||||
movzx eax, [ebx+DIRENTRY.entryLength]
|
movzx ecx, [ebx+DIRENTRY.entryLength]
|
||||||
add ebx, eax
|
jecxz .stop
|
||||||
|
add ebx, ecx
|
||||||
cmp ebx, edx
|
cmp ebx, edx
|
||||||
jb .start_rec
|
jb .start_rec
|
||||||
push eax
|
jmp .stop
|
||||||
jmp @f
|
|
||||||
|
|
||||||
.test_find:
|
.test_find:
|
||||||
cmp byte [esi], 0
|
cmp byte [esi], 0
|
||||||
@ -1674,7 +1672,9 @@ findInode:
|
|||||||
jne @b
|
jne @b
|
||||||
inc esi
|
inc esi
|
||||||
@@:
|
@@:
|
||||||
pop edx edx edi ecx eax
|
pop edx
|
||||||
|
.stop:
|
||||||
|
pop edx edi ecx eax
|
||||||
; ebx -> matched directory entry, esi -> name without parent, or not changed
|
; ebx -> matched directory entry, esi -> name without parent, or not changed
|
||||||
cmp edi, esi
|
cmp edi, esi
|
||||||
jnz @f
|
jnz @f
|
||||||
|
Loading…
Reference in New Issue
Block a user