The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
common/stdint.h
"
4
5
/**
6
* unified kernel error codes.
7
*
8
* all kernel subsystems return kerr_t from fallible operations.
9
* KERR_OK (0) indicates success, all other values indicate failure.
10
* values are negative to allow direct mapping to userspace errno at
11
* the syscall boundary.
12
*/
13
typedef
enum
14
{
15
KERR_OK
= 0,
// success
16
KERR_NOMEM
= -1,
// out of memory
17
KERR_IO
= -2,
// i/o error
18
KERR_NOTFOUND
= -3,
// file or resource not found
19
KERR_PERM
= -4,
// permission denied
20
KERR_INVAL
= -5,
// invalid argument
21
KERR_BUSY
= -6,
// resource busy
22
KERR_NOSPC
= -7,
// no space left on device
23
KERR_RANGE
= -8,
// value out of range
24
KERR_EXIST
= -9,
// resource already exists
25
KERR_ISDIR
= -10,
// is a directory (expected file)
26
KERR_NOTDIR
= -11,
// not a directory (expected directory)
27
KERR_PIPE
= -12,
// broken pipe
28
KERR_NOENT
= -13,
// no such entry
29
KERR_FAULT
= -14,
// bad address (pointer validation failed)
30
KERR_NOTEMPTY
= -15,
// directory not empty
31
KERR_LOOP
= -16,
// too many symbolic links in a path
32
KERR_NOEXEC
= -17,
// not a program the kernel can start
33
KERR_FBIG
= -18,
// a file would be larger than the filesystem allows
34
}
kerr_t
;
35
36
/**
37
* check if a kerr_t value indicates success.
38
*/
39
static
inline
bool
kerr_ok(
kerr_t
err)
40
{
41
return
err ==
KERR_OK
;
42
}
43
44
/**
45
* check if a kerr_t value indicates failure.
46
*/
47
static
inline
bool
kerr_failed(
kerr_t
err)
48
{
49
return
err !=
KERR_OK
;
50
}
51
52
/**
53
* convert a kerr_t to a human-readable string for debug output.
54
* @param err the error code.
55
* @return static string describing the error.
56
*/
57
const
char
*
status_to_str
(
kerr_t
err);
stdint.h
status_to_str
const char * status_to_str(kerr_t err)
convert a kerr_t to a human-readable string for debug output.
Definition
error.c:3
kerr_t
kerr_t
unified kernel error codes.
Definition
error.h:14
KERR_NOMEM
@ KERR_NOMEM
Definition
error.h:16
KERR_NOTEMPTY
@ KERR_NOTEMPTY
Definition
error.h:30
KERR_RANGE
@ KERR_RANGE
Definition
error.h:23
KERR_NOTFOUND
@ KERR_NOTFOUND
Definition
error.h:18
KERR_NOENT
@ KERR_NOENT
Definition
error.h:28
KERR_INVAL
@ KERR_INVAL
Definition
error.h:20
KERR_EXIST
@ KERR_EXIST
Definition
error.h:24
KERR_FAULT
@ KERR_FAULT
Definition
error.h:29
KERR_FBIG
@ KERR_FBIG
Definition
error.h:33
KERR_IO
@ KERR_IO
Definition
error.h:17
KERR_NOEXEC
@ KERR_NOEXEC
Definition
error.h:32
KERR_PIPE
@ KERR_PIPE
Definition
error.h:27
KERR_BUSY
@ KERR_BUSY
Definition
error.h:21
KERR_NOTDIR
@ KERR_NOTDIR
Definition
error.h:26
KERR_NOSPC
@ KERR_NOSPC
Definition
error.h:22
KERR_LOOP
@ KERR_LOOP
Definition
error.h:31
KERR_ISDIR
@ KERR_ISDIR
Definition
error.h:25
KERR_OK
@ KERR_OK
Definition
error.h:15
KERR_PERM
@ KERR_PERM
Definition
error.h:19
src
common
error.h
Generated by
1.18.0