Rizin
unix-like reverse engineering framework and cli tools
error.c File Reference
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "uv.h"
#include "internal.h"

Go to the source code of this file.

Functions

void uv_fatal_error (const int errorno, const char *syscall)
 
int uv_translate_sys_error (int sys_errno)
 

Function Documentation

◆ uv_fatal_error()

void uv_fatal_error ( const int  errorno,
const char *  syscall 
)

Definition at line 35 of file error.c.

35  {
36  char* buf = NULL;
37  const char* errmsg;
38 
39  FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
40  FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno,
41  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL);
42 
43  if (buf) {
44  errmsg = buf;
45  } else {
46  errmsg = "Unknown error";
47  }
48 
49  /* FormatMessage messages include a newline character already, so don't add
50  * another. */
51  if (syscall) {
52  fprintf(stderr, "%s: (%d) %s", syscall, errorno, errmsg);
53  } else {
54  fprintf(stderr, "(%d) %s", errorno, errmsg);
55  }
56 
57  if (buf) {
58  LocalFree(buf);
59  }
60 
61  DebugBreak();
62  abort();
63 }
#define NULL
Definition: cris-opc.c:27
voidpf void * buf
Definition: ioapi.h:138
const char * syscall
Definition: internal.h:270

References NULL, and syscall.

Referenced by fs__create_junction(), fs__sendfile(), make_program_env(), pipe_alloc_accept(), post_completion(), post_completion_read_wait(), post_completion_write_wait(), post_write_completion(), uv__fd_hash_add(), uv__fd_hash_init(), uv__hrtime(), uv__init_global_job_handle(), uv__init_overlapped_dummy(), uv__once_inner(), uv__pipe_queue_ipc_xfer_info(), uv__pipe_write_data(), uv__poll(), uv__poll_wine(), uv__util_init(), uv_fs_event_start(), uv_pipe_bind(), uv_pipe_connect(), uv_pipe_read_start(), uv_process_close(), uv_process_fs_event_req(), uv_queue_non_overlapped_write(), uv_relative_path(), uv_rwlock_rdlock(), uv_rwlock_rdunlock(), uv_rwlock_tryrdlock(), uv_rwlock_trywrlock(), uv_rwlock_wrlock(), uv_rwlock_wrunlock(), uv_set_process_title(), uv_spawn(), uv_split_path(), uv_tcp_listen(), uv_tcp_read_start(), uv_tcp_write(), uv_winapi_init(), and uv_winsock_init().

◆ uv_translate_sys_error()

int uv_translate_sys_error ( int  sys_errno)

Definition at line 66 of file error.c.

66  {
67  if (sys_errno <= 0) {
68  return sys_errno; /* If < 0 then it's already a libuv error. */
69  }
70 
71  switch (sys_errno) {
72  case ERROR_NOACCESS: return UV_EACCES;
73  case WSAEACCES: return UV_EACCES;
74  case ERROR_ELEVATION_REQUIRED: return UV_EACCES;
75  case ERROR_CANT_ACCESS_FILE: return UV_EACCES;
76  case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE;
77  case WSAEADDRINUSE: return UV_EADDRINUSE;
78  case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL;
79  case WSAEAFNOSUPPORT: return UV_EAFNOSUPPORT;
80  case WSAEWOULDBLOCK: return UV_EAGAIN;
81  case WSAEALREADY: return UV_EALREADY;
82  case ERROR_INVALID_FLAGS: return UV_EBADF;
83  case ERROR_INVALID_HANDLE: return UV_EBADF;
84  case ERROR_LOCK_VIOLATION: return UV_EBUSY;
85  case ERROR_PIPE_BUSY: return UV_EBUSY;
86  case ERROR_SHARING_VIOLATION: return UV_EBUSY;
87  case ERROR_OPERATION_ABORTED: return UV_ECANCELED;
88  case WSAEINTR: return UV_ECANCELED;
89  case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET;
90  case ERROR_CONNECTION_ABORTED: return UV_ECONNABORTED;
91  case WSAECONNABORTED: return UV_ECONNABORTED;
92  case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED;
93  case WSAECONNREFUSED: return UV_ECONNREFUSED;
94  case ERROR_NETNAME_DELETED: return UV_ECONNRESET;
95  case WSAECONNRESET: return UV_ECONNRESET;
96  case ERROR_ALREADY_EXISTS: return UV_EEXIST;
97  case ERROR_FILE_EXISTS: return UV_EEXIST;
98  case ERROR_BUFFER_OVERFLOW: return UV_EFAULT;
99  case WSAEFAULT: return UV_EFAULT;
100  case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
101  case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;
102  case ERROR_INSUFFICIENT_BUFFER: return UV_EINVAL;
103  case ERROR_INVALID_DATA: return UV_EINVAL;
104  case ERROR_INVALID_PARAMETER: return UV_EINVAL;
105  case ERROR_SYMLINK_NOT_SUPPORTED: return UV_EINVAL;
106  case WSAEINVAL: return UV_EINVAL;
107  case WSAEPFNOSUPPORT: return UV_EINVAL;
108  case WSAESOCKTNOSUPPORT: return UV_EINVAL;
109  case ERROR_BEGINNING_OF_MEDIA: return UV_EIO;
110  case ERROR_BUS_RESET: return UV_EIO;
111  case ERROR_CRC: return UV_EIO;
112  case ERROR_DEVICE_DOOR_OPEN: return UV_EIO;
113  case ERROR_DEVICE_REQUIRES_CLEANING: return UV_EIO;
114  case ERROR_DISK_CORRUPT: return UV_EIO;
115  case ERROR_EOM_OVERFLOW: return UV_EIO;
116  case ERROR_FILEMARK_DETECTED: return UV_EIO;
117  case ERROR_GEN_FAILURE: return UV_EIO;
118  case ERROR_INVALID_BLOCK_LENGTH: return UV_EIO;
119  case ERROR_IO_DEVICE: return UV_EIO;
120  case ERROR_NO_DATA_DETECTED: return UV_EIO;
121  case ERROR_NO_SIGNAL_SENT: return UV_EIO;
122  case ERROR_OPEN_FAILED: return UV_EIO;
123  case ERROR_SETMARK_DETECTED: return UV_EIO;
124  case ERROR_SIGNAL_REFUSED: return UV_EIO;
125  case WSAEISCONN: return UV_EISCONN;
126  case ERROR_CANT_RESOLVE_FILENAME: return UV_ELOOP;
127  case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE;
128  case WSAEMFILE: return UV_EMFILE;
129  case WSAEMSGSIZE: return UV_EMSGSIZE;
130  case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG;
131  case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH;
132  case WSAENETUNREACH: return UV_ENETUNREACH;
133  case WSAENOBUFS: return UV_ENOBUFS;
134  case ERROR_BAD_PATHNAME: return UV_ENOENT;
135  case ERROR_DIRECTORY: return UV_ENOENT;
136  case ERROR_ENVVAR_NOT_FOUND: return UV_ENOENT;
137  case ERROR_FILE_NOT_FOUND: return UV_ENOENT;
138  case ERROR_INVALID_NAME: return UV_ENOENT;
139  case ERROR_INVALID_DRIVE: return UV_ENOENT;
140  case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT;
141  case ERROR_MOD_NOT_FOUND: return UV_ENOENT;
142  case ERROR_PATH_NOT_FOUND: return UV_ENOENT;
143  case WSAHOST_NOT_FOUND: return UV_ENOENT;
144  case WSANO_DATA: return UV_ENOENT;
145  case ERROR_NOT_ENOUGH_MEMORY: return UV_ENOMEM;
146  case ERROR_OUTOFMEMORY: return UV_ENOMEM;
147  case ERROR_CANNOT_MAKE: return UV_ENOSPC;
148  case ERROR_DISK_FULL: return UV_ENOSPC;
149  case ERROR_EA_TABLE_FULL: return UV_ENOSPC;
150  case ERROR_END_OF_MEDIA: return UV_ENOSPC;
151  case ERROR_HANDLE_DISK_FULL: return UV_ENOSPC;
152  case ERROR_NOT_CONNECTED: return UV_ENOTCONN;
153  case WSAENOTCONN: return UV_ENOTCONN;
154  case ERROR_DIR_NOT_EMPTY: return UV_ENOTEMPTY;
155  case WSAENOTSOCK: return UV_ENOTSOCK;
156  case ERROR_NOT_SUPPORTED: return UV_ENOTSUP;
157  case ERROR_BROKEN_PIPE: return UV_EOF;
158  case ERROR_ACCESS_DENIED: return UV_EPERM;
159  case ERROR_PRIVILEGE_NOT_HELD: return UV_EPERM;
160  case ERROR_BAD_PIPE: return UV_EPIPE;
161  case ERROR_NO_DATA: return UV_EPIPE;
162  case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE;
163  case WSAESHUTDOWN: return UV_EPIPE;
164  case WSAEPROTONOSUPPORT: return UV_EPROTONOSUPPORT;
165  case ERROR_WRITE_PROTECT: return UV_EROFS;
166  case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
167  case WSAETIMEDOUT: return UV_ETIMEDOUT;
168  case ERROR_NOT_SAME_DEVICE: return UV_EXDEV;
169  case ERROR_INVALID_FUNCTION: return UV_EISDIR;
170  case ERROR_META_EXPANSION_TOO_LONG: return UV_E2BIG;
171  default: return UV_UNKNOWN;
172  }
173 }
#define ERROR_SYMLINK_NOT_SUPPORTED
Definition: winapi.h:4642
#define ERROR_ELEVATION_REQUIRED
Definition: winapi.h:4638

References ERROR_ELEVATION_REQUIRED, and ERROR_SYMLINK_NOT_SUPPORTED.

Referenced by SOCKOPT_SETTER(), uv__convert_utf16_to_utf8(), uv__convert_utf8_to_utf16(), uv__fast_poll_process_poll_req(), uv__get_handle(), uv__getaddrinfo_done(), uv__getaddrinfo_translate_error(), uv__getnameinfo_work(), uv__getpwuid_r(), uv__kill(), uv__pipe_getname(), uv__slow_poll_process_poll_req(), uv__tcp_bind(), uv__tcp_connect(), uv__tcp_try_write(), uv__tty_try_write(), uv__udp_connect(), uv__udp_disconnect(), uv__udp_init_ex(), uv__udp_recv_start(), uv__udp_send(), uv__udp_set_membership4(), uv__udp_set_membership6(), uv__udp_set_source_membership4(), uv__udp_set_source_membership6(), uv__udp_try_send(), uv_accept(), uv_chdir(), uv_cpu_info(), uv_cwd(), uv_exepath(), uv_fs_event_start(), uv_get_process_title(), uv_getaddrinfo(), uv_getrusage(), uv_if_indextoiid(), uv_if_indextoname(), uv_interface_addresses(), uv_kill(), uv_listen(), uv_os_getenv(), uv_os_gethostname(), uv_os_getpriority(), uv_os_setenv(), uv_os_setpriority(), uv_os_tmpdir(), uv_os_uname(), uv_os_unsetenv(), uv_pipe_bind(), uv_pipe_chmod(), uv_pipe_endgame(), uv_pipe_open(), uv_pipe_read_error(), uv_poll_close(), uv_poll_init_socket(), uv_process_fs_event_req(), uv_process_pipe_connect_req(), uv_process_pipe_write_req(), uv_process_proc_exit(), uv_process_tcp_accept_req(), uv_process_tcp_connect_req(), uv_process_tcp_read_req(), uv_process_tcp_write_req(), uv_process_tty_read_line_req(), uv_process_tty_read_raw_req(), uv_process_tty_write_req(), uv_process_udp_recv_req(), uv_process_udp_send_req(), uv_read_start(), uv_read_stop(), uv_resident_set_memory(), uv_rwlock_init(), uv_sem_init(), uv_set_process_title(), uv_spawn(), uv_tcp_close_reset(), uv_tcp_endgame(), uv_tcp_init_ex(), uv_tcp_open(), uv_thread_join(), uv_tty_get_winsize(), uv_tty_init(), uv_tty_set_mode(), uv_udp_open(), uv_udp_set_broadcast(), uv_udp_set_multicast_interface(), uv_uptime(), uv_write(), and uv_write2().