From 28424105e255f0a4c887b6e6a83afd6dce372709 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 23 Feb 2020 06:31:47 +0100 Subject: Added ft_read.s ft_write.s error handling --- ft_read.s | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'ft_read.s') diff --git a/ft_read.s b/ft_read.s index 564f2fc..f65ade3 100644 --- a/ft_read.s +++ b/ft_read.s @@ -12,6 +12,10 @@ global _ft_read +%define F_GETFD 1 +%define SYSCALL_READ 0x2000003 +%define SYSCALL_FCNTL 0x200005c + ; int ft_read(int, void*, size_t); _ft_read: cmp rdx, 0 @@ -20,7 +24,19 @@ _ft_read: jl FT_READ_ERROR cmp rsi, 0 je FT_READ_ERROR - mov rax, 0x2000003 + + push rdx + push rsi + xor rsi, rsi + mov esi, F_GETFD + mov rax, SYSCALL_FCNTL + syscall + pop rsi + pop rdx + cmp eax, 0 + jne FT_READ_ERROR + + mov rax, SYSCALL_READ syscall ret FT_READ_ERROR: -- cgit