Doug Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 1 | // Copyright 2016 The Fuchsia Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Adam Barth | 57eacf5 | 2020-11-04 00:38:09 +0000 | [diff] [blame] | 5 | #ifndef SYSROOT_ZIRCON_ERRORS_H_ |
| 6 | #define SYSROOT_ZIRCON_ERRORS_H_ |
Doug Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 7 | |
| 8 | // Zircon statuses are signed 32 bit integers. The space of values is |
| 9 | // divided as follows: |
| 10 | // - The zero value is for the OK status. |
| 11 | // - Negative values are defined by the system, in this file. |
| 12 | // - Positive values are reserved for protocol-specific error values, |
| 13 | // and will never be defined by the system. |
| 14 | |
| 15 | #define ZX_OK (0) |
| 16 | |
| 17 | // ======= Internal failures ======= |
| 18 | // ZX_ERR_INTERNAL: The system encountered an otherwise unspecified error |
| 19 | // while performing the operation. |
| 20 | #define ZX_ERR_INTERNAL (-1) |
| 21 | |
| 22 | // ZX_ERR_NOT_SUPPORTED: The operation is not implemented, supported, |
| 23 | // or enabled. |
| 24 | #define ZX_ERR_NOT_SUPPORTED (-2) |
| 25 | |
| 26 | // ZX_ERR_NO_RESOURCES: The system was not able to allocate some resource |
| 27 | // needed for the operation. |
| 28 | #define ZX_ERR_NO_RESOURCES (-3) |
| 29 | |
| 30 | // ZX_ERR_NO_MEMORY: The system was not able to allocate memory needed |
| 31 | // for the operation. |
| 32 | #define ZX_ERR_NO_MEMORY (-4) |
| 33 | |
| 34 | // -5 used to be ZX_ERR_CALL_FAILED. |
| 35 | |
| 36 | // ZX_ERR_INTERNAL_INTR_RETRY: The system call was interrupted, but should be |
| 37 | // retried. This should not be seen outside of the VDSO. |
| 38 | #define ZX_ERR_INTERNAL_INTR_RETRY (-6) |
| 39 | |
| 40 | // ======= Parameter errors ======= |
| 41 | // ZX_ERR_INVALID_ARGS: an argument is invalid, ex. null pointer |
| 42 | #define ZX_ERR_INVALID_ARGS (-10) |
| 43 | |
| 44 | // ZX_ERR_BAD_HANDLE: A specified handle value does not refer to a handle. |
| 45 | #define ZX_ERR_BAD_HANDLE (-11) |
| 46 | |
| 47 | // ZX_ERR_WRONG_TYPE: The subject of the operation is the wrong type to |
| 48 | // perform the operation. |
| 49 | // Example: Attempting a message_read on a thread handle. |
| 50 | #define ZX_ERR_WRONG_TYPE (-12) |
| 51 | |
| 52 | // ZX_ERR_BAD_SYSCALL: The specified syscall number is invalid. |
| 53 | #define ZX_ERR_BAD_SYSCALL (-13) |
| 54 | |
| 55 | // ZX_ERR_OUT_OF_RANGE: An argument is outside the valid range for this |
| 56 | // operation. |
| 57 | #define ZX_ERR_OUT_OF_RANGE (-14) |
| 58 | |
| 59 | // ZX_ERR_BUFFER_TOO_SMALL: A caller provided buffer is too small for |
| 60 | // this operation. |
| 61 | #define ZX_ERR_BUFFER_TOO_SMALL (-15) |
| 62 | |
| 63 | // ======= Precondition or state errors ======= |
| 64 | // ZX_ERR_BAD_STATE: operation failed because the current state of the |
| 65 | // object does not allow it, or a precondition of the operation is |
| 66 | // not satisfied |
| 67 | #define ZX_ERR_BAD_STATE (-20) |
| 68 | |
| 69 | // ZX_ERR_TIMED_OUT: The time limit for the operation elapsed before |
| 70 | // the operation completed. |
| 71 | #define ZX_ERR_TIMED_OUT (-21) |
| 72 | |
| 73 | // ZX_ERR_SHOULD_WAIT: The operation cannot be performed currently but |
| 74 | // potentially could succeed if the caller waits for a prerequisite |
| 75 | // to be satisfied, for example waiting for a handle to be readable |
| 76 | // or writable. |
| 77 | // Example: Attempting to read from a channel that has no |
| 78 | // messages waiting but has an open remote will return ZX_ERR_SHOULD_WAIT. |
| 79 | // Attempting to read from a channel that has no messages waiting |
| 80 | // and has a closed remote end will return ZX_ERR_PEER_CLOSED. |
| 81 | #define ZX_ERR_SHOULD_WAIT (-22) |
| 82 | |
| 83 | // ZX_ERR_CANCELED: The in-progress operation (e.g. a wait) has been |
| 84 | // canceled. |
| 85 | #define ZX_ERR_CANCELED (-23) |
| 86 | |
| 87 | // ZX_ERR_PEER_CLOSED: The operation failed because the remote end of the |
| 88 | // subject of the operation was closed. |
| 89 | #define ZX_ERR_PEER_CLOSED (-24) |
| 90 | |
| 91 | // ZX_ERR_NOT_FOUND: The requested entity is not found. |
| 92 | #define ZX_ERR_NOT_FOUND (-25) |
| 93 | |
| 94 | // ZX_ERR_ALREADY_EXISTS: An object with the specified identifier |
| 95 | // already exists. |
| 96 | // Example: Attempting to create a file when a file already exists |
| 97 | // with that name. |
| 98 | #define ZX_ERR_ALREADY_EXISTS (-26) |
| 99 | |
| 100 | // ZX_ERR_ALREADY_BOUND: The operation failed because the named entity |
| 101 | // is already owned or controlled by another entity. The operation |
| 102 | // could succeed later if the current owner releases the entity. |
| 103 | #define ZX_ERR_ALREADY_BOUND (-27) |
| 104 | |
| 105 | // ZX_ERR_UNAVAILABLE: The subject of the operation is currently unable |
| 106 | // to perform the operation. |
| 107 | // Note: This is used when there's no direct way for the caller to |
| 108 | // observe when the subject will be able to perform the operation |
| 109 | // and should thus retry. |
| 110 | #define ZX_ERR_UNAVAILABLE (-28) |
| 111 | |
Doug Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 112 | // ======= Permission check errors ======= |
| 113 | // ZX_ERR_ACCESS_DENIED: The caller did not have permission to perform |
| 114 | // the specified operation. |
| 115 | #define ZX_ERR_ACCESS_DENIED (-30) |
| 116 | |
| 117 | // ======= Input-output errors ======= |
| 118 | // ZX_ERR_IO: Otherwise unspecified error occurred during I/O. |
| 119 | #define ZX_ERR_IO (-40) |
| 120 | |
| 121 | // ZX_ERR_REFUSED: The entity the I/O operation is being performed on |
| 122 | // rejected the operation. |
| 123 | // Example: an I2C device NAK'ing a transaction or a disk controller |
| 124 | // rejecting an invalid command, or a stalled USB endpoint. |
| 125 | #define ZX_ERR_IO_REFUSED (-41) |
| 126 | |
| 127 | // ZX_ERR_IO_DATA_INTEGRITY: The data in the operation failed an integrity |
| 128 | // check and is possibly corrupted. |
| 129 | // Example: CRC or Parity error. |
| 130 | #define ZX_ERR_IO_DATA_INTEGRITY (-42) |
| 131 | |
| 132 | // ZX_ERR_IO_DATA_LOSS: The data in the operation is currently unavailable |
| 133 | // and may be permanently lost. |
| 134 | // Example: A disk block is irrecoverably damaged. |
| 135 | #define ZX_ERR_IO_DATA_LOSS (-43) |
| 136 | |
| 137 | // ZX_ERR_IO_NOT_PRESENT: The device is no longer available (has been |
| 138 | // unplugged from the system, powered down, or the driver has been |
| 139 | // unloaded) |
| 140 | #define ZX_ERR_IO_NOT_PRESENT (-44) |
| 141 | |
| 142 | // ZX_ERR_IO_OVERRUN: More data was received from the device than expected. |
| 143 | // Example: a USB "babble" error due to a device sending more data than |
| 144 | // the host queued to receive. |
| 145 | #define ZX_ERR_IO_OVERRUN (-45) |
| 146 | |
| 147 | // ZX_ERR_IO_MISSED_DEADLINE: An operation did not complete within the required timeframe. |
| 148 | // Example: A USB isochronous transfer that failed to complete due to an overrun or underrun. |
| 149 | #define ZX_ERR_IO_MISSED_DEADLINE (-46) |
| 150 | |
| 151 | // ZX_ERR_IO_INVALID: The data in the operation is invalid parameter or is out of range. |
| 152 | // Example: A USB transfer that failed to complete with TRB Error |
| 153 | #define ZX_ERR_IO_INVALID (-47) |
| 154 | |
| 155 | // ======== Filesystem Errors ======== |
| 156 | // ZX_ERR_BAD_PATH: Path name is too long. |
| 157 | #define ZX_ERR_BAD_PATH (-50) |
| 158 | |
| 159 | // ZX_ERR_NOT_DIR: Object is not a directory or does not support |
| 160 | // directory operations. |
| 161 | // Example: Attempted to open a file as a directory or |
| 162 | // attempted to do directory operations on a file. |
| 163 | #define ZX_ERR_NOT_DIR (-51) |
| 164 | |
| 165 | // ZX_ERR_NOT_FILE: Object is not a regular file. |
| 166 | #define ZX_ERR_NOT_FILE (-52) |
| 167 | |
| 168 | // ZX_ERR_FILE_BIG: This operation would cause a file to exceed a |
| 169 | // filesystem-specific size limit |
| 170 | #define ZX_ERR_FILE_BIG (-53) |
| 171 | |
| 172 | // ZX_ERR_NO_SPACE: Filesystem or device space is exhausted. |
| 173 | #define ZX_ERR_NO_SPACE (-54) |
| 174 | |
| 175 | // ZX_ERR_NOT_EMPTY: Directory is not empty. |
| 176 | #define ZX_ERR_NOT_EMPTY (-55) |
| 177 | |
| 178 | // ======== Flow Control ======== |
| 179 | // These are not errors, as such, and will never be returned |
| 180 | // by a syscall or public API. They exist to allow callbacks |
| 181 | // to request changes in operation. |
| 182 | // |
| 183 | // ZX_ERR_STOP: Do not call again. |
| 184 | // Example: A notification callback will be called on every |
| 185 | // event until it returns something other than ZX_OK. |
| 186 | // This status allows differentiation between "stop due to |
| 187 | // an error" and "stop because the work is done." |
| 188 | #define ZX_ERR_STOP (-60) |
| 189 | |
| 190 | // ZX_ERR_NEXT: Advance to the next item. |
| 191 | // Example: A notification callback will use this response |
| 192 | // to indicate it did not "consume" an item passed to it, |
| 193 | // but by choice, not due to an error condition. |
| 194 | #define ZX_ERR_NEXT (-61) |
| 195 | |
| 196 | // ZX_ERR_ASYNC: Ownership of the item has moved to an asynchronous worker. |
| 197 | // |
| 198 | // Unlike ZX_ERR_STOP, which implies that iteration on an object |
| 199 | // should stop, and ZX_ERR_NEXT, which implies that iteration |
| 200 | // should continue to the next item, ZX_ERR_ASYNC implies |
| 201 | // that an asynchronous worker is responsible for continuing iteration. |
| 202 | // |
| 203 | // Example: A notification callback will be called on every |
| 204 | // event, but one event needs to handle some work asynchronously |
| 205 | // before it can continue. ZX_ERR_ASYNC implies the worker is |
| 206 | // responsible for resuming iteration once its work has completed. |
| 207 | #define ZX_ERR_ASYNC (-62) |
| 208 | |
| 209 | // ======== Network-related errors ======== |
| 210 | |
| 211 | // ZX_ERR_PROTOCOL_NOT_SUPPORTED: Specified protocol is not |
| 212 | // supported. |
| 213 | #define ZX_ERR_PROTOCOL_NOT_SUPPORTED (-70) |
| 214 | |
| 215 | // ZX_ERR_ADDRESS_UNREACHABLE: Host is unreachable. |
| 216 | #define ZX_ERR_ADDRESS_UNREACHABLE (-71) |
| 217 | |
| 218 | // ZX_ERR_ADDRESS_IN_USE: Address is being used by someone else. |
| 219 | #define ZX_ERR_ADDRESS_IN_USE (-72) |
| 220 | |
| 221 | // ZX_ERR_NOT_CONNECTED: Socket is not connected. |
| 222 | #define ZX_ERR_NOT_CONNECTED (-73) |
| 223 | |
| 224 | // ZX_ERR_CONNECTION_REFUSED: Remote peer rejected the connection. |
| 225 | #define ZX_ERR_CONNECTION_REFUSED (-74) |
| 226 | |
| 227 | // ZX_ERR_CONNECTION_RESET: Connection was reset. |
| 228 | #define ZX_ERR_CONNECTION_RESET (-75) |
| 229 | |
| 230 | // ZX_ERR_CONNECTION_ABORTED: Connection was aborted. |
| 231 | #define ZX_ERR_CONNECTION_ABORTED (-76) |
Adam Barth | 57eacf5 | 2020-11-04 00:38:09 +0000 | [diff] [blame] | 232 | |
| 233 | // ======= VDSO-private errors ======= |
| 234 | |
| 235 | // ZX_ERR_INTERNAL_INTR_KILLED: A task was killed during an operation. |
| 236 | #define ZX_ERR_INTERNAL_INTR_KILLED (-502) |
| 237 | |
| 238 | #endif // SYSROOT_ZIRCON_ERRORS_H_ |