Kernel+LibC: Add some errno codes

Kernel now returns ENOMEM and other errnos, so we dont have to write
error messages
This commit is contained in:
Bananymous
2023-03-02 21:10:44 +02:00
parent 90a7268e5a
commit 52aa98ba25
16 changed files with 87 additions and 31 deletions

32
libc/string/strerror.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include <errno.h>
#include <string.h>
int errno = 0;
char* strerror(int error)
{
switch (error)
{
case ENOMEM:
return "Cannot allocate memory";
case EINVAL:
return "Invalid argument";
case EISDIR:
return "Is a directory";
case ENOTDIR:
return "Not a directory";
case ENOENT:
return "No such file or directory";
case EIO:
return "Input/output error";
default:
break;
}
// FIXME: sprintf
//static char buffer[26];
//sprintf(buffer, "Unknown error %d", error);
//return buffer;
errno = EINVAL;
return "Unknown error";
}