diff --git a/src/file.asm b/src/file.asm index e66551a..470f821 100644 --- a/src/file.asm +++ b/src/file.asm @@ -6,14 +6,15 @@ extern strlen extern umask_get section .text - global fstatat + global stat + global fgettype global fgetmod global fopen global fclose global fexist global fwrite -;----- fstatat(*file[], *statBuffer[]) -----; +;----- stat(*file[], *statBuffer[]) -----; ; Gets information from a file, stores it into statBuffer[] ; Return value: 0 if stats received, -errno otherwise ; Used registers: @@ -45,8 +46,8 @@ fgettype: mov rax, -EINVAL ret .buffok: - mov rax, [rdi + ST_MODE] - and rax, 0xF000 + mov eax, dword [rdi + ST_MODE] + and eax, 0xF000 ret ;----- fgetmod(*statBuffer[]) -----; @@ -61,8 +62,8 @@ fgetmod: mov rax, -EINVAL ret .buffok: - mov rax, [rdi + ST_MODE] - and rax, 0x0FFF + mov eax, [rdi + ST_MODE] + and eax, 0x0FFF ret ;----- fopen(*file[], char mode) -----; diff --git a/src/tests.asm b/src/tests.asm index 82e257a..8dece88 100644 --- a/src/tests.asm +++ b/src/tests.asm @@ -89,6 +89,9 @@ extern fopen extern fclose extern fexist extern fwrite +extern stat +extern fgettype +extern fgetmod section .rodata ;;; @@ -129,6 +132,9 @@ section .rodata ;file.asm TEST_fopen equ 1 ;Includes fclose TEST_fwrite equ 1 + TEST_stat equ 1 + TEST_fgettype equ 1 + TEST_fgetmod equ 1 ;;; ;;; Global test messages @@ -1236,6 +1242,18 @@ _start: call fclose %endif +;--- stat() +%if TEST_stat +%endif + +;--- fgettype() +%if TEST_fgettype +%endif + +;--- fgetmod() +%if TEST_fgetmod +%endif + ;;; ;;; TEST RESULTS ;;;