2 * Unix SMB/CIFS implementation.
3 * error mapping functions
4 * Copyright (C) Andrew Tridgell 2001
5 * Copyright (C) Andrew Bartlett 2001
6 * Copyright (C) Tim Potter 2000
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
24 /* Mapping between Unix, and NT error numbers */
29 } unix_nt_errmap
[] = {
30 { EAGAIN
, STATUS_MORE_ENTRIES
},
31 { EINTR
, STATUS_MORE_ENTRIES
},
32 { ENOBUFS
, STATUS_MORE_ENTRIES
},
34 { EWOULDBLOCK
, STATUS_MORE_ENTRIES
},
36 { EINPROGRESS
, NT_STATUS_MORE_PROCESSING_REQUIRED
},
37 { EPERM
, NT_STATUS_ACCESS_DENIED
},
38 { EACCES
, NT_STATUS_ACCESS_DENIED
},
39 { ENOENT
, NT_STATUS_OBJECT_NAME_NOT_FOUND
},
40 { ENOTDIR
, NT_STATUS_NOT_A_DIRECTORY
},
41 { EIO
, NT_STATUS_IO_DEVICE_ERROR
},
42 { EBADF
, NT_STATUS_INVALID_HANDLE
},
43 { EINVAL
, NT_STATUS_INVALID_PARAMETER
},
44 { EEXIST
, NT_STATUS_OBJECT_NAME_COLLISION
},
45 { ENFILE
, NT_STATUS_TOO_MANY_OPENED_FILES
},
46 { EMFILE
, NT_STATUS_TOO_MANY_OPENED_FILES
},
47 { ENOSPC
, NT_STATUS_DISK_FULL
},
48 { ENOTSOCK
, NT_STATUS_INVALID_HANDLE
},
49 { EFAULT
, NT_STATUS_INVALID_PARAMETER
},
50 { EMSGSIZE
, NT_STATUS_INVALID_BUFFER_SIZE
},
51 { ENOMEM
, NT_STATUS_NO_MEMORY
},
52 { EISDIR
, NT_STATUS_FILE_IS_A_DIRECTORY
},
54 { EPIPE
, NT_STATUS_CONNECTION_DISCONNECTED
},
56 { EBUSY
, NT_STATUS_SHARING_VIOLATION
},
57 { ENOSYS
, NT_STATUS_INVALID_SYSTEM_SERVICE
},
59 { EOPNOTSUPP
, NT_STATUS_NOT_SUPPORTED
},
61 { EMLINK
, NT_STATUS_TOO_MANY_LINKS
},
62 { ENOSYS
, NT_STATUS_NOT_SUPPORTED
},
64 { ELOOP
, NT_STATUS_OBJECT_PATH_NOT_FOUND
},
67 { ENODATA
, NT_STATUS_NOT_FOUND
},
70 { EFTYPE
, NT_STATUS_OBJECT_PATH_NOT_FOUND
},
73 { EDQUOT
, NT_STATUS_DISK_FULL
}, /* Windows apps need this, not NT_STATUS_QUOTA_EXCEEDED */
76 { ENOTEMPTY
, NT_STATUS_DIRECTORY_NOT_EMPTY
},
79 { EXDEV
, NT_STATUS_NOT_SAME_DEVICE
},
82 { EROFS
, NT_STATUS_MEDIA_WRITE_PROTECTED
},
85 { ENAMETOOLONG
, NT_STATUS_NAME_TOO_LONG
},
88 { EFBIG
, NT_STATUS_DISK_FULL
},
91 { EADDRINUSE
, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED
},
94 { ENETUNREACH
, NT_STATUS_NETWORK_UNREACHABLE
},
97 { EHOSTUNREACH
, NT_STATUS_HOST_UNREACHABLE
},
100 { ECONNREFUSED
, NT_STATUS_CONNECTION_REFUSED
},
103 { EADDRNOTAVAIL
,NT_STATUS_ADDRESS_NOT_ASSOCIATED
},
106 { ETIMEDOUT
, NT_STATUS_IO_TIMEOUT
},
108 #ifdef ESOCKTNOSUPPORT
109 { ESOCKTNOSUPPORT
,NT_STATUS_INVALID_PARAMETER_MIX
},
112 { EAFNOSUPPORT
, NT_STATUS_INVALID_PARAMETER_MIX
},
115 { ECONNABORTED
, NT_STATUS_CONNECTION_ABORTED
},
118 { ECONNRESET
, NT_STATUS_CONNECTION_RESET
},
121 { ENOPROTOOPT
, NT_STATUS_INVALID_PARAMETER_MIX
},
124 { ENODEV
, NT_STATUS_NO_SUCH_DEVICE
},
127 { ENOATTR
, NT_STATUS_NOT_FOUND
},
130 { ECANCELED
, NT_STATUS_CANCELLED
},
133 { ENOTSUP
, NT_STATUS_NOT_SUPPORTED
},
136 { 0, NT_STATUS_UNSUCCESSFUL
}
140 /*********************************************************************
141 Map an NT error code from a Unix error code.
142 *********************************************************************/
143 NTSTATUS
map_nt_error_from_unix_common(int unix_error
)
147 /* Look through list */
148 for (i
=0;i
<ARRAY_SIZE(unix_nt_errmap
);i
++) {
149 if (unix_nt_errmap
[i
].unix_error
== unix_error
) {
150 return unix_nt_errmap
[i
].nt_error
;
155 return NT_STATUS_UNSUCCESSFUL
;