The ELF loader now uses errno.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-11-22 18:06:40 +01:00
parent 6986963b4b
commit 9deb183786
3 changed files with 5 additions and 3 deletions

View File

@ -17,5 +17,6 @@
#define EISDIR 25
#define EPERM 26
#define EIO 27
#define ENOEXEC 28
#endif

View File

@ -60,6 +60,7 @@ namespace Maxsi
case EISDIR: return (char*) "Is a directory";
case EPERM: return (char*) "Permission denied";
case EIO: return (char*) "Input/output error";
case ENOEXEC: return (char*) "Not executable";
default: return (char*) "Unknown error condition";
}
}

View File

@ -23,6 +23,7 @@
******************************************************************************/
#include "platform.h"
#include <libmaxsi/error.h>
#include <libmaxsi/memory.h>
#include "elf.h"
#include "memorymanagement.h"
@ -117,14 +118,13 @@ namespace Sortix
addr_t Construct(Process* process, const void* file, size_t filelen)
{
// TODO: These messages should be returned by errno instead!
if ( filelen < sizeof(Header) ) { Log::PrintF("File is not executable\n"); return 0; }
if ( filelen < sizeof(Header) ) { Error::Set(ENOEXEC); return 0; }
const Header* header = (const Header*) file;
if ( !(header->magic[0] == 0x7F && header->magic[1] == 'E' &&
header->magic[2] == 'L' && header->magic[3] == 'F' ) )
{
Log::PrintF("File is not executable\n");
Error::Set(ENOEXEC);
return 0;
}