LibC: syscall() now returns -1 on error and updates errno

This commit is contained in:
2023-05-07 01:51:39 +03:00
parent 2fe9af7165
commit 10d9b72da1
5 changed files with 23 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
#include <BAN/Assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
@@ -45,7 +46,7 @@ long syscall(long syscall, ...)
case SYS_TERMID:
{
char* buffer = va_arg(args, char*);
Kernel::syscall(SYS_TERMID, buffer);
ret = Kernel::syscall(SYS_TERMID, buffer);
break;
}
case SYS_CLOSE:
@@ -82,10 +83,18 @@ long syscall(long syscall, ...)
}
default:
puts("LibC: Unhandeled syscall");
ret = -ENOSYS;
break;
}
va_end(args);
if (ret < 0)
{
errno = -ret;
return -1;
}
return ret;
}