Kernel, libc: Implement EFAULT

This commit is contained in:
apio 2022-10-12 19:25:35 +02:00
parent e37ff67da2
commit 5f8376409d
5 changed files with 8 additions and 5 deletions

View File

@ -5,6 +5,7 @@
#define ENOEXEC 8
#define EBADF 9
#define ENOMEM 12
#define EFAULT 14
#define EISDIR 21
#define EINVAL 22
#define EMFILE 24

View File

@ -14,7 +14,7 @@ void sys_exec(Context* context, const char* pathname)
{
if (!pathname)
{
context->rax = -EINVAL; // FIXME: This should probably return EFAULT.
context->rax = -EFAULT;
return;
}

View File

@ -66,8 +66,8 @@ void sys_write(Context* context, int fd, size_t size, const char* addr)
{
if (!addr)
{
STDIO_FAIL(write, EINVAL);
context->rax = -EINVAL; // FIXME: This should probably return EFAULT.
STDIO_FAIL(write, EFAULT);
context->rax = -EFAULT;
return;
}
if (fd >= TASK_MAX_FDS || fd < 0)
@ -142,8 +142,8 @@ void sys_read(Context* context, int fd, size_t size, char* buffer)
{
if (!buffer)
{
STDIO_FAIL(read, EINVAL);
context->rax = -EINVAL; // FIXME: This should probably return EFAULT.
STDIO_FAIL(read, EFAULT);
context->rax = -EFAULT;
return;
}
if (fd >= TASK_MAX_FDS || fd < 0)

View File

@ -9,6 +9,7 @@ extern int errno;
#define ENOEXEC 8 // Exec format error
#define EBADF 9 // Bad file descriptor
#define ENOMEM 12 // Cannot allocate memory
#define EFAULT 14 // Bad address
#define EISDIR 21 // Is a directory
#define EINVAL 22 // Invalid argument
#define EMFILE 24 // Too many open files

View File

@ -128,6 +128,7 @@ extern "C"
case EMFILE: return "Too many open files";
case EISDIR: return "Is a directory";
case ENOEXEC: return "Exec format error";
case EFAULT: return "Bad address";
case 0: return "Success";
default: return (char*)(unsigned long int)err;
}