fstatat -> stat, fgettype/fgetmod: rax->eax (st_mode is dword, not qword)
This commit is contained in:
13
src/file.asm
13
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) -----;
|
||||
|
@@ -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
|
||||
;;;
|
||||
|
Reference in New Issue
Block a user