forked from KolibriOS/kolibrios
ext fs optimizing
git-svn-id: svn://kolibrios.org@6853 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
f1c9b0ad0f
commit
be199bc49c
@ -1544,15 +1544,14 @@ linkInode:
|
|||||||
jmp @b
|
jmp @b
|
||||||
|
|
||||||
unlinkInode:
|
unlinkInode:
|
||||||
; in: eax = inode from which to unlink, ebx = inode to unlink
|
; in: eax = directory inode number, esi = inode to unlink
|
||||||
; out: eax = current number of links to inode, -1 = error
|
push edi
|
||||||
push edx ebx
|
|
||||||
lea ebx, [ebp+EXTFS.inodeBuffer]
|
lea ebx, [ebp+EXTFS.inodeBuffer]
|
||||||
call readInode
|
call readInode
|
||||||
jc .fail
|
jc .ret
|
||||||
push eax
|
xor ecx, ecx
|
||||||
.loop:
|
.loop:
|
||||||
mov ecx, [esp]
|
push ecx
|
||||||
call extfsGetExtent
|
call extfsGetExtent
|
||||||
jc .fail_loop
|
jc .fail_loop
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
@ -1560,64 +1559,48 @@ unlinkInode:
|
|||||||
call extfsReadBlock
|
call extfsReadBlock
|
||||||
jc .fail_loop
|
jc .fail_loop
|
||||||
.first_dir_entry: ; edi -> block
|
.first_dir_entry: ; edi -> block
|
||||||
mov eax, [esp+4]
|
cmp [ebx+DIRENTRY.inodeNumber], esi
|
||||||
cmp [ebx+DIRENTRY.inodeNumber], eax
|
|
||||||
jne @f
|
jne @f
|
||||||
mov [ebx+DIRENTRY.inodeNumber], 0
|
mov [ebx+DIRENTRY.inodeNumber], 0
|
||||||
mov word [ebx+DIRENTRY.nameLength], 0 ; fileType = 0
|
mov word [ebx+DIRENTRY.nameLength], 0 ; fileType = 0
|
||||||
jmp .write_block
|
jmp .write_block
|
||||||
|
|
||||||
|
.fail:
|
||||||
|
pop edi
|
||||||
|
movi eax, ERROR_FS_FAIL
|
||||||
|
stc
|
||||||
|
.fail_loop:
|
||||||
|
pop edi
|
||||||
|
jmp .ret
|
||||||
|
|
||||||
|
.next:
|
||||||
|
pop ecx ecx
|
||||||
|
inc ecx
|
||||||
|
jmp .loop
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
mov edx, ebx
|
mov edx, ebx
|
||||||
add edx, [ebp+EXTFS.bytesPerBlock]
|
add edx, [ebp+EXTFS.bytesPerBlock]
|
||||||
push edx
|
push edx
|
||||||
mov edx, ebx
|
@@:
|
||||||
movzx ecx, [ebx+DIRENTRY.entryLength]
|
movzx ecx, [ebx+DIRENTRY.entryLength]
|
||||||
|
jecxz .fail
|
||||||
|
mov edx, ebx
|
||||||
add ebx, ecx
|
add ebx, ecx
|
||||||
.dir_entry:
|
cmp ebx, [esp]
|
||||||
cmp [ebx+DIRENTRY.inodeNumber], eax
|
jnc .next
|
||||||
jne @f
|
cmp [ebx+DIRENTRY.inodeNumber], esi
|
||||||
|
jnz @b
|
||||||
mov cx, [ebx+DIRENTRY.entryLength]
|
mov cx, [ebx+DIRENTRY.entryLength]
|
||||||
add [edx+DIRENTRY.entryLength], cx
|
add [edx+DIRENTRY.entryLength], cx
|
||||||
pop eax
|
pop eax
|
||||||
jmp .write_block
|
|
||||||
|
|
||||||
@@:
|
|
||||||
mov edx, ebx
|
|
||||||
movzx ecx, [ebx+DIRENTRY.entryLength]
|
|
||||||
test ecx, ecx
|
|
||||||
jz .fail_inode
|
|
||||||
add ebx, ecx
|
|
||||||
cmp ebx, [esp]
|
|
||||||
jb .dir_entry
|
|
||||||
pop ecx
|
|
||||||
inc dword[esp]
|
|
||||||
jmp .loop
|
|
||||||
|
|
||||||
.fail_inode:
|
|
||||||
pop eax
|
|
||||||
.fail_loop:
|
|
||||||
pop eax
|
|
||||||
.fail:
|
|
||||||
or eax, -1
|
|
||||||
jmp @f
|
|
||||||
|
|
||||||
.write_block:
|
.write_block:
|
||||||
pop eax
|
pop eax
|
||||||
mov eax, edi
|
mov eax, edi
|
||||||
mov ebx, [ebp+EXTFS.tempBlockBuffer]
|
mov ebx, [ebp+EXTFS.tempBlockBuffer]
|
||||||
call extfsWriteBlock
|
call extfsWriteBlock
|
||||||
mov eax, [esp]
|
.ret:
|
||||||
lea ebx, [ebp+EXTFS.inodeBuffer]
|
pop edi
|
||||||
call readInode
|
|
||||||
jc .fail
|
|
||||||
dec word [ebx+INODE.linksCount]
|
|
||||||
mov eax, [esp]
|
|
||||||
call writeInode
|
|
||||||
jc .fail
|
|
||||||
movzx eax, word [ebx+INODE.linksCount]
|
|
||||||
@@:
|
|
||||||
pop ebx edx
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
findInode:
|
findInode:
|
||||||
@ -2161,16 +2144,12 @@ ext_SetFileInfo:
|
|||||||
ext_Delete:
|
ext_Delete:
|
||||||
call extfsWritingInit
|
call extfsWritingInit
|
||||||
call findInode
|
call findInode
|
||||||
mov ebx, esi
|
jc .error
|
||||||
push eax
|
push ecx
|
||||||
jc .ret
|
movzx edi, [ebp+EXTFS.inodeBuffer.accessMode]
|
||||||
pop eax
|
and edi, TYPE_MASK
|
||||||
lea edx, [ebp+EXTFS.inodeBuffer]
|
cmp edi, DIRECTORY
|
||||||
movzx edx, [edx+INODE.accessMode]
|
|
||||||
and edx, TYPE_MASK
|
|
||||||
cmp edx, DIRECTORY
|
|
||||||
jne .file
|
jne .file
|
||||||
push ebx ecx edx
|
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
.checkDirectory:
|
.checkDirectory:
|
||||||
push ecx
|
push ecx
|
||||||
@ -2178,60 +2157,70 @@ ext_Delete:
|
|||||||
jc .empty
|
jc .empty
|
||||||
mov ebx, [ebp+EXTFS.tempBlockBuffer]
|
mov ebx, [ebp+EXTFS.tempBlockBuffer]
|
||||||
call extfsReadBlock
|
call extfsReadBlock
|
||||||
jc .not_empty_eax
|
jc .error8
|
||||||
mov edx, ebx
|
mov edx, ebx
|
||||||
add edx, [ebp+EXTFS.bytesPerBlock]
|
add edx, [ebp+EXTFS.bytesPerBlock]
|
||||||
movzx ecx, [ebx+DIRENTRY.entryLength]
|
|
||||||
add ebx, ecx
|
|
||||||
.dir_entry:
|
.dir_entry:
|
||||||
cmp byte [ebx+DIRENTRY.nameLength], 1
|
movzx ecx, [ebx+DIRENTRY.nameLength]
|
||||||
jne @f
|
mov ax, word [ebx+DIRENTRY.name]
|
||||||
cmp byte [ebx+DIRENTRY.name], '.'
|
jecxz @f
|
||||||
jne .not_empty
|
cmp al, '.'
|
||||||
|
jnz .not_empty
|
||||||
|
dec ecx
|
||||||
|
jz @f
|
||||||
|
cmp al, ah
|
||||||
|
jnz .not_empty
|
||||||
|
dec ecx
|
||||||
|
jnz .not_empty
|
||||||
@@:
|
@@:
|
||||||
cmp byte [ebx+DIRENTRY.nameLength], 2
|
mov cx, [ebx+DIRENTRY.entryLength]
|
||||||
jne .not_empty
|
jecxz @f
|
||||||
cmp word [ebx+DIRENTRY.name], '..'
|
|
||||||
jne .not_empty
|
|
||||||
movzx ecx, [ebx+DIRENTRY.entryLength]
|
|
||||||
add ebx, ecx
|
add ebx, ecx
|
||||||
cmp ebx, edx
|
cmp ebx, edx
|
||||||
jb .dir_entry
|
jb .dir_entry
|
||||||
|
@@:
|
||||||
pop ecx
|
pop ecx
|
||||||
inc ecx
|
inc ecx
|
||||||
jmp .checkDirectory
|
jmp .checkDirectory
|
||||||
|
|
||||||
.not_empty:
|
.not_empty:
|
||||||
pop eax eax
|
pop eax eax
|
||||||
.error_stack8:
|
|
||||||
pop eax eax
|
|
||||||
push ERROR_ACCESS_DENIED
|
push ERROR_ACCESS_DENIED
|
||||||
jmp .ret
|
jmp .ret
|
||||||
|
|
||||||
|
.error8:
|
||||||
|
pop ebx
|
||||||
|
.error4:
|
||||||
|
pop ebx
|
||||||
|
.error:
|
||||||
|
push eax
|
||||||
|
jmp .ret
|
||||||
|
|
||||||
.empty:
|
.empty:
|
||||||
|
pop ecx ecx
|
||||||
cmp eax, ERROR_END_OF_FILE
|
cmp eax, ERROR_END_OF_FILE
|
||||||
jnz .not_empty_eax
|
jnz .error
|
||||||
pop edx edx ecx ebx
|
push ecx
|
||||||
.file:
|
.file:
|
||||||
mov eax, ecx
|
mov eax, ecx
|
||||||
push ebx ecx
|
|
||||||
call unlinkInode
|
call unlinkInode
|
||||||
cmp eax, -1
|
jc .error4
|
||||||
je .error_stack8
|
pop eax
|
||||||
pop ebx
|
|
||||||
test eax, eax
|
|
||||||
jz @f
|
|
||||||
xor eax, eax
|
|
||||||
cmp edx, DIRECTORY
|
|
||||||
jnz .error_stack4_eax ; hardlinks
|
|
||||||
mov eax, [esp]
|
|
||||||
call unlinkInode
|
|
||||||
@@:
|
|
||||||
mov eax, [esp]
|
|
||||||
lea ebx, [ebp+EXTFS.inodeBuffer]
|
lea ebx, [ebp+EXTFS.inodeBuffer]
|
||||||
|
cmp edi, DIRECTORY
|
||||||
|
jnz @f
|
||||||
|
dec [ebx+INODE.linksCount]
|
||||||
|
call writeInode
|
||||||
|
@@:
|
||||||
|
mov eax, esi
|
||||||
call readInode
|
call readInode
|
||||||
jc .error_stack4_eax
|
jc .error
|
||||||
push edx
|
dec [ebx+INODE.linksCount]
|
||||||
|
jz @f
|
||||||
|
cmp edi, DIRECTORY
|
||||||
|
jnz .hardlinks
|
||||||
|
@@:
|
||||||
|
push esi edi
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
call extfsTruncateFile ; free file's data
|
call extfsTruncateFile ; free file's data
|
||||||
@ -2241,13 +2230,10 @@ ext_Delete:
|
|||||||
push edi
|
push edi
|
||||||
rep stosb
|
rep stosb
|
||||||
call fsGetTime
|
call fsGetTime
|
||||||
pop ebx ecx
|
pop ebx edi esi
|
||||||
add eax, 978307200
|
add eax, 978307200
|
||||||
mov [ebx+INODE.deletedTime], eax
|
mov [ebx+INODE.deletedTime], eax
|
||||||
mov eax, [esp]
|
mov eax, esi
|
||||||
call writeInode
|
|
||||||
jc .error_stack4_eax
|
|
||||||
pop eax
|
|
||||||
dec eax
|
dec eax
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
div [ebp+EXTFS.superblock.inodesPerGroup]
|
div [ebp+EXTFS.superblock.inodesPerGroup]
|
||||||
@ -2255,7 +2241,7 @@ ext_Delete:
|
|||||||
mov ebx, [ebp+EXTFS.descriptorTable]
|
mov ebx, [ebp+EXTFS.descriptorTable]
|
||||||
shl eax, 5
|
shl eax, 5
|
||||||
add ebx, eax
|
add ebx, eax
|
||||||
cmp ecx, DIRECTORY
|
cmp edi, DIRECTORY
|
||||||
jnz @f
|
jnz @f
|
||||||
dec [ebx+BGDESCR.directoriesCount]
|
dec [ebx+BGDESCR.directoriesCount]
|
||||||
@@:
|
@@:
|
||||||
@ -2266,9 +2252,9 @@ ext_Delete:
|
|||||||
mov ebx, [ebp+EXTFS.tempBlockBuffer]
|
mov ebx, [ebp+EXTFS.tempBlockBuffer]
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
call extfsReadBlock
|
call extfsReadBlock
|
||||||
jc .error_stack4_eax
|
pop edx
|
||||||
pop eax
|
jc .error
|
||||||
mov edx, eax
|
mov eax, edx
|
||||||
and edx, 31
|
and edx, 31
|
||||||
shr eax, 5
|
shr eax, 5
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
@ -2277,8 +2263,11 @@ ext_Delete:
|
|||||||
mov eax, ecx
|
mov eax, ecx
|
||||||
call extfsWriteBlock
|
call extfsWriteBlock
|
||||||
inc [ebp+EXTFS.superblock.inodesFree]
|
inc [ebp+EXTFS.superblock.inodesFree]
|
||||||
|
.hardlinks:
|
||||||
|
mov eax, esi
|
||||||
|
lea ebx, [ebp+EXTFS.inodeBuffer]
|
||||||
|
call writeInode
|
||||||
push eax
|
push eax
|
||||||
.disk_sync:
|
|
||||||
call writeSuperblock
|
call writeSuperblock
|
||||||
mov esi, [ebp+PARTITION.Disk]
|
mov esi, [ebp+PARTITION.Disk]
|
||||||
call disk_sync
|
call disk_sync
|
||||||
@ -2288,13 +2277,6 @@ ext_Delete:
|
|||||||
pop eax
|
pop eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.not_empty_eax:
|
|
||||||
add esp, 12
|
|
||||||
.error_stack4_eax:
|
|
||||||
pop ebx
|
|
||||||
push eax
|
|
||||||
jmp .disk_sync
|
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
ext_CreateFolder:
|
ext_CreateFolder:
|
||||||
call extfsWritingInit
|
call extfsWritingInit
|
||||||
|
Loading…
Reference in New Issue
Block a user