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 5 #pragma once 6 7 // Zircon statuses are signed 32 bit integers. The space of values is 8 // divided as follows: 9 // - The zero value is for the OK status. 10 // - Negative values are defined by the system, in this file. 11 // - Positive values are reserved for protocol-specific error values, 12 // and will never be defined by the system. 13 14 #define ZX_OK (0) 15 16 // ======= Internal failures ======= 17 // ZX_ERR_INTERNAL: The system encountered an otherwise unspecified error 18 // while performing the operation. 19 #define ZX_ERR_INTERNAL (-1) 20 21 // ZX_ERR_NOT_SUPPORTED: The operation is not implemented, supported, 22 // or enabled. 23 #define ZX_ERR_NOT_SUPPORTED (-2) 24 25 // ZX_ERR_NO_RESOURCES: The system was not able to allocate some resource 26 // needed for the operation. 27 #define ZX_ERR_NO_RESOURCES (-3) 28 29 // ZX_ERR_NO_MEMORY: The system was not able to allocate memory needed 30 // for the operation. 31 #define ZX_ERR_NO_MEMORY (-4) 32 33 // -5 used to be ZX_ERR_CALL_FAILED. 34 35 // ZX_ERR_INTERNAL_INTR_RETRY: The system call was interrupted, but should be 36 // retried. This should not be seen outside of the VDSO. 37 #define ZX_ERR_INTERNAL_INTR_RETRY (-6) 38 39 // ======= Parameter errors ======= 40 // ZX_ERR_INVALID_ARGS: an argument is invalid, ex. null pointer 41 #define ZX_ERR_INVALID_ARGS (-10) 42 43 // ZX_ERR_BAD_HANDLE: A specified handle value does not refer to a handle. 44 #define ZX_ERR_BAD_HANDLE (-11) 45 46 // ZX_ERR_WRONG_TYPE: The subject of the operation is the wrong type to 47 // perform the operation. 48 // Example: Attempting a message_read on a thread handle. 49 #define ZX_ERR_WRONG_TYPE (-12) 50 51 // ZX_ERR_BAD_SYSCALL: The specified syscall number is invalid. 52 #define ZX_ERR_BAD_SYSCALL (-13) 53 54 // ZX_ERR_OUT_OF_RANGE: An argument is outside the valid range for this 55 // operation. 56 #define ZX_ERR_OUT_OF_RANGE (-14) 57 58 // ZX_ERR_BUFFER_TOO_SMALL: A caller provided buffer is too small for 59 // this operation. 60 #define ZX_ERR_BUFFER_TOO_SMALL (-15) 61 62 // ======= Precondition or state errors ======= 63 // ZX_ERR_BAD_STATE: operation failed because the current state of the 64 // object does not allow it, or a precondition of the operation is 65 // not satisfied 66 #define ZX_ERR_BAD_STATE (-20) 67 68 // ZX_ERR_TIMED_OUT: The time limit for the operation elapsed before 69 // the operation completed. 70 #define ZX_ERR_TIMED_OUT (-21) 71 72 // ZX_ERR_SHOULD_WAIT: The operation cannot be performed currently but 73 // potentially could succeed if the caller waits for a prerequisite 74 // to be satisfied, for example waiting for a handle to be readable 75 // or writable. 76 // Example: Attempting to read from a channel that has no 77 // messages waiting but has an open remote will return ZX_ERR_SHOULD_WAIT. 78 // Attempting to read from a channel that has no messages waiting 79 // and has a closed remote end will return ZX_ERR_PEER_CLOSED. 80 #define ZX_ERR_SHOULD_WAIT (-22) 81 82 // ZX_ERR_CANCELED: The in-progress operation (e.g. a wait) has been 83 // canceled. 84 #define ZX_ERR_CANCELED (-23) 85 86 // ZX_ERR_PEER_CLOSED: The operation failed because the remote end of the 87 // subject of the operation was closed. 88 #define ZX_ERR_PEER_CLOSED (-24) 89 90 // ZX_ERR_NOT_FOUND: The requested entity is not found. 91 #define ZX_ERR_NOT_FOUND (-25) 92 93 // ZX_ERR_ALREADY_EXISTS: An object with the specified identifier 94 // already exists. 95 // Example: Attempting to create a file when a file already exists 96 // with that name. 97 #define ZX_ERR_ALREADY_EXISTS (-26) 98 99 // ZX_ERR_ALREADY_BOUND: The operation failed because the named entity 100 // is already owned or controlled by another entity. The operation 101 // could succeed later if the current owner releases the entity. 102 #define ZX_ERR_ALREADY_BOUND (-27) 103 104 // ZX_ERR_UNAVAILABLE: The subject of the operation is currently unable 105 // to perform the operation. 106 // Note: This is used when there's no direct way for the caller to 107 // observe when the subject will be able to perform the operation 108 // and should thus retry. 109 #define ZX_ERR_UNAVAILABLE (-28) 110 111 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) 232