2011-08-05 08:25:00 -04:00
|
|
|
/******************************************************************************
|
|
|
|
|
|
|
|
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
|
|
|
|
|
|
|
This file is part of LibMaxsi.
|
|
|
|
|
|
|
|
LibMaxsi is free software: you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the Free
|
|
|
|
Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
|
more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with LibMaxsi. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
error.cpp
|
|
|
|
Error reporting functions and utilities.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-02-11 20:03:34 -05:00
|
|
|
#include <libmaxsi/platform.h>
|
|
|
|
#include <libmaxsi/error.h>
|
2011-12-01 08:54:19 -05:00
|
|
|
#ifndef SORTIX_KERNEL
|
2012-02-11 20:03:34 -05:00
|
|
|
#include <libmaxsi/syscall.h>
|
2011-12-01 08:54:19 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
namespace Maxsi
|
|
|
|
{
|
|
|
|
namespace Error
|
|
|
|
{
|
2011-11-22 12:21:01 -05:00
|
|
|
extern "C" { int errno = 0; }
|
2011-11-22 11:26:47 -05:00
|
|
|
|
2011-12-01 08:54:19 -05:00
|
|
|
#ifndef SORTIX_KERNEL
|
2011-12-09 06:41:06 -05:00
|
|
|
DEFN_SYSCALL1(int, SysRegisterErrno, SYSCALL_REGISTER_ERRNO, int*);
|
2011-12-01 08:54:19 -05:00
|
|
|
|
2011-11-22 11:26:47 -05:00
|
|
|
extern "C" void init_error_functions()
|
|
|
|
{
|
|
|
|
errno = 0;
|
|
|
|
SysRegisterErrno(&errno);
|
|
|
|
}
|
2011-12-01 08:54:19 -05:00
|
|
|
#endif
|
2011-11-22 11:26:47 -05:00
|
|
|
|
|
|
|
extern "C" char* strerror(int code)
|
|
|
|
{
|
|
|
|
switch ( code )
|
|
|
|
{
|
|
|
|
case ENOTBLK: return (char*) "Block device required";
|
|
|
|
case ENODEV: return (char*) "No such device";
|
|
|
|
case EWOULDBLOCK: return (char*) "Operation would block";
|
|
|
|
case EBADF: return (char*) "Bad file descriptor";
|
|
|
|
case EOVERFLOW: return (char*) "Value too large to be stored in data type";
|
|
|
|
case ENOENT: return (char*) "No such file or directory";
|
|
|
|
case ENOSPC: return (char*) "No space left on device";
|
|
|
|
case EEXIST: return (char*) "File exists";
|
|
|
|
case EROFS: return (char*) "Read-only file system";
|
|
|
|
case EINVAL: return (char*) "Invalid argument";
|
|
|
|
case ENOTDIR: return (char*) "Not a directory";
|
|
|
|
case ENOMEM: return (char*) "Not enough space";
|
|
|
|
case ERANGE: return (char*) "Result too large";
|
|
|
|
case EISDIR: return (char*) "Is a directory";
|
2011-11-22 12:21:01 -05:00
|
|
|
case EPERM: return (char*) "Operation not permitted";
|
2011-11-22 11:26:47 -05:00
|
|
|
case EIO: return (char*) "Input/output error";
|
2011-12-01 04:45:44 -05:00
|
|
|
case ENOEXEC: return (char*) "Exec format error";
|
2011-11-22 12:21:01 -05:00
|
|
|
case EACCESS: return (char*) "Permission denied";
|
2011-09-15 16:38:40 -04:00
|
|
|
case ESRCH: return (char*) "No such process";
|
2011-11-26 14:56:45 -05:00
|
|
|
case ENOTTY: return (char*) "Not a tty";
|
2011-12-01 08:54:19 -05:00
|
|
|
case ECHILD: return (char*) "No child processes";
|
2012-01-14 10:09:30 -05:00
|
|
|
case ENOSYS: return (char*) "Function not implemented";
|
2012-01-18 09:40:31 -05:00
|
|
|
case ENOTSUP: return (char*) "Operation not supported";
|
2012-01-22 12:49:04 -05:00
|
|
|
case EBLOCKING: return (char*) "Operation is blocking";
|
2012-03-06 07:36:44 -05:00
|
|
|
case EINTR: return (char*) "Interrupted function call";
|
2012-03-10 17:12:31 -05:00
|
|
|
case ENOTEMPTY: return (char*) "Directory not empty";
|
2012-03-10 17:18:27 -05:00
|
|
|
case EBUSY: return (char*) "Device or resource busy";
|
2012-03-02 19:06:32 -05:00
|
|
|
case ELAKE: return (char*) "Sit by a lake";
|
2011-11-22 11:26:47 -05:00
|
|
|
default: return (char*) "Unknown error condition";
|
|
|
|
}
|
|
|
|
}
|
2011-08-05 08:25:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|