Kernel, libc: Implement EFAULT
This commit is contained in:
parent
e37ff67da2
commit
5f8376409d
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user