mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-28 19:53:12 +03:00
ext2: support for files bigger than 4 GB
git-svn-id: svn://kolibrios.org@6849 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1ab6d8bc4e
commit
861e7b4ea9
@ -1018,28 +1018,34 @@ doublyIndirectBlockAlloc:
|
|||||||
extfsExtendFile:
|
extfsExtendFile:
|
||||||
; in:
|
; in:
|
||||||
; [ebp+EXTFS.inodeBuffer] = inode
|
; [ebp+EXTFS.inodeBuffer] = inode
|
||||||
; eax = inode number
|
; ecx = inode number
|
||||||
; ecx = new size
|
; edx:eax = new size
|
||||||
push ebx ecx edx esi edi eax
|
push ebx esi edi ecx
|
||||||
lea esi, [ebp+EXTFS.inodeBuffer]
|
lea esi, [ebp+EXTFS.inodeBuffer]
|
||||||
mov eax, ecx
|
mov ebx, [esi+INODE.fileSize]
|
||||||
mov edx, [esi+INODE.fileSize]
|
mov ecx, [esi+INODE.fileSizeHigh]
|
||||||
cmp edx, eax
|
cmp ebx, eax
|
||||||
|
sbb ecx, edx
|
||||||
jnc .ret
|
jnc .ret
|
||||||
|
mov ecx, [esi+INODE.fileSizeHigh]
|
||||||
mov [esi+INODE.fileSize], eax
|
mov [esi+INODE.fileSize], eax
|
||||||
mov ecx, [ebp+EXTFS.sectorsPerBlockLog]
|
mov [esi+INODE.fileSizeHigh], edx
|
||||||
add ecx, 9
|
sub eax, 1
|
||||||
dec eax
|
sbb edx, 0
|
||||||
shr eax, cl
|
div [ebp+EXTFS.bytesPerBlock]
|
||||||
inc eax
|
inc eax
|
||||||
sub edx, 1
|
xchg eax, ebx
|
||||||
|
mov edx, ecx
|
||||||
|
sub eax, 1
|
||||||
|
sbb edx, 0
|
||||||
jc @f
|
jc @f
|
||||||
shr edx, cl
|
div [ebp+EXTFS.bytesPerBlock]
|
||||||
@@:
|
@@:
|
||||||
inc edx
|
inc eax
|
||||||
sub eax, edx
|
sub ebx, eax
|
||||||
jz .ret
|
jz .ret
|
||||||
push eax
|
push ebx
|
||||||
|
mov edx, eax
|
||||||
@@:
|
@@:
|
||||||
mov ecx, [esp]
|
mov ecx, [esp]
|
||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
@ -1184,7 +1190,7 @@ extfsExtendFile:
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop edi
|
pop edi
|
||||||
.ret:
|
.ret:
|
||||||
pop edi edi esi edx ecx ebx
|
pop edi edi esi ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.errSave:
|
.errSave:
|
||||||
@ -1308,19 +1314,21 @@ freeDoublyIndirectBlock:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
extfsTruncateFile:
|
extfsTruncateFile:
|
||||||
; in: ecx = new size, [ebp+EXTFS.inodeBuffer] = inode
|
; in: edx:eax = new size, [ebp+EXTFS.inodeBuffer] = inode
|
||||||
push ebx ecx edx esi edi
|
|
||||||
lea esi, [ebp+EXTFS.inodeBuffer]
|
lea esi, [ebp+EXTFS.inodeBuffer]
|
||||||
cmp ecx, [esi+INODE.fileSize]
|
mov ecx, edx
|
||||||
|
cmp eax, [esi+INODE.fileSize]
|
||||||
|
sbb ecx, [esi+INODE.fileSizeHigh]
|
||||||
jnc .ret
|
jnc .ret
|
||||||
mov [esi+INODE.fileSize], ecx
|
mov [esi+INODE.fileSize], eax
|
||||||
mov edx, ecx
|
mov [esi+INODE.fileSizeHigh], edx
|
||||||
jecxz .directBlocks
|
sub eax, 1
|
||||||
dec edx
|
sbb edx, 0
|
||||||
mov ecx, [ebp+EXTFS.sectorsPerBlockLog]
|
jc @f
|
||||||
add ecx, 9
|
div [ebp+EXTFS.bytesPerBlock]
|
||||||
shr edx, cl
|
@@:
|
||||||
inc edx
|
inc eax
|
||||||
|
mov edx, eax
|
||||||
cmp edx, 12
|
cmp edx, 12
|
||||||
jc .directBlocks
|
jc .directBlocks
|
||||||
sub edx, 12
|
sub edx, 12
|
||||||
@ -1399,7 +1407,6 @@ extfsTruncateFile:
|
|||||||
.done:
|
.done:
|
||||||
call kernel_free
|
call kernel_free
|
||||||
.ret:
|
.ret:
|
||||||
pop edi esi edx ecx ebx
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
linkInode:
|
linkInode:
|
||||||
@ -1485,9 +1492,10 @@ linkInode:
|
|||||||
push ecx
|
push ecx
|
||||||
jnz @f
|
jnz @f
|
||||||
.alloc_block:
|
.alloc_block:
|
||||||
mov ecx, [esi+INODE.fileSize]
|
mov eax, [esi+INODE.fileSize]
|
||||||
add ecx, [ebp+EXTFS.bytesPerBlock]
|
add eax, [ebp+EXTFS.bytesPerBlock]
|
||||||
mov eax, [esp+24]
|
xor edx, edx
|
||||||
|
mov ecx, [esp+24]
|
||||||
call extfsExtendFile
|
call extfsExtendFile
|
||||||
jc .error_get_inode_block
|
jc .error_get_inode_block
|
||||||
mov eax, [esp+24]
|
mov eax, [esp+24]
|
||||||
@ -1633,20 +1641,20 @@ findInode:
|
|||||||
mov edx, esi
|
mov edx, esi
|
||||||
rep movsb
|
rep movsb
|
||||||
pop esi
|
pop esi
|
||||||
pushd 0 ROOT_INODE
|
pushd ebx 0 ROOT_INODE
|
||||||
mov edi, esi
|
mov edi, esi
|
||||||
cmp [edx+INODE.fileSize], 0
|
cmp [edx+INODE.fileSize], 0
|
||||||
jz .not_found
|
jz .not_found
|
||||||
cmp byte [esi], 0
|
cmp byte [esi], 0
|
||||||
jnz .next_path_part
|
jnz .next_path_part
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop esi ecx
|
pop esi ecx ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
pop esi esi
|
pop esi esi
|
||||||
.error:
|
.error:
|
||||||
pop esi ecx
|
pop esi ecx ebx
|
||||||
xor edi, edi
|
xor edi, edi
|
||||||
stc
|
stc
|
||||||
ret
|
ret
|
||||||
@ -1729,7 +1737,7 @@ findInode:
|
|||||||
movi eax, ERROR_FILE_NOT_FOUND
|
movi eax, ERROR_FILE_NOT_FOUND
|
||||||
stc
|
stc
|
||||||
.ret:
|
.ret:
|
||||||
pop esi ecx
|
pop esi ecx ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
writeSuperblock:
|
writeSuperblock:
|
||||||
@ -1762,9 +1770,7 @@ ext_ReadFolder:
|
|||||||
call ext_lock
|
call ext_lock
|
||||||
cmp byte [esi], 0
|
cmp byte [esi], 0
|
||||||
jz .root_folder
|
jz .root_folder
|
||||||
push ebx
|
|
||||||
call findInode
|
call findInode
|
||||||
pop ebx
|
|
||||||
jc .error_ret
|
jc .error_ret
|
||||||
lea esi, [ebp+EXTFS.inodeBuffer]
|
lea esi, [ebp+EXTFS.inodeBuffer]
|
||||||
test [esi+INODE.accessMode], FLAG_FILE
|
test [esi+INODE.accessMode], FLAG_FILE
|
||||||
@ -1972,10 +1978,8 @@ ext_ReadFolder:
|
|||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
ext_ReadFile:
|
ext_ReadFile:
|
||||||
call ext_lock
|
call ext_lock
|
||||||
pushd 0 ebx
|
|
||||||
call findInode
|
call findInode
|
||||||
pop ebx
|
pushd 0 eax
|
||||||
push eax
|
|
||||||
jc .ret
|
jc .ret
|
||||||
lea esi, [ebp+EXTFS.inodeBuffer]
|
lea esi, [ebp+EXTFS.inodeBuffer]
|
||||||
mov byte [esp], ERROR_ACCESS_DENIED
|
mov byte [esp], ERROR_ACCESS_DENIED
|
||||||
@ -2079,12 +2083,9 @@ ext_ReadFile:
|
|||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
ext_GetFileInfo:
|
ext_GetFileInfo:
|
||||||
call ext_lock
|
call ext_lock
|
||||||
mov edx, [ebx+16]
|
|
||||||
cmp byte [esi], 0
|
cmp byte [esi], 0
|
||||||
jz .is_root
|
jz .is_root
|
||||||
push edx
|
|
||||||
call findInode
|
call findInode
|
||||||
pop edx
|
|
||||||
lea esi, [ebp+EXTFS.inodeBuffer]
|
lea esi, [ebp+EXTFS.inodeBuffer]
|
||||||
jnc @f
|
jnc @f
|
||||||
push eax
|
push eax
|
||||||
@ -2096,6 +2097,7 @@ ext_GetFileInfo:
|
|||||||
mov edi, esi
|
mov edi, esi
|
||||||
lea esi, [ebp+EXTFS.rootInodeBuffer]
|
lea esi, [ebp+EXTFS.rootInodeBuffer]
|
||||||
@@:
|
@@:
|
||||||
|
mov edx, [ebx+16]
|
||||||
mov bl, [edi]
|
mov bl, [edi]
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, edx
|
mov edi, edx
|
||||||
@ -2133,12 +2135,11 @@ ext_GetFileInfo:
|
|||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
ext_SetFileInfo:
|
ext_SetFileInfo:
|
||||||
call extfsWritingInit
|
call extfsWritingInit
|
||||||
pushd [ebx+16]
|
|
||||||
call findInode
|
call findInode
|
||||||
pop edx
|
|
||||||
jc @f
|
jc @f
|
||||||
push esi ; inode number
|
push esi
|
||||||
lea esi, [edx+16]
|
mov esi, [ebx+16]
|
||||||
|
add esi, 16
|
||||||
lea edi, [ebp+EXTFS.inodeBuffer]
|
lea edi, [ebp+EXTFS.inodeBuffer]
|
||||||
call fsCalculateTime
|
call fsCalculateTime
|
||||||
add eax, 978307200 ; 01.01.1970-01.01.2001 = (365*31+8)*24*60*60
|
add eax, 978307200 ; 01.01.1970-01.01.2001 = (365*31+8)*24*60*60
|
||||||
@ -2236,12 +2237,14 @@ ext_Delete:
|
|||||||
lea ebx, [ebp+EXTFS.inodeBuffer]
|
lea ebx, [ebp+EXTFS.inodeBuffer]
|
||||||
call readInode
|
call readInode
|
||||||
jc .error_stack4_eax
|
jc .error_stack4_eax
|
||||||
xor ecx, ecx
|
push edx
|
||||||
|
xor eax, eax
|
||||||
|
xor edx, edx
|
||||||
call extfsTruncateFile ; free file's data
|
call extfsTruncateFile ; free file's data
|
||||||
movzx ecx, [ebp+EXTFS.superblock.inodeSize]
|
movzx ecx, [ebp+EXTFS.superblock.inodeSize]
|
||||||
lea edi, [ebp+EXTFS.inodeBuffer]
|
lea edi, [ebp+EXTFS.inodeBuffer]
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
push edx edi
|
push edi
|
||||||
rep stosb
|
rep stosb
|
||||||
call fsGetTime
|
call fsGetTime
|
||||||
pop ebx ecx
|
pop ebx ecx
|
||||||
@ -2408,7 +2411,8 @@ ext_CreateFile:
|
|||||||
call linkInode
|
call linkInode
|
||||||
jc .error2
|
jc .error2
|
||||||
pop esi ebx
|
pop esi ebx
|
||||||
mov ecx, [ebx+12]
|
mov eax, [ebx+12]
|
||||||
|
xor edx, edx
|
||||||
jmp ext_WriteFile.start
|
jmp ext_WriteFile.start
|
||||||
|
|
||||||
.exist:
|
.exist:
|
||||||
@ -2416,8 +2420,11 @@ ext_CreateFile:
|
|||||||
test [ebp+EXTFS.inodeBuffer.accessMode], FLAG_FILE
|
test [ebp+EXTFS.inodeBuffer.accessMode], FLAG_FILE
|
||||||
jz .error ; not a file
|
jz .error ; not a file
|
||||||
pop ebx
|
pop ebx
|
||||||
mov ecx, [ebx+12]
|
mov eax, [ebx+12]
|
||||||
|
xor edx, edx
|
||||||
|
push eax edx ebx esi
|
||||||
call extfsTruncateFile
|
call extfsTruncateFile
|
||||||
|
pop esi ebx edx eax
|
||||||
jmp ext_WriteFile.start
|
jmp ext_WriteFile.start
|
||||||
|
|
||||||
.error2:
|
.error2:
|
||||||
@ -2431,26 +2438,27 @@ ext_CreateFile:
|
|||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
ext_WriteFile:
|
ext_WriteFile:
|
||||||
call extfsWritingInit
|
call extfsWritingInit
|
||||||
push ebx
|
|
||||||
call findInode
|
call findInode
|
||||||
pop ebx
|
|
||||||
pushd 0 eax
|
pushd 0 eax
|
||||||
jc .ret
|
jc .ret
|
||||||
mov byte [esp], ERROR_ACCESS_DENIED
|
mov byte [esp], ERROR_ACCESS_DENIED
|
||||||
test [ebp+EXTFS.inodeBuffer.accessMode], FLAG_FILE
|
test [ebp+EXTFS.inodeBuffer.accessMode], FLAG_FILE
|
||||||
jz .ret ; not a file
|
jz .ret ; not a file
|
||||||
mov ecx, [ebx+4]
|
mov byte [esp], 0
|
||||||
add ecx, [ebx+12]
|
mov eax, [ebx+4]
|
||||||
|
mov edx, [ebx+8]
|
||||||
|
add eax, [ebx+12]
|
||||||
|
adc edx, 0
|
||||||
.start:
|
.start:
|
||||||
push esi
|
push esi
|
||||||
mov eax, esi
|
mov ecx, esi
|
||||||
call extfsExtendFile
|
call extfsExtendFile
|
||||||
jc .errorExtend
|
jc .errorExtend
|
||||||
mov eax, [ebx+4]
|
mov eax, [ebx+4]
|
||||||
|
mov edx, [ebx+8]
|
||||||
mov ecx, [ebx+12]
|
mov ecx, [ebx+12]
|
||||||
mov esi, [ebx+16]
|
mov esi, [ebx+16]
|
||||||
.write:
|
.write:
|
||||||
xor edx, edx
|
|
||||||
div [ebp+EXTFS.bytesPerBlock]
|
div [ebp+EXTFS.bytesPerBlock]
|
||||||
test edx, edx
|
test edx, edx
|
||||||
jz .aligned
|
jz .aligned
|
||||||
@ -2547,44 +2555,52 @@ ext_WriteFile:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.erase:
|
.erase:
|
||||||
push eax eax edx
|
push eax eax edi
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
jmp .write
|
jmp .write
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
ext_SetFileEnd:
|
ext_SetFileEnd:
|
||||||
call extfsWritingInit
|
call extfsWritingInit
|
||||||
pushd [ebx+4]
|
|
||||||
call findInode
|
call findInode
|
||||||
pop ecx
|
|
||||||
jc .error2
|
jc .error2
|
||||||
lea edi, [ebp+EXTFS.inodeBuffer]
|
lea edi, [ebp+EXTFS.inodeBuffer]
|
||||||
movi eax, ERROR_ACCESS_DENIED
|
movi eax, ERROR_ACCESS_DENIED
|
||||||
test [edi+INODE.accessMode], FLAG_FILE
|
test [edi+INODE.accessMode], FLAG_FILE
|
||||||
jz .error2 ; not a file
|
jz .error2 ; not a file
|
||||||
push esi
|
mov eax, [ebx+4]
|
||||||
|
mov edx, [ebx+8]
|
||||||
mov ebx, [edi+INODE.fileSize]
|
mov ebx, [edi+INODE.fileSize]
|
||||||
mov eax, esi
|
mov ecx, [edi+INODE.fileSizeHigh]
|
||||||
cmp ebx, ecx
|
push esi ecx
|
||||||
|
cmp ebx, eax
|
||||||
|
sbb ecx, edx
|
||||||
|
mov ecx, esi
|
||||||
jnc @f
|
jnc @f
|
||||||
call extfsExtendFile
|
call extfsExtendFile
|
||||||
|
pop esi
|
||||||
jc .error
|
jc .error
|
||||||
sub ecx, ebx
|
mov eax, [edi+INODE.fileSize]
|
||||||
cmp ecx, 1000001h
|
mov edx, [edi+INODE.fileSizeHigh]
|
||||||
|
sub eax, ebx
|
||||||
|
sbb edx, esi
|
||||||
|
jnz .done
|
||||||
|
cmp eax, 1000001h
|
||||||
jnc .done
|
jnc .done
|
||||||
push ecx
|
push eax
|
||||||
stdcall kernel_alloc, ecx
|
stdcall kernel_alloc, eax
|
||||||
pop ecx
|
pop ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .error
|
jz .error
|
||||||
push ecx
|
push ecx
|
||||||
add ecx, 3
|
add ecx, 3
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
|
mov edx, esi
|
||||||
mov esi, eax
|
mov esi, eax
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
rep stosd
|
rep stosd
|
||||||
pop ecx edx
|
pop ecx edi
|
||||||
push esi
|
push esi
|
||||||
call ext_WriteFile.erase
|
call ext_WriteFile.erase
|
||||||
call kernel_free
|
call kernel_free
|
||||||
@ -2593,6 +2609,7 @@ ext_SetFileEnd:
|
|||||||
|
|
||||||
@@:
|
@@:
|
||||||
call extfsTruncateFile
|
call extfsTruncateFile
|
||||||
|
pop eax
|
||||||
.done:
|
.done:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
.error:
|
.error:
|
||||||
|
Loading…
Reference in New Issue
Block a user