fstatat -> stat, fgettype/fgetmod: rax->eax (st_mode is dword, not qword)

This commit is contained in:
2025-07-27 14:19:09 +02:00
parent dbf2af0253
commit efd35b2957
2 changed files with 25 additions and 6 deletions

View File

@@ -6,14 +6,15 @@ extern strlen
extern umask_get extern umask_get
section .text section .text
global fstatat global stat
global fgettype
global fgetmod global fgetmod
global fopen global fopen
global fclose global fclose
global fexist global fexist
global fwrite global fwrite
;----- fstatat(*file[], *statBuffer[]) -----; ;----- stat(*file[], *statBuffer[]) -----;
; Gets information from a file, stores it into statBuffer[] ; Gets information from a file, stores it into statBuffer[]
; Return value: 0 if stats received, -errno otherwise ; Return value: 0 if stats received, -errno otherwise
; Used registers: ; Used registers:
@@ -45,8 +46,8 @@ fgettype:
mov rax, -EINVAL mov rax, -EINVAL
ret ret
.buffok: .buffok:
mov rax, [rdi + ST_MODE] mov eax, dword [rdi + ST_MODE]
and rax, 0xF000 and eax, 0xF000
ret ret
;----- fgetmod(*statBuffer[]) -----; ;----- fgetmod(*statBuffer[]) -----;
@@ -61,8 +62,8 @@ fgetmod:
mov rax, -EINVAL mov rax, -EINVAL
ret ret
.buffok: .buffok:
mov rax, [rdi + ST_MODE] mov eax, [rdi + ST_MODE]
and rax, 0x0FFF and eax, 0x0FFF
ret ret
;----- fopen(*file[], char mode) -----; ;----- fopen(*file[], char mode) -----;

View File

@@ -89,6 +89,9 @@ extern fopen
extern fclose extern fclose
extern fexist extern fexist
extern fwrite extern fwrite
extern stat
extern fgettype
extern fgetmod
section .rodata section .rodata
;;; ;;;
@@ -129,6 +132,9 @@ section .rodata
;file.asm ;file.asm
TEST_fopen equ 1 ;Includes fclose TEST_fopen equ 1 ;Includes fclose
TEST_fwrite equ 1 TEST_fwrite equ 1
TEST_stat equ 1
TEST_fgettype equ 1
TEST_fgetmod equ 1
;;; ;;;
;;; Global test messages ;;; Global test messages
@@ -1236,6 +1242,18 @@ _start:
call fclose call fclose
%endif %endif
;--- stat()
%if TEST_stat
%endif
;--- fgettype()
%if TEST_fgettype
%endif
;--- fgetmod()
%if TEST_fgetmod
%endif
;;; ;;;
;;; TEST RESULTS ;;; TEST RESULTS
;;; ;;;