Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
trn_result_to_errno: use trn_lookup_result
Browse files Browse the repository at this point in the history
  • Loading branch information
misson20000 committed Sep 1, 2018
1 parent b138907 commit 0ae83b1
Showing 1 changed file with 3 additions and 32 deletions.
35 changes: 3 additions & 32 deletions lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,36 +229,7 @@ int dbg_printf(char const *fmt, ...) {
}

int trn_result_to_errno(result_t r) {
switch (r) {
case RESULT_OK:
return 0;
case LIBTRANSISTOR_ERR_OUT_OF_MEMORY:
return ENOMEM;
case LIBTRANSISTOR_ERR_INVALID_ARGUMENT:
return EINVAL;
case FSPSRV_ERR_NOT_FOUND:
case LIBTRANSISTOR_ERR_FS_NOT_FOUND:
case LIBTRANSISTOR_ERR_FS_INVALID_PATH:
return ENOENT;
case FSPSRV_ERR_EXISTS:
case LIBTRANSISTOR_ERR_FS_PATH_EXISTS:
return EEXIST;
case LIBTRANSISTOR_ERR_FS_NOT_A_DIRECTORY:
return ENOTDIR;
case LIBTRANSISTOR_ERR_FS_NAME_TOO_LONG:
return ENAMETOOLONG;
case FSPSRV_ERR_DIRECTORY_NOT_EMPTY:
return ENOTEMPTY;
case LIBTRANSISTOR_ERR_FS_READ_ONLY:
return EROFS;
case LIBTRANSISTOR_ERR_FS_ACCESS_DENIED:
return EACCES;
case LIBTRANSISTOR_ERR_FS_IO_ERROR:
return EIO;
default:
// Make the debugger's life easy: print his error before turning it
// into a useless code...
dbg_printf("UNSUPPORTED ERROR: %x\n", r);
return ENOSYS;
}
trn_result_description_t d;
trn_lookup_result(r, &d);
return d.closest_errno;
}

0 comments on commit 0ae83b1

Please sign in to comment.