| 24 | namespace tensorflow { |
| 25 | |
| 26 | error::Code ErrnoToCode(int err_number) { |
| 27 | error::Code code; |
| 28 | switch (err_number) { |
| 29 | case 0: |
| 30 | code = error::OK; |
| 31 | break; |
| 32 | case EINVAL: // Invalid argument |
| 33 | case ENAMETOOLONG: // Filename too long |
| 34 | case E2BIG: // Argument list too long |
| 35 | case EDESTADDRREQ: // Destination address required |
| 36 | case EDOM: // Mathematics argument out of domain of function |
| 37 | case EFAULT: // Bad address |
| 38 | case EILSEQ: // Illegal byte sequence |
| 39 | case ENOPROTOOPT: // Protocol not available |
| 40 | case ENOSTR: // Not a STREAM |
| 41 | case ENOTSOCK: // Not a socket |
| 42 | case ENOTTY: // Inappropriate I/O control operation |
| 43 | case EPROTOTYPE: // Protocol wrong type for socket |
| 44 | case ESPIPE: // Invalid seek |
| 45 | code = error::INVALID_ARGUMENT; |
| 46 | break; |
| 47 | case ETIMEDOUT: // Connection timed out |
| 48 | case ETIME: // Timer expired |
| 49 | code = error::DEADLINE_EXCEEDED; |
| 50 | break; |
| 51 | case ENODEV: // No such device |
| 52 | case ENOENT: // No such file or directory |
| 53 | case ENXIO: // No such device or address |
| 54 | case ESRCH: // No such process |
| 55 | code = error::NOT_FOUND; |
| 56 | break; |
| 57 | case EEXIST: // File exists |
| 58 | case EADDRNOTAVAIL: // Address not available |
| 59 | case EALREADY: // Connection already in progress |
| 60 | code = error::ALREADY_EXISTS; |
| 61 | break; |
| 62 | case EPERM: // Operation not permitted |
| 63 | case EACCES: // Permission denied |
| 64 | case EROFS: // Read only file system |
| 65 | code = error::PERMISSION_DENIED; |
| 66 | break; |
| 67 | case ENOTEMPTY: // Directory not empty |
| 68 | case EISDIR: // Is a directory |
| 69 | case ENOTDIR: // Not a directory |
| 70 | case EADDRINUSE: // Address already in use |
| 71 | case EBADF: // Invalid file descriptor |
| 72 | case EBUSY: // Device or resource busy |
| 73 | case ECHILD: // No child processes |
| 74 | case EISCONN: // Socket is connected |
| 75 | #if !defined(_WIN32) && !defined(__HAIKU__) |
| 76 | case ENOTBLK: // Block device required |
| 77 | #endif |
| 78 | case ENOTCONN: // The socket is not connected |
| 79 | case EPIPE: // Broken pipe |
| 80 | #if !defined(_WIN32) |
| 81 | case ESHUTDOWN: // Cannot send after transport endpoint shutdown |
| 82 | #endif |
| 83 | case ETXTBSY: // Text file busy |