Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: translate fs errno codes to libuv error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Sep 5, 2011
1 parent bb0c6e6 commit efcd273
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/unix/error.c
Expand Up @@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>


/* TODO Expose callback to user to handle fatal error like V8 does. */
Expand Down Expand Up @@ -65,7 +66,7 @@ char* uv_strerror(uv_err_t err) {
}


static uv_err_code uv_translate_sys_error(int sys_errno) {
uv_err_code uv_translate_sys_error(int sys_errno) {
switch (sys_errno) {
case 0: return UV_OK;
case EACCES: return UV_EACCESS;
Expand All @@ -83,6 +84,9 @@ static uv_err_code uv_translate_sys_error(int sys_errno) {
case ENOTCONN: return UV_ENOTCONN;
default: return UV_UNKNOWN;
}

assert(0 && "unreachable");
return -1;
}


Expand Down
2 changes: 1 addition & 1 deletion src/unix/fs.c
Expand Up @@ -111,7 +111,7 @@ static int uv__fs_after(eio_req* eio) {
assert(req->cb);

req->result = req->eio->result;
req->errorno = req->eio->errorno;
req->errorno = uv_translate_sys_error(req->eio->errorno);

switch (req->fs_type) {
case UV_FS_READDIR:
Expand Down
1 change: 1 addition & 0 deletions src/unix/internal.h
Expand Up @@ -74,6 +74,7 @@ int uv__cloexec(int fd, int set) __attribute__((unused));
int uv__socket(int domain, int type, int protocol);

/* error */
uv_err_code uv_translate_sys_error(int sys_errno);
uv_err_t uv_err_new(uv_loop_t* loop, int sys_error);
uv_err_t uv_err_new_artificial(uv_loop_t* loop, int code);
void uv_fatal_error(const int errorno, const char* syscall);
Expand Down

0 comments on commit efcd273

Please sign in to comment.