xref: /haiku/headers/os/support/Errors.h (revision 268f99dd7dc4bd7474a8bd2742d3f1ec1de6752a)
1686bdd59SAxel Dörfler /*
229e8fa59SJohn Scipione  * Copyright 2007-2014 Haiku, Inc. All rights reserved.
3686bdd59SAxel Dörfler  * Distributed under the terms of the MIT License.
4686bdd59SAxel Dörfler  */
552a38012Sejakowatz #ifndef _ERRORS_H
652a38012Sejakowatz #define _ERRORS_H
752a38012Sejakowatz 
8686bdd59SAxel Dörfler 
9afe886fcSDavid Reid #include <limits.h>
1052a38012Sejakowatz 
1152a38012Sejakowatz 
124a50aa51SAxel Dörfler /* Error baselines */
131f285441SIngo Weinhold #define B_GENERAL_ERROR_BASE		INT_MIN
14965aa03fSIngo Weinhold #define B_OS_ERROR_BASE				(B_GENERAL_ERROR_BASE + 0x1000)
15965aa03fSIngo Weinhold #define B_APP_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x2000)
16965aa03fSIngo Weinhold #define B_INTERFACE_ERROR_BASE		(B_GENERAL_ERROR_BASE + 0x3000)
17965aa03fSIngo Weinhold #define B_MEDIA_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x4000)
18965aa03fSIngo Weinhold 										/* - 0x41ff */
19965aa03fSIngo Weinhold #define B_TRANSLATION_ERROR_BASE	(B_GENERAL_ERROR_BASE + 0x4800)
20965aa03fSIngo Weinhold 										/* - 0x48ff */
21965aa03fSIngo Weinhold #define B_MIDI_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x5000)
22965aa03fSIngo Weinhold #define B_STORAGE_ERROR_BASE		(B_GENERAL_ERROR_BASE + 0x6000)
23965aa03fSIngo Weinhold #define B_POSIX_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x7000)
24965aa03fSIngo Weinhold #define B_MAIL_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x8000)
25965aa03fSIngo Weinhold #define B_PRINT_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x9000)
26965aa03fSIngo Weinhold #define B_DEVICE_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0xa000)
2752a38012Sejakowatz 
284a50aa51SAxel Dörfler /* Developer-defined errors start at (B_ERRORS_END+1) */
2952a38012Sejakowatz #define B_ERRORS_END				(B_GENERAL_ERROR_BASE + 0xffff)
3052a38012Sejakowatz 
314a50aa51SAxel Dörfler /* General Errors */
32965aa03fSIngo Weinhold #define B_NO_MEMORY					(B_GENERAL_ERROR_BASE + 0)
33965aa03fSIngo Weinhold #define B_IO_ERROR					(B_GENERAL_ERROR_BASE + 1)
34965aa03fSIngo Weinhold #define B_PERMISSION_DENIED			(B_GENERAL_ERROR_BASE + 2)
35965aa03fSIngo Weinhold #define B_BAD_INDEX					(B_GENERAL_ERROR_BASE + 3)
36965aa03fSIngo Weinhold #define B_BAD_TYPE					(B_GENERAL_ERROR_BASE + 4)
37965aa03fSIngo Weinhold #define B_BAD_VALUE					(B_GENERAL_ERROR_BASE + 5)
38965aa03fSIngo Weinhold #define B_MISMATCHED_VALUES			(B_GENERAL_ERROR_BASE + 6)
39965aa03fSIngo Weinhold #define B_NAME_NOT_FOUND			(B_GENERAL_ERROR_BASE + 7)
40965aa03fSIngo Weinhold #define B_NAME_IN_USE				(B_GENERAL_ERROR_BASE + 8)
41965aa03fSIngo Weinhold #define B_TIMED_OUT					(B_GENERAL_ERROR_BASE + 9)
42965aa03fSIngo Weinhold #define B_INTERRUPTED				(B_GENERAL_ERROR_BASE + 10)
43965aa03fSIngo Weinhold #define B_WOULD_BLOCK				(B_GENERAL_ERROR_BASE + 11)
44965aa03fSIngo Weinhold #define B_CANCELED					(B_GENERAL_ERROR_BASE + 12)
45965aa03fSIngo Weinhold #define B_NO_INIT					(B_GENERAL_ERROR_BASE + 13)
46d7571ebcSAxel Dörfler #define B_NOT_INITIALIZED			(B_GENERAL_ERROR_BASE + 13)
47965aa03fSIngo Weinhold #define B_BUSY						(B_GENERAL_ERROR_BASE + 14)
48965aa03fSIngo Weinhold #define B_NOT_ALLOWED				(B_GENERAL_ERROR_BASE + 15)
49965aa03fSIngo Weinhold #define B_BAD_DATA					(B_GENERAL_ERROR_BASE + 16)
50965aa03fSIngo Weinhold #define B_DONT_DO_THAT				(B_GENERAL_ERROR_BASE + 17)
5152a38012Sejakowatz 
52965aa03fSIngo Weinhold #define B_ERROR						(-1)
53965aa03fSIngo Weinhold #define B_OK						((int)0)
54965aa03fSIngo Weinhold #define B_NO_ERROR					((int)0)
5552a38012Sejakowatz 
564a50aa51SAxel Dörfler /* Kernel Kit Errors */
57965aa03fSIngo Weinhold #define B_BAD_SEM_ID				(B_OS_ERROR_BASE + 0)
58965aa03fSIngo Weinhold #define B_NO_MORE_SEMS				(B_OS_ERROR_BASE + 1)
5952a38012Sejakowatz 
60965aa03fSIngo Weinhold #define B_BAD_THREAD_ID				(B_OS_ERROR_BASE + 0x100)
61965aa03fSIngo Weinhold #define B_NO_MORE_THREADS			(B_OS_ERROR_BASE + 0x101)
62965aa03fSIngo Weinhold #define B_BAD_THREAD_STATE			(B_OS_ERROR_BASE + 0x102)
63965aa03fSIngo Weinhold #define B_BAD_TEAM_ID				(B_OS_ERROR_BASE + 0x103)
64965aa03fSIngo Weinhold #define B_NO_MORE_TEAMS				(B_OS_ERROR_BASE + 0x104)
6552a38012Sejakowatz 
66965aa03fSIngo Weinhold #define B_BAD_PORT_ID				(B_OS_ERROR_BASE + 0x200)
67965aa03fSIngo Weinhold #define B_NO_MORE_PORTS				(B_OS_ERROR_BASE + 0x201)
6852a38012Sejakowatz 
69965aa03fSIngo Weinhold #define B_BAD_IMAGE_ID				(B_OS_ERROR_BASE + 0x300)
70965aa03fSIngo Weinhold #define B_BAD_ADDRESS				(B_OS_ERROR_BASE + 0x301)
71965aa03fSIngo Weinhold #define B_NOT_AN_EXECUTABLE			(B_OS_ERROR_BASE + 0x302)
72965aa03fSIngo Weinhold #define B_MISSING_LIBRARY			(B_OS_ERROR_BASE + 0x303)
73965aa03fSIngo Weinhold #define B_MISSING_SYMBOL			(B_OS_ERROR_BASE + 0x304)
74aa4b5749SAlexander von Gluck IV #define B_UNKNOWN_EXECUTABLE		(B_OS_ERROR_BASE + 0x305)
75aa4b5749SAlexander von Gluck IV #define B_LEGACY_EXECUTABLE			(B_OS_ERROR_BASE + 0x306)
7652a38012Sejakowatz 
77965aa03fSIngo Weinhold #define B_DEBUGGER_ALREADY_INSTALLED	(B_OS_ERROR_BASE + 0x400)
7852a38012Sejakowatz 
794a50aa51SAxel Dörfler /* Application Kit Errors */
80965aa03fSIngo Weinhold #define B_BAD_REPLY							(B_APP_ERROR_BASE + 0)
81965aa03fSIngo Weinhold #define B_DUPLICATE_REPLY					(B_APP_ERROR_BASE + 1)
82965aa03fSIngo Weinhold #define B_MESSAGE_TO_SELF					(B_APP_ERROR_BASE + 2)
83965aa03fSIngo Weinhold #define B_BAD_HANDLER						(B_APP_ERROR_BASE + 3)
84965aa03fSIngo Weinhold #define B_ALREADY_RUNNING					(B_APP_ERROR_BASE + 4)
85965aa03fSIngo Weinhold #define B_LAUNCH_FAILED						(B_APP_ERROR_BASE + 5)
86965aa03fSIngo Weinhold #define B_AMBIGUOUS_APP_LAUNCH				(B_APP_ERROR_BASE + 6)
87965aa03fSIngo Weinhold #define B_UNKNOWN_MIME_TYPE					(B_APP_ERROR_BASE + 7)
88965aa03fSIngo Weinhold #define B_BAD_SCRIPT_SYNTAX					(B_APP_ERROR_BASE + 8)
89965aa03fSIngo Weinhold #define B_LAUNCH_FAILED_NO_RESOLVE_LINK		(B_APP_ERROR_BASE + 9)
90965aa03fSIngo Weinhold #define B_LAUNCH_FAILED_EXECUTABLE			(B_APP_ERROR_BASE + 10)
91965aa03fSIngo Weinhold #define B_LAUNCH_FAILED_APP_NOT_FOUND		(B_APP_ERROR_BASE + 11)
92965aa03fSIngo Weinhold #define B_LAUNCH_FAILED_APP_IN_TRASH		(B_APP_ERROR_BASE + 12)
93965aa03fSIngo Weinhold #define B_LAUNCH_FAILED_NO_PREFERRED_APP	(B_APP_ERROR_BASE + 13)
94965aa03fSIngo Weinhold #define B_LAUNCH_FAILED_FILES_APP_NOT_FOUND	(B_APP_ERROR_BASE + 14)
95965aa03fSIngo Weinhold #define B_BAD_MIME_SNIFFER_RULE				(B_APP_ERROR_BASE + 15)
96965aa03fSIngo Weinhold #define B_NOT_A_MESSAGE						(B_APP_ERROR_BASE + 16)
97965aa03fSIngo Weinhold #define B_SHUTDOWN_CANCELLED				(B_APP_ERROR_BASE + 17)
98965aa03fSIngo Weinhold #define B_SHUTTING_DOWN						(B_APP_ERROR_BASE + 18)
9952a38012Sejakowatz 
1004a50aa51SAxel Dörfler /* Storage Kit/File System Errors */
101965aa03fSIngo Weinhold #define B_FILE_ERROR						(B_STORAGE_ERROR_BASE + 0)
102*eb1d596fSAugustin Cavalier /* 1 was B_FILE_NOT_FOUND (deprecated) */
103965aa03fSIngo Weinhold #define B_FILE_EXISTS						(B_STORAGE_ERROR_BASE + 2)
104965aa03fSIngo Weinhold #define B_ENTRY_NOT_FOUND					(B_STORAGE_ERROR_BASE + 3)
105965aa03fSIngo Weinhold #define B_NAME_TOO_LONG						(B_STORAGE_ERROR_BASE + 4)
106965aa03fSIngo Weinhold #define B_NOT_A_DIRECTORY					(B_STORAGE_ERROR_BASE + 5)
107965aa03fSIngo Weinhold #define B_DIRECTORY_NOT_EMPTY				(B_STORAGE_ERROR_BASE + 6)
108965aa03fSIngo Weinhold #define B_DEVICE_FULL						(B_STORAGE_ERROR_BASE + 7)
109965aa03fSIngo Weinhold #define B_READ_ONLY_DEVICE					(B_STORAGE_ERROR_BASE + 8)
110965aa03fSIngo Weinhold #define B_IS_A_DIRECTORY					(B_STORAGE_ERROR_BASE + 9)
111965aa03fSIngo Weinhold #define B_NO_MORE_FDS						(B_STORAGE_ERROR_BASE + 10)
112965aa03fSIngo Weinhold #define B_CROSS_DEVICE_LINK					(B_STORAGE_ERROR_BASE + 11)
113965aa03fSIngo Weinhold #define B_LINK_LIMIT						(B_STORAGE_ERROR_BASE + 12)
114965aa03fSIngo Weinhold #define B_BUSTED_PIPE						(B_STORAGE_ERROR_BASE + 13)
115965aa03fSIngo Weinhold #define B_UNSUPPORTED						(B_STORAGE_ERROR_BASE + 14)
116965aa03fSIngo Weinhold #define B_PARTITION_TOO_SMALL				(B_STORAGE_ERROR_BASE + 15)
117dec78bb2SIngo Weinhold #define B_PARTIAL_READ						(B_STORAGE_ERROR_BASE + 16)
118dec78bb2SIngo Weinhold #define B_PARTIAL_WRITE						(B_STORAGE_ERROR_BASE + 17)
11952a38012Sejakowatz 
1204a50aa51SAxel Dörfler /* POSIX Errors */
12139d58e2fSIngo Weinhold #ifdef B_USE_POSITIVE_POSIX_ERRORS
12239d58e2fSIngo Weinhold #	define B_TO_POSIX_ERROR(error)		(-(error))
12339d58e2fSIngo Weinhold #	define B_FROM_POSIX_ERROR(error)	(-(error))
12439d58e2fSIngo Weinhold #else
12539d58e2fSIngo Weinhold #	define B_TO_POSIX_ERROR(error)		(error)
12639d58e2fSIngo Weinhold #	define B_FROM_POSIX_ERROR(error)	(error)
12739d58e2fSIngo Weinhold #endif
12839d58e2fSIngo Weinhold 
12939d58e2fSIngo Weinhold #define B_POSIX_ENOMEM	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 0)
13039d58e2fSIngo Weinhold #define E2BIG			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 1)
13139d58e2fSIngo Weinhold #define ECHILD			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 2)
13239d58e2fSIngo Weinhold #define EDEADLK			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 3)
13339d58e2fSIngo Weinhold #define EFBIG			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 4)
13439d58e2fSIngo Weinhold #define EMLINK			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 5)
13539d58e2fSIngo Weinhold #define ENFILE			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 6)
13639d58e2fSIngo Weinhold #define ENODEV			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 7)
13739d58e2fSIngo Weinhold #define ENOLCK			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 8)
13839d58e2fSIngo Weinhold #define ENOSYS			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 9)
13939d58e2fSIngo Weinhold #define ENOTTY			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 10)
14039d58e2fSIngo Weinhold #define ENXIO			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 11)
14139d58e2fSIngo Weinhold #define ESPIPE			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 12)
14239d58e2fSIngo Weinhold #define ESRCH			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 13)
14339d58e2fSIngo Weinhold #define EFPOS			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 14)
14439d58e2fSIngo Weinhold #define ESIGPARM		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 15)
14539d58e2fSIngo Weinhold #define EDOM			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 16)
14639d58e2fSIngo Weinhold #define ERANGE			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 17)
14739d58e2fSIngo Weinhold #define EPROTOTYPE		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 18)
14839d58e2fSIngo Weinhold #define EPROTONOSUPPORT	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 19)
14939d58e2fSIngo Weinhold #define EPFNOSUPPORT	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 20)
15039d58e2fSIngo Weinhold #define EAFNOSUPPORT	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 21)
15139d58e2fSIngo Weinhold #define EADDRINUSE		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 22)
15239d58e2fSIngo Weinhold #define EADDRNOTAVAIL	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 23)
15339d58e2fSIngo Weinhold #define ENETDOWN		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 24)
15439d58e2fSIngo Weinhold #define ENETUNREACH		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 25)
15539d58e2fSIngo Weinhold #define ENETRESET		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 26)
15639d58e2fSIngo Weinhold #define ECONNABORTED	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 27)
15739d58e2fSIngo Weinhold #define ECONNRESET		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 28)
15839d58e2fSIngo Weinhold #define EISCONN			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 29)
15939d58e2fSIngo Weinhold #define ENOTCONN		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 30)
16039d58e2fSIngo Weinhold #define ESHUTDOWN		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 31)
16139d58e2fSIngo Weinhold #define ECONNREFUSED	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 32)
16239d58e2fSIngo Weinhold #define EHOSTUNREACH	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 33)
16339d58e2fSIngo Weinhold #define ENOPROTOOPT		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 34)
16439d58e2fSIngo Weinhold #define ENOBUFS			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 35)
16539d58e2fSIngo Weinhold #define EINPROGRESS		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 36)
16639d58e2fSIngo Weinhold #define EALREADY		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 37)
16739d58e2fSIngo Weinhold #define EILSEQ			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 38)
16839d58e2fSIngo Weinhold #define ENOMSG			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 39)
16939d58e2fSIngo Weinhold #define ESTALE			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 40)
17039d58e2fSIngo Weinhold #define EOVERFLOW		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 41)
17139d58e2fSIngo Weinhold #define EMSGSIZE		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 42)
17239d58e2fSIngo Weinhold #define EOPNOTSUPP		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 43)
17339d58e2fSIngo Weinhold #define ENOTSOCK		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 44)
17439d58e2fSIngo Weinhold #define EHOSTDOWN		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 45)
17539d58e2fSIngo Weinhold #define EBADMSG			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 46)
17639d58e2fSIngo Weinhold #define ECANCELED		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 47)
17739d58e2fSIngo Weinhold #define EDESTADDRREQ	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 48)
17839d58e2fSIngo Weinhold #define EDQUOT			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 49)
17939d58e2fSIngo Weinhold #define EIDRM			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 50)
18039d58e2fSIngo Weinhold #define EMULTIHOP		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 51)
18139d58e2fSIngo Weinhold #define ENODATA			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 52)
18239d58e2fSIngo Weinhold #define ENOLINK			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 53)
18339d58e2fSIngo Weinhold #define ENOSR			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 54)
18439d58e2fSIngo Weinhold #define ENOSTR			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 55)
18539d58e2fSIngo Weinhold #define ENOTSUP			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 56)
18639d58e2fSIngo Weinhold #define EPROTO			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 57)
18739d58e2fSIngo Weinhold #define ETIME			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 58)
18839d58e2fSIngo Weinhold #define ETXTBSY			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 59)
1897c447600SIngo Weinhold #define ENOATTR			B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 60)
19052b4ed60SJérôme Duval #define ENOTRECOVERABLE	B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 61)
19152b4ed60SJérôme Duval #define EOWNERDEAD		B_TO_POSIX_ERROR(B_POSIX_ERROR_BASE + 62)
19239d58e2fSIngo Weinhold 
19339d58e2fSIngo Weinhold /* B_NO_MEMORY (0x80000000) can't be negated, so it needs special handling */
19439d58e2fSIngo Weinhold #ifdef B_USE_POSITIVE_POSIX_ERRORS
19539d58e2fSIngo Weinhold #	define ENOMEM		B_POSIX_ENOMEM
19639d58e2fSIngo Weinhold #else
19739d58e2fSIngo Weinhold #	define ENOMEM		B_NO_MEMORY
19839d58e2fSIngo Weinhold #endif
1999f20e178SJérôme Duval 
2004a50aa51SAxel Dörfler /* POSIX errors that can be mapped to BeOS error codes */
20139d58e2fSIngo Weinhold #define EACCES			B_TO_POSIX_ERROR(B_PERMISSION_DENIED)
20239d58e2fSIngo Weinhold #define EINTR			B_TO_POSIX_ERROR(B_INTERRUPTED)
20339d58e2fSIngo Weinhold #define EIO				B_TO_POSIX_ERROR(B_IO_ERROR)
20439d58e2fSIngo Weinhold #define EBUSY			B_TO_POSIX_ERROR(B_BUSY)
20539d58e2fSIngo Weinhold #define EFAULT			B_TO_POSIX_ERROR(B_BAD_ADDRESS)
20639d58e2fSIngo Weinhold #define ETIMEDOUT		B_TO_POSIX_ERROR(B_TIMED_OUT)
20739d58e2fSIngo Weinhold #define EAGAIN 			B_TO_POSIX_ERROR(B_WOULD_BLOCK)	/* SysV compatibility */
20839d58e2fSIngo Weinhold #define EWOULDBLOCK 	B_TO_POSIX_ERROR(B_WOULD_BLOCK)	/* BSD compatibility */
20939d58e2fSIngo Weinhold #define EBADF			B_TO_POSIX_ERROR(B_FILE_ERROR)
21039d58e2fSIngo Weinhold #define EEXIST			B_TO_POSIX_ERROR(B_FILE_EXISTS)
21139d58e2fSIngo Weinhold #define EINVAL			B_TO_POSIX_ERROR(B_BAD_VALUE)
21239d58e2fSIngo Weinhold #define ENAMETOOLONG	B_TO_POSIX_ERROR(B_NAME_TOO_LONG)
21339d58e2fSIngo Weinhold #define ENOENT			B_TO_POSIX_ERROR(B_ENTRY_NOT_FOUND)
21439d58e2fSIngo Weinhold #define EPERM			B_TO_POSIX_ERROR(B_NOT_ALLOWED)
21539d58e2fSIngo Weinhold #define ENOTDIR			B_TO_POSIX_ERROR(B_NOT_A_DIRECTORY)
21639d58e2fSIngo Weinhold #define EISDIR			B_TO_POSIX_ERROR(B_IS_A_DIRECTORY)
21739d58e2fSIngo Weinhold #define ENOTEMPTY		B_TO_POSIX_ERROR(B_DIRECTORY_NOT_EMPTY)
21839d58e2fSIngo Weinhold #define ENOSPC			B_TO_POSIX_ERROR(B_DEVICE_FULL)
21939d58e2fSIngo Weinhold #define EROFS			B_TO_POSIX_ERROR(B_READ_ONLY_DEVICE)
22039d58e2fSIngo Weinhold #define EMFILE			B_TO_POSIX_ERROR(B_NO_MORE_FDS)
22139d58e2fSIngo Weinhold #define EXDEV			B_TO_POSIX_ERROR(B_CROSS_DEVICE_LINK)
22239d58e2fSIngo Weinhold #define ELOOP			B_TO_POSIX_ERROR(B_LINK_LIMIT)
22339d58e2fSIngo Weinhold #define ENOEXEC			B_TO_POSIX_ERROR(B_NOT_AN_EXECUTABLE)
22439d58e2fSIngo Weinhold #define EPIPE			B_TO_POSIX_ERROR(B_BUSTED_PIPE)
225afe886fcSDavid Reid 
2264a50aa51SAxel Dörfler /* new error codes that can be mapped to POSIX errors */
22739d58e2fSIngo Weinhold #define B_BUFFER_OVERFLOW			B_FROM_POSIX_ERROR(EOVERFLOW)
22839d58e2fSIngo Weinhold #define B_TOO_MANY_ARGS				B_FROM_POSIX_ERROR(E2BIG)
22939d58e2fSIngo Weinhold #define B_FILE_TOO_LARGE			B_FROM_POSIX_ERROR(EFBIG)
23039d58e2fSIngo Weinhold #define B_RESULT_NOT_REPRESENTABLE	B_FROM_POSIX_ERROR(ERANGE)
23139d58e2fSIngo Weinhold #define B_DEVICE_NOT_FOUND			B_FROM_POSIX_ERROR(ENODEV)
23239d58e2fSIngo Weinhold #define B_NOT_SUPPORTED				B_FROM_POSIX_ERROR(EOPNOTSUPP)
23368145d0dSAxel Dörfler 
2344a50aa51SAxel Dörfler /* Media Kit Errors */
235965aa03fSIngo Weinhold #define B_STREAM_NOT_FOUND				(B_MEDIA_ERROR_BASE + 0)
236965aa03fSIngo Weinhold #define B_SERVER_NOT_FOUND				(B_MEDIA_ERROR_BASE + 1)
237965aa03fSIngo Weinhold #define B_RESOURCE_NOT_FOUND			(B_MEDIA_ERROR_BASE + 2)
238965aa03fSIngo Weinhold #define B_RESOURCE_UNAVAILABLE			(B_MEDIA_ERROR_BASE + 3)
239965aa03fSIngo Weinhold #define B_BAD_SUBSCRIBER				(B_MEDIA_ERROR_BASE + 4)
240965aa03fSIngo Weinhold #define B_SUBSCRIBER_NOT_ENTERED		(B_MEDIA_ERROR_BASE + 5)
241965aa03fSIngo Weinhold #define B_BUFFER_NOT_AVAILABLE			(B_MEDIA_ERROR_BASE + 6)
242965aa03fSIngo Weinhold #define B_LAST_BUFFER_ERROR				(B_MEDIA_ERROR_BASE + 7)
24352a38012Sejakowatz 
244d4d27facSStephan Aßmus #define B_MEDIA_SYSTEM_FAILURE			(B_MEDIA_ERROR_BASE + 100)
245d4d27facSStephan Aßmus #define B_MEDIA_BAD_NODE				(B_MEDIA_ERROR_BASE + 101)
246d4d27facSStephan Aßmus #define B_MEDIA_NODE_BUSY				(B_MEDIA_ERROR_BASE + 102)
247d4d27facSStephan Aßmus #define B_MEDIA_BAD_FORMAT				(B_MEDIA_ERROR_BASE + 103)
248d4d27facSStephan Aßmus #define B_MEDIA_BAD_BUFFER				(B_MEDIA_ERROR_BASE + 104)
249d4d27facSStephan Aßmus #define B_MEDIA_TOO_MANY_NODES			(B_MEDIA_ERROR_BASE + 105)
250d4d27facSStephan Aßmus #define B_MEDIA_TOO_MANY_BUFFERS		(B_MEDIA_ERROR_BASE + 106)
251d4d27facSStephan Aßmus #define B_MEDIA_NODE_ALREADY_EXISTS		(B_MEDIA_ERROR_BASE + 107)
252d4d27facSStephan Aßmus #define B_MEDIA_BUFFER_ALREADY_EXISTS	(B_MEDIA_ERROR_BASE + 108)
253d4d27facSStephan Aßmus #define B_MEDIA_CANNOT_SEEK				(B_MEDIA_ERROR_BASE + 109)
254d4d27facSStephan Aßmus #define B_MEDIA_CANNOT_CHANGE_RUN_MODE	(B_MEDIA_ERROR_BASE + 110)
255d4d27facSStephan Aßmus #define B_MEDIA_APP_ALREADY_REGISTERED	(B_MEDIA_ERROR_BASE + 111)
256d4d27facSStephan Aßmus #define B_MEDIA_APP_NOT_REGISTERED		(B_MEDIA_ERROR_BASE + 112)
257d4d27facSStephan Aßmus #define B_MEDIA_CANNOT_RECLAIM_BUFFERS	(B_MEDIA_ERROR_BASE + 113)
258d4d27facSStephan Aßmus #define B_MEDIA_BUFFERS_NOT_RECLAIMED	(B_MEDIA_ERROR_BASE + 114)
259d4d27facSStephan Aßmus #define B_MEDIA_TIME_SOURCE_STOPPED		(B_MEDIA_ERROR_BASE + 115)
260d4d27facSStephan Aßmus #define B_MEDIA_TIME_SOURCE_BUSY		(B_MEDIA_ERROR_BASE + 116)
261d4d27facSStephan Aßmus #define B_MEDIA_BAD_SOURCE				(B_MEDIA_ERROR_BASE + 117)
262d4d27facSStephan Aßmus #define B_MEDIA_BAD_DESTINATION			(B_MEDIA_ERROR_BASE + 118)
263d4d27facSStephan Aßmus #define B_MEDIA_ALREADY_CONNECTED		(B_MEDIA_ERROR_BASE + 119)
264d4d27facSStephan Aßmus #define B_MEDIA_NOT_CONNECTED			(B_MEDIA_ERROR_BASE + 120)
265d4d27facSStephan Aßmus #define B_MEDIA_BAD_CLIP_FORMAT			(B_MEDIA_ERROR_BASE + 121)
266d4d27facSStephan Aßmus #define B_MEDIA_ADDON_FAILED			(B_MEDIA_ERROR_BASE + 122)
267d4d27facSStephan Aßmus #define B_MEDIA_ADDON_DISABLED			(B_MEDIA_ERROR_BASE + 123)
268d4d27facSStephan Aßmus #define B_MEDIA_CHANGE_IN_PROGRESS		(B_MEDIA_ERROR_BASE + 124)
269d4d27facSStephan Aßmus #define B_MEDIA_STALE_CHANGE_COUNT		(B_MEDIA_ERROR_BASE + 125)
270d4d27facSStephan Aßmus #define B_MEDIA_ADDON_RESTRICTED		(B_MEDIA_ERROR_BASE + 126)
271d4d27facSStephan Aßmus #define B_MEDIA_NO_HANDLER				(B_MEDIA_ERROR_BASE + 127)
272d4d27facSStephan Aßmus #define B_MEDIA_DUPLICATE_FORMAT		(B_MEDIA_ERROR_BASE + 128)
273d4d27facSStephan Aßmus #define B_MEDIA_REALTIME_DISABLED		(B_MEDIA_ERROR_BASE + 129)
274d4d27facSStephan Aßmus #define B_MEDIA_REALTIME_UNAVAILABLE	(B_MEDIA_ERROR_BASE + 130)
275d4d27facSStephan Aßmus 
2764a50aa51SAxel Dörfler /* Mail Kit Errors */
277965aa03fSIngo Weinhold #define B_MAIL_NO_DAEMON				(B_MAIL_ERROR_BASE + 0)
278965aa03fSIngo Weinhold #define B_MAIL_UNKNOWN_USER				(B_MAIL_ERROR_BASE + 1)
279965aa03fSIngo Weinhold #define B_MAIL_WRONG_PASSWORD			(B_MAIL_ERROR_BASE + 2)
280965aa03fSIngo Weinhold #define B_MAIL_UNKNOWN_HOST				(B_MAIL_ERROR_BASE + 3)
281965aa03fSIngo Weinhold #define B_MAIL_ACCESS_ERROR				(B_MAIL_ERROR_BASE + 4)
282965aa03fSIngo Weinhold #define B_MAIL_UNKNOWN_FIELD			(B_MAIL_ERROR_BASE + 5)
283965aa03fSIngo Weinhold #define B_MAIL_NO_RECIPIENT				(B_MAIL_ERROR_BASE + 6)
284965aa03fSIngo Weinhold #define B_MAIL_INVALID_MAIL				(B_MAIL_ERROR_BASE + 7)
28552a38012Sejakowatz 
2864a50aa51SAxel Dörfler /* Printing Errors */
287965aa03fSIngo Weinhold #define B_NO_PRINT_SERVER				(B_PRINT_ERROR_BASE + 0)
28852a38012Sejakowatz 
2894a50aa51SAxel Dörfler /* Device Kit Errors */
290965aa03fSIngo Weinhold #define B_DEV_INVALID_IOCTL				(B_DEVICE_ERROR_BASE + 0)
291965aa03fSIngo Weinhold #define B_DEV_NO_MEMORY					(B_DEVICE_ERROR_BASE + 1)
292965aa03fSIngo Weinhold #define B_DEV_BAD_DRIVE_NUM				(B_DEVICE_ERROR_BASE + 2)
293965aa03fSIngo Weinhold #define B_DEV_NO_MEDIA					(B_DEVICE_ERROR_BASE + 3)
294965aa03fSIngo Weinhold #define B_DEV_UNREADABLE				(B_DEVICE_ERROR_BASE + 4)
295965aa03fSIngo Weinhold #define B_DEV_FORMAT_ERROR				(B_DEVICE_ERROR_BASE + 5)
296965aa03fSIngo Weinhold #define B_DEV_TIMEOUT					(B_DEVICE_ERROR_BASE + 6)
297965aa03fSIngo Weinhold #define B_DEV_RECALIBRATE_ERROR			(B_DEVICE_ERROR_BASE + 7)
298965aa03fSIngo Weinhold #define B_DEV_SEEK_ERROR				(B_DEVICE_ERROR_BASE + 8)
299965aa03fSIngo Weinhold #define B_DEV_ID_ERROR					(B_DEVICE_ERROR_BASE + 9)
300965aa03fSIngo Weinhold #define B_DEV_READ_ERROR				(B_DEVICE_ERROR_BASE + 10)
301965aa03fSIngo Weinhold #define B_DEV_WRITE_ERROR				(B_DEVICE_ERROR_BASE + 11)
302965aa03fSIngo Weinhold #define B_DEV_NOT_READY					(B_DEVICE_ERROR_BASE + 12)
303965aa03fSIngo Weinhold #define B_DEV_MEDIA_CHANGED				(B_DEVICE_ERROR_BASE + 13)
304965aa03fSIngo Weinhold #define B_DEV_MEDIA_CHANGE_REQUESTED	(B_DEVICE_ERROR_BASE + 14)
305965aa03fSIngo Weinhold #define B_DEV_RESOURCE_CONFLICT			(B_DEVICE_ERROR_BASE + 15)
306965aa03fSIngo Weinhold #define B_DEV_CONFIGURATION_ERROR		(B_DEVICE_ERROR_BASE + 16)
307965aa03fSIngo Weinhold #define B_DEV_DISABLED_BY_USER			(B_DEVICE_ERROR_BASE + 17)
308965aa03fSIngo Weinhold #define B_DEV_DOOR_OPEN					(B_DEVICE_ERROR_BASE + 18)
309a4733dd5SAxel Dörfler 
310965aa03fSIngo Weinhold #define B_DEV_INVALID_PIPE				(B_DEVICE_ERROR_BASE + 19)
311965aa03fSIngo Weinhold #define B_DEV_CRC_ERROR					(B_DEVICE_ERROR_BASE + 20)
312965aa03fSIngo Weinhold #define B_DEV_STALLED					(B_DEVICE_ERROR_BASE + 21)
313965aa03fSIngo Weinhold #define B_DEV_BAD_PID					(B_DEVICE_ERROR_BASE + 22)
314965aa03fSIngo Weinhold #define B_DEV_UNEXPECTED_PID			(B_DEVICE_ERROR_BASE + 23)
315965aa03fSIngo Weinhold #define B_DEV_DATA_OVERRUN				(B_DEVICE_ERROR_BASE + 24)
316965aa03fSIngo Weinhold #define B_DEV_DATA_UNDERRUN				(B_DEVICE_ERROR_BASE + 25)
317965aa03fSIngo Weinhold #define B_DEV_FIFO_OVERRUN				(B_DEVICE_ERROR_BASE + 26)
318965aa03fSIngo Weinhold #define B_DEV_FIFO_UNDERRUN				(B_DEVICE_ERROR_BASE + 27)
319965aa03fSIngo Weinhold #define B_DEV_PENDING					(B_DEVICE_ERROR_BASE + 28)
320965aa03fSIngo Weinhold #define B_DEV_MULTIPLE_ERRORS			(B_DEVICE_ERROR_BASE + 29)
321965aa03fSIngo Weinhold #define B_DEV_TOO_LATE					(B_DEVICE_ERROR_BASE + 30)
32252a38012Sejakowatz 
323d7571ebcSAxel Dörfler /* Translation Kit Errors */
324d7571ebcSAxel Dörfler #define B_TRANSLATION_BASE_ERROR		(B_TRANSLATION_ERROR_BASE + 0)
325d7571ebcSAxel Dörfler #define B_NO_TRANSLATOR					(B_TRANSLATION_ERROR_BASE + 1)
326d7571ebcSAxel Dörfler #define B_ILLEGAL_DATA					(B_TRANSLATION_ERROR_BASE + 2)
327d7571ebcSAxel Dörfler 
32839d58e2fSIngo Weinhold 
32939d58e2fSIngo Weinhold #define B_TO_POSITIVE_ERROR(error)	_to_positive_error(error)
33039d58e2fSIngo Weinhold #define B_TO_NEGATIVE_ERROR(error)	_to_negative_error(error)
33139d58e2fSIngo Weinhold 
33239d58e2fSIngo Weinhold 
33339d58e2fSIngo Weinhold #ifdef __cplusplus
33439d58e2fSIngo Weinhold extern "C" {
33539d58e2fSIngo Weinhold #endif
33639d58e2fSIngo Weinhold 
33739d58e2fSIngo Weinhold int _to_positive_error(int error);
33839d58e2fSIngo Weinhold int _to_negative_error(int error);
33939d58e2fSIngo Weinhold 
34039d58e2fSIngo Weinhold #ifdef __cplusplus
34139d58e2fSIngo Weinhold }
34239d58e2fSIngo Weinhold #endif
34339d58e2fSIngo Weinhold 
3444a50aa51SAxel Dörfler #endif	/* _ERRORS_H */
345